bls

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 25, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

README

BLS

Pure GO bls library.

Implements the BLS12-381 curve.

Documentation

Index

Constants

View Source
const (
	// LegendreZero is the legendre symbol of zero.
	LegendreZero = LegendreSymbol(iota)

	// LegendreQuadraticResidue is the legendre symbol of quadratic residue.
	LegendreQuadraticResidue

	// LegendreQuadraticNonResidue is the legendre symbol of quadratic non-residue.
	LegendreQuadraticNonResidue
)

Variables

View Source
var BCoeff = FQReprToFQRaw(FQRepr{0xaa270000000cfff3, 0x53cc0032fc34000a, 0x478fe97a6b0a807f, 0xb1d37ebee6ba24d7, 0x8ec9733bbf78ab2f, 0x9d645513d83de7e})

BCoeff of the G1 curve.

View Source
var BCoeffFQ2 = NewFQ2(BCoeff, BCoeff)

BCoeffFQ2 of the G2 curve.

View Source
var FQ12One = NewFQ12(FQ6One, FQ6Zero)

FQ12One is the one element of FQ12.

View Source
var FQ12Zero = NewFQ12(FQ6Zero, FQ6Zero)

FQ12Zero is the zero element of FQ12.

View Source
var FQ2One = FQ2{
	// contains filtered or unexported fields
}

FQ2One gets the one-element of the field.

View Source
var FQ2Zero = FQ2{
	// contains filtered or unexported fields
}

FQ2Zero gets the zero element of the field.

FQ6One represents the one value of FQ6.

FQ6Zero represents the zero value of FQ6.

View Source
var FQOne = FQReprToFQ(bigOne)

FQOne is the one FQ element

View Source
var FQR2, _ = FQReprFromString("2708263910654730174793787626328176511836455197166317677006154293982164122222515399004018013397331347120527951271750", 10)

FQR2 is R^2 % Q.

View Source
var FQZero = FQReprToFQRaw(bigZero)

FQZero is the zero FQ element

View Source
var FRR, _ = FRReprFromString("10920338887063814464675503992315976177888879664585288394250266608035967270910", 10)

FRR is 2**256 % r used for moving numbers into Montgomery form.

View Source
var FRR2, _ = FRReprFromString("3294906474794265442129797520630710739278575682199800681788903916070560242797", 10)

FRR2 is R^2 % r.

View Source
var G1AffineOne = &G1Affine{FQReprToFQ(g1GeneratorX), FQReprToFQ(g1GeneratorY), false}

G1AffineOne represents the point at 1 on G1.

View Source
var G1AffineZero = &G1Affine{FQZero.Copy(), FQOne.Copy(), true}

G1AffineZero represents the point at infinity on G1.

View Source
var G1ProjectiveOne = G1AffineOne.ToProjective()

G1ProjectiveOne is the generator point on G1.

View Source
var G1ProjectiveZero = &G1Projective{FQZero.Copy(), FQOne.Copy(), FQZero.Copy()}

G1ProjectiveZero is the point at infinity where Z = 0.

View Source
var G2AffineOne = &G2Affine{
	x: NewFQ2(
		FQReprToFQ(g2GeneratorXC0),
		FQReprToFQ(g2GeneratorXC1),
	),
	y: NewFQ2(
		FQReprToFQ(g2GeneratorYC0),
		FQReprToFQ(g2GeneratorYC1),
	), infinity: false}

G2AffineOne represents the point at 1 on G2.

View Source
var G2AffineZero = &G2Affine{FQ2Zero, FQ2One, true}

G2AffineZero represents the point at infinity on G2.

View Source
var G2ProjectiveOne = G2AffineOne.ToProjective()

G2ProjectiveOne is the generator point on G2.

View Source
var G2ProjectiveZero = &G2Projective{FQ2Zero.Copy(), FQ2One.Copy(), FQ2Zero.Copy()}

G2ProjectiveZero is the point at infinity where Z = 0.

View Source
var QFieldModulus, _ = FQReprFromString("4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787", 10)

QFieldModulus is the modulus of the field.

View Source
var RFieldModulus, _ = FRReprFromString("52435875175126190479447740508185965837690552500527637822603658699938581184513", 10)

RFieldModulus is the modulus of the R field.

Functions

func AddNoCarry

func AddNoCarry(a, b [6]uint64) [6]uint64

AddNoCarry finds the value of 384-bit a + b and returns the resulting 384-bit value.

func AddWithCarry

func AddWithCarry(a, b, carry uint64) (uint64, uint64)

AddWithCarry finds the value a + b + carry and returns the full 128-bit value in 2 64-bit integers.

func CompareTwoPairings

func CompareTwoPairings(P1 *G1Projective, Q1 *G2Projective, P2 *G1Projective, Q2 *G2Projective) bool

