bn256

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

B b coeff of the curve

ID bn256 ID

Functions

func GenE2 added in v0.2.0

func GenE2() gopter.Gen

GenE2 generates an E2 elmt

func GenE6 added in v0.2.0

func GenE6() gopter.Gen

GenE6 generates an E6 elmt

func GenE12 added in v0.2.0

func GenE12() gopter.Gen

GenE12 generates an E6 elmt

func GenFp added in v0.2.0

func GenFp() gopter.Gen

GenFp generates an Fp element

func GenFr added in v0.2.0

func GenFr() gopter.Gen

GenFr generates an Fr element

Types

type E2 added in v0.2.0

type E2 struct {
	A0, A1 fp.Element
}

E2 is a degree two finite field extension of fp.Element

func (*E2) Add added in v0.2.0

func (z *E2) Add(x, y *E2) *E2

Add adds two elements of E2

func (*E2) Clone added in v0.2.0

func (z *E2) Clone() *E2

Clone returns a copy of self

func (*E2) Conjugate added in v0.2.0

func (z *E2) Conjugate(x *E2) *E2

Conjugate conjugates an element in E2

func (*E2) Double added in v0.2.0

func (z *E2) Double(x *E2) *E2

Double doubles an E2 element

func (*E2) Equal added in v0.2.0

func (z *E2) Equal(x *E2) bool

Equal returns true if z equals x, fasle otherwise

func (*E2) FromMont added in v0.2.0

func (z *E2) FromMont() *E2

FromMont converts from mont form

func (*E2) Inverse added in v0.2.0

func (z *E2) Inverse(x *E2) *E2

Inverse sets z to the E2-inverse of x, returns z

func (*E2) IsZero added in v0.2.0

func (z *E2) IsZero() bool

IsZero returns true if the two elements are equal, fasle otherwise

func (*E2) Mul added in v0.2.0

func (z *E2) Mul(x, y *E2) *E2

Mul sets z to the E2-product of x,y, returns z

func (*E2) MulByElement added in v0.2.0

func (z *E2) MulByElement(x *E2, y *fp.Element) *E2

MulByElement multiplies an element in E2 by an element in fp

func (*E2) MulByNonResidue added in v0.2.0

func (z *E2) MulByNonResidue(x *E2) *E2

MulByNonResidue multiplies a E2 by (9,1)

func (*E2) MulByNonResidue1Power1 added in v0.2.0

func (z *E2) MulByNonResidue1Power1(x *E2) *E2

MulByNonResidue1Power1 set z=x*(9,1)^(1*(p^1-1)/6) and return z

func (*E2) MulByNonResidue1Power2 added in v0.2.0

func (z *E2) MulByNonResidue1Power2(x *E2) *E2

MulByNonResidue1Power2 set z=x*(9,1)^(2*(p^1-1)/6) and return z

func (*E2) MulByNonResidue1Power3 added in v0.2.0

func (z *E2) MulByNonResidue1Power3(x *E2) *E2

MulByNonResidue1Power3 set z=x*(9,1)^(3*(p^1-1)/6) and return z

func (*E2) MulByNonResidue1Power4 added in v0.2.0

func (z *E2) MulByNonResidue1Power4(x *E2) *E2

MulByNonResidue1Power4 set z=x*(9,1)^(4*(p^1-1)/6) and return z

func (*E2) MulByNonResidue1Power5 added in v0.2.0

func (z *E2) MulByNonResidue1Power5(x *E2) *E2

MulByNonResidue1Power5 set z=x*(9,1)^(5*(p^1-1)/6) and return z

func (*E2) MulByNonResidue2Power1 added in v0.2.0

func (z *E2) MulByNonResidue2Power1(x *E2) *E2

MulByNonResidue2Power1 set z=x*(9,1)^(1*(p^2-1)/6) and return z

func (*E2) MulByNonResidue2Power2 added in v0.2.0

func (z *E2) MulByNonResidue2Power2(x *E2) *E2

MulByNonResidue2Power2 set z=x*(9,1)^(2*(p^2-1)/6) and return z

func (*E2) MulByNonResidue2Power3 added in v0.2.0

func (z *E2) MulByNonResidue2Power3(x *E2) *E2

MulByNonResidue2Power3 set z=x*(9,1)^(3*(p^2-1)/6) and return z

func (*E2) MulByNonResidue2Power4 added in v0.2.0

func (z *E2) MulByNonResidue2Power4(x *E2) *E2

