Documentation ¶
Index ¶
- Constants
- Variables
- func FinalExp(out *GT, x *GT)
- func Fp2Add(out *Fp2, x *Fp2, y *Fp2)
- func Fp2Div(out *Fp2, x *Fp2, y *Fp2)
- func Fp2Inv(out *Fp2, x *Fp2)
- func Fp2Mul(out *Fp2, x *Fp2, y *Fp2)
- func Fp2Neg(out *Fp2, x *Fp2)
- func Fp2Sqr(out *Fp2, x *Fp2)
- func Fp2SquareRoot(out *Fp2, x *Fp2) bool
- func Fp2Sub(out *Fp2, x *Fp2, y *Fp2)
- func FpAdd(out *Fp, x *Fp, y *Fp)
- func FpDiv(out *Fp, x *Fp, y *Fp)
- func FpInv(out *Fp, x *Fp)
- func FpMul(out *Fp, x *Fp, y *Fp)
- func FpNeg(out *Fp, x *Fp)
- func FpSqr(out *Fp, x *Fp)
- func FpSquareRoot(out *Fp, x *Fp) bool
- func FpSub(out *Fp, x *Fp, y *Fp)
- func FrAdd(out *Fr, x *Fr, y *Fr)
- func FrDiv(out *Fr, x *Fr, y *Fr)
- func FrEvaluatePolynomial(y *Fr, c []Fr, x *Fr) error
- func FrInv(out *Fr, x *Fr)
- func FrLagrangeInterpolation(out *Fr, xVec []Fr, yVec []Fr) error
- func FrMul(out *Fr, x *Fr, y *Fr)
- func FrNeg(out *Fr, x *Fr)
- func FrSqr(out *Fr, x *Fr)
- func FrSquareRoot(out *Fr, x *Fr) bool
- func FrSub(out *Fr, x *Fr, y *Fr)
- func G1Add(out *G1, x *G1, y *G1)
- func G1Dbl(out *G1, x *G1)
- func G1EvaluatePolynomial(y *G1, c []G1, x *Fr) error
- func G1LagrangeInterpolation(out *G1, xVec []Fr, yVec []G1) error
- func G1Mul(out *G1, x *G1, y *Fr)
- func G1MulCT(out *G1, x *G1, y *Fr)
- func G1MulVec(out *G1, xVec []G1, yVec []Fr)
- func G1Neg(out *G1, x *G1)
- func G1Normalize(out *G1, x *G1)
- func G1Sub(out *G1, x *G1, y *G1)
- func G1ToBytes(p *G1) []byte
- func G2Add(out *G2, x *G2, y *G2)
- func G2Dbl(out *G2, x *G2)
- func G2EvaluatePolynomial(y *G2, c []G2, x *Fr) error
- func G2LagrangeInterpolation(out *G2, xVec []Fr, yVec []G2) error
- func G2Mul(out *G2, x *G2, y *Fr)
- func G2MulVec(out *G2, xVec []G2, yVec []Fr)
- func G2Neg(out *G2, x *G2)
- func G2Normalize(out *G2, x *G2)
- func G2Sub(out *G2, x *G2, y *G2)
- func G2ToBytes(p *G2) []byte
- func GTAdd(out *GT, x *GT, y *GT)
- func GTDiv(out *GT, x *GT, y *GT)
- func GTInv(out *GT, x *GT)
- func GTMul(out *GT, x *GT, y *GT)
- func GTNeg(out *GT, x *GT)
- func GTPow(out *GT, x *GT, y *Fr)
- func GTSub(out *GT, x *GT, y *GT)
- func GetCoef() []uint64
- func GetCurveOrder() string
- func GetDomain() []byte
- func GetFieldOrder() string
- func GetFpByteSize() int
- func GetFpUnitSize() int
- func GetFrByteSize() int
- func GetFrUnitSize() int
- func GetG1ByteSize() int
- func GetG2ByteSize() int
- func GetMaxOpUnitSize() int
- func GetOpUnitSize() int
- func GetUint64NumToPrecompute() int
- func InitCurve(curve int) error
- func MapToG1(out *G1, x *Fp) error
- func MapToG2(out *G2, x *Fp2) error
- func MarshalMessage(message []byte) ([]byte, error)
- func MillerLoop(out *GT, x *G1, y *G2)
- func MillerLoopVec(out *GT, xVec []G1, yVec []G2)
- func Pairing(out *GT, x *G1, y *G2)
- func PrecomputeG2(Q *G2) []uint64
- func PrecomputedMillerLoop(out *GT, P *G1, Qbuf []uint64)
- func PrecomputedMillerLoop2(out *GT, P1 *G1, Q1buf []uint64, P2 *G1, Q2buf []uint64)
- func SetDomain(_domain []byte)
- func SetDstG1(s string) error
- func SetDstG2(s string) error
- func SetETHserialization(enable bool)
- func SetMapToMode(mode int) error
- func VerifyOrderG1(doVerify bool)
- func VerifyOrderG2(doVerify bool)
- type Fp
- func (x *Fp) Clear()
- func (x *Fp) Deserialize(buf []byte) error
- func (x *Fp) GetString(base int) string
- func (x *Fp) IsEqual(rhs *Fp) bool
- func (x *Fp) IsNegative() bool
- func (x *Fp) IsOdd() bool
- func (x *Fp) IsOne() bool
- func (x *Fp) IsValid() bool
- func (x *Fp) IsZero() bool
- func (x *Fp) Serialize() []byte
- func (x *Fp) SetBigEndianMod(buf []byte) error
- func (x *Fp) SetByCSPRNG()
- func (x *Fp) SetHashOf(buf []byte) bool
- func (x *Fp) SetInt64(v int64)
- func (x *Fp) SetLittleEndian(buf []byte) error
- func (x *Fp) SetLittleEndianMod(buf []byte) error
- func (x *Fp) SetString(s string, base int) error
- type Fp2
- type Fr
- func (x *Fr) Clear()
- func (x *Fr) Deserialize(buf []byte) error
- func (x *Fr) GetString(base int) string
- func (x *Fr) IsEqual(rhs *Fr) bool
- func (x *Fr) IsNegative() bool
- func (x *Fr) IsOdd() bool
- func (x *Fr) IsOne() bool
- func (x *Fr) IsValid() bool
- func (x *Fr) IsZero() bool
- func (x *Fr) Serialize() []byte
- func (x *Fr) SetBigEndianMod(buf []byte) error
- func (x *Fr) SetByCSPRNG() bool
- func (x *Fr) SetHashOf(buf []byte) bool
- func (x *Fr) SetInt64(v int64)
- func (x *Fr) SetLittleEndian(buf []byte) error
- func (x *Fr) SetLittleEndianMod(buf []byte) error
- func (x *Fr) SetString(s string, base int) error
- type G1
- func (x *G1) Clear()
- func (x *G1) Deserialize(buf []byte) error
- func (x *G1) DeserializeUncompressed(buf []byte) error
- func (x *G1) GetString(base int) string
- func (x *G1) HashAndMapTo(buf []byte) error
- func (x *G1) IsEqual(rhs *G1) bool
- func (x *G1) IsValid() bool
- func (x *G1) IsValidOrder() bool
- func (x *G1) IsZero() bool
- func (x *G1) Serialize() []byte
- func (x *G1) SerializeUncompressed() []byte
- func (x *G1) SetString(s string, base int) error
- type G2
- func (x *G2) Clear()
- func (x *G2) Deserialize(buf []byte) error
- func (x *G2) DeserializeUncompressed(buf []byte) error
- func (x *G2) GetString(base int) string
- func (x *G2) HashAndMapTo(buf []byte) error
- func (x *G2) IsEqual(rhs *G2) bool
- func (x *G2) IsValid() bool
- func (x *G2) IsValidOrder() bool
- func (x *G2) IsZero() bool
- func (x *G2) Serialize() []byte
- func (x *G2) SerializeUncompressed() []byte
- func (x *G2) SetString(s string, base int) error
- type GT
- func (x *GT) Clear()
- func (x *GT) Deserialize(buf []byte) error
- func (x *GT) GetString(base int) string
- func (x *GT) IsEqual(rhs *GT) bool
- func (x *GT) IsOne() bool
- func (x *GT) IsZero() bool
- func (x *GT) Serialize() []byte
- func (x *GT) SetInt64(v int64)
- func (x *GT) SetString(s string, base int) error
- type PrivateKey
- type PublicKey
- type Signature
Constants ¶
const BLS12_381 = C.MCL_BLS12_381
BLS12_381 --
const CurveFp254BNb = C.mclBn_CurveFp254BNb
CurveFp254BNb -- 254 bit curve
const CurveFp382_1 = C.mclBn_CurveFp382_1
CurveFp382_1 -- 382 bit curve 1
const CurveFp382_2 = C.mclBn_CurveFp382_2
CurveFp382_2 -- 382 bit curve 2
const CurveSNARK1 = C.mclBn_CurveSNARK1
254-bit BN curve with support for roots of unity
const IRTF = 5 /* MCL_MAP_TO_MODE_HASH_TO_CURVE_07 */
IRTF -- for SetMapToMode
const ZERO_HEADER = 1 << 6
Variables ¶
var (
HashToG1 func([]byte) (*G1, error)
)
Functions ¶
func FrEvaluatePolynomial ¶
FrEvaluatePolynomial -- y = c[0] + c[1] * x + c[2] * x^2 + ...
func FrLagrangeInterpolation ¶
FrLagrangeInterpolation --
func G1EvaluatePolynomial ¶
G1EvaluatePolynomial -- y = c[0] + c[1] * x + c[2] * x^2 + ...
func G1LagrangeInterpolation ¶
G1LagrangeInterpolation --
func G2EvaluatePolynomial ¶
G2EvaluatePolynomial -- y = c[0] + c[1] * x + c[2] * x^2 + ...
func G2LagrangeInterpolation ¶
G2LagrangeInterpolation --
func GetFieldOrder ¶
func GetFieldOrder() string
GetFieldOrder -- return the characteristic of the field where a curve is defined
func GetOpUnitSize ¶
func GetOpUnitSize() int
GetOpUnitSize -- the length of Fr is GetOpUnitSize() * 8 bytes
func MarshalMessage ¶
MarshalMessage marshalls message into byte slice
func MillerLoopVec ¶
MillerLoopVec -- multi pairings ; out = prod_i e(xVec[i], yVec[i])
func PrecomputedMillerLoop ¶
PrecomputedMillerLoop --
func PrecomputedMillerLoop2 ¶
PrecomputedMillerLoop2 --
func VerifyOrderG1 ¶
func VerifyOrderG1(doVerify bool)
VerifyOrderG1 -- verify order if SetString/Deserialize are called
func VerifyOrderG2 ¶
func VerifyOrderG2(doVerify bool)
VerifyOrderG2 -- verify order if SetString/Deserialize are called
Types ¶
type Fp ¶
type Fp struct {
// contains filtered or unexported fields
}
Fp --
func (*Fp) SetLittleEndianMod ¶
SetLittleEndianMod --
type Fr ¶
type Fr struct {
// contains filtered or unexported fields
}
Fr --
func (*Fr) SetLittleEndianMod ¶
SetLittleEndianMod --
type G1 ¶
G1 --
func G1FromBytes ¶
func HashToG103 ¶
HashToG103 converts message to G1 point https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-03
func HashToG107 ¶
HashToG107 converts message to G1 point https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-07
func (*G1) DeserializeUncompressed ¶
DeserializeUncompressed -- x.Deserialize() + y.Deserialize()
func (*G1) SerializeUncompressed ¶
SerializeUncompressed -- all zero array if x.IsZero()
type G2 ¶
G2 --
func G2FromBytes ¶
func (*G2) DeserializeUncompressed ¶
DeserializeUncompressed -- x.Deserialize() + y.Deserialize()
func (*G2) SerializeUncompressed ¶
SerializeUncompressed -- all zero array if x.IsZero()
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
func CreateRandomBlsKeys ¶
func CreateRandomBlsKeys(total int) ([]*PrivateKey, error)
CreateRandomBlsKeys creates an slice of random private keys
func GenerateBlsKey ¶
func GenerateBlsKey() (*PrivateKey, error)
GenerateBlsKey creates a random private and its corresponding public keys
func UnmarshalPrivateKey ¶
func UnmarshalPrivateKey(data []byte) (*PrivateKey, error)
UnmarshalPrivateKey reads the private key from the given byte array
func (*PrivateKey) MarshalJSON ¶
func (p *PrivateKey) MarshalJSON() ([]byte, error)
MarshalJSON marshal the key to bytes.
func (*PrivateKey) PublicKey ¶
func (p *PrivateKey) PublicKey() *PublicKey
PublicKey returns the public key from the PrivateKey
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey represents bls public key
func AggregatePublicKeys ¶
AggregatePublicKeys calculates P1 + P2 + ...
func CollectPublicKeys ¶
func CollectPublicKeys(keys []*PrivateKey) []*PublicKey
CollectPublicKeys colects public keys from slice of private keys
func UnmarshalPublicKey ¶
UnmarshalPublicKey reads the public key from the given byte array
func (*PublicKey) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*PublicKey) UnmarshalJSON ¶
UnmarshalJSON implements the json.Marshaler interface.
type Signature ¶
type Signature struct {
// contains filtered or unexported fields
}
Signature represents bls signature which is point on the curve
func AggregateSignatures ¶
Aggregate sums the given array of signatures
func UnmarshalSignature ¶
UnmarshalSignature reads the signature from the given byte array