CompareTwoPairings checks e(P1, Q1) == e(P2, Q2) <=> FE(ML(P1, Q1)ML(-P2, Q2)) == 1

func CompressG1

func CompressG1(affine *G1Affine) [48]byte

CompressG1 compresses a G1 point into an int.

func CompressG2

func CompressG2(affine *G2Affine) [96]byte

CompressG2 compresses a G2 point into an int.

func MACWithCarry

func MACWithCarry(a, b, c, carry uint64) (uint64, uint64)

MACWithCarry finds the value a + b * c + carry and returns the full 128-bit value in 2 64-bit integers.

func MontReduce

func MontReduce(hi, lo [6]uint64) (out [6]uint64)

MontReduce reduces the 768-bit value using montgomery reduction.

func MultiplyFQRepr

func MultiplyFQRepr(a, b [6]uint64) (hi [6]uint64, lo [6]uint64)

MultiplyFQRepr multiplies two FQRepr values together.

func SubNoBorrow

func SubNoBorrow(a, b [6]uint64) [6]uint64

SubNoBorrow finds the value of 384-bit a - b and returns the resulting 384-bit value.

func SubWithBorrow

func SubWithBorrow(a, b, borrow uint64) (uint64, uint64)

SubWithBorrow finds the value a - b - borrow and returns the result and the borrow.

Types

type BitIterator

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

BitIterator is an iterator through bits.

func NewBitIterator

func NewBitIterator(arr []uint64) BitIterator

NewBitIterator creates a new bit iterator given an array of ints.

func (*BitIterator) Next

func (bi *BitIterator) Next() (bool, bool)

Next returns the next bit in the bit iterator with the second return value as true when finished.

type FQ

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

FQ is an element in a field.

func FQReprToFQ

func FQReprToFQ(o FQRepr) FQ

FQReprToFQ gets a pointer to a FQ given a pointer to an FQRepr

func FQReprToFQRaw

func FQReprToFQRaw(o FQRepr) FQ

FQReprToFQRaw gets a pointer to a FQ without converting to montgomery form.

func HashFQ

func HashFQ(hasher hash.Hash) FQ

HashFQ calculates a new FQ2 value based on a hash.

func RandFQ

func RandFQ(reader io.Reader) (FQ, error)

RandFQ generates a random FQ element.

func (*FQ) AddAssign

func (f *FQ) AddAssign(other FQ)

AddAssign multiplies a field element by this one.

func (FQ) Cmp

func (f FQ) Cmp(other FQ) int

Cmp compares this field element to another.

func (FQ) Copy

func (f FQ) Copy() FQ

Copy creates a copy of the field element.

func (*FQ) DivAssign

func (f *FQ) DivAssign(other FQ)

DivAssign divides the field element by another

func (*FQ) DoubleAssign

func (f *FQ) DoubleAssign()

DoubleAssign doubles the element

func (FQ) Equals

func (f FQ) Equals(other FQ) bool

Equals checks equality of two field elements.

func (FQ) Exp

func (f FQ) Exp(n FQRepr) FQ

Exp raises the element to a specific power.

func (FQ) Inverse

func (f FQ) Inverse() (FQ, bool)

Inverse finds the inverse of the field element.

func (*FQ) IsValid

func (f *FQ) IsValid() bool

IsValid checks if the element is valid.

func (FQ) IsZero

func (f FQ) IsZero() bool

IsZero checks if the field element is zero.

func (*FQ) Legendre

func (f *FQ) Legendre() LegendreSymbol

Legendre gets the legendre symbol of the element.

func (*FQ) MulAssign

func (f *FQ) MulAssign(other FQ)

MulAssign multiplies a field element by this one.

func (FQ) MulBits

func (f FQ) MulBits(b *FQRepr) FQ

MulBits multiplies the number by a big number.

func (FQ) MulBytes

func (f FQ) MulBytes(b []byte) FQ

MulBytes multiplies the number by some bytes.

func (*FQ) NegAssign

func (f *FQ) NegAssign()

NegAssign gets the negative value of the field element mod QFieldModulus.

func (FQ) Parity

func (f FQ) Parity() bool

Parity checks if the point is greater than the point negated.

func (FQ) Sqrt

func (f FQ) Sqrt() (FQ, bool)

Sqrt calculates the square root of the field element.

func (*FQ) SquareAssign

func (f *FQ) SquareAssign()

SquareAssign squares a field element.

func (FQ) String

func (f FQ) String() string

func (*FQ) SubAssign

func (f *FQ) SubAssign(other FQ)

SubAssign subtracts a field element from this one.

func (*FQ) ToRepr

func (f *FQ) ToRepr() FQRepr