MulByNonResidue2Power4 set z=x*(9,1)^(4*(p^2-1)/6) and return z

func (*E2) MulByNonResidue2Power5 added in v0.2.0

func (z *E2) MulByNonResidue2Power5(x *E2) *E2

MulByNonResidue2Power5 set z=x*(9,1)^(5*(p^2-1)/6) and return z

func (*E2) MulByNonResidue3Power1 added in v0.2.0

func (z *E2) MulByNonResidue3Power1(x *E2) *E2

MulByNonResidue3Power1 set z=x*(9,1)^(1*(p^3-1)/6) and return z

func (*E2) MulByNonResidue3Power2 added in v0.2.0

func (z *E2) MulByNonResidue3Power2(x *E2) *E2

MulByNonResidue3Power2 set z=x*(9,1)^(2*(p^3-1)/6) and return z

func (*E2) MulByNonResidue3Power3 added in v0.2.0

func (z *E2) MulByNonResidue3Power3(x *E2) *E2

MulByNonResidue3Power3 set z=x*(9,1)^(3*(p^3-1)/6) and return z

func (*E2) MulByNonResidue3Power4 added in v0.2.0

func (z *E2) MulByNonResidue3Power4(x *E2) *E2

MulByNonResidue3Power4 set z=x*(9,1)^(4*(p^3-1)/6) and return z

func (*E2) MulByNonResidue3Power5 added in v0.2.0

func (z *E2) MulByNonResidue3Power5(x *E2) *E2

MulByNonResidue3Power5 set z=x*(9,1)^(5*(p^3-1)/6) and return z

func (*E2) MulByNonResidueInv added in v0.2.0

func (z *E2) MulByNonResidueInv(x *E2) *E2

MulByNonResidueInv multiplies a E2 by (9,1)^{-1}

func (*E2) Neg added in v0.2.0

func (z *E2) Neg(x *E2) *E2

Neg negates an E2 element

func (*E2) Set added in v0.2.0

func (z *E2) Set(x *E2) *E2

Set sets an E2 from x

func (*E2) SetOne added in v0.2.0

func (z *E2) SetOne() *E2

SetOne sets z to 1 in Montgomery form and returns z

func (*E2) SetRandom added in v0.2.0

func (z *E2) SetRandom() *E2

SetRandom sets a0 and a1 to random values

func (*E2) SetString added in v0.2.0

func (z *E2) SetString(s1, s2 string) *E2

SetString sets a E2 element from strings

func (*E2) SetZero added in v0.2.0

func (z *E2) SetZero() *E2

SetZero sets an e2 elmt to zero

func (*E2) Square added in v0.2.0

func (z *E2) Square(x *E2) *E2

Square sets z to the E2-product of x,x returns z

func (*E2) String added in v0.2.0

func (z *E2) String() string

String implements Stringer interface for fancy printing

func (*E2) Sub added in v0.2.0

func (z *E2) Sub(x, y *E2) *E2

Sub two elements of E2

func (*E2) ToMont added in v0.2.0

func (z *E2) ToMont() *E2

ToMont converts to mont form

type E6 added in v0.2.0

type E6 struct {
	B0, B1, B2 E2
}

E6 is a degree three finite field extension of fp2

func (*E6) Add added in v0.2.0

func (z *E6) Add(x, y *E6) *E6

Add adds two elements of E6

func (*E6) Double added in v0.2.0

func (z *E6) Double(x *E6) *E6

Double doubles an element in E6

func (*E6) Equal added in v0.2.0

func (z *E6) Equal(x *E6) bool

Equal returns true if z equals x, fasle otherwise

func (*E6) FromMont added in v0.2.0

func (z *E6) FromMont() *E6

FromMont converts from Mont form

func (*E6) Inverse added in v0.2.0

func (z *E6) Inverse(x *E6) *E6

Inverse an element in E6

func (*E6) Mul added in v0.2.0

func (z *E6) Mul(x, y *E6) *E6

Mul sets z to the E6 product of x,y, returns z

func (*E6) MulByNonResidue added in v0.2.0

func (z *E6) MulByNonResidue(x *E6) *E6

MulByNonResidue mul x by (0,1,0)

func (*E6) Neg added in v0.2.0

func (z *E6) Neg(x *E6) *E6

Neg negates the E6 number

func (*E6) Set added in v0.2.0

func (z *E6) Set(x *E6) *E6

Set Sets a E6 elmt form another E6 elmt

func (*E6) SetOne added in v0.2.0

func (z *E6) SetOne() *E6

