bls12381

package
v0.0.0-...-7685c8a Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

README

bls12381

This package implements the BLS12-381 curve groups, fields, and pairing interfaces.

Documentation

Overview

Package bls12381 implements the BLS12-381 curve groups, fields, and pairing interfaces.

See README.md for details.

Index

Constants

View Source
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_"
)
View Source
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_"
)
View Source
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_"
)
View Source
const (
	// BaseFieldNameG1 is the G1 base field name.
	BaseFieldNameG1 = "BLS12381Fp"
)
View Source
const (
	// BaseFieldNameG2 is the G2 base field name.
	BaseFieldNameG2 = "BLS12381Fp2"
)
View Source
const FamilyName = "BLS12381"

FamilyName is the BLS12-381 family name.

View Source
const (
	// GtName is the target group name.
	GtName = "BLS12381Fp12Mul"
)
View Source
const (
	OptimalAteAlgorithm curves.PairingAlgorithm = "OptimalAte"
)

Variables

This section is empty.

Functions

func NewOptimalAtePPE

NewOptimalAtePPE returns the optimal ate pairing engine.

Types

type 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

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

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

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

BaseFieldG1 represents the base field for G1.

func NewG1BaseField

func NewG1BaseField() *BaseFieldG1

NewG1BaseField returns a new instance.

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

BaseFieldG2 represents the base field for G2.

func NewG2BaseField

func NewG2BaseField() *BaseFieldG2

NewG2BaseField returns a new instance.

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

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

SourceSubGroup returns the source subgroup.

func (*FamilyTrait) TargetSubGroup

func (*FamilyTrait) TargetSubGroup() algebra.MultiplicativeGroup[*GtElement]

TargetSubGroup returns the target subgroup.

func (*FamilyTrait) TwistedSubGroup

TwistedSubGroup returns the twisted subgroup.

type G1

G1 represents the BLS12-381 G1 group.

func NewG1

func NewG1() *G1

NewG1 returns the BLS12-381 G1 group instance.

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

func (*G1) Cofactor() cardinal.Cardinal

Cofactor returns the curve cofactor.

func (*G1) DualStructure

DualStructure returns the dual group structure.

func (*G1) ElementSize

func (*G1) ElementSize() int

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

func (c *G1) FromBytes(input []byte) (*PointG1, error)

FromBytes decodes an element from bytes.

func (*G1) FromCompressed

func (*G1) FromCompressed(input []byte) (*PointG1, error)

FromCompressed decodes a compressed point.

func (*G1) FromUncompressed

func (*G1) FromUncompressed(input []byte) (*PointG1, error)

FromUncompressed decodes an uncompressed point.

func (*G1) FromWideBytes

func (c *G1) FromWideBytes(input []byte) (*PointG1, error)

FromWideBytes decodes an element from wide bytes.

func (*G1) Hash

func (c *G1) Hash(bytes []byte) (*PointG1, error)

Hash maps input bytes to an element or point.

func (*G1) HashWithDst

func (*G1) HashWithDst(dst string, bytes []byte) (*PointG1, error)

HashWithDst maps input bytes to a point with a custom DST.

func (*G1) MultiPair

func (*G1) MultiPair(these []*PointG1, with []*PointG2) (*GtElement, error)

MultiPair computes a multi-pairing.

func (*G1) MultiPairAndInvertDuals

func (*G1) MultiPairAndInvertDuals(these []*PointG1, with []*PointG2) (*GtElement, error)

MultiPairAndInvertDuals computes a multi-pairing and inverts dual points.

func (*G1) MultiScalarMul

func (*G1) MultiScalarMul(scalars []*Scalar, points []*PointG1) (*PointG1, error)

MultiScalarMul computes a multiscalar multiplication.

func (*G1) MultiScalarOp

func (c *G1) MultiScalarOp(scalars []*Scalar, points []*PointG1) (*PointG1, error)

MultiScalarOp computes a multiscalar operation.

func (*G1) Name

func (*G1) Name() string

Name returns the name of the structure.

func (*G1) Order

func (*G1) Order() cardinal.Cardinal

Order returns the group or field order.

func (*G1) PairingAlgorithm

func (*G1) PairingAlgorithm() curves.PairingAlgorithm

PairingAlgorithm returns the pairing algorithm identifier.

func (*G1) ScalarBaseMul

func (c *G1) ScalarBaseMul(sc *Scalar) *PointG1