ToRepr gets the 256-bit representation of the field element.

type FQ12

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

FQ12 is an element of Fq12, represented by c0 + c1 * w.

func FinalExponentiation

func FinalExponentiation(r *FQ12) *FQ12

FinalExponentiation performs the final exponentiation on the FQ12 element.

func MillerLoop

func MillerLoop(items []MillerLoopItem) *FQ12

MillerLoop runs the miller loop algorithm.

func NewFQ12

func NewFQ12(c0 *FQ6, c1 *FQ6) *FQ12

NewFQ12 creates a new FQ12 element from two FQ6 elements.

func Pairing

func Pairing(p *G1Projective, q *G2Projective) *FQ12

Pairing performs a pairing given the G1 and G2 elements.

func RandFQ12

func RandFQ12(reader io.Reader) (*FQ12, error)

RandFQ12 generates a random FQ12 element.

func (*FQ12) AddAssign

func (f *FQ12) AddAssign(other *FQ12)

AddAssign adds two FQ12 elements together.

func (*FQ12) ConjugateAssign

func (f *FQ12) ConjugateAssign()

ConjugateAssign returns the conjugate of the FQ12 element.

func (FQ12) Copy

func (f FQ12) Copy() *FQ12

Copy returns a copy of the FQ12 element.

func (*FQ12) DoubleAssign

func (f *FQ12) DoubleAssign()

DoubleAssign doubles each coefficient in an FQ12 element.

func (FQ12) Equals

func (f FQ12) Equals(other *FQ12) bool

Equals checks if two FQ12 elements are equal.

func (FQ12) Exp

func (f FQ12) Exp(n FQRepr) *FQ12

Exp raises the element ot a specific power.

func (*FQ12) FrobeniusMapAssign

func (f *FQ12) FrobeniusMapAssign(power uint8)

FrobeniusMapAssign calculates the frobenius map of an FQ12 element.

func (*FQ12) InverseAssign

func (f *FQ12) InverseAssign() bool

InverseAssign finds the inverse of an FQ12

func (*FQ12) IsZero

func (f *FQ12) IsZero() bool

IsZero returns if the FQ12 element is zero.

func (*FQ12) MulAssign

func (f *FQ12) MulAssign(other *FQ12)

MulAssign multiplies two FQ12 elements together.

func (*FQ12) MulBy014Assign

func (f *FQ12) MulBy014Assign(c0 FQ2, c1 FQ2, c4 FQ2)

MulBy014Assign multiplies FQ12 element by 3 FQ2 elements.

func (*FQ12) NegAssign

func (f *FQ12) NegAssign()

NegAssign negates each coefficient in an FQ12 element.

func (*FQ12) SquareAssign

func (f *FQ12) SquareAssign()

SquareAssign squares the FQ2 element.

func (*FQ12) String

func (f *FQ12) String() string

func (*FQ12) SubAssign

func (f *FQ12) SubAssign(other *FQ12)

SubAssign subtracts one FQ12 element from another.

type FQ2

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

FQ2 represents an element of Fq2, represented by c0 + c1 * u.

func HashFQ2

func HashFQ2(hasher hash.Hash) FQ2

HashFQ2 calculates a new FQ2 value based on a hash.

func NewFQ2

func NewFQ2(c0 FQ, c1 FQ) FQ2

NewFQ2 constructs a new FQ2 element given two FQ elements.

func RandFQ2

func RandFQ2(reader io.Reader) (FQ2, error)

RandFQ2 generates a random FQ2 element.

func (*FQ2) AddAssign

func (f *FQ2) AddAssign(other FQ2)

AddAssign adds two FQ2 elements together.

func (FQ2) Cmp

func (f FQ2) Cmp(other FQ2) int

Cmp compares two FQ2 elements.

func (*FQ2) Copy

func (f *FQ2) Copy() FQ2

Copy returns a copy of the field element.

func (*FQ2) DivAssign

func (f *FQ2) DivAssign(other FQ2)

DivAssign divides the FQ2 element by another FQ2 element.

func (*FQ2) DoubleAssign

func (f *FQ2) DoubleAssign()

DoubleAssign doubles an FQ2 element.

func (FQ2) Equals

func (f FQ2) Equals(other FQ2) bool

Equals checks if this FQ2 equals another one.

func (FQ2) Exp

func (f FQ2) Exp(n FQRepr) FQ2

Exp raises the element ot a specific power.

func (*FQ2) FrobeniusMapAssign

func (f *FQ2) FrobeniusMapAssign(power uint8)

FrobeniusMapAssign multiplies the element by the Frobenius automorphism coefficient.

func (*FQ2) InverseAssign

func (f *FQ2) InverseAssign() bool

InverseAssign finds the inverse of the field element.

