bls

package module
v0.0.0-...-77c4a4f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2024 License: MIT Imports: 7 Imported by: 0

README

bls

Precompiled bls library for go

This library use the precompiled bls and mcl. Thank herumi for the great work.

And this library also bundle with GMP for the dependency.

Note

Because of the precompiled libs are managed by git-lfs, so before go get github.com/moonfruit/bls or simply clone the repository, you must install git-lfs first.

Documentation

Index

Constants

View Source
const (
	// BN160
	BN160 = Curve(C.MCL_BN160)

	// BN254 -- 254 bit curve
	BN254 = Curve(C.MCL_BN254)

	// BN_SNARK1
	BN_SNARK1 = Curve(C.MCL_BN_SNARK1)

	// BN381_1 -- 382 bit curve 1
	BN381_1 = Curve(C.MCL_BN381_1)

	// BN381_2 -- 382 bit curve 2
	BN381_2 = Curve(C.MCL_BN381_2)

	// BLS12_381
	BLS12_381 = Curve(C.MCL_BLS12_381)
)

noinspection GoSnakeCaseUsage,GoNameStartsWithPackageName

View Source
const IoSerializeHexStr = C.MCLBN_IO_SERIALIZE_HEX_STR

IoSerializeHexStr

Variables

This section is empty.

Functions

func FinalExp

func FinalExp(out *GT, x *GT)

FinalExp --

func FrAdd

func FrAdd(out *Fr, x *Fr, y *Fr)

FrAdd --

func FrDiv

func FrDiv(out *Fr, x *Fr, y *Fr)

FrDiv --

func FrEvaluatePolynomial

func FrEvaluatePolynomial(y *Fr, c []Fr, x *Fr) error

FrEvaluatePolynomial -- y = c[0] + c[1] * x + c[2] * x^2 + ...

func FrInv

func FrInv(out *Fr, x *Fr)

FrInv --

func FrLagrangeInterpolation

func FrLagrangeInterpolation(out *Fr, xVec []Fr, yVec []Fr) error

FrLagrangeInterpolation --

func FrMul

func FrMul(out *Fr, x *Fr, y *Fr)

FrMul --

func FrNeg

func FrNeg(out *Fr, x *Fr)

FrNeg --

func FrSub

func FrSub(out *Fr, x *Fr, y *Fr)

FrSub --

func G1Add

func G1Add(out *G1, x *G1, y *G1)

G1Add --

func G1Dbl

func G1Dbl(out *G1, x *G1)

G1Dbl --

func G1EvaluatePolynomial

func G1EvaluatePolynomial(y *G1, c []G1, x *Fr) error

G1EvaluatePolynomial -- y = c[0] + c[1] * x + c[2] * x^2 + ...

func G1LagrangeInterpolation

func G1LagrangeInterpolation(out *G1, xVec []Fr, yVec []G1) error

G1LagrangeInterpolation --

func G1Mul

func G1Mul(out *G1, x *G1, y *Fr)

G1Mul --

func G1MulCT

func G1MulCT(out *G1, x *G1, y *Fr)

G1MulCT -- constant time (depending on bit lengh of y)

func G1Neg

func G1Neg(out *G1, x *G1)

G1Neg --

func G1Sub

func G1Sub(out *G1, x *G1, y *G1)

G1Sub --

func G2Add

func G2Add(out *G2, x *G2, y *G2)

G2Add --

func G2Dbl

func G2Dbl(out *G2, x *G2)

G2Dbl --

func G2EvaluatePolynomial

func G2EvaluatePolynomial(y *G2, c []G2, x *Fr) error

G2EvaluatePolynomial -- y = c[0] + c[1] * x + c[2] * x^2 + ...

func G2LagrangeInterpolation

func G2LagrangeInterpolation(out *G2, xVec []Fr, yVec []G2) error

G2LagrangeInterpolation --

func G2Mul

func G2Mul(out *G2, x *G2, y *Fr)

G2Mul --

func G2Neg

func G2Neg(out *G2, x *G2)

G2Neg --

func G2Sub

func G2Sub(out *G2, x *G2, y *G2)

G2Sub --

func GTAdd

func GTAdd(out *GT, x *GT, y *GT)

GTAdd --

func GTDiv

func GTDiv(out *GT, x *GT, y *GT)

GTDiv --

func GTInv

func GTInv(out *GT, x *GT)

GTInv --

