bls

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

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 BatchVerifyDistinctMsg

func BatchVerifyDistinctMsg(curve int, pkVec []PublicKey, msgVec []Sign, sign Sign) error

func BatchVerifySameMsg

func BatchVerifySameMsg(curve int, msg string, pkVec []PublicKey, sign Sign) error

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 G2IsValid

func G2IsValid(rhs *PublicKey) bool

IsValid --

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 SaveBLS

func SaveBLS(file string, key *SecretKey) error

func SchnorrNIZKVerify

func SchnorrNIZKVerify(curve int, proof Proof, P PublicKey) error

func Schnorr_test

func Schnorr_test(curve int, r, c SecretKey, G, V, P PublicKey) error

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 GTBatchAdd

func GTBatchAdd(eVec []GT) (e GT)

func GTBatchMul

func GTBatchMul(eVec []GT) (e 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 Proof deprecated

type Proof struct {
	C, R SecretKey
}

Deprecated: use SchnorrProof

func SchnorrNIZKProve

func SchnorrNIZKProve(curve int, sec SecretKey) (*Proof, error)

func (*Proof) DecodeRLP

func (pf *Proof) DecodeRLP(s *rlp.Stream) error

func (*Proof) Deserialize

func (pf *Proof) Deserialize(buf []byte) error

Deserialize --

func (*Proof) EncodeRLP

func (pf *Proof) EncodeRLP(w io.Writer) error

func (*Proof) MarshalText

func (pf *Proof) MarshalText() ([]byte, error)

func (*Proof) Serialize

func (pf *Proof) Serialize() []byte

Serialize --

func (*Proof) UnmarshalText

func (pf *Proof) UnmarshalText(text []byte) error

type PublicKey

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

PublicKey --

func DHKeyExchange

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

DHKeyExchange --

func GetGeneratorOfG2

func GetGeneratorOfG2() (pub *PublicKey)

add@20190716 get G2

func GetMasterPublicKey

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

GetMasterPublicKey --

func PubkeyBatchAdd

func PubkeyBatchAdd(pkVec []PublicKey) (pub PublicKey)

PubBatchAdd --

func SynthSameMsg

func SynthSameMsg(curve int, pkVec []PublicKey, mVec []string) ([]PublicKey, []string, []string, error)

func (*PublicKey) Add

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

Add --

func (*PublicKey) DecodeRLP

func (pub *PublicKey) DecodeRLP(s *rlp.Stream) error

func (*PublicKey) Deserialize

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

Deserialize --

func (*PublicKey) EncodeRLP

func (pub *PublicKey) EncodeRLP(w io.Writer) error

func (*PublicKey) GetHexString

func (pub *PublicKey) GetHexString() string

GetHexString --

func (*PublicKey) IsEqual

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

IsEqual --

func (*PublicKey) MarshalText

func (pub *PublicKey) MarshalText() ([]byte, error)

func (*PublicKey) Mul

func (pub *PublicKey) Mul(rhs *SecretKey)

Mul --

func (*PublicKey) Recover

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

Recover --

func (*PublicKey) Serialize

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

Serialize --

func (*PublicKey) Set

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

Set --

func (*PublicKey) SetHexString

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

SetHexString --

func (*PublicKey) UnmarshalText

func (pub *PublicKey) UnmarshalText(text []byte) error

type PublicKeyHex

type PublicKeyHex [96]byte

Match only 192 hex char length public keys

func (PublicKeyHex) Bytes

func (pe PublicKeyHex) Bytes() []byte

func (PublicKeyHex) MarshalText

func (pe PublicKeyHex) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*PublicKeyHex) ParseBlsPubKey

func (pe *PublicKeyHex) ParseBlsPubKey() (*PublicKey, error)

func (PublicKeyHex) String

func (pe PublicKeyHex) String() string

func (*PublicKeyHex) UnmarshalText

func (pe *PublicKeyHex) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type SchnorrProof

type SchnorrProof struct {
	C, R SecretKey
}

func (*SchnorrProof) DecodeRLP

func (pf *SchnorrProof) DecodeRLP(s *rlp.Stream) error

func (*SchnorrProof) Deserialize

func (pf *SchnorrProof) Deserialize(buf []byte) error

Deserialize --

func (*SchnorrProof) EncodeRLP

func (pf *SchnorrProof) EncodeRLP(w io.Writer) error

func (*SchnorrProof) MarshalText

func (pf *SchnorrProof) MarshalText() ([]byte, error)

func (*SchnorrProof) Serialize

func (pf *SchnorrProof) Serialize() []byte

Serialize --

func (*SchnorrProof) UnmarshalText

func (pf *SchnorrProof) UnmarshalText(text []byte) error

func (*SchnorrProof) VerifySchnorrNIZK

func (sig *SchnorrProof) VerifySchnorrNIZK(pk PublicKey) error

type SchnorrProofHex

type SchnorrProofHex [64]byte

Match only 128 hex char length proof

func (SchnorrProofHex) MarshalText

func (pfe SchnorrProofHex) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (SchnorrProofHex) String

func (pfe SchnorrProofHex) String() string

func (*SchnorrProofHex) UnmarshalText

func (pfe *SchnorrProofHex) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type SecretKey

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

SecretKey --

func GenerateKey

func GenerateKey() *SecretKey

func LoadBLS

func LoadBLS(file string) (*SecretKey, error)

func SeckeyBatchAdd

func SeckeyBatchAdd(secVec []SecretKey) (sec SecretKey)

SecBatchAdd --

func (*SecretKey) Add

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

Add --

func (*SecretKey) Deserialize

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

Deserialize --

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

func (sec *SecretKey) MakeSchnorrNIZKP() (*SchnorrProof, error)

func (*SecretKey) Mul

func (sec *SecretKey) Mul(rhs *SecretKey)

Mul --

func (*SecretKey) Recover

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

Recover --

func (*SecretKey) Serialize

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

Serialize --

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

Sign -- Constant Time version

func (*SecretKey) Sub

func (sec *SecretKey) Sub(rhs *SecretKey)

Sub --

type Sign

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

Sign --

func AggregateSign

func AggregateSign(sigVec []Sign) (sig Sign)

func MsgsToHashToG1

func MsgsToHashToG1(mVec []string) ([]Sign, error)

func (*Sign) Add

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

Add --

func (*Sign) Deserialize

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

Deserialize --

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

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

SetHexString --

func (*Sign) Verify

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

Verify --

func (*Sign) VerifyPop

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

VerifyPop --

Jump to

Keyboard shortcuts

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