Documentation
¶
Overview ¶
Package bls12381 implements the BLS12-381 curve groups, fields, and pairing interfaces.
See README.md for details.
Index ¶
- Constants
- func NewOptimalAtePPE() ...
- type BaseFieldElementG1
- func (fe *BaseFieldElementG1) MarshalBinary() (data []byte, err error)
- func (fe *BaseFieldElementG1) MarshalCBOR() ([]byte, error)
- func (*BaseFieldElementG1) Structure() algebra.Structure[*BaseFieldElementG1]
- func (fe *BaseFieldElementG1) UnmarshalBinary(data []byte) error
- func (fe *BaseFieldElementG1) UnmarshalCBOR(data []byte) error
- type BaseFieldElementG2
- func (fe *BaseFieldElementG2) MarshalBinary() ([]byte, error)
- func (fe *BaseFieldElementG2) MarshalCBOR() ([]byte, error)
- func (*BaseFieldElementG2) Structure() algebra.Structure[*BaseFieldElementG2]
- func (fe *BaseFieldElementG2) UnmarshalBinary(data []byte) error
- func (fe *BaseFieldElementG2) UnmarshalCBOR(data []byte) error
- type BaseFieldG1
- func (*BaseFieldG1) BitLen() int
- func (*BaseFieldG1) Characteristic() cardinal.Cardinal
- func (*BaseFieldG1) ElementSize() int
- func (f *BaseFieldG1) FromBytesBEReduce(input []byte) (*BaseFieldElementG1, error)
- func (*BaseFieldG1) Hash(bytes []byte) (*BaseFieldElementG1, error)
- func (*BaseFieldG1) Name() string
- func (*BaseFieldG1) Order() cardinal.Cardinal
- func (*BaseFieldG1) WideElementSize() int
- type BaseFieldG2
- func (*BaseFieldG2) Characteristic() cardinal.Cardinal
- func (*BaseFieldG2) ElementSize() int
- func (*BaseFieldG2) ExtensionDegree() uint
- func (f *BaseFieldG2) FromBytes(data []byte) (*BaseFieldElementG2, error)
- func (*BaseFieldG2) FromWideBytes(data []byte) (*BaseFieldElementG2, error)
- func (*BaseFieldG2) Hash(bytes []byte) (*BaseFieldElementG2, error)
- func (*BaseFieldG2) IsDomain() bool
- func (*BaseFieldG2) Name() string
- func (*BaseFieldG2) Order() cardinal.Cardinal
- func (*BaseFieldG2) WideElementSize() int
- type FamilyTrait
- type G1
- func (*G1) BaseField() algebra.FiniteField[*BaseFieldElementG1]
- func (*G1) BaseStructure() algebra.Structure[*BaseFieldElementG1]
- func (*G1) Cofactor() cardinal.Cardinal
- func (*G1) DualStructure() ...
- func (*G1) ElementSize() int
- func (*G1) FromAffine(x, y *BaseFieldElementG1) (*PointG1, error)
- func (*G1) FromAffineX(x *BaseFieldElementG1, b bool) (*PointG1, error)
- func (c *G1) FromBytes(input []byte) (*PointG1, error)
- func (*G1) FromCompressed(input []byte) (*PointG1, error)
- func (*G1) FromUncompressed(input []byte) (*PointG1, error)
- func (c *G1) FromWideBytes(input []byte) (*PointG1, error)
- func (c *G1) Hash(bytes []byte) (*PointG1, error)
- func (*G1) HashWithDst(dst string, bytes []byte) (*PointG1, error)
- func (*G1) MultiPair(these []*PointG1, with []*PointG2) (*GtElement, error)
- func (*G1) MultiPairAndInvertDuals(these []*PointG1, with []*PointG2) (*GtElement, error)
- func (*G1) MultiScalarMul(scalars []*Scalar, points []*PointG1) (*PointG1, error)
- func (c *G1) MultiScalarOp(scalars []*Scalar, points []*PointG1) (*PointG1, error)
- func (*G1) Name() string
- func (*G1) Order() cardinal.Cardinal
- func (*G1) PairingAlgorithm() curves.PairingAlgorithm
- func (c *G1) ScalarBaseMul(sc *Scalar) *PointG1
- func (c *G1) ScalarBaseOp(sc *Scalar) *PointG1
- func (*G1) ScalarField() algebra.PrimeField[*Scalar]
- func (*G1) ScalarRing() algebra.ZModLike[*Scalar]
- func (*G1) ScalarStructure() algebra.Structure[*Scalar]
- func (*G1) WideElementSize() int
- type G2
- func (*G2) BaseField() algebra.FiniteField[*BaseFieldElementG2]
- func (*G2) BaseStructure() algebra.Structure[*BaseFieldElementG2]
- func (*G2) Cofactor() cardinal.Cardinal
- func (*G2) DualStructure() ...
- func (*G2) ElementSize() int
- func (*G2) FromAffine(x, y *BaseFieldElementG2) (*PointG2, error)
- func (c *G2) FromBytes(input []byte) (*PointG2, error)
- func (*G2) FromCompressed(input []byte) (*PointG2, error)
- func (*G2) FromUncompressed(input []byte) (*PointG2, error)
- func (c *G2) FromWideBytes(input []byte) (*PointG2, error)
- func (c *G2) Hash(bytes []byte) (*PointG2, error)
- func (*G2) HashWithDst(dst string, bytes []byte) (*PointG2, error)
- func (*G2) MultiPair(these []*PointG2, with []*PointG1) (*GtElement, error)
- func (*G2) MultiPairAndInvertDuals(these []*PointG2, with []*PointG1) (*GtElement, error)
- func (*G2) MultiScalarMul(scalars []*Scalar, points []*PointG2) (*PointG2, error)
- func (c *G2) MultiScalarOp(scalars []*Scalar, points []*PointG2) (*PointG2, error)
- func (*G2) Name() string
- func (*G2) Order() cardinal.Cardinal
- func (*G2) PairingAlgorithm() curves.PairingAlgorithm
- func (c *G2) ScalarBaseMul(sc *Scalar) *PointG2
- func (c *G2) ScalarBaseOp(sc *Scalar) *PointG2
- func (*G2) ScalarField() algebra.PrimeField[*Scalar]
- func (*G2) ScalarRing() algebra.ZModLike[*Scalar]
- func (*G2) ScalarStructure() algebra.Structure[*Scalar]
- func (*G2) WideElementSize() int
- type Gt
- func (*Gt) ElementSize() int
- func (*Gt) FromBytes(inBytes []byte) (*GtElement, error)
- func (*Gt) Hash(bytes []byte) (*GtElement, error)
- func (*Gt) Name() string
- func (*Gt) One() *GtElement
- func (g *Gt) OpIdentity() *GtElement
- func (*Gt) Order() cardinal.Cardinal
- func (*Gt) Random(prng io.Reader) (*GtElement, error)
- type GtElement
- func (ge *GtElement) Bytes() []byte
- func (ge *GtElement) Clone() *GtElement
- func (ge *GtElement) Div(e *GtElement) *GtElement
- func (ge *GtElement) Equal(rhs *GtElement) bool
- func (ge *GtElement) HashCode() base.HashCode
- func (ge *GtElement) Inv() *GtElement
- func (ge *GtElement) IsOne() bool
- func (ge *GtElement) IsOpIdentity() bool
- func (ge *GtElement) MarshalBinary() ([]byte, error)
- func (ge *GtElement) Mul(e *GtElement) *GtElement
- func (ge *GtElement) Op(e *GtElement) *GtElement
- func (ge *GtElement) OpInv() *GtElement
- func (ge *GtElement) Square() *GtElement
- func (ge *GtElement) String() string
- func (*GtElement) Structure() algebra.Structure[*GtElement]
- func (ge *GtElement) TryDiv(e *GtElement) (*GtElement, error)
- func (ge *GtElement) TryInv() (*GtElement, error)
- func (ge *GtElement) TryOpInv() (*GtElement, error)
- func (ge *GtElement) UnmarshalBinary(data []byte) error
- type OptimalAtePPE
- func (p *OptimalAtePPE) Add(g1 *PointG1, g2 *PointG2) error
- func (p *OptimalAtePPE) AddAndInvG1(g1 *PointG1, g2 *PointG2) error
- func (p *OptimalAtePPE) AddAndInvG2(g1 *PointG1, g2 *PointG2) error
- func (p *OptimalAtePPE) Check() bool
- func (p *OptimalAtePPE) Equal(...) bool
- func (*OptimalAtePPE) Name() curves.PairingAlgorithm
- func (p *OptimalAtePPE) Reset()
- func (p *OptimalAtePPE) Result() *GtElement
- func (*OptimalAtePPE) Type() curves.PairingType
- type PointG1
- func (p *PointG1) AffineX() (*BaseFieldElementG1, error)
- func (p *PointG1) AffineY() (*BaseFieldElementG1, error)
- func (p *PointG1) Bytes() []byte
- func (p *PointG1) HashCode() base.HashCode
- func (*PointG1) InSourceGroup() bool
- func (p *PointG1) IsTorsionFree() bool
- func (p *PointG1) MarshalBinary() (data []byte, err error)
- func (p *PointG1) MarshalCBOR() ([]byte, error)
- func (p *PointG1) MultiPair(with ...*PointG2) (*GtElement, error)
- func (p *PointG1) MultiPairAndInvertDuals(with ...*PointG2) (*GtElement, error)
- func (p *PointG1) Pair(p2 *PointG2) (*GtElement, error)
- func (p *PointG1) ScalarMul(actor *Scalar) *PointG1
- func (p *PointG1) ScalarOp(sc *Scalar) *PointG1
- func (p *PointG1) String() string
- func (*PointG1) Structure() algebra.Structure[*PointG1]
- func (p *PointG1) ToCompressed() []byte
- func (p *PointG1) ToUncompressed() []byte
- func (p *PointG1) UnmarshalBinary(data []byte) error
- func (p *PointG1) UnmarshalCBOR(data []byte) error
- type PointG2
- func (p *PointG2) AffineX() (*BaseFieldElementG2, error)
- func (p *PointG2) AffineY() (*BaseFieldElementG2, error)
- func (p *PointG2) Bytes() []byte
- func (p *PointG2) HashCode() base.HashCode
- func (*PointG2) InSourceGroup() bool
- func (p *PointG2) IsTorsionFree() bool
- func (p *PointG2) MarshalBinary() (data []byte, err error)
- func (p *PointG2) MarshalCBOR() ([]byte, error)
- func (p *PointG2) MultiPair(with ...*PointG1) (*GtElement, error)
- func (p *PointG2) MultiPairAndInvertDuals(with ...*PointG1) (*GtElement, error)
- func (p *PointG2) Pair(p1 *PointG1) (*GtElement, error)
- func (p *PointG2) ScalarMul(actor *Scalar) *PointG2
- func (p *PointG2) ScalarOp(sc *Scalar) *PointG2
- func (p *PointG2) String() string
- func (*PointG2) Structure() algebra.Structure[*PointG2]
- func (p *PointG2) ToCompressed() []byte
- func (p *PointG2) ToUncompressed() []byte
- func (p *PointG2) UnmarshalBinary(data []byte) error
- func (p *PointG2) UnmarshalCBOR(data []byte) error
- type Scalar
- type ScalarField
- func (*ScalarField) BitLen() int
- func (f *ScalarField) Characteristic() cardinal.Cardinal
- func (*ScalarField) ElementSize() int
- func (f *ScalarField) FromBytesBEReduce(input []byte) (*Scalar, error)
- func (*ScalarField) Hash(input []byte) (*Scalar, error)
- func (*ScalarField) Name() string
- func (*ScalarField) Order() cardinal.Cardinal
- func (*ScalarField) WideElementSize() int
Constants ¶
const ( // CurveNameG1 is the G1 curve name. CurveNameG1 = "BLS12381G1" // Hash2CurveSuiteG1 is the hash-to-curve suite string for G1. Hash2CurveSuiteG1 = "BLS12381G1_XMD:SHA-256_SSWU_RO_" )
const ( // CurveNameG2 is the G2 curve name. CurveNameG2 = "BLS12381G2" // Hash2CurveSuiteG2 is the hash-to-curve suite string for G2. Hash2CurveSuiteG2 = "BLS12381G2_XMD:SHA-256_SSWU_RO_" )
const ( // ScalarFieldName is the scalar field name. ScalarFieldName = "BLS12381Fq" // Hash2CurveScalarSuite is the hash-to-curve scalar suite string. Hash2CurveScalarSuite = "BLS12381G1_XMD:SHA-256_SSWU_RO_SC_" )
const (
// BaseFieldNameG1 is the G1 base field name.
BaseFieldNameG1 = "BLS12381Fp"
)
const (
// BaseFieldNameG2 is the G2 base field name.
BaseFieldNameG2 = "BLS12381Fp2"
)
const FamilyName = "BLS12381"
FamilyName is the BLS12-381 family name.
const (
// GtName is the target group name.
GtName = "BLS12381Fp12Mul"
)
const (
OptimalAteAlgorithm curves.PairingAlgorithm = "OptimalAte"
)
Variables ¶
This section is empty.
Functions ¶
func NewOptimalAtePPE ¶
func NewOptimalAtePPE() curves.PPE[*PointG1, *BaseFieldElementG1, *PointG2, *BaseFieldElementG2, *GtElement, *Scalar]
NewOptimalAtePPE returns the optimal ate pairing engine.
Types ¶
type BaseFieldElementG1 ¶
type BaseFieldElementG1 struct {
traits.PrimeFieldElementTrait[*bls12381Impl.Fp, bls12381Impl.Fp, *BaseFieldElementG1, BaseFieldElementG1]
}
BaseFieldElementG1 represents an element of the G1 base field.
func (*BaseFieldElementG1) MarshalBinary ¶
func (fe *BaseFieldElementG1) MarshalBinary() (data []byte, err error)
MarshalBinary implements encoding.BinaryMarshaler.
func (*BaseFieldElementG1) MarshalCBOR ¶
func (fe *BaseFieldElementG1) MarshalCBOR() ([]byte, error)
MarshalCBOR implements cbor.Marshaler.
func (*BaseFieldElementG1) Structure ¶
func (*BaseFieldElementG1) Structure() algebra.Structure[*BaseFieldElementG1]
Structure returns the algebraic structure for the receiver.
func (*BaseFieldElementG1) UnmarshalBinary ¶
func (fe *BaseFieldElementG1) UnmarshalBinary(data []byte) error
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*BaseFieldElementG1) UnmarshalCBOR ¶
func (fe *BaseFieldElementG1) UnmarshalCBOR(data []byte) error
UnmarshalCBOR implements cbor.Unmarshaler.
type BaseFieldElementG2 ¶
type BaseFieldElementG2 struct {
traits.FiniteFieldElementTrait[*bls12381Impl.Fp2, bls12381Impl.Fp2, *BaseFieldElementG2, BaseFieldElementG2]
}
BaseFieldElementG2 represents an element of the G2 base field.
func (*BaseFieldElementG2) MarshalBinary ¶
func (fe *BaseFieldElementG2) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler.
func (*BaseFieldElementG2) MarshalCBOR ¶
func (fe *BaseFieldElementG2) MarshalCBOR() ([]byte, error)
MarshalCBOR implements cbor.Marshaler.
func (*BaseFieldElementG2) Structure ¶
func (*BaseFieldElementG2) Structure() algebra.Structure[*BaseFieldElementG2]
Structure returns the algebraic structure for the receiver.
func (*BaseFieldElementG2) UnmarshalBinary ¶
func (fe *BaseFieldElementG2) UnmarshalBinary(data []byte) error
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*BaseFieldElementG2) UnmarshalCBOR ¶
func (fe *BaseFieldElementG2) UnmarshalCBOR(data []byte) error
UnmarshalCBOR implements cbor.Unmarshaler.
type BaseFieldG1 ¶
type BaseFieldG1 struct {
traits.PrimeFieldTrait[*bls12381Impl.Fp, *BaseFieldElementG1, BaseFieldElementG1]
}
BaseFieldG1 represents the base field for G1.
func (*BaseFieldG1) BitLen ¶
func (*BaseFieldG1) BitLen() int
BitLen returns the field modulus bit length.
func (*BaseFieldG1) Characteristic ¶
func (*BaseFieldG1) Characteristic() cardinal.Cardinal
Characteristic returns the field characteristic.
func (*BaseFieldG1) ElementSize ¶
func (*BaseFieldG1) ElementSize() int
ElementSize returns the element size in bytes.
func (*BaseFieldG1) FromBytesBEReduce ¶
func (f *BaseFieldG1) FromBytesBEReduce(input []byte) (*BaseFieldElementG1, error)
FromBytesBEReduce reduces a big-endian integer into the field.
func (*BaseFieldG1) Hash ¶
func (*BaseFieldG1) Hash(bytes []byte) (*BaseFieldElementG1, error)
Hash maps input bytes to an element or point.
func (*BaseFieldG1) Name ¶
func (*BaseFieldG1) Name() string
Name returns the name of the structure.
func (*BaseFieldG1) Order ¶
func (*BaseFieldG1) Order() cardinal.Cardinal
Order returns the group or field order.
func (*BaseFieldG1) WideElementSize ¶
func (*BaseFieldG1) WideElementSize() int
WideElementSize returns the wide element size in bytes.
type BaseFieldG2 ¶
type BaseFieldG2 struct {
traits.FiniteFieldTrait[*bls12381Impl.Fp2, *BaseFieldElementG2, BaseFieldElementG2]
}
BaseFieldG2 represents the base field for G2.
func (*BaseFieldG2) Characteristic ¶
func (*BaseFieldG2) Characteristic() cardinal.Cardinal
Characteristic returns the field characteristic.
func (*BaseFieldG2) ElementSize ¶
func (*BaseFieldG2) ElementSize() int
ElementSize returns the element size in bytes.
func (*BaseFieldG2) ExtensionDegree ¶
func (*BaseFieldG2) ExtensionDegree() uint
ExtensionDegree returns the field extension degree.
func (*BaseFieldG2) FromBytes ¶
func (f *BaseFieldG2) FromBytes(data []byte) (*BaseFieldElementG2, error)
FromBytes decodes an element from bytes.
func (*BaseFieldG2) FromWideBytes ¶
func (*BaseFieldG2) FromWideBytes(data []byte) (*BaseFieldElementG2, error)
FromWideBytes decodes an element from wide bytes.
func (*BaseFieldG2) Hash ¶
func (*BaseFieldG2) Hash(bytes []byte) (*BaseFieldElementG2, error)
Hash maps input bytes to an element or point.
func (*BaseFieldG2) IsDomain ¶
func (*BaseFieldG2) IsDomain() bool
IsDomain reports whether the field forms an integral domain.
func (*BaseFieldG2) Name ¶
func (*BaseFieldG2) Name() string
Name returns the name of the structure.
func (*BaseFieldG2) Order ¶
func (*BaseFieldG2) Order() cardinal.Cardinal
Order returns the group or field order.
func (*BaseFieldG2) WideElementSize ¶
func (*BaseFieldG2) WideElementSize() int
WideElementSize returns the wide element size in bytes.
type FamilyTrait ¶
type FamilyTrait struct{}
FamilyTrait provides traits for the BLS12-381 family.
func (*FamilyTrait) GetPPE ¶
func (*FamilyTrait) GetPPE(name curves.PairingAlgorithm) (out curves.PPE[*PointG1, *BaseFieldElementG1, *PointG2, *BaseFieldElementG2, *GtElement, *Scalar], exists bool)
GetPPE returns a pairing engine by algorithm name.
func (*FamilyTrait) Name ¶
func (*FamilyTrait) Name() string
Name returns the name of the structure.
func (*FamilyTrait) SourceSubGroup ¶
func (*FamilyTrait) SourceSubGroup() curves.PairingFriendlyCurve[*PointG1, *BaseFieldElementG1, *PointG2, *BaseFieldElementG2, *GtElement, *Scalar]
SourceSubGroup returns the source subgroup.
func (*FamilyTrait) TargetSubGroup ¶
func (*FamilyTrait) TargetSubGroup() algebra.MultiplicativeGroup[*GtElement]
TargetSubGroup returns the target subgroup.
func (*FamilyTrait) TwistedSubGroup ¶
func (*FamilyTrait) TwistedSubGroup() curves.PairingFriendlyCurve[*PointG2, *BaseFieldElementG2, *PointG1, *BaseFieldElementG1, *GtElement, *Scalar]
TwistedSubGroup returns the twisted subgroup.
type G1 ¶
type G1 struct {
traits.PrimeCurveTrait[*bls12381Impl.Fp, *bls12381Impl.G1Point, *PointG1, PointG1]
}
G1 represents the BLS12-381 G1 group.
func (*G1) BaseField ¶
func (*G1) BaseField() algebra.FiniteField[*BaseFieldElementG1]
BaseField returns the base field.
func (*G1) BaseStructure ¶
func (*G1) BaseStructure() algebra.Structure[*BaseFieldElementG1]
BaseStructure returns the base field structure.
func (*G1) DualStructure ¶
func (*G1) DualStructure() curves.PairingFriendlyCurve[*PointG2, *BaseFieldElementG2, *PointG1, *BaseFieldElementG1, *GtElement, *Scalar]
DualStructure returns the dual group structure.
func (*G1) ElementSize ¶
ElementSize returns the element size in bytes.
func (*G1) FromAffine ¶
func (*G1) FromAffine(x, y *BaseFieldElementG1) (*PointG1, error)
FromAffine builds a point from affine coordinates.
func (*G1) FromAffineX ¶
func (*G1) FromAffineX(x *BaseFieldElementG1, b bool) (*PointG1, error)
FromAffineX builds a point from an affine x-coordinate.
func (*G1) FromCompressed ¶
FromCompressed decodes a compressed point.
func (*G1) FromUncompressed ¶
FromUncompressed decodes an uncompressed point.
func (*G1) FromWideBytes ¶
FromWideBytes decodes an element from wide bytes.
func (*G1) HashWithDst ¶
HashWithDst maps input bytes to a point with a custom DST.
func (*G1) MultiPairAndInvertDuals ¶
MultiPairAndInvertDuals computes a multi-pairing and inverts dual points.
func (*G1) MultiScalarMul ¶
MultiScalarMul computes a multiscalar multiplication.
func (*G1) MultiScalarOp ¶
MultiScalarOp computes a multiscalar operation.
func (*G1) PairingAlgorithm ¶
func (*G1) PairingAlgorithm() curves.PairingAlgorithm
PairingAlgorithm returns the pairing algorithm identifier.
func (*G1) ScalarBaseMul ¶
ScalarBaseMul multiplies the generator by a scalar.
func (*G1) ScalarBaseOp ¶
ScalarBaseOp adds a scalar multiple of the generator.
func (*G1) ScalarField ¶
func (*G1) ScalarField() algebra.PrimeField[*Scalar]
ScalarField returns the scalar field.
func (*G1) ScalarRing ¶
ScalarRing returns the scalar ring.
func (*G1) ScalarStructure ¶
ScalarStructure returns the scalar structure.
func (*G1) WideElementSize ¶
WideElementSize returns the wide element size in bytes.
type G2 ¶
type G2 struct {
traits.PrimeCurveTrait[*bls12381Impl.Fp2, *bls12381Impl.G2Point, *PointG2, PointG2]
}
G2 represents the BLS12-381 G2 group.
func (*G2) BaseField ¶
func (*G2) BaseField() algebra.FiniteField[*BaseFieldElementG2]
BaseField returns the base field.
func (*G2) BaseStructure ¶
func (*G2) BaseStructure() algebra.Structure[*BaseFieldElementG2]
BaseStructure returns the base field structure.
func (*G2) DualStructure ¶
func (*G2) DualStructure() curves.PairingFriendlyCurve[*PointG1, *BaseFieldElementG1, *PointG2, *BaseFieldElementG2, *GtElement, *Scalar]
DualStructure returns the dual group structure.
func (*G2) ElementSize ¶
ElementSize returns the element size in bytes.
func (*G2) FromAffine ¶
func (*G2) FromAffine(x, y *BaseFieldElementG2) (*PointG2, error)
FromAffine builds a point from affine coordinates.
func (*G2) FromCompressed ¶
FromCompressed decodes a compressed point.
func (*G2) FromUncompressed ¶
FromUncompressed decodes an uncompressed point.
func (*G2) FromWideBytes ¶
FromWideBytes decodes an element from wide bytes.
func (*G2) HashWithDst ¶
HashWithDst maps input bytes to a point with a custom DST.
func (*G2) MultiPairAndInvertDuals ¶
MultiPairAndInvertDuals computes a multi-pairing and inverts dual points.
func (*G2) MultiScalarMul ¶
MultiScalarMul computes a multiscalar multiplication.
func (*G2) MultiScalarOp ¶
MultiScalarOp computes a multiscalar operation.
func (*G2) PairingAlgorithm ¶
func (*G2) PairingAlgorithm() curves.PairingAlgorithm
PairingAlgorithm returns the pairing algorithm identifier.
func (*G2) ScalarBaseMul ¶
ScalarBaseMul multiplies the generator by a scalar.
func (*G2) ScalarBaseOp ¶
ScalarBaseOp adds a scalar multiple of the generator.
func (*G2) ScalarField ¶
func (*G2) ScalarField() algebra.PrimeField[*Scalar]
ScalarField returns the scalar field.
func (*G2) ScalarRing ¶
ScalarRing returns the scalar ring.
func (*G2) ScalarStructure ¶
ScalarStructure returns the scalar structure.
func (*G2) WideElementSize ¶
WideElementSize returns the wide element size in bytes.
type Gt ¶
type Gt struct{}
Gt represents the BLS12-381 GT group.
func (*Gt) ElementSize ¶
ElementSize returns the element size in bytes.
type GtElement ¶
type GtElement struct {
V bls12381Impl.Gt
}
GtElement represents an element of the target group.
func (*GtElement) IsOpIdentity ¶
IsOpIdentity reports whether the element is the identity.
func (*GtElement) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*GtElement) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
type OptimalAtePPE ¶
type OptimalAtePPE struct {
// contains filtered or unexported fields
}
OptimalAtePPE implements the optimal ate pairing engine.
func (*OptimalAtePPE) Add ¶
func (p *OptimalAtePPE) Add(g1 *PointG1, g2 *PointG2) error
Add sets the receiver to lhs + rhs.
func (*OptimalAtePPE) AddAndInvG1 ¶
func (p *OptimalAtePPE) AddAndInvG1(g1 *PointG1, g2 *PointG2) error
AddAndInvG1 adds a pair with G1 inverted.
func (*OptimalAtePPE) AddAndInvG2 ¶
func (p *OptimalAtePPE) AddAndInvG2(g1 *PointG1, g2 *PointG2) error
AddAndInvG2 adds a pair with G2 inverted.
func (*OptimalAtePPE) Check ¶
func (p *OptimalAtePPE) Check() bool
Check verifies the accumulated pairing.
func (*OptimalAtePPE) Equal ¶
func (p *OptimalAtePPE) Equal(other curves.PPE[*PointG1, *BaseFieldElementG1, *PointG2, *BaseFieldElementG2, *GtElement, *Scalar]) bool
Equal reports whether the receiver equals v.
func (*OptimalAtePPE) Name ¶
func (*OptimalAtePPE) Name() curves.PairingAlgorithm
Name returns the name of the structure.
func (*OptimalAtePPE) Reset ¶
func (p *OptimalAtePPE) Reset()
Reset clears the pairing engine state.
func (*OptimalAtePPE) Result ¶
func (p *OptimalAtePPE) Result() *GtElement
Result returns the accumulated pairing result.
func (*OptimalAtePPE) Type ¶
func (*OptimalAtePPE) Type() curves.PairingType
Type returns the pairing type.
type PointG1 ¶
type PointG1 struct {
traits.PrimePointTrait[*bls12381Impl.Fp, *bls12381Impl.G1Point, bls12381Impl.G1Point, *PointG1, PointG1]
}
PointG1 represents a point in G1.
func (*PointG1) AffineX ¶
func (p *PointG1) AffineX() (*BaseFieldElementG1, error)
AffineX returns the affine x-coordinate.
func (*PointG1) AffineY ¶
func (p *PointG1) AffineY() (*BaseFieldElementG1, error)
AffineY returns the affine y-coordinate.
func (*PointG1) InSourceGroup ¶
InSourceGroup reports whether p is in the source group.
func (*PointG1) IsTorsionFree ¶
IsTorsionFree reports whether the point is torsion-free.
func (*PointG1) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*PointG1) MarshalCBOR ¶
MarshalCBOR implements cbor.Marshaler.
func (*PointG1) MultiPairAndInvertDuals ¶
MultiPairAndInvertDuals computes a multi-pairing and inverts dual points.
func (*PointG1) ToCompressed ¶
ToCompressed encodes the point in compressed form.
func (*PointG1) ToUncompressed ¶
ToUncompressed encodes the point in uncompressed form.
func (*PointG1) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*PointG1) UnmarshalCBOR ¶
UnmarshalCBOR implements cbor.Unmarshaler.
type PointG2 ¶
type PointG2 struct {
traits.PrimePointTrait[*bls12381Impl.Fp2, *bls12381Impl.G2Point, bls12381Impl.G2Point, *PointG2, PointG2]
}
PointG2 represents a point in G2.
func (*PointG2) AffineX ¶
func (p *PointG2) AffineX() (*BaseFieldElementG2, error)
AffineX returns the affine x-coordinate.
func (*PointG2) AffineY ¶
func (p *PointG2) AffineY() (*BaseFieldElementG2, error)
AffineY returns the affine y-coordinate.
func (*PointG2) InSourceGroup ¶
InSourceGroup reports whether p is in the source group.
func (*PointG2) IsTorsionFree ¶
IsTorsionFree reports whether the point is torsion-free.
func (*PointG2) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*PointG2) MarshalCBOR ¶
MarshalCBOR implements cbor.Marshaler.
func (*PointG2) MultiPairAndInvertDuals ¶
MultiPairAndInvertDuals computes a multi-pairing and inverts dual points.
func (*PointG2) ToCompressed ¶
ToCompressed encodes the point in compressed form.
func (*PointG2) ToUncompressed ¶
ToUncompressed encodes the point in uncompressed form.
func (*PointG2) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*PointG2) UnmarshalCBOR ¶
UnmarshalCBOR implements cbor.Unmarshaler.
type Scalar ¶
type Scalar struct {
traits.PrimeFieldElementTrait[*bls12381Impl.Fq, bls12381Impl.Fq, *Scalar, Scalar]
}
Scalar represents a scalar field element.
func (*Scalar) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*Scalar) MarshalCBOR ¶
MarshalCBOR implements cbor.Marshaler.
func (*Scalar) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*Scalar) UnmarshalCBOR ¶
UnmarshalCBOR implements cbor.Unmarshaler.
type ScalarField ¶
type ScalarField struct {
traits.PrimeFieldTrait[*bls12381Impl.Fq, *Scalar, Scalar]
}
ScalarField represents the scalar field.
func NewScalarField ¶
func NewScalarField() *ScalarField
NewScalarField returns the scalar field instance.
func (*ScalarField) BitLen ¶
func (*ScalarField) BitLen() int
BitLen returns the field modulus bit length.
func (*ScalarField) Characteristic ¶
func (f *ScalarField) Characteristic() cardinal.Cardinal
Characteristic returns the field characteristic.
func (*ScalarField) ElementSize ¶
func (*ScalarField) ElementSize() int
ElementSize returns the element size in bytes.
func (*ScalarField) FromBytesBEReduce ¶
func (f *ScalarField) FromBytesBEReduce(input []byte) (*Scalar, error)
FromBytesBEReduce reduces a big-endian integer into the field.
func (*ScalarField) Hash ¶
func (*ScalarField) Hash(input []byte) (*Scalar, error)
Hash maps input bytes to an element or point.
func (*ScalarField) Name ¶
func (*ScalarField) Name() string
Name returns the name of the structure.
func (*ScalarField) Order ¶
func (*ScalarField) Order() cardinal.Cardinal
Order returns the group or field order.
func (*ScalarField) WideElementSize ¶
func (*ScalarField) WideElementSize() int
WideElementSize returns the wide element size in bytes.