bls

package
v0.0.0-...-9fbb145 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: MIT Imports: 5 Imported by: 0

README

bls library from: https://github.com/herumi/bls

test:
 go test -tags bn256 .
 go test -tags bn384 .
 go test -tags bn384_256 .

Documentation

Index

Constants

View Source
const BLS12_381 = C.MCL_BLS12_381

BLS12_381

View Source
const CurveFp254BNb = C.mclBn_CurveFp254BNb

CurveFp254BNb -- 254 bit curve

View Source
const CurveFp382_1 = C.mclBn_CurveFp382_1

CurveFp382_1 -- 382 bit curve 1

View Source
const CurveFp382_2 = C.mclBn_CurveFp382_2

CurveFp382_2 -- 382 bit curve 2

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 Init

func Init(curve int) error

Init -- call this function before calling all the other operations this function is not thread safe

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 SetRandFunc

func SetRandFunc(randReader io.Reader)

SetRandFunc --

func VerifyPairing

func VerifyPairing(X *Sign, Y *Sign, pub *PublicKey) bool

VerifyPairing --

Types

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) Deserialize

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

Deserialize --

func (*ID) DeserializeHexStr

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

DeserializeHexStr --

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 -- alias of Serialize

func (*ID) IsEqual

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

IsEqual --

func (*ID) Serialize

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

Serialize --

func (*ID) SerializeToHexStr

func (id *ID) SerializeToHexStr() string

SerializeToHexStr --

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 GetPublicKey

func GetPublicKey(buf []byte) *PublicKey

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

var m_cacheBlsPubs = make(map[string]*PublicKey)

func GetPublicKey(buf []byte) *PublicKey {
	key := string(buf)
	pub, ok := m_cacheBlsPubs[key]
	if ok {
		return pub
	}
	pub = &PublicKey{}
	if err := pub.Deserialize(buf); err != nil {
		//log.Debug("bls.PublicKey.Deserialize", "invalid public key", key, "error", err)
		return nil
	}
	m_cacheBlsPubs[key] = pub
	return pub
}

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) Deserialize

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

Deserialize --

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 -- alias of Serialize

func (*SecretKey) GetMasterSecretKey

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

GetMasterSecretKey --

func (*SecretKey) GetPop

func (sec *SecretKey) GetPop() (sig *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) Serialize

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

Serialize --

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()

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) (sig *Sign)

Sign -- Constant Time version

func (*SecretKey) SignHash

func (sec *SecretKey) SignHash(hash []byte) (sig *Sign)

SignHash --

type Sign

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

Sign --

func HashAndMapToSignature

func HashAndMapToSignature(buf []byte) *Sign

HashAndMapToSignature --

func (*Sign) Add

func (sig *Sign) Add(rhs *Sign)

Add --

func (*Sign) Deserialize

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

Deserialize --

func (*Sign) DeserializeHexStr

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

DeserializeHexStr --

func (*Sign) GetHexString

func (sig *Sign) GetHexString() string

GetHexString --

func (*Sign) IsEqual

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

IsEqual --

func (*Sign) Recover

func (sig *Sign) Recover(sigVec []Sign, idVec []ID) error

Recover --

func (*Sign) Serialize

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

Serialize --

func (*Sign) SerializeToHexStr

func (sig *Sign) SerializeToHexStr() string

SerializeToHexStr --

func (*Sign) SetHexString

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

SetHexString --

func (*Sign) Verify

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

Verify --

func (*Sign) VerifyAggregateHashes

func (sig *Sign) VerifyAggregateHashes(pubVec []PublicKey, hash [][]byte) bool

VerifyAggregateHashes --

func (*Sign) VerifyHash

func (sig *Sign) VerifyHash(pub *PublicKey, hash []byte) bool

VerifyHash --

func (*Sign) VerifyPop

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

VerifyPop --

Jump to

Keyboard shortcuts

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