ScalarBaseMul multiplies the generator by a scalar.

func (*G1) ScalarBaseOp

func (c *G1) ScalarBaseOp(sc *Scalar) *PointG1

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

func (*G1) ScalarRing() algebra.ZModLike[*Scalar]

ScalarRing returns the scalar ring.

func (*G1) ScalarStructure

func (*G1) ScalarStructure() algebra.Structure[*Scalar]

ScalarStructure returns the scalar structure.

func (*G1) WideElementSize

func (*G1) WideElementSize() int

WideElementSize returns the wide element size in bytes.

type G2

G2 represents the BLS12-381 G2 group.

func NewG2

func NewG2() *G2

NewG2 returns the BLS12-381 G2 group instance.

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

func (*G2) Cofactor() cardinal.Cardinal

Cofactor returns the curve cofactor.

func (*G2) DualStructure

DualStructure returns the dual group structure.

func (*G2) ElementSize

func (*G2) ElementSize() int

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

func (c *G2) FromBytes(input []byte) (*PointG2, error)

FromBytes decodes an element from bytes.

func (*G2) FromCompressed

func (*G2) FromCompressed(input []byte) (*PointG2, error)

FromCompressed decodes a compressed point.

func (*G2) FromUncompressed

func (*G2) FromUncompressed(input []byte) (*PointG2, error)

FromUncompressed decodes an uncompressed point.

func (*G2) FromWideBytes

func (c *G2) FromWideBytes(input []byte) (*PointG2, error)

FromWideBytes decodes an element from wide bytes.

func (*G2) Hash

func (c *G2) Hash(bytes []byte) (*PointG2, error)

Hash maps input bytes to an element or point.

func (*G2) HashWithDst

func (*G2) HashWithDst(dst string, bytes []byte) (*PointG2, error)

HashWithDst maps input bytes to a point with a custom DST.

func (*G2) MultiPair

func (*G2) MultiPair(these []*PointG2, with []*PointG1) (*GtElement, error)

MultiPair computes a multi-pairing.

func (*G2) MultiPairAndInvertDuals

func (*G2) MultiPairAndInvertDuals(these []*PointG2, with []*PointG1) (*GtElement, error)

MultiPairAndInvertDuals computes a multi-pairing and inverts dual points.

func (*G2) MultiScalarMul

func (*G2) MultiScalarMul(scalars []*Scalar, points []*PointG2) (*PointG2, error)

MultiScalarMul computes a multiscalar multiplication.

func (*G2) MultiScalarOp

func (c *G2) MultiScalarOp(scalars []*Scalar, points []*PointG2) (*PointG2, error)

MultiScalarOp computes a multiscalar operation.

func (*G2) Name

func (*G2) Name() string

Name returns the name of the structure.

func (*G2) Order

func (*G2) Order() cardinal.Cardinal

Order returns the group or field order.

func (*G2) PairingAlgorithm

func (*G2) PairingAlgorithm() curves.PairingAlgorithm

PairingAlgorithm returns the pairing algorithm identifier.

func (*G2) ScalarBaseMul

func (c *G2) ScalarBaseMul(sc *Scalar) *PointG2

ScalarBaseMul multiplies the generator by a scalar.

func (*G2) ScalarBaseOp

func (c *G2) ScalarBaseOp(sc *Scalar) *PointG2

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

func (*G2) ScalarRing() algebra.ZModLike[*Scalar]

ScalarRing returns the scalar ring.

func (*G2) ScalarStructure

func (*G2) ScalarStructure() algebra.Structure[*Scalar]

ScalarStructure returns the scalar structure.

func (*G2) WideElementSize

func (*G2) WideElementSize() int

WideElementSize returns the wide element size in bytes.

type Gt

type Gt struct{}

Gt represents the BLS12-381 GT group.

func NewGt

func NewGt() *Gt

NewGt returns the BLS12-381 GT group instance.

func (*Gt) ElementSize

func (*Gt) ElementSize() int

ElementSize returns the element size in bytes.

func (*Gt) FromBytes

func (*Gt) FromBytes(inBytes []byte) (*GtElement, error)

FromBytes decodes an element from bytes.

func (*Gt) Hash

func (*Gt) Hash(bytes []byte) (*GtElement, error)

Hash maps input bytes to an element or point.

func (*Gt) Name

func (*Gt) Name() string

Name returns the name of the structure.

func (*Gt) One

func (*Gt) One() *GtElement