func (FQ2) IsZero

func (f FQ2) IsZero() bool

IsZero checks if the field element is zero.

func (FQ2) Legendre

func (f FQ2) Legendre() LegendreSymbol

Legendre gets the legendre symbol of the FQ2 element.

func (*FQ2) MulAssign

func (f *FQ2) MulAssign(other FQ2)

MulAssign multiplies two FQ2 elements together.

func (FQ2) MulBits

func (f FQ2) MulBits(b *big.Int) FQ2

MulBits multiplies the number by a big number.

func (*FQ2) MultiplyByNonresidueAssign

func (f *FQ2) MultiplyByNonresidueAssign()

MultiplyByNonresidueAssign multiplies this element by the cubic and quadratic nonresidue 1 + u.

func (*FQ2) NegAssign

func (f *FQ2) NegAssign()

NegAssign negates a FQ2 element.

func (*FQ2) Norm

func (f *FQ2) Norm() FQ

Norm gets the norm of Fq2 as extension field in i over Fq.

func (FQ2) Parity

func (f FQ2) Parity() bool

Parity checks if the point is greater than the point negated.

func (FQ2) Sqrt

func (f FQ2) Sqrt() (FQ2, bool)

Sqrt finds the sqrt of a field element.

func (*FQ2) SquareAssign

func (f *FQ2) SquareAssign()

SquareAssign squares the FQ2 element.

func (FQ2) String

func (f FQ2) String() string

func (*FQ2) SubAssign

func (f *FQ2) SubAssign(other FQ2)

SubAssign subtracts one field element from another.

type FQ6

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

FQ6 is an element of FQ6 represented by c0 + c1*v + v2*v**2

func NewFQ6

func NewFQ6(c0 FQ2, c1 FQ2, c2 FQ2) *FQ6

NewFQ6 creates a new FQ6 element.

func RandFQ6

func RandFQ6(reader io.Reader) (*FQ6, error)

RandFQ6 generates a random FQ6 element.

func (*FQ6) AddAssign

func (f *FQ6) AddAssign(other *FQ6)

AddAssign the coefficients of the FQ6 element to another.

func (FQ6) Copy

func (f FQ6) Copy() *FQ6

Copy creates a copy of the field element.

func (*FQ6) DoubleAssign

func (f *FQ6) DoubleAssign()

DoubleAssign doubles the coefficients of the FQ6 element.

func (FQ6) Equals

func (f FQ6) Equals(other *FQ6) bool

Equals checks if two FQ6 elements are equal.

func (FQ6) Exp

func (f FQ6) Exp(n *FQRepr) *FQ6

Exp raises the element ot a specific power.

func (*FQ6) FrobeniusMapAssign

func (f *FQ6) FrobeniusMapAssign(power uint8)

FrobeniusMapAssign runs the frobenius map algorithm with a certain power.

func (*FQ6) InverseAssign

func (f *FQ6) InverseAssign() bool

InverseAssign finds the inverse of the FQ6 element.

func (FQ6) IsZero

func (f FQ6) IsZero() bool

IsZero checks if the FQ6 element is zero.

func (*FQ6) MulAssign

func (f *FQ6) MulAssign(other *FQ6)

MulAssign multiplies two FQ6 elements together.

func (*FQ6) MulBy01Assign

func (f *FQ6) MulBy01Assign(c0 FQ2, c1 FQ2)

MulBy01Assign multiplies by c0 and c1.

func (*FQ6) MulBy1Assign

func (f *FQ6) MulBy1Assign(c1 FQ2)

MulBy1Assign multiplies the FQ6 by an FQ2.

func (*FQ6) MulByNonresidueAssign

func (f *FQ6) MulByNonresidueAssign()

MulByNonresidueAssign multiplies by quadratic nonresidue v.

func (*FQ6) NegAssign

func (f *FQ6) NegAssign()

NegAssign negates the coefficients of the FQ6 element.

func (*FQ6) SquareAssign

func (f *FQ6) SquareAssign()

SquareAssign squares the FQ6 element.

func (FQ6) String

func (f FQ6) String() string

func (*FQ6) SubAssign

func (f *FQ6) SubAssign(other *FQ6)

SubAssign subtracts the coefficients of the FQ6 element from another.

type FQRepr

type FQRepr [6]uint64

FQRepr represents a uint384. The least significant bits are first.

func FQReprFromBigInt

func FQReprFromBigInt(n *big.Int) (FQRepr, error)

FQReprFromBigInt create a FQRepr from a big.Int.

func FQReprFromBytes

func FQReprFromBytes(b [48]byte) FQRepr

FQReprFromBytes gets a new FQRepr from big-endian bytes.

func FQReprFromString

func FQReprFromString(s string, b uint) (FQRepr, error)