func GTMul

func GTMul(out *GT, x *GT, y *GT)

GTMul --

func GTNeg

func GTNeg(out *GT, x *GT)

GTNeg --

func GTPow

func GTPow(out *GT, x *GT, y *Fr)

GTPow --

func GTSub

func GTSub(out *GT, x *GT, y *GT)

GTSub --

func GetCurveOrder

func GetCurveOrder() string

GetCurveOrder -- return the order of G1

func GetFieldOrder

func GetFieldOrder() string

GetFieldOrder -- return the characteristic of the field where a curve is defined

func GetFpUnitSize

func GetFpUnitSize() int

GetFpUnitSize() -- same as GetMaxOpUnitSize()

func GetFrUnitSize

func GetFrUnitSize() int

GetFrUnitSize() --

func GetMaxOpUnitSize

func GetMaxOpUnitSize() int

GetMaxOpUnitSize --

func GetOpUnitSize

func GetOpUnitSize() int

GetOpUnitSize -- the length of Fr is GetOpUnitSize() * 8 bytes

func GetUint64NumToPrecompute

func GetUint64NumToPrecompute() int

GetUint64NumToPrecompute --

func MillerLoop

func MillerLoop(out *GT, x *G1, y *G2)

MillerLoop --

func Pairing

func Pairing(out *GT, x *G1, y *G2)

Pairing --

func PrecomputeG2

func PrecomputeG2(Qbuf []uint64, Q *G2)

PrecomputeG2 --

func PrecomputedMillerLoop

func PrecomputedMillerLoop(out *GT, P *G1, Qbuf []uint64)

PrecomputedMillerLoop --

func PrecomputedMillerLoop2

func PrecomputedMillerLoop2(out *GT, P1 *G1, Q1buf []uint64, P2 *G1, Q2buf []uint64)

PrecomputedMillerLoop2 --

func SHA256_Final

func SHA256_Final(md *C.uchar, c unsafe.Pointer) C.int

noinspection GoSnakeCaseUsage

func SHA256_Init

func SHA256_Init(c unsafe.Pointer) C.int

noinspection GoSnakeCaseUsage

func SHA256_Update

func SHA256_Update(c, data unsafe.Pointer, len C.size_t) C.int

noinspection GoSnakeCaseUsage

func SHA512_Final

func SHA512_Final(md *C.uchar, c unsafe.Pointer) C.int

noinspection GoSnakeCaseUsage

func SHA512_Init

func SHA512_Init(c unsafe.Pointer) C.int

noinspection GoSnakeCaseUsage

func SHA512_Update

func SHA512_Update(c, data unsafe.Pointer, len C.size_t) C.int

noinspection GoSnakeCaseUsage

Types

type Curve

type Curve int8

func CurrentCurve

func CurrentCurve() Curve

func (Curve) Init

func (curve Curve) Init()

func (Curve) IsValid

func (curve Curve) IsValid() bool

func (Curve) PublicKeyLength

func (curve Curve) PublicKeyLength() int

func (Curve) Run

func (curve Curve) Run(fun func())

func (Curve) SecretKeyLength

func (curve Curve) SecretKeyLength() int

func (Curve) SignLength

func (curve Curve) SignLength() int

func (Curve) String

func (curve Curve) String() string

type Fr

type Fr struct {
	// contains filtered or unexported fields
}

Fr --

func (*Fr) Clear

func (x *Fr) Clear()

Clear --

func (*Fr) Deserialize

func (x *Fr) Deserialize(buf []byte) error

Deserialize --

func (*Fr) GetString

func (x *Fr) GetString(base int) string

GetString --

func (*Fr) IsEqual

func (x *Fr) IsEqual(rhs *Fr) bool

IsEqual --

func (*Fr) IsOne

func (x *Fr) IsOne() bool

IsOne --

func (*Fr) IsZero

func (x *Fr) IsZero() bool

IsZero --

func (*Fr) Serialize

func (x *Fr) Serialize() []byte

Serialize --

func (*Fr) SetByCSPRNG

func (x *Fr) SetByCSPRNG()

SetByCSPRNG --

func (*Fr) SetHashOf

func (x *Fr) SetHashOf(buf []byte) bool

SetHashOf --

func (*Fr) SetInt64

func (x *Fr) SetInt64(v int64)

SetInt64 --

func (*Fr) SetLittleEndian