SetOne sets z to 1 in Montgomery form and returns z

func (*E6) SetRandom added in v0.2.0

func (z *E6) SetRandom() *E6

SetRandom set z to a random elmt

func (*E6) SetString added in v0.2.0

func (z *E6) SetString(s1, s2, s3, s4, s5, s6 string) *E6

SetString sets a E6 elmt from stringf

func (*E6) Square added in v0.2.0

func (z *E6) Square(x *E6) *E6

Square sets z to the E6 product of x,x, returns z

func (*E6) String added in v0.2.0

func (z *E6) String() string

String puts E6 elmt in string form

func (*E6) Sub added in v0.2.0

func (z *E6) Sub(x, y *E6) *E6

Sub two elements of E6

func (*E6) ToMont added in v0.2.0

func (z *E6) ToMont() *E6

ToMont converts to Mont form

type E12 added in v0.2.0

type E12 struct {
	C0, C1 E6
}

E12 is a degree two finite field extension of fp6

func (*E12) Add added in v0.2.0

func (z *E12) Add(x, y *E12) *E12

Add set z=x+y in E12 and return z

func (*E12) Conjugate added in v0.2.0

func (z *E12) Conjugate(x *E12) *E12

Conjugate set z to x conjugated and return z

func (*E12) CyclotomicSquare added in v0.2.0

func (z *E12) CyclotomicSquare(x *E12) *E12

CyclotomicSquare https://eprint.iacr.org/2009/565.pdf, 3.2

func (*E12) Double added in v0.2.0

func (z *E12) Double(x *E12) *E12

Double sets z=2*x and returns z

func (*E12) Equal added in v0.2.0

func (z *E12) Equal(x *E12) bool

Equal returns true if z equals x, fasle otherwise

func (*E12) Exp added in v0.2.0

func (z *E12) Exp(x *E12, e big.Int) *E12

Exp sets z=x**e and returns it

func (*E12) FromMont added in v0.2.0

func (z *E12) FromMont() *E12

FromMont converts from Mont form

func (*E12) Inverse added in v0.2.0

func (z *E12) Inverse(x *E12) *E12

Inverse set z to the inverse of x in E12 and return z

func (*E12) InverseUnitary added in v0.2.0

func (z *E12) InverseUnitary(x *E12) *E12

InverseUnitary inverse a unitary element

func (*E12) Mul added in v0.2.0

func (z *E12) Mul(x, y *E12) *E12

Mul set z=x*y in E12 and return z

func (*E12) Set added in v0.2.0

func (z *E12) Set(x *E12) *E12

Set copies x into z and returns z

func (*E12) SetOne added in v0.2.0

func (z *E12) SetOne() *E12

SetOne sets z to 1 in Montgomery form and returns z

func (*E12) SetRandom added in v0.2.0

func (z *E12) SetRandom() *E12

SetRandom used only in tests

func (*E12) SetString added in v0.2.0

func (z *E12) SetString(s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11 string) *E12

SetString sets a E12 from string

func (*E12) Square added in v0.2.0

func (z *E12) Square(x *E12) *E12

Square set z=x*x in E12 and return z

func (*E12) String added in v0.2.0

func (z *E12) String() string

String puts E12 in string form

func (*E12) Sub added in v0.2.0

func (z *E12) Sub(x, y *E12) *E12

Sub sets z to x sub y and return z

func (*E12) ToMont added in v0.2.0

func (z *E12) ToMont() *E12

ToMont converts to Mont form

type G1Affine

type G1Affine struct {
	X, Y fp.Element
}

G1Affine point in affine coordinates

func (*G1Affine) Equal

func (p *G1Affine) Equal(a *G1Affine) bool

Equal tests if two points (in Affine coordinates) are equal

func (*G1Affine) FromJacobian added in v0.2.0

func (p *G1Affine) FromJacobian(p1 *G1Jac) *G1Affine

FromJacobian rescale a point in Jacobian coord in z=1 plane

func (*G1Affine) IsInfinity

func (p *G1Affine) IsInfinity() bool