FQReprFromString creates a FQRepr from a string.

func NewFQRepr

func NewFQRepr(n uint64) FQRepr

NewFQRepr creates a new number given a uint64.

func (*FQRepr) AddNoCarry

func (f *FQRepr) AddNoCarry(g FQRepr)

AddNoCarry adds two FQReprs to another and does not handle carry.

func (FQRepr) Bit

func (f FQRepr) Bit(n uint) bool

Bit checks if a bit is set (little-endian)

func (FQRepr) BitLen

func (f FQRepr) BitLen() uint

BitLen counts the number of bits the number is.

func (FQRepr) Bytes

func (f FQRepr) Bytes() [48]byte

Bytes gets the bytes used for an FQRepr.

func (*FQRepr) Cmp

func (f *FQRepr) Cmp(g FQRepr) int

Cmp compares two FQRepr's

func (*FQRepr) Copy

func (f *FQRepr) Copy() FQRepr

Copy copies a FQRepr to a new instance and returns it.

func (*FQRepr) Div2

func (f *FQRepr) Div2()

Div2 divides the FQRepr by 2.

func (*FQRepr) Equals

func (f *FQRepr) Equals(g FQRepr) bool

Equals checks if two FQRepr's are equal.

func (FQRepr) IsEven

func (f FQRepr) IsEven() bool

IsEven checks if the FQRepr is even.

func (FQRepr) IsOdd

func (f FQRepr) IsOdd() bool

IsOdd checks if the FQRepr is odd.

func (FQRepr) IsZero

func (f FQRepr) IsZero() bool

IsZero checks if the FQRepr is zero.

func (*FQRepr) Lsh

func (f *FQRepr) Lsh(n uint)

Lsh shifts the FQRepr left by a certain number of bits.

func (*FQRepr) Mul2

func (f *FQRepr) Mul2()

Mul2 multiplies the FQRepr by 2.

func (*FQRepr) Rsh

func (f *FQRepr) Rsh(n uint)

Rsh shifts the FQRepr right by a certain number of bits.

func (FQRepr) String

func (f FQRepr) String() string

ToString converts the FQRepr to a string.

func (*FQRepr) SubNoBorrow

func (f *FQRepr) SubNoBorrow(g FQRepr)

SubNoBorrow subtracts two FQReprs from another and does not handle borrow.

func (FQRepr) ToBig

func (f FQRepr) ToBig() *big.Int

ToBig gets the big.Int representation of the FQRepr.

type FR

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

FR is an element in a field.

func FRReprToFR

func FRReprToFR(o *FRRepr) *FR

FRReprToFR gets a pointer to a FR given a pointer to an FRRepr

func HashFR

func HashFR(hasher hash.Hash) *FR

HashFR calculates a new FR2 value based on a hash.

func HashSecretKey

func HashSecretKey(b [32]byte) *FR

func RandFR

func RandFR(reader io.Reader) (*FR, error)

RandFR generates a random FR element.

func (*FR) AddAssign

func (f *FR) AddAssign(other *FR)

AddAssign multiplies a field element by this one.

func (*FR) Bytes

func (f *FR) Bytes() [32]byte

Bytes gets the representation of the FR in bytes.

func (FR) Cmp

func (f FR) Cmp(other *FR) int

Cmp compares this field element to another.

func (*FR) Copy

func (f *FR) Copy() *FR

Copy copies an FR element.

func (*FR) DoubleAssign

func (f *FR) DoubleAssign()

DoubleAssign doubles the element

func (FR) Equals

func (f FR) Equals(other *FR) bool

Equals checks equality of two field elements.

func (*FR) Exp

func (f *FR) Exp(n *FRRepr) *FR

Exp raises the element to a specific power.

func (FR) Inverse

func (f FR) Inverse() *FR

Inverse finds the inverse of the field element.

func (*FR) IsValid

func (f *FR) IsValid() bool

IsValid checks if the element is valid.

func (FR) IsZero

func (f FR) IsZero() bool

IsZero checks if the field element is zero.

func (*FR) Legendre

func (f *FR) Legendre() LegendreSymbol

Legendre gets the legendre symbol of the element.

func (FR) MulAssign

func (f FR) MulAssign(other *FR)

MulAssign multiplies a field element by this one.

func (FR) MulBits

func (f FR) MulBits(b *FRRepr) *FR

MulBits multiplies the number by a big number.

func (FR) MulBytes

func (f FR) MulBytes(b []byte) *FR

MulBytes multiplies the number by some bytes.

func (*FR) NegAssign

func (f *FR) NegAssign()

NegAssign gets the negative value of the field element mod RFieldModulus.

func (FR) Parity

func (f FR) Parity() bool

