Documentation ¶
Index ¶
- Constants
- func Bls12381FqNew() *native.Field
- type Engine
- type Fq
- type G1
- func (g1 *G1) Add(arg1, arg2 *G1) *G1
- func (g1 *G1) BigInt() (x, y *big.Int)
- func (g1 *G1) CMove(arg1, arg2 *G1, choice int) *G1
- func (g1 *G1) ClearCofactor(a *G1) *G1
- func (g1 *G1) Double(a *G1) *G1
- func (g1 *G1) Equal(rhs *G1) int
- func (g1 *G1) FromCompressed(input *[FieldBytes]byte) (*G1, error)
- func (g1 *G1) FromUncompressed(input *[WideFieldBytes]byte) (*G1, error)
- func (g1 *G1) Generator() *G1
- func (g1 *G1) GetX() *fp
- func (g1 *G1) GetY() *fp
- func (g1 *G1) Hash(hash *native.EllipticPointHasher, msg, dst []byte) *G1
- func (g1 *G1) Identity() *G1
- func (g1 *G1) InCorrectSubgroup() int
- func (g1 *G1) IsIdentity() int
- func (g1 *G1) IsOnCurve() int
- func (g1 *G1) Mul(a *G1, s *native.Field) *G1
- func (g1 *G1) MulByX(a *G1) *G1
- func (g1 *G1) Neg(a *G1) *G1
- func (g1 *G1) Random(reader io.Reader) (*G1, error)
- func (g1 *G1) Set(a *G1) *G1
- func (g1 *G1) SetBigInt(x, y *big.Int) (*G1, error)
- func (g1 *G1) Sub(arg1, arg2 *G1) *G1
- func (g1 *G1) SumOfProducts(points []*G1, scalars []*native.Field) (*G1, error)
- func (g1 *G1) ToAffine(a *G1) *G1
- func (g1 *G1) ToCompressed() [FieldBytes]byte
- func (g1 *G1) ToUncompressed() [WideFieldBytes]byte
- type G2
- func (g2 *G2) Add(arg1, arg2 *G2) *G2
- func (g2 *G2) BigInt() (x, y *big.Int)
- func (g2 *G2) CMove(arg1, arg2 *G2, choice int) *G2
- func (g2 *G2) ClearCofactor(a *G2) *G2
- func (g2 *G2) Double(a *G2) *G2
- func (g2 *G2) Equal(rhs *G2) int
- func (g2 *G2) FromCompressed(input *[WideFieldBytes]byte) (*G2, error)
- func (g2 *G2) FromUncompressed(input *[DoubleWideFieldBytes]byte) (*G2, error)
- func (g2 *G2) Generator() *G2
- func (g2 *G2) GetX() *fp2
- func (g2 *G2) GetY() *fp2
- func (g2 *G2) Hash(hash *native.EllipticPointHasher, msg, dst []byte) *G2
- func (g2 *G2) Identity() *G2
- func (g2 *G2) InCorrectSubgroup() int
- func (g2 *G2) IsIdentity() int
- func (g2 *G2) IsOnCurve() int
- func (g2 *G2) Mul(a *G2, s *native.Field) *G2
- func (g2 *G2) MulByX(a *G2) *G2
- func (g2 *G2) Neg(a *G2) *G2
- func (g2 *G2) Random(reader io.Reader) (*G2, error)
- func (g2 *G2) Set(a *G2) *G2
- func (g2 *G2) SetBigInt(x, y *big.Int) (*G2, error)
- func (g2 *G2) Sub(arg1, arg2 *G2) *G2
- func (g2 *G2) SumOfProducts(points []*G2, scalars []*native.Field) (*G2, error)
- func (g2 *G2) ToAffine(a *G2) *G2
- func (g2 *G2) ToCompressed() [WideFieldBytes]byte
- func (g2 *G2) ToUncompressed() [DoubleWideFieldBytes]byte
- type Gt
- func (gt *Gt) Add(arg1, arg2 *Gt) *Gt
- func (gt *Gt) Bytes() [GtFieldBytes]byte
- func (gt *Gt) Double(a *Gt) *Gt
- func (gt *Gt) Equal(rhs *Gt) int
- func (gt *Gt) FinalExponentiation(a *Gt) *Gt
- func (gt *Gt) Generator() *Gt
- func (gt *Gt) Invert(a *Gt) (*Gt, int)
- func (gt *Gt) IsOne() int
- func (gt *Gt) IsZero() int
- func (gt *Gt) Mul(a *Gt, s *native.Field) *Gt
- func (gt *Gt) Neg(a *Gt) *Gt
- func (gt *Gt) Random(reader io.Reader) (*Gt, error)
- func (gt *Gt) Set(a *Gt) *Gt
- func (gt *Gt) SetBytes(input *[GtFieldBytes]byte) (*Gt, int)
- func (gt *Gt) SetOne() *Gt
- func (gt *Gt) Square(a *Gt) *Gt
- func (gt *Gt) Sub(arg1, arg2 *Gt) *Gt
Constants ¶
const ( Limbs = 6 FieldBytes = 48 WideFieldBytes = 96 DoubleWideFieldBytes = 192 )
const GtFieldBytes = 576
GtFieldBytes is the number of bytes needed to represent this field
Variables ¶
This section is empty.
Functions ¶
func Bls12381FqNew ¶
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) AddPairInvG1 ¶
AddPairInvG1 adds a pair of points to be paired. G1 point is negated
func (*Engine) AddPairInvG2 ¶
AddPairInvG2 adds a pair of points to be paired. G2 point is negated
type Fq ¶
type Fq [native.FieldLimbs]uint64
type G1 ¶
type G1 struct {
// contains filtered or unexported fields
}
G1 is a point in g1
func (*G1) ClearCofactor ¶
ClearCofactor multiplies by (1 - z), where z is the parameter of BLS12-381, which [suffices to clear](https://ia.cr/2019/403) the cofactor and map elliptic curve points to elements of G1.
func (*G1) FromCompressed ¶
func (g1 *G1) FromCompressed(input *[FieldBytes]byte) (*G1, error)
FromCompressed deserializes this element from compressed form.
func (*G1) FromUncompressed ¶
func (g1 *G1) FromUncompressed(input *[WideFieldBytes]byte) (*G1, error)
FromUncompressed deserializes this element from uncompressed form.
func (*G1) Hash ¶
func (g1 *G1) Hash(hash *native.EllipticPointHasher, msg, dst []byte) *G1
Hash uses the hasher to map bytes to a valid point
func (*G1) InCorrectSubgroup ¶
InCorrectSubgroup returns 1 if the point is torsion free, 0 otherwise
func (*G1) IsIdentity ¶
IsIdentity returns true if this point is at infinity
func (*G1) SetBigInt ¶
SetBigInt creates a point from affine x, y and returns the point if it is on the curve
func (*G1) SumOfProducts ¶
SumOfProducts computes the multi-exponentiation for the specified points and scalars and stores the result in `g1`. Returns an error if the lengths of the arguments is not equal.
func (*G1) ToCompressed ¶
func (g1 *G1) ToCompressed() [FieldBytes]byte
ToCompressed serializes this element into compressed form.
func (*G1) ToUncompressed ¶
func (g1 *G1) ToUncompressed() [WideFieldBytes]byte
ToUncompressed serializes this element into uncompressed form.
type G2 ¶
type G2 struct {
// contains filtered or unexported fields
}
G2 is a point in g2
func (*G2) ClearCofactor ¶
ClearCofactor using [Budroni-Pintore](https://ia.cr/2017/419). This is equivalent to multiplying by h_{eff} = 3(z^2 - 1) * h_2 where h_2 is the cofactor of G_2 and z is the parameter of BLS12-381.
func (*G2) FromCompressed ¶
func (g2 *G2) FromCompressed(input *[WideFieldBytes]byte) (*G2, error)
FromCompressed deserializes this element from compressed form.
func (*G2) FromUncompressed ¶
func (g2 *G2) FromUncompressed(input *[DoubleWideFieldBytes]byte) (*G2, error)
FromUncompressed deserializes this element from uncompressed form.
func (*G2) Hash ¶
func (g2 *G2) Hash(hash *native.EllipticPointHasher, msg, dst []byte) *G2
Hash uses the hasher to map bytes to a valid point
func (*G2) InCorrectSubgroup ¶
InCorrectSubgroup returns 1 if the point is torsion free, 0 otherwise
func (*G2) IsIdentity ¶
IsIdentity returns true if this point is at infinity
func (*G2) SetBigInt ¶
SetBigInt creates a point from affine x, y and returns the point if it is on the curve
func (*G2) SumOfProducts ¶
SumOfProducts computes the multi-exponentiation for the specified points and scalars and stores the result in `g2`. Returns an error if the lengths of the arguments is not equal.
func (*G2) ToCompressed ¶
func (g2 *G2) ToCompressed() [WideFieldBytes]byte
ToCompressed serializes this element into compressed form.
func (*G2) ToUncompressed ¶
func (g2 *G2) ToUncompressed() [DoubleWideFieldBytes]byte
ToUncompressed serializes this element into uncompressed form.
type Gt ¶
type Gt fp12
Gt is the target group
func (*Gt) Bytes ¶
func (gt *Gt) Bytes() [GtFieldBytes]byte
Bytes returns the Gt field byte representation
func (*Gt) FinalExponentiation ¶
FinalExponentiation performs a "final exponentiation" routine to convert the result of a Miller loop into an element of `Gt` with help of efficient squaring operation in the so-called `cyclotomic subgroup` of `Fq6` so that it can be compared with other elements of `Gt`.