One returns the multiplicative identity.

func (*Gt) OpIdentity

func (g *Gt) OpIdentity() *GtElement

OpIdentity returns the group identity.

func (*Gt) Order

func (*Gt) Order() cardinal.Cardinal

Order returns the group or field order.

func (*Gt) Random

func (*Gt) Random(prng io.Reader) (*GtElement, error)

Random samples a random element.

type GtElement

type GtElement struct {
	V bls12381Impl.Gt
}

GtElement represents an element of the target group.

func (*GtElement) Bytes

func (ge *GtElement) Bytes() []byte

Bytes returns the canonical byte encoding.

func (*GtElement) Clone

func (ge *GtElement) Clone() *GtElement

Clone returns a copy of the element.

func (*GtElement) Div

func (ge *GtElement) Div(e *GtElement) *GtElement

Div sets the receiver to lhs / rhs, if rhs is nonzero.

func (*GtElement) Equal

func (ge *GtElement) Equal(rhs *GtElement) bool

Equal reports whether the receiver equals v.

func (*GtElement) HashCode

func (ge *GtElement) HashCode() base.HashCode

HashCode returns a hash code for the receiver.

func (*GtElement) Inv

func (ge *GtElement) Inv() *GtElement

Inv sets the receiver to the inverse of a, if it exists.

func (*GtElement) IsOne

func (ge *GtElement) IsOne() bool

IsOne reports whether the receiver is one.

func (*GtElement) IsOpIdentity

func (ge *GtElement) IsOpIdentity() bool

IsOpIdentity reports whether the element is the identity.

func (*GtElement) MarshalBinary

func (ge *GtElement) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*GtElement) Mul

func (ge *GtElement) Mul(e *GtElement) *GtElement

Mul sets the receiver to lhs * rhs.

func (*GtElement) Op

func (ge *GtElement) Op(e *GtElement) *GtElement

Op applies the group operation.

func (*GtElement) OpInv

func (ge *GtElement) OpInv() *GtElement

OpInv returns the group inverse.

func (*GtElement) Square

func (ge *GtElement) Square() *GtElement

Square sets the receiver to v^2.

func (*GtElement) String

func (ge *GtElement) String() string

String returns the string form of the receiver.

func (*GtElement) Structure

func (*GtElement) Structure() algebra.Structure[*GtElement]

Structure returns the algebraic structure for the receiver.

func (*GtElement) TryDiv

func (ge *GtElement) TryDiv(e *GtElement) (*GtElement, error)

TryDiv divides by the given element.

func (*GtElement) TryInv

func (ge *GtElement) TryInv() (*GtElement, error)

TryInv returns the multiplicative inverse.

func (*GtElement) TryOpInv

func (ge *GtElement) TryOpInv() (*GtElement, error)

TryOpInv returns the group inverse.

func (*GtElement) UnmarshalBinary

func (ge *GtElement) UnmarshalBinary(data []byte) error

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

Equal reports whether the receiver equals v.

func (*OptimalAtePPE) Name

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

Type returns the pairing type.

type 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) Bytes

func (p *PointG1) Bytes() []byte

Bytes returns the canonical byte encoding.

func (*PointG1) HashCode

func (p *PointG1) HashCode() base.HashCode

HashCode returns a hash code for the receiver.

func (*PointG1) InSourceGroup

func (*PointG1) InSourceGroup() bool

InSourceGroup reports whether p is in the source group.

func (*PointG1) IsTorsionFree

func (p *PointG1) IsTorsionFree() bool

IsTorsionFree reports whether the point is torsion-free.

func (*PointG1) MarshalBinary

func (p *PointG1) MarshalBinary() (data []byte, err error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*PointG1) MarshalCBOR

func (p *PointG1) MarshalCBOR() ([]byte, error)

MarshalCBOR implements cbor.Marshaler.

func (*PointG1) MultiPair

func (p *PointG1) MultiPair(with ...*PointG2) (*GtElement, error)

MultiPair computes a multi-pairing.

func (*PointG1) MultiPairAndInvertDuals

func (p *PointG1) MultiPairAndInvertDuals(with ...*PointG2) (*GtElement, error)

MultiPairAndInvertDuals computes a multi-pairing and inverts dual points.

func (*PointG1) Pair

func (p *PointG1) Pair(p2 *PointG2) (*GtElement, error)

Pair computes the pairing of p and q.

func (*PointG1) ScalarMul