func (x *Fr) SetLittleEndian(buf []byte) error

SetLittleEndian --

func (*Fr) SetString

func (x *Fr) SetString(s string, base int) error

SetString --

type G1

type G1 struct {
	// contains filtered or unexported fields
}

G1 --

func (*G1) Clear

func (x *G1) Clear()

Clear --

func (*G1) Deserialize

func (x *G1) Deserialize(buf []byte) error

Deserialize --

func (*G1) GetString

func (x *G1) GetString(base int) string

GetString --

func (*G1) HashAndMapTo

func (x *G1) HashAndMapTo(buf []byte) error

HashAndMapTo --

func (*G1) IsEqual

func (x *G1) IsEqual(rhs *G1) bool

IsEqual --

func (*G1) IsZero

func (x *G1) IsZero() bool

IsZero --

func (*G1) Serialize

func (x *G1) Serialize() []byte

Serialize --

func (*G1) SetString

func (x *G1) SetString(s string, base int) error

SetString --

type G2

type G2 struct {
	// contains filtered or unexported fields
}

G2 --

func (*G2) Clear

func (x *G2) Clear()

Clear --

func (*G2) Deserialize

func (x *G2) Deserialize(buf []byte) error

Deserialize --

func (*G2) GetString

func (x *G2) GetString(base int) string

GetString --

func (*G2) HashAndMapTo

func (x *G2) HashAndMapTo(buf []byte) error

HashAndMapTo --

func (*G2) IsEqual

func (x *G2) IsEqual(rhs *G2) bool

IsEqual --

func (*G2) IsZero

func (x *G2) IsZero() bool

IsZero --

func (*G2) Serialize

func (x *G2) Serialize() []byte

Serialize --

func (*G2) SetString

func (x *G2) SetString(s string, base int) error

SetString --

type GT

type GT struct {
	// contains filtered or unexported fields
}

GT --

func (*GT) Clear

func (x *GT) Clear()

Clear --

func (*GT) Deserialize

func (x *GT) Deserialize(buf []byte) error

Deserialize --

func (*GT) GetString

func (x *GT) GetString(base int) string

GetString --

func (*GT) IsEqual

func (x *GT) IsEqual(rhs *GT) bool

IsEqual --

func (*GT) IsOne

func (x *GT) IsOne() bool

IsOne --

func (*GT) IsZero

func (x *GT) IsZero() bool

IsZero --

func (*GT) Serialize

func (x *GT) Serialize() []byte

Serialize --

func (*GT) SetInt64

func (x *GT) SetInt64(v int64)

SetInt64 --

func (*GT) SetString

func (x *GT) SetString(s string, base int) error

SetString --

type ID

type ID struct {
	// contains filtered or unexported fields
}

ID --

func (*ID) GetDecString

func (id *ID) GetDecString() string

GetDecString --

func (*ID) GetHexString

func (id *ID) GetHexString() string

GetHexString --

func (*ID) GetLittleEndian

func (id *ID) GetLittleEndian() []byte

GetLittleEndian --

func (*ID) IsEqual

func (id *ID) IsEqual(rhs *ID) bool

IsEqual --

func (*ID) SetDecString

func (id *ID) SetDecString(s string) error

SetDecString --

func (*ID) SetHexString

func (id *ID) SetHexString(s string) error

SetHexString --

func (*ID) SetLittleEndian

func (id *ID) SetLittleEndian(buf []byte) error

SetLittleEndian --

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

PublicKey --

func DHKeyExchange

func DHKeyExchange(sec *SecretKey, pub *PublicKey) (out PublicKey)

DHKeyExchange --

func GetMasterPublicKey

func GetMasterPublicKey(msk []SecretKey) (mpk []PublicKey)

GetMasterPublicKey --

func (*PublicKey) Add

func (pub *PublicKey) Add(rhs *PublicKey)

Add --

func (*PublicKey) Deserialize

func (pub *PublicKey) Deserialize(buf []byte) error

Deserialize --

func (*PublicKey) DeserializeHexStr

func (pub *PublicKey) DeserializeHexStr(s string) error

DeserializeHexStr --

func (*PublicKey) GetHexString

func (pub *PublicKey) GetHexString() string

GetHexString --

func (*PublicKey) IsEqual

func (pub *PublicKey) IsEqual(rhs *PublicKey) bool

IsEqual --

func (*PublicKey) Recover