Parity checks if the point is greater than the point negated.

func (FR) Sqrt

func (f FR) Sqrt() *FR

Sqrt calculates the square root of the field element.

func (*FR) SquareAssign

func (f *FR) SquareAssign()

SquareAssign squares a field element.

func (FR) String

func (f FR) String() string

func (*FR) SubAssign

func (f *FR) SubAssign(other *FR)

SubAssign subtracts a field element from this one.

func (*FR) ToRepr

func (f *FR) ToRepr() *FRRepr

ToRepr gets the 256-bit representation of the field element.

type FRRepr

type FRRepr [4]uint64

FRRepr represents a uint256.

func FRReprFromBigInt

func FRReprFromBigInt(n *big.Int) (*FRRepr, error)

FRReprFromBigInt create a FRRepr from a big.Int.

func FRReprFromBytes

func FRReprFromBytes(b [32]byte) *FRRepr

FRReprFromBytes gets a new FRRepr from big-endian bytes.

func FRReprFromString

func FRReprFromString(s string, b uint) (*FRRepr, error)

FRReprFromString creates a FRRepr from a string.

func NewFRRepr

func NewFRRepr(n uint64) *FRRepr

NewFRRepr creates a new number given a uint64.

func (*FRRepr) AddNoCarry

func (f *FRRepr) AddNoCarry(g *FRRepr)

AddNoCarry adds two FRReprs to another and does not handle carry.

func (FRRepr) Bit

func (f FRRepr) Bit(n uint) bool

Bit checks if a bit is set (little-endian)

func (FRRepr) BitLen

func (f FRRepr) BitLen() uint

BitLen counts the number of bits the number is.

func (FRRepr) Bytes

func (f FRRepr) Bytes() [32]byte

Bytes gets the bytes used for an FRRepr.

func (*FRRepr) Cmp

func (f *FRRepr) Cmp(g *FRRepr) int

Cmp compares two FRRepr's

func (*FRRepr) Copy

func (f *FRRepr) Copy() *FRRepr

Copy copies a FRRepr to a new instance and returns it.

func (*FRRepr) Div2

func (f *FRRepr) Div2()

Div2 divides the FRRepr by 2.

func (*FRRepr) Equals

func (f *FRRepr) Equals(g *FRRepr) bool

Equals checks if two FRRepr's are equal.

func (FRRepr) IsEven

func (f FRRepr) IsEven() bool

IsEven checks if the FRRepr is even.

func (FRRepr) IsOdd

func (f FRRepr) IsOdd() bool

IsOdd checks if the FRRepr is odd.

func (FRRepr) IsZero

func (f FRRepr) IsZero() bool

IsZero checks if the FRRepr is zero.

func (*FRRepr) Lsh

func (f *FRRepr) Lsh(n uint)

Lsh shifts the FRRepr left by a certain number of bits.

func (*FRRepr) Mul2

func (f *FRRepr) Mul2()

Mul2 multiplies the FRRepr by 2.

func (*FRRepr) Rsh

func (f *FRRepr) Rsh(n uint)

Rsh shifts the FRRepr right by a certain number of bits.

func (FRRepr) String

func (f FRRepr) String() string

ToString converts the FRRepr to a string.

func (*FRRepr) SubNoBorrow

func (f *FRRepr) SubNoBorrow(g *FRRepr)

SubNoBorrow subtracts two FRReprs from another and does not handle borrow.

func (FRRepr) ToBig

func (f FRRepr) ToBig() *big.Int

ToBig gets the big.Int representation of the FRRepr.

func (*FRRepr) ToFQ

func (f *FRRepr) ToFQ() FQRepr

ToFQ converts an FRRepr to an FQ.

type G1Affine

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

G1Affine is an affine point on the G1 curve.

func ClearH

func ClearH(p *G1Affine) *G1Affine

ClearH clears the cofactor for Ell1.

func DecompressG1

func DecompressG1(b [48]byte) (*G1Affine, error)

DecompressG1 decompresses the big int into an affine point and checks if it is in the correct prime group.

func DecompressG1Unchecked

func DecompressG1Unchecked(b [48]byte) (*G1Affine, error)

DecompressG1Unchecked decompresses the big int into an affine point without checking if it's in the correct prime group.

func GetG1PointFromX

func GetG1PointFromX(x FQ, greatest bool) (*G1Affine, error)

GetG1PointFromX attempts to reconstruct an affine point given an x-coordinate. The point is not guaranteed to be in the subgroup. If and only if `greatest` is set will the lexicographically largest y-coordinate be selected.

func HashG1

func HashG1(msg []byte) *G1Affine

HashG1 converts a message to a point on the G2 curve.

func NewG1Affine

func NewG1Affine(x FQ, y FQ) *G1Affine

