Fp12Size is the length in bytes of an Fp12 element.
const Fp12Size = 2 * Fp6Size
Fp2Size is the length in bytes of an Fp2 element.
const Fp2Size = 2 * FpSize
Fp4Size is the size of an Fp4 element
const Fp4Size = 4 * FpSize
Fp6Size is the length in bytes of an Fp6 element.
const Fp6Size = 3 * Fp2Size
FpSize is the length in bytes of an Fp element.
const FpSize = 48
ScalarSize is the length in bytes of a Scalar.
const ScalarSize = 32
URootSize is the length in bytes of a root of unit.
const URootSize = Fp12Size
func EasyExponentiation(g *Cyclo6, f *Fp12)
EasyExponentiation calculates g = f^(p^6-1)(p^2+1), where g becomes an element of the 6-th cyclotomic group.
func FpOrder() []byte
FpOrder is the order of the base field for towering returned as a big-endian slice.
FpOrder = 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab.
func HardExponentiation(u *URoot, g *Cyclo6)
HardExponentiation calculates u = g^(Cy_6(p)/r), where u is a root of unity.
func ScalarOrder() []byte
ScalarOrder is the order of the scalar field of the pairing groups, order is returned as a big-endian slice.
ScalarOrder = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001
Cyclo6 represents an element of the 6th cyclotomic group.
type Cyclo6 Fp12
func (z *Cyclo6) Frob(x *Cyclo6)
func (z *Cyclo6) Inv(x *Cyclo6)
func (z Cyclo6) IsEqual(x *Cyclo6) int
func (z Cyclo6) IsIdentity() int
func (z *Cyclo6) Mul(x, y *Cyclo6)
func (z *Cyclo6) PowToX(x *Cyclo6)
PowToX computes z = x^paramX, where paramX is the parameter of the BLS curve.
func (z *Cyclo6) Sqr(x *Cyclo6)
func (z Cyclo6) String() string
Fp represents prime field elements as positive integers less than FpOrder.
type Fp struct {
// contains filtered or unexported fields
}
func (z *Fp) Add(x, y *Fp)
func (z *Fp) CMov(x, y *Fp, b int)
CMov sets z=x if b == 0 and z=y if b == 1. Its behavior is undefined if b takes any other value.
func (z *Fp) ExpVarTime(x *Fp, n []byte)
ExpVarTime calculates z=x^n, where n is the exponent in big-endian order.
func (z *Fp) Inv(x *Fp)
func (z Fp) IsEqual(x *Fp) int
IsEqual returns 1 if z == x and 0 otherwise.
func (z Fp) IsNegative() int
IsNegative returns 0 if the least absolute residue for z is in [0,(p-1)/2], and 1 otherwise. Equivalently, this function returns 1 if z is lexicographically larger than -z.
func (z Fp) IsZero() int
IsZero returns 1 if z == 0 and 0 otherwise.
func (z *Fp) MarshalBinary() ([]byte, error)
MarshalBinary returns a slice of FpSize bytes that contains the minimal residue of z such that 0 <= z < FpOrder (in big-endian order).
func (z *Fp) Mul(x, y *Fp)
func (z *Fp) Neg()
func (z *Fp) Random(r io.Reader) error
func (z *Fp) SetBytes(data []byte)
SetBytes assigns to z the number modulo FpOrder stored in the slice (in big-endian order).
func (z *Fp) SetOne()
func (z *Fp) SetString(s string) error
SetString reconstructs a Fp from a numeric string from 0 to FpOrder-1.
func (z *Fp) SetUint64(n uint64)
func (z Fp) Sgn0() int
func (z *Fp) Sqr(x *Fp)
func (z *Fp) Sqrt(x *Fp) int
Sqrt returns 1 and sets z=sqrt(x) only if x is a quadratic-residue; otherwise, returns 0 and z is unmodified.
func (z Fp) String() string
func (z *Fp) Sub(x, y *Fp)
func (z *Fp) UnmarshalBinary(b []byte) error
UnmarshalBinary reconstructs a Fp from a slice that must have at least FpSize bytes and contain a number (in big-endian order) from 0 to FpOrder-1.
Fp12 represents an element of the field Fp12 = Fp6[w]/(w^2-v)., where v in Fp6.
type Fp12 [2]Fp6
func (z *Fp12) Add(x, y *Fp12)
func (z *Fp12) CMov(x, y *Fp12, b int)
func (z *Fp12) Cjg()
func (z *Fp12) Exp(x *Fp12, n []byte)
Exp calculates z=x^n, where n is the exponent in big-endian order.
func (z *Fp12) Frob(x *Fp12)
func (z *Fp12) FromFp12Alt(x *Fp12Cubic)
func (z *Fp12) Inv(x *Fp12)
func (z Fp12) IsEqual(x *Fp12) int
func (z Fp12) IsZero() int
func (z Fp12) MarshalBinary() (b []byte, e error)
func (z *Fp12) Mul(x, y *Fp12)
func (z *Fp12) MulBeta()
func (z *Fp12) Neg()
func (z *Fp12) SetOne()
func (z *Fp12) Sqr(x *Fp12)
func (z Fp12) String() string
func (z *Fp12) Sub(x, y *Fp12)
func (z *Fp12) UnmarshalBinary(b []byte) error
Fp12Cubic represents elements of Fp4[w]/w^3-t
type Fp12Cubic [3]Fp4
func (z *Fp12Cubic) Add(x *Fp12Cubic, y *Fp12Cubic)
func (z *Fp12Cubic) FromFp12(x *Fp12)
func (z Fp12Cubic) IsEqual(x *Fp12Cubic) int
func (z *Fp12Cubic) Mul(x *Fp12Cubic, y *Fp12Cubic)
func (z *Fp12Cubic) MulLine(x *Fp12Cubic, y *LineValue)
func (z *Fp12Cubic) SetOne()
func (z *Fp12Cubic) Sqr(x *Fp12Cubic)
func (z Fp12Cubic) String() string
type Fp2 [2]Fp
func (z *Fp2) Add(x, y *Fp2)
func (z *Fp2) CMov(x, y *Fp2, b int)
func (z *Fp2) Cjg()
func (z *Fp2) ExpVarTime(x *Fp2, n []byte)
ExpVarTime calculates z=x^n, where n is the exponent in big-endian order.
func (z *Fp2) Frob(x *Fp2)
func (z *Fp2) Inv(x *Fp2)
func (z Fp2) IsEqual(x *Fp2) int
func (z Fp2) IsNegative() int
IsNegative returns 1 if z is lexicographically larger than -z; otherwise returns 0.
func (z Fp2) IsZero() int
func (z Fp2) MarshalBinary() (b []byte, e error)
func (z *Fp2) Mul(x, y *Fp2)
func (z *Fp2) MulBeta()
func (z *Fp2) Neg()
func (z *Fp2) SetOne()
func (z *Fp2) SetString(s0, s1 string) (err error)
SetString reconstructs a Fp2 element as s0+s1*i, where s0 and s1 are numeric strings from 0 to FpOrder-1.
func (z Fp2) Sgn0() int
func (z *Fp2) Sqr(x *Fp2)
func (z *Fp2) Sqrt(x *Fp2) int
Sqrt returns 1 and sets z=sqrt(x) only if x is a quadratic-residue; otherwise, returns 0 and z is unmodified.
func (z Fp2) String() string
func (z *Fp2) Sub(x, y *Fp2)
func (z *Fp2) UnmarshalBinary(b []byte) error
Fp4 is obtained by adjoining t, the square root of u+1 to Fp2
type Fp4 [2]Fp2
func (z *Fp4) Add(x *Fp4, y *Fp4)
func (z *Fp4) Inv(x *Fp4)
func (z *Fp4) IsEqual(x *Fp4) int
func (z *Fp4) IsZero() int
func (z *Fp4) Mul(x *Fp4, y *Fp4)
func (z *Fp4) Neg()
func (z *Fp4) SetOne()
func (z *Fp4) Sqr(x *Fp4)
func (z Fp4) String() string
func (z *Fp4) Sub(x *Fp4, y *Fp4)
type Fp6 [3]Fp2
func (z *Fp6) Add(x, y *Fp6)
func (z *Fp6) CMov(x, y *Fp6, b int)
func (z *Fp6) Frob(x *Fp6)
func (z *Fp6) Inv(x *Fp6)
func (z Fp6) IsEqual(x *Fp6) int
func (z Fp6) IsZero() int
func (z Fp6) MarshalBinary() (b []byte, e error)
func (z *Fp6) Mul(x, y *Fp6)
func (z *Fp6) MulBeta()
func (z *Fp6) Neg()
func (z *Fp6) SetOne()
func (z *Fp6) Sqr(x *Fp6)
func (z Fp6) String() string
func (z *Fp6) Sub(x, y *Fp6)
func (z *Fp6) UnmarshalBinary(b []byte) error
LineValue a represents a[0]+a[1]*w^2+a[2]*w^3, with all values in Fp2. This lets us shave off a number of Fp2 multiplications.
type LineValue [3]Fp2
func (z *LineValue) IsZero() int
func (z *LineValue) SetOne()
Scalar represents positive integers less than ScalarOrder.
type Scalar struct {
// contains filtered or unexported fields
}
func (z *Scalar) Add(x, y *Scalar)
func (z *Scalar) Inv(x *Scalar)
func (z Scalar) IsEqual(x *Scalar) int
func (z Scalar) IsZero() int
func (z *Scalar) MarshalBinary() ([]byte, error)
MarshalBinary returns a slice of ScalarSize bytes that contains the minimal residue of z such that 0 <= z < ScalarOrder (in big-endian order).
func (z *Scalar) Mul(x, y *Scalar)
func (z *Scalar) Neg()
func (z *Scalar) Random(r io.Reader) error
func (z *Scalar) Set(x *Scalar)
func (z *Scalar) SetBytes(data []byte)
SetBytes assigns to z the number modulo ScalarOrder stored in the slice (in big-endian order).
func (z *Scalar) SetOne()
func (z *Scalar) SetString(s string) error
SetString reconstructs a Fp from a numeric string from 0 to ScalarOrder-1.
func (z *Scalar) SetUint64(n uint64)
func (z *Scalar) Sqr(x *Scalar)
func (z Scalar) String() string
func (z *Scalar) Sub(x, y *Scalar)
func (z *Scalar) UnmarshalBinary(data []byte) error
UnmarshalBinary reconstructs a Scalar from a slice that must have at least ScalarSize bytes and contain a number (in big-endian order) from 0 to ScalarOrder-1.
URoot represents an n-th root of unit, that is an element x in Cyclo6 such that x^n=1, where n = ScalarOrder().
type URoot Cyclo6
func (z *URoot) Exp(x *URoot, n []byte)
func (z *URoot) Inv(x *URoot)
func (z URoot) IsEqual(x *URoot) int
func (z URoot) IsIdentity() int
func (z URoot) MarshalBinary() ([]byte, error)
func (z *URoot) Mul(x, y *URoot)
func (z *URoot) SetIdentity()
func (z *URoot) Sqr(x *URoot)
func (z URoot) String() string
func (z *URoot) UnmarshalBinary(b []byte) error