func (p *PointG1) ScalarMul(actor *Scalar) *PointG1

ScalarMul multiplies the point by a scalar.

func (*PointG1) ScalarOp

func (p *PointG1) ScalarOp(sc *Scalar) *PointG1

ScalarOp adds a scalar multiple of q to the receiver.

func (*PointG1) String

func (p *PointG1) String() string

String returns the string form of the receiver.

func (*PointG1) Structure

func (*PointG1) Structure() algebra.Structure[*PointG1]

Structure returns the algebraic structure for the receiver.

func (*PointG1) ToCompressed

func (p *PointG1) ToCompressed() []byte

ToCompressed encodes the point in compressed form.

func (*PointG1) ToUncompressed

func (p *PointG1) ToUncompressed() []byte

ToUncompressed encodes the point in uncompressed form.

func (*PointG1) UnmarshalBinary

func (p *PointG1) UnmarshalBinary(data []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (*PointG1) UnmarshalCBOR

func (p *PointG1) UnmarshalCBOR(data []byte) error

UnmarshalCBOR implements cbor.Unmarshaler.

type 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) Bytes

func (p *PointG2) Bytes() []byte

Bytes returns the canonical byte encoding.

func (*PointG2) HashCode

func (p *PointG2) HashCode() base.HashCode

HashCode returns a hash code for the receiver.

func (*PointG2) InSourceGroup

func (*PointG2) InSourceGroup() bool

InSourceGroup reports whether p is in the source group.

func (*PointG2) IsTorsionFree

func (p *PointG2) IsTorsionFree() bool

IsTorsionFree reports whether the point is torsion-free.

func (*PointG2) MarshalBinary

func (p *PointG2) MarshalBinary() (data []byte, err error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*PointG2) MarshalCBOR

func (p *PointG2) MarshalCBOR() ([]byte, error)

MarshalCBOR implements cbor.Marshaler.

func (*PointG2) MultiPair

func (p *PointG2) MultiPair(with ...*PointG1) (*GtElement, error)

MultiPair computes a multi-pairing.

func (*PointG2) MultiPairAndInvertDuals

func (p *PointG2) MultiPairAndInvertDuals(with ...*PointG1) (*GtElement, error)

MultiPairAndInvertDuals computes a multi-pairing and inverts dual points.

func (*PointG2) Pair

func (p *PointG2) Pair(p1 *PointG1) (*GtElement, error)

Pair computes the pairing of p and q.

func (*PointG2) ScalarMul

func (p *PointG2) ScalarMul(actor *Scalar) *PointG2

ScalarMul multiplies the point by a scalar.

func (*PointG2) ScalarOp

func (p *PointG2) ScalarOp(sc *Scalar) *PointG2

ScalarOp adds a scalar multiple of q to the receiver.

func (*PointG2) String

func (p *PointG2) String() string

String returns the string form of the receiver.

func (*PointG2) Structure

func (*PointG2) Structure() algebra.Structure[*PointG2]

Structure returns the algebraic structure for the receiver.

func (*PointG2) ToCompressed

func (p *PointG2) ToCompressed() []byte

ToCompressed encodes the point in compressed form.

func (*PointG2) ToUncompressed

func (p *PointG2) ToUncompressed() []byte

ToUncompressed encodes the point in uncompressed form.

func (*PointG2) UnmarshalBinary

func (p *PointG2) UnmarshalBinary(data []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (*PointG2) UnmarshalCBOR

func (p *PointG2) UnmarshalCBOR(data []byte) error

UnmarshalCBOR implements cbor.Unmarshaler.

type Scalar

Scalar represents a scalar field element.

func (*Scalar) MarshalBinary

func (s *Scalar) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*Scalar) MarshalCBOR

func (s *Scalar) MarshalCBOR() ([]byte, error)

MarshalCBOR implements cbor.Marshaler.

func (*Scalar) Structure

func (*Scalar) Structure() algebra.Structure[*Scalar]

Structure returns the algebraic structure for the receiver.

func (*Scalar) UnmarshalBinary

func (s *Scalar) UnmarshalBinary(data []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (*Scalar) UnmarshalCBOR

func (s *Scalar) UnmarshalCBOR(data []byte) error

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.

Directories

Path Synopsis
Package impl contains low-level BLS12-381 field arithmetic, points, and pairing engine code.
Package impl contains low-level BLS12-381 field arithmetic, points, and pairing engine code.

Jump to

Keyboard shortcuts

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