NewG1Affine constructs a new G1Affine point.

func (G1Affine) Copy

func (g G1Affine) Copy() *G1Affine

Copy returns a copy of the G1Affine point.

func (G1Affine) Equals

func (g G1Affine) Equals(other *G1Affine) bool

Equals checks if two affine points are equal.

func (G1Affine) IsInCorrectSubgroupAssumingOnCurve

func (g G1Affine) IsInCorrectSubgroupAssumingOnCurve() bool

IsInCorrectSubgroupAssumingOnCurve checks if the point multiplied by the field characteristic equals zero.

func (G1Affine) IsOnCurve

func (g G1Affine) IsOnCurve() bool

IsOnCurve checks if a point is on the G1 curve.

func (G1Affine) IsZero

func (g G1Affine) IsZero() bool

IsZero checks if the point is infinity.

func (G1Affine) Mul

func (g G1Affine) Mul(b FQRepr) *G1Projective

Mul performs a EC multiply operation on the point.

func (G1Affine) MulFR

func (g G1Affine) MulFR(b *FRRepr) *G1Projective

MulFR performs a EC multiply operation on the point.

func (*G1Affine) NegAssign

func (g *G1Affine) NegAssign()

NegAssign negates the point.

func (G1Affine) ScaleByCofactor

func (g G1Affine) ScaleByCofactor() *G1Projective

ScaleByCofactor scales the G1Affine point by the cofactor.

func (*G1Affine) SerializeBytes

func (g *G1Affine) SerializeBytes() [96]byte

SerializeBytes returns the serialized bytes for the point represented.

func (*G1Affine) SetRawBytes

func (g *G1Affine) SetRawBytes(uncompressed [96]byte)

SetRawBytes sets the coords given the serialized bytes.

func (G1Affine) String

func (g G1Affine) String() string

func (G1Affine) ToProjective

func (g G1Affine) ToProjective() *G1Projective

ToProjective converts an affine point to a projective one.

type G1Projective

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

G1Projective is a projective point on the G1 curve.

func NewG1Projective

func NewG1Projective(x FQ, y FQ, z FQ) *G1Projective

NewG1Projective creates a new G1Projective point.

func RandG1

func RandG1(r io.Reader) (*G1Projective, error)

RandG1 generates a random G1 element.

func (G1Projective) Add

func (g G1Projective) Add(other *G1Projective) *G1Projective

Add performs an EC Add operation with another point.

func (G1Projective) AddAffine

func (g G1Projective) AddAffine(other *G1Affine) *G1Projective

AddAffine performs an EC Add operation with an affine point.

func (G1Projective) Copy

func (g G1Projective) Copy() *G1Projective

Copy returns a copy of the G1Projective point.

func (G1Projective) Double

func (g G1Projective) Double() *G1Projective

Double performs EC doubling on the point.

func (G1Projective) Equal

func (g G1Projective) Equal(other *G1Projective) bool

Equal checks if two projective points are equal.

func (G1Projective) IsZero

func (g G1Projective) IsZero() bool

IsZero checks if the G1Projective point is zero.

func (G1Projective) Mul

func (g G1Projective) Mul(b FQRepr) *G1Projective

Mul performs a EC multiply operation on the point.

func (G1Projective) MulFR

func (g G1Projective) MulFR(b *FRRepr) *G1Projective

MulFR performs a EC multiply operation on the point.

func (*G1Projective) NegAssign

func (g *G1Projective) NegAssign()

NegAssign negates the point.

func (G1Projective) String

func (g G1Projective) String() string

func (G1Projective) ToAffine

func (g G1Projective) ToAffine() *G1Affine

ToAffine converts a G1Projective point to affine form.

type G2Affine

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

G2Affine is an affine point on the G2 curve.

func DecompressG2

func DecompressG2(c [96]byte) (*G2Affine, error)

DecompressG2 decompresses a G2 point from a big int and checks if it is in the correct subgroup.

func DecompressG2Unchecked

func DecompressG2Unchecked(c [96]byte) (*G2Affine, error)

DecompressG2Unchecked decompresses a G2 point from a big int.

func GetG2PointFromX

func GetG2PointFromX(x FQ2, greatest bool) (*G2Affine, error)

GetG2PointFromX attempts to reconstruct an affine point given an x-coordinate. The point is not guaranteed to be in the subgroup. If and only if `greatest` is set will the lexicographically largest y-coordinate be selected.

func HashG2

func HashG2(msg []byte) *G2Affine

HashG2 converts a message to a point on the G2 curve.

func NewG2Affine

func NewG2Affine(x FQ2, y FQ2) *G2Affine

NewG2Affine constructs a new G2Affine point.

func OptimizedSWU2MapHelper

