go-ethereum: github.com/ethereum/go-ethereum/crypto/bls12381 Index | Files

package bls12381

import "github.com/ethereum/go-ethereum/crypto/bls12381"

Index

Package Files

arithmetic_fallback.go bls12_381.go field_element.go fp.go fp12.go fp2.go fp6.go g1.go g2.go gt.go isogeny.go pairing.go swu.go utils.go

type E Uses

type E = fe12

E is type for target group element

func (*E) Equal Uses

func (g *E) Equal(g2 *E) bool

Equal returns true if given two element is equal, otherwise returns false

func (*E) IsOne Uses

func (e *E) IsOne() bool

IsOne returns true if given element equals to one

func (*E) One Uses

func (e *E) One() *E

One sets a new target group element to one

func (*E) Set Uses

func (e *E) Set(e2 *E) *E

type Engine Uses

type Engine struct {
    G1  *G1
    G2  *G2
    // contains filtered or unexported fields
}

Engine is BLS12-381 elliptic curve pairing engine

func NewPairingEngine Uses

func NewPairingEngine() *Engine

NewPairingEngine creates new pairing engine instance.

func (*Engine) AddPair Uses

func (e *Engine) AddPair(g1 *PointG1, g2 *PointG2) *Engine

AddPair adds a g1, g2 point pair to pairing engine

func (*Engine) AddPairInv Uses

func (e *Engine) AddPairInv(g1 *PointG1, g2 *PointG2) *Engine

AddPairInv adds a G1, G2 point pair to pairing engine. G1 point is negated.

func (*Engine) Check Uses

func (e *Engine) Check() bool

Check computes pairing and checks if result is equal to one

func (*Engine) GT Uses

func (e *Engine) GT() *GT

GT returns target group instance.

func (*Engine) Reset Uses

func (e *Engine) Reset() *Engine

Reset deletes added pairs.

func (*Engine) Result Uses

func (e *Engine) Result() *E

Result computes pairing and returns target group element as result.

type G1 Uses

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

G1 is struct for G1 group.

func NewG1 Uses

func NewG1() *G1

NewG1 constructs a new G1 instance.

func (*G1) Add Uses

func (g *G1) Add(r, p1, p2 *PointG1) *PointG1

Add adds two G1 points p1, p2 and assigns the result to point at first argument.

func (*G1) Affine Uses

func (g *G1) Affine(p *PointG1) *PointG1

Add adds two G1 points p1, p2 and assigns the result to point at first argument.

func (*G1) ClearCofactor Uses

func (g *G1) ClearCofactor(p *PointG1)

ClearCofactor maps given a G1 point to correct subgroup

func (*G1) DecodePoint Uses

func (g *G1) DecodePoint(in []byte) (*PointG1, error)

DecodePoint given encoded (x, y) coordinates in 128 bytes returns a valid G1 Point.

func (*G1) Double Uses

func (g *G1) Double(r, p *PointG1) *PointG1

Double doubles a G1 point p and assigns the result to the point at first argument.

func (*G1) EncodePoint Uses

func (g *G1) EncodePoint(p *PointG1) []byte

EncodePoint encodes a point into 128 bytes.

func (*G1) Equal Uses

func (g *G1) Equal(p1, p2 *PointG1) bool

Equal checks if given two G1 point is equal in their affine form.

func (*G1) FromBytes Uses

func (g *G1) FromBytes(in []byte) (*PointG1, error)

FromBytes constructs a new point given uncompressed byte input. FromBytes does not take zcash flags into account. Byte input expected to be larger than 96 bytes. First 96 bytes should be concatenation of x and y values. Point (0, 0) is considered as infinity.

func (*G1) InCorrectSubgroup Uses

func (g *G1) InCorrectSubgroup(p *PointG1) bool

InCorrectSubgroup checks whether given point is in correct subgroup.

func (*G1) IsAffine Uses

func (g *G1) IsAffine(p *PointG1) bool

IsAffine checks a G1 point whether it is in affine form.

func (*G1) IsOnCurve Uses

func (g *G1) IsOnCurve(p *PointG1) bool

IsOnCurve checks a G1 point is on curve.

func (*G1) IsZero Uses

func (g *G1) IsZero(p *PointG1) bool

IsZero returns true if given point is equal to zero.

func (*G1) MapToCurve Uses

func (g *G1) MapToCurve(in []byte) (*PointG1, error)

MapToCurve given a byte slice returns a valid G1 point. This mapping function implements the Simplified Shallue-van de Woestijne-Ulas method. https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-06 Input byte slice should be a valid field element, otherwise an error is returned.

func (*G1) MulScalar Uses

func (g *G1) MulScalar(c, p *PointG1, e *big.Int) *PointG1

MulScalar multiplies a point by given scalar value in big.Int and assigns the result to point at first argument.

func (*G1) MultiExp Uses

func (g *G1) MultiExp(r *PointG1, points []*PointG1, powers []*big.Int) (*PointG1, error)

MultiExp calculates multi exponentiation. Given pairs of G1 point and scalar values (P_0, e_0), (P_1, e_1), ... (P_n, e_n) calculates r = e_0 * P_0 + e_1 * P_1 + ... + e_n * P_n Length of points and scalars are expected to be equal, otherwise an error is returned. Result is assigned to point at first argument.

func (*G1) Neg Uses

func (g *G1) Neg(r, p *PointG1) *PointG1

Neg negates a G1 point p and assigns the result to the point at first argument.

func (*G1) New Uses

func (g *G1) New() *PointG1

New creates a new G1 Point which is equal to zero in other words point at infinity.

func (*G1) One Uses

func (g *G1) One() *PointG1

One returns a new G1 Point which is equal to generator point.

func (*G1) Q Uses

func (g *G1) Q() *big.Int

Q returns group order in big.Int.

func (*G1) Sub Uses

func (g *G1) Sub(c, a, b *PointG1) *PointG1

Sub subtracts two G1 points p1, p2 and assigns the result to point at first argument.

func (*G1) ToBytes Uses

func (g *G1) ToBytes(p *PointG1) []byte

ToBytes serializes a point into bytes in uncompressed form. ToBytes does not take zcash flags into account. ToBytes returns (0, 0) if point is infinity.

func (*G1) Zero Uses

func (g *G1) Zero() *PointG1

Zero returns a new G1 Point which is equal to point at infinity.

type G2 Uses

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

G2 is struct for G2 group.

func NewG2 Uses

func NewG2() *G2

NewG2 constructs a new G2 instance.

func (*G2) Add Uses

func (g *G2) Add(r, p1, p2 *PointG2) *PointG2

Add adds two G2 points p1, p2 and assigns the result to point at first argument.

func (*G2) Affine Uses

func (g *G2) Affine(p *PointG2) *PointG2

Affine calculates affine form of given G2 point.

func (*G2) ClearCofactor Uses

func (g *G2) ClearCofactor(p *PointG2)

ClearCofactor maps given a G2 point to correct subgroup

func (*G2) DecodePoint Uses

func (g *G2) DecodePoint(in []byte) (*PointG2, error)

DecodePoint given encoded (x, y) coordinates in 256 bytes returns a valid G1 Point.

func (*G2) Double Uses

func (g *G2) Double(r, p *PointG2) *PointG2

Double doubles a G2 point p and assigns the result to the point at first argument.

func (*G2) EncodePoint Uses

func (g *G2) EncodePoint(p *PointG2) []byte

EncodePoint encodes a point into 256 bytes.

func (*G2) Equal Uses

func (g *G2) Equal(p1, p2 *PointG2) bool

Equal checks if given two G2 point is equal in their affine form.

func (*G2) FromBytes Uses

func (g *G2) FromBytes(in []byte) (*PointG2, error)

FromBytes constructs a new point given uncompressed byte input. FromBytes does not take zcash flags into account. Byte input expected to be larger than 96 bytes. First 192 bytes should be concatenation of x and y values Point (0, 0) is considered as infinity.

func (*G2) InCorrectSubgroup Uses

func (g *G2) InCorrectSubgroup(p *PointG2) bool

InCorrectSubgroup checks whether given point is in correct subgroup.

func (*G2) IsAffine Uses

func (g *G2) IsAffine(p *PointG2) bool

IsAffine checks a G2 point whether it is in affine form.

func (*G2) IsOnCurve Uses

func (g *G2) IsOnCurve(p *PointG2) bool

IsOnCurve checks a G2 point is on curve.

func (*G2) IsZero Uses

func (g *G2) IsZero(p *PointG2) bool

IsZero returns true if given point is equal to zero.

func (*G2) MapToCurve Uses

func (g *G2) MapToCurve(in []byte) (*PointG2, error)

MapToCurve given a byte slice returns a valid G2 point. This mapping function implements the Simplified Shallue-van de Woestijne-Ulas method. https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-05#section-6.6.2 Input byte slice should be a valid field element, otherwise an error is returned.

func (*G2) MulScalar Uses

func (g *G2) MulScalar(c, p *PointG2, e *big.Int) *PointG2

MulScalar multiplies a point by given scalar value in big.Int and assigns the result to point at first argument.

func (*G2) MultiExp Uses

func (g *G2) MultiExp(r *PointG2, points []*PointG2, powers []*big.Int) (*PointG2, error)

MultiExp calculates multi exponentiation. Given pairs of G2 point and scalar values (P_0, e_0), (P_1, e_1), ... (P_n, e_n) calculates r = e_0 * P_0 + e_1 * P_1 + ... + e_n * P_n Length of points and scalars are expected to be equal, otherwise an error is returned. Result is assigned to point at first argument.

func (*G2) Neg Uses

func (g *G2) Neg(r, p *PointG2) *PointG2

Neg negates a G2 point p and assigns the result to the point at first argument.

func (*G2) New Uses

func (g *G2) New() *PointG2

New creates a new G2 Point which is equal to zero in other words point at infinity.

func (*G2) One Uses

func (g *G2) One() *PointG2

One returns a new G2 Point which is equal to generator point.

func (*G2) Q Uses

func (g *G2) Q() *big.Int

Q returns group order in big.Int.

func (*G2) Sub Uses

func (g *G2) Sub(c, a, b *PointG2) *PointG2

Sub subtracts two G2 points p1, p2 and assigns the result to point at first argument.

func (*G2) ToBytes Uses

func (g *G2) ToBytes(p *PointG2) []byte

ToBytes serializes a point into bytes in uncompressed form, does not take zcash flags into account, returns (0, 0) if point is infinity.

func (*G2) Zero Uses

func (g *G2) Zero() *PointG2

Zero returns a new G2 Point which is equal to point at infinity.

type GT Uses

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

GT is type for target multiplicative group GT.

func NewGT Uses

func NewGT() *GT

NewGT constructs new target group instance.

func (*GT) Add Uses

func (g *GT) Add(c, a, b *E)

Add adds two field element `a` and `b` and assigns the result to the element in first argument.

func (*GT) Exp Uses

func (g *GT) Exp(c, a *E, s *big.Int)

Exp exponents an element `a` by a scalar `s` and assigns the result to the element in first argument.

func (*GT) FromBytes Uses

func (g *GT) FromBytes(in []byte) (*E, error)

FromBytes expects 576 byte input and returns target group element FromBytes returns error if given element is not on correct subgroup.

func (*GT) Inverse Uses

func (g *GT) Inverse(c, a *E)

Inverse inverses an element `a` and assigns the result to the element in first argument.

func (*GT) IsValid Uses

func (g *GT) IsValid(e *E) bool

IsValid checks whether given target group element is in correct subgroup.

func (*GT) Mul Uses

func (g *GT) Mul(c, a, b *E)

Mul multiplies two field element `a` and `b` and assigns the result to the element in first argument.

func (*GT) New Uses

func (g *GT) New() *E

New initializes a new target group element which is equal to one

func (*GT) Q Uses

func (g *GT) Q() *big.Int

Q returns group order in big.Int.

func (*GT) Square Uses

func (g *GT) Square(c, a *E)

Square squares an element `a` and assigns the result to the element in first argument.

func (*GT) Sub Uses

func (g *GT) Sub(c, a, b *E)

Sub subtracts two field element `a` and `b`, and assigns the result to the element in first argument.

func (*GT) ToBytes Uses

func (g *GT) ToBytes(e *E) []byte

ToBytes serializes target group element.

type PointG1 Uses

type PointG1 [3]fe

PointG1 is type for point in G1. PointG1 is both used for Affine and Jacobian point representation. If z is equal to one the point is considered as in affine form.

func (*PointG1) Set Uses

func (p *PointG1) Set(p2 *PointG1) *PointG1

func (*PointG1) Zero Uses

func (p *PointG1) Zero() *PointG1

Zero returns G1 point in point at infinity representation

type PointG2 Uses

type PointG2 [3]fe2

PointG2 is type for point in G2. PointG2 is both used for Affine and Jacobian point representation. If z is equal to one the point is considered as in affine form.

func (*PointG2) Set Uses

func (p *PointG2) Set(p2 *PointG2) *PointG2

Set copies valeus of one point to another.

func (*PointG2) Zero Uses

func (p *PointG2) Zero() *PointG2

Zero returns G2 point in point at infinity representation

Package bls12381 imports 9 packages (graph) and is imported by 11 packages. Updated 2020-06-25. Refresh now. Tools for package owners.