IsInfinity checks if the point is infinity (in affine, it's encoded as (0,0))

func (*G1Affine) Neg

func (p *G1Affine) Neg(a *G1Affine) *G1Affine

Neg computes -G

func (*G1Affine) String

func (p *G1Affine) String() string

type G1Jac

type G1Jac struct {
	X, Y, Z fp.Element
}

G1Jac is a point with fp.Element coordinates

func (*G1Jac) AddAssign added in v0.2.0

func (p *G1Jac) AddAssign(a *G1Jac) *G1Jac

AddAssign point addition in montgomery form https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#addition-add-2007-bl

func (*G1Jac) Clone

func (p *G1Jac) Clone() *G1Jac

Clone returns a copy of self

func (*G1Jac) Double

func (p *G1Jac) Double(q *G1Jac) *G1Jac

Double doubles a point in Jacobian coordinates https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2007-bl

func (*G1Jac) DoubleAssign added in v0.2.0

func (p *G1Jac) DoubleAssign() *G1Jac

DoubleAssign doubles a point in Jacobian coordinates https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2007-bl

func (*G1Jac) Equal

func (p *G1Jac) Equal(a *G1Jac) bool

Equal tests if two points (in Jacobian coordinates) are equal

func (*G1Jac) FromAffine added in v0.2.0

func (p *G1Jac) FromAffine(Q *G1Affine) *G1Jac

FromAffine sets p = Q, p in Jacboian, Q in affine

func (*G1Jac) MultiExp

func (p *G1Jac) MultiExp(points []G1Affine, scalars []fr.Element) chan G1Jac

MultiExp complexity O(n)

func (*G1Jac) Neg

func (p *G1Jac) Neg(a *G1Jac) *G1Jac

Neg computes -G

func (*G1Jac) ScalarMulGLV added in v0.2.0

func (p *G1Jac) ScalarMulGLV(a *G1Affine, s *big.Int) *G1Jac

ScalarMulGLV performs scalar multiplication using GLV (without the lattice reduction)

func (*G1Jac) ScalarMultiplication added in v0.2.0

func (p *G1Jac) ScalarMultiplication(a *G1Affine, s *big.Int) *G1Jac

ScalarMultiplication algo for exponentiation

func (*G1Jac) Set

func (p *G1Jac) Set(a *G1Jac) *G1Jac

Set set p to the provided point

func (*G1Jac) String

func (p *G1Jac) String() string

func (*G1Jac) SubAssign added in v0.2.0

func (p *G1Jac) SubAssign(a G1Jac) *G1Jac

SubAssign substracts two points on the curve

type G1Proj added in v0.2.0

type G1Proj struct {
	X, Y, Z fp.Element
}

G1Proj point in projective coordinates

func (*G1Proj) FromJacobian added in v0.2.0

func (p *G1Proj) FromJacobian(Q *G1Jac) *G1Proj

FromJacobian converts a point from Jacobian to projective coordinates

type G2Affine

type G2Affine struct {
	X, Y E2
}

G2Affine point in affine coordinates

func (*G2Affine) Equal

func (p *G2Affine) Equal(a *G2Affine) bool

Equal tests if two points (in Affine coordinates) are equal

func (*G2Affine) FromJacobian added in v0.2.0

func (p *G2Affine) FromJacobian(p1 *G2Jac) *G2Affine

FromJacobian rescale a point in Jacobian coord in z=1 plane

func (*G2Affine) IsInfinity

func (p *G2Affine) IsInfinity() bool

IsInfinity checks if the point is infinity (in affine, it's encoded as (0,0))

func (*G2Affine) Neg

func (p *G2Affine) Neg(a *G2Affine) *G2Affine

Neg computes -G

func (*G2Affine) String

func (p *G2Affine) String() string

type G2Jac

type G2Jac struct {
	X, Y, Z E2
}

G2Jac is a point with E2 coordinates

func (*G2Jac) AddAssign added in v0.2.0

func (p *G2Jac) AddAssign(a *G2Jac) *G2Jac

AddAssign point addition in montgomery form https://hyperelliptic.org/EFD/g2p/auto-shortw-jacobian-3.html#addition-add-2007-bl

func (*G2Jac) Clone

func (p *G2Jac) Clone() *G2Jac

Clone returns a copy of self

func (*G2Jac) Double

func (p *G2Jac) Double(q *G2Jac) *G2Jac

Double doubles a point in Jacobian coordinates https://hyperelliptic.org/EFD/g2p/auto-shortw-jacobian-3.html#doubling-dbl-2007-bl

func (*G2Jac) DoubleAssign added in v0.2.0

func (p *G2Jac) DoubleAssign() *G2Jac

DoubleAssign doubles a point in Jacobian coordinates https://hyperelliptic.org/EFD/g2p/auto-shortw-jacobian-3.html#doubling-dbl-2007-bl

func (*G2Jac) Equal

func (p *G2Jac) Equal(a *G2Jac) bool

Equal tests if two points (in Jacobian coordinates) are equal

func (*G2Jac) FromAffine added in v0.2.0

func (p *G2Jac) FromAffine(Q *G2Affine) *G2Jac

FromAffine sets p = Q, p in Jacboian, Q in affine

func (*G2Jac) MultiExp

func (p *G2Jac) MultiExp(points []G2Affine, scalars []fr.Element) chan G2Jac

MultiExp complexity O(n)

func (*G2Jac) Neg

func (p *G2Jac) Neg(a *G2Jac) *G2Jac

Neg computes -G

func (*G2Jac) ScalarMulGLV added in v0.2.0

func (p *G2Jac) ScalarMulGLV(a *G2Affine, s *big.Int) *G2Jac

ScalarMulGLV performs scalar multiplication using GLV (without the lattice reduction)

func (*G2Jac) ScalarMultiplication added in v0.2.0

func (p *G2Jac) ScalarMultiplication(a *G2Affine, s *big.Int) *G2Jac

ScalarMultiplication algo for exponentiation

func (*G2Jac) Set

func (p *G2Jac) Set(a *G2Jac) *G2Jac

Set set p to the provided point

func (*G2Jac) String

func (p *G2Jac) String() string

func (*G2Jac) SubAssign added in v0.2.0

func (p *G2Jac) SubAssign(a G2Jac) *G2Jac

SubAssign substracts two points on the curve

type G2Proj added in v0.2.0

type G2Proj struct {
	X, Y, Z E2
}

G2Proj point in projective coordinates

func (*G2Proj) FromJacobian added in v0.2.0

func (p *G2Proj) FromJacobian(Q *G2Jac) *G2Proj

FromJacobian converts a point from Jacobian to projective coordinates

type PairingResult

type PairingResult = E12

PairingResult target group of the pairing

func FinalExponentiation added in v0.2.0

func FinalExponentiation(z *PairingResult, _z ...*PairingResult) PairingResult

FinalExponentiation computes the final expo x**(p**6-1)(p**2+1)(p**4 - p**2 +1)/r

func MillerLoop added in v0.2.0

func MillerLoop(P G1Affine, Q G2Affine) *PairingResult

MillerLoop Miller loop

func (*PairingResult) Expt added in v0.2.0

Expt set z to x^t in PairingResult and return z (t is the generator of the BN curve)

func (*PairingResult) FinalExponentiation added in v0.2.0

func (z *PairingResult) FinalExponentiation(x *PairingResult) *PairingResult

FinalExponentiation sets z to the final expo x**((p**12 - 1)/r), returns z

func (*PairingResult) Frobenius added in v0.2.0

func (z *PairingResult) Frobenius(x *PairingResult) *PairingResult

Frobenius set z to Frobenius(x), return z

func (*PairingResult) FrobeniusCube added in v0.2.0

func (z *PairingResult) FrobeniusCube(x *PairingResult) *PairingResult

FrobeniusCube set z to Frobenius^3(x), return z

func (*PairingResult) FrobeniusSquare added in v0.2.0

func (z *PairingResult) FrobeniusSquare(x *PairingResult) *PairingResult

FrobeniusSquare set z to Frobenius^2(x), and return z

func (*PairingResult) MulByV added in v0.2.0

func (z *PairingResult) MulByV(x *PairingResult, y *E2) *PairingResult

MulByV set z to x*(y*v) and return z here y*v means the PairingResult element with C0.B1=y and all other components 0

func (*PairingResult) MulByV2W added in v0.2.0

func (z *PairingResult) MulByV2W(x *PairingResult, y *E2) *PairingResult

MulByV2W set z to x*(y*v^2*w) and return z here y*v^2*w means the PairingResult element with C1.B2=y and all other components 0

func (*PairingResult) MulByVW added in v0.2.0

func (z *PairingResult) MulByVW(x *PairingResult, y *E2) *PairingResult

MulByVW set z to x*(y*v*w) and return z here y*v*w means the PairingResult element with C1.B1=y and all other components 0

Directories

Path Synopsis
Package fp contains field arithmetic operations Package fp contains field arithmetic operations Package fp contains field arithmetic operations
Package fp contains field arithmetic operations Package fp contains field arithmetic operations Package fp contains field arithmetic operations
Package fr contains field arithmetic operations Package fr contains field arithmetic operations Package fr contains field arithmetic operations
Package fr contains field arithmetic operations Package fr contains field arithmetic operations Package fr contains field arithmetic operations

Jump to

Keyboard shortcuts

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