func OptimizedSWU2MapHelper(t FQ2) *G2Affine

func SWEncodeG2

func SWEncodeG2(t FQ2) *G2Affine

SWEncodeG2 implements the Shallue-van de Woestijne encoding.

func (G2Affine) Copy

func (g G2Affine) Copy() *G2Affine

Copy returns a copy of the G2Affine point.

func (G2Affine) Equals

func (g G2Affine) Equals(other *G2Affine) bool

Equals checks if two affine points are equal.

func (G2Affine) IsInCorrectSubgroupAssumingOnCurve

func (g G2Affine) IsInCorrectSubgroupAssumingOnCurve() bool

IsInCorrectSubgroupAssumingOnCurve checks if the point multiplied by the field characteristic equals zero.

func (G2Affine) IsOnCurve

func (g G2Affine) IsOnCurve() bool

IsOnCurve checks if a point is on the G2 curve.

func (G2Affine) IsZero

func (g G2Affine) IsZero() bool

IsZero checks if the point is infinity.

func (G2Affine) Mul

func (g G2Affine) Mul(b FQRepr) *G2Projective

Mul performs a EC multiply operation on the point.

func (G2Affine) MulBig

func (g G2Affine) MulBig(b big.Int) *G2Projective

MulBig performs a EC multiply operation on the point.

func (G2Affine) MulFR

func (g G2Affine) MulFR(b *FRRepr) *G2Projective

MulFR performs a EC multiply operation on the point.

func (*G2Affine) NegAssign

func (g *G2Affine) NegAssign()

NegAssign negates the point.

func (G2Affine) ScaleByCofactor

func (g G2Affine) ScaleByCofactor() *G2Projective

ScaleByCofactor scales the G2Affine point by the cofactor.

func (*G2Affine) SerializeBytes

func (g *G2Affine) SerializeBytes() [192]byte

SerializeBytes returns the serialized bytes for the points represented.

func (*G2Affine) SetRawBytes

func (g *G2Affine) SetRawBytes(uncompressed [192]byte) error

SetRawBytes sets the coords given the serialized bytes.

func (G2Affine) String

func (g G2Affine) String() string

func (G2Affine) ToProjective

func (g G2Affine) ToProjective() *G2Projective

ToProjective converts an affine point to a projective one.

type G2Prepared

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

G2Prepared is a prepared G2 point multiplication by blsX.

func G2AffineToPrepared

func G2AffineToPrepared(q *G2Affine) *G2Prepared

G2AffineToPrepared performs multiplication of the affine point by blsX.

func (G2Prepared) IsZero

func (g G2Prepared) IsZero() bool

IsZero checks if the point is at infinity.

type G2Projective

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

G2Projective is a projective point on the G2 curve.

func HashG2WithDomain

func HashG2WithDomain(messageHash [32]byte, domain [8]byte) *G2Projective

Warning: See BLS standardisation process. This implementation is known to be unsecure.

func NewG2Projective

func NewG2Projective(x FQ2, y FQ2, z FQ2) *G2Projective

NewG2Projective creates a new G2Projective point.

func RandG2

func RandG2(r io.Reader) (*G2Projective, error)

RandG2 generates a random G2 element.

func (G2Projective) Add

func (g G2Projective) Add(other *G2Projective) *G2Projective

Add performs an EC Add operation with another point.

func (G2Projective) AddAffine

func (g G2Projective) AddAffine(other *G2Affine) *G2Projective

AddAffine performs an EC Add operation with an affine point.

func (G2Projective) Copy

func (g G2Projective) Copy() *G2Projective

Copy returns a copy of the G2Projective point.

func (G2Projective) Double

func (g G2Projective) Double() *G2Projective

Double performs EC doubling on the point.

func (G2Projective) Equals

func (g G2Projective) Equals(other *G2Projective) bool

Equal checks if two projective points are equal.

func (G2Projective) IsZero

func (g G2Projective) IsZero() bool

IsZero checks if the G2Projective point is zero.

func (G2Projective) Mul

func (g G2Projective) Mul(b FQRepr) *G2Projective

Mul performs a EC multiply operation on the point.

func (G2Projective) MulFR

func (g G2Projective) MulFR(b *FRRepr) *G2Projective

MulFR performs a EC multiply operation on the point.

func (G2Projective) String

func (g G2Projective) String() string

func (G2Projective) ToAffine

func (g G2Projective) ToAffine() *G2Affine

ToAffine converts a G2Projective point to affine form.

type LegendreSymbol

type LegendreSymbol uint8

LegendreSymbol is the legendre symbol of an element.

type MillerLoopItem

type MillerLoopItem struct {
	P *G1Affine
	Q *G2Prepared
}

MillerLoopItem are the inputs to the miller loop.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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