func (pub *PublicKey) Recover(pubVec []PublicKey, idVec []ID) error

Recover --

func (*PublicKey) Serialize

func (pub *PublicKey) Serialize() []byte

Serialize --

func (*PublicKey) SerializeToHexStr

func (pub *PublicKey) SerializeToHexStr() string

SerializeToHexStr --

func (*PublicKey) Set

func (pub *PublicKey) Set(mpk []PublicKey, id *ID) error

Set --

func (*PublicKey) SetHexString

func (pub *PublicKey) SetHexString(s string) error

SetHexString --

type SecretKey

type SecretKey struct {
	// contains filtered or unexported fields
}

SecretKey --

func (*SecretKey) Add

func (sec *SecretKey) Add(rhs *SecretKey)

Add --

func (*SecretKey) DeserializeHexStr

func (sec *SecretKey) DeserializeHexStr(s string) error

DeserializeHexStr --

func (*SecretKey) GetDecString

func (sec *SecretKey) GetDecString() string

GetDecString --

func (*SecretKey) GetHexString

func (sec *SecretKey) GetHexString() string

GetHexString --

func (*SecretKey) GetLittleEndian

func (sec *SecretKey) GetLittleEndian() []byte

GetLittleEndian --

func (*SecretKey) GetMasterSecretKey

func (sec *SecretKey) GetMasterSecretKey(k int) (msk []SecretKey)

GetMasterSecretKey --

func (*SecretKey) GetPop

func (sec *SecretKey) GetPop() (sign *Sign)

GetPop --

func (*SecretKey) GetPublicKey

func (sec *SecretKey) GetPublicKey() (pub *PublicKey)

GetPublicKey --

func (*SecretKey) IsEqual

func (sec *SecretKey) IsEqual(rhs *SecretKey) bool

IsEqual --

func (*SecretKey) Recover

func (sec *SecretKey) Recover(secVec []SecretKey, idVec []ID) error

Recover --

func (*SecretKey) SerializeToHexStr

func (sec *SecretKey) SerializeToHexStr() string

SerializeToHexStr --

func (*SecretKey) Set

func (sec *SecretKey) Set(msk []SecretKey, id *ID) error

Set --

func (*SecretKey) SetByCSPRNG

func (sec *SecretKey) SetByCSPRNG() *SecretKey

SetByCSPRNG --

func (*SecretKey) SetDecString

func (sec *SecretKey) SetDecString(s string) error

SetDecString --

func (*SecretKey) SetHexString

func (sec *SecretKey) SetHexString(s string) error

SetHexString --

func (*SecretKey) SetLittleEndian

func (sec *SecretKey) SetLittleEndian(buf []byte) error

SetLittleEndian --

func (*SecretKey) Sign

func (sec *SecretKey) Sign(m string) (sign *Sign)

Sign -- Constant Time version

func (*SecretKey) SignBytes

func (sec *SecretKey) SignBytes(buf []byte) (sign *Sign)

SignBytes --

type Sign

type Sign struct {
	// contains filtered or unexported fields
}

Sign --

func (*Sign) Add

func (sign *Sign) Add(rhs *Sign)

Add --

func (*Sign) Deserialize

func (sign *Sign) Deserialize(buf []byte) error

Deserialize --

func (*Sign) DeserializeHexStr

func (sign *Sign) DeserializeHexStr(s string) error

DeserializeHexStr --

func (*Sign) GetHexString

func (sign *Sign) GetHexString() string

GetHexString --

func (*Sign) IsEqual

func (sign *Sign) IsEqual(rhs *Sign) bool

IsEqual --

func (*Sign) Recover

func (sign *Sign) Recover(signVec []Sign, idVec []ID) error

Recover --

func (*Sign) Serialize

func (sign *Sign) Serialize() []byte

Serialize --

func (*Sign) SerializeToHexStr

func (sign *Sign) SerializeToHexStr() string

SerializeToHexStr --

func (*Sign) SetHexString

func (sign *Sign) SetHexString(s string) error

SetHexString --

func (*Sign) Verify

func (sign *Sign) Verify(pub *PublicKey, m string) bool

Verify --

func (*Sign) VerifyBytes

func (sign *Sign) VerifyBytes(pub *PublicKey, buf []byte) bool

VerifyBytes --

func (*Sign) VerifyPop

func (sign *Sign) VerifyPop(pub *PublicKey) bool

VerifyPop --

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL