fptower

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const SizeOfGT = sizeOfFp * 24

Variables

This section is empty.

Functions

This section is empty.

Types

type E12 added in v0.6.0

type E12 struct {
	C0, C1, C2 E4
}

E12 is a degree three finite field extension of fp4

func (*E12) Add added in v0.6.0

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

Add adds two elements of E12

func (*E12) Conjugate added in v0.6.0

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

Conjugate set z to x conjugated and return z

func (*E12) Double added in v0.6.0

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

Double doubles an element in E12

func (*E12) Equal added in v0.6.0

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

Equal returns true if z equals x, fasle otherwise

func (*E12) Exp added in v0.6.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.6.0

func (z *E12) FromMont() *E12

FromMont converts from Mont form

func (*E12) Inverse added in v0.6.0

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

Inverse an element in E12

func (*E12) InverseUnitary added in v0.6.0

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

InverseUnitary inverse a unitary element

func (*E12) Mul added in v0.6.0

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

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

func (*E12) MulBy01 added in v0.6.0

func (z *E12) MulBy01(c0, c1 *E4) *E12

MulBy01 multiplication by sparse element (c0,c1,0)

func (*E12) MulByE2 added in v0.6.0

func (z *E12) MulByE2(x *E12, y *E4) *E12

MulByE2 multiplies an element in E12 by an element in E2

func (*E12) MulByNonResidue added in v0.6.0

func (z *E12) MulByNonResidue(x *E12) *E12

MulByNonResidue mul x by (0,1,0)

func (*E12) Neg added in v0.6.0

func (z *E12) Neg(x *E12) *E12

Neg negates the E12 number

func (*E12) Set added in v0.6.0

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

Set Sets a E12 elmt form another E12 elmt

func (*E12) SetOne added in v0.6.0

func (z *E12) SetOne() *E12

SetOne sets z to 1 in Montgomery form and returns z

func (*E12) SetRandom added in v0.6.0

func (z *E12) SetRandom() (*E12, error)

SetRandom set z to a random elmt

func (*E12) SetString added in v0.6.0

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

SetString sets a E12 elmt from stringf

func (*E12) Square added in v0.6.0

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

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

func (*E12) String added in v0.6.0

func (z *E12) String() string

String puts E12 elmt in string form

func (*E12) Sub added in v0.6.0

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

Sub two elements of E12

func (*E12) ToMont added in v0.6.0

func (z *E12) ToMont() *E12

ToMont converts to Mont form

type E2

type E2 struct {
	A0, A1 fp.Element
}

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

func (*E2) Add

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

Add adds two elements of E2

func (*E2) Cmp

func (z *E2) Cmp(x *E2) int

Cmp compares (lexicographic order) z and x and returns:

-1 if z <  x
 0 if z == x
+1 if z >  x

func (*E2) Conjugate

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

Conjugate conjugates an element in E2

func (*E2) Double

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

Double doubles an E2 element

func (*E2) Equal

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

Equal returns true if z equals x, fasle otherwise

func (*E2) Exp

func (z *E2) Exp(x E2, exponent *big.Int) *E2

Exp sets z=x**e and returns it

func (*E2) FromMont

func (z *E2) FromMont() *E2

FromMont converts from mont form

func (*E2) Inverse

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

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

func (*E2) IsZero

func (z *E2) IsZero() bool

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

func (*E2) Legendre

func (z *E2) Legendre() int

Legendre returns the Legendre symbol of z

func (*E2) LexicographicallyLargest

func (z *E2) LexicographicallyLargest() bool

LexicographicallyLargest returns true if this element is strictly lexicographically larger than its negation, false otherwise

func (*E2) Mul

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

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

func (*E2) MulByElement

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

MulByElement multiplies an element in E2 by an element in fp

func (*E2) MulByNonResidue

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

MulByNonResidue multiplies a E2 by (0,1)

func (*E2) MulByNonResidueInv

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

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

func (*E2) Neg

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

Neg negates an E2 element

func (*E2) Set

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

Set sets an E2 from x

func (*E2) SetOne

func (z *E2) SetOne() *E2

SetOne sets z to 1 in Montgomery form and returns z

func (*E2) SetRandom

func (z *E2) SetRandom() (*E2, error)

SetRandom sets a0 and a1 to random values

func (*E2) SetString

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

SetString sets a E2 element from strings

func (*E2) SetZero

func (z *E2) SetZero() *E2

SetZero sets an E2 elmt to zero

func (*E2) Sqrt

func (z *E2) Sqrt(x *E2) *E2

Sqrt sets z to the square root of and returns z The function does not test wether the square root exists or not, it's up to the caller to call Legendre beforehand. cf https://eprint.iacr.org/2012/685.pdf (algo 10)

func (*E2) Square

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

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

func (*E2) String

func (z *E2) String() string

String implements Stringer interface for fancy printing

func (*E2) Sub

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

Sub two elements of E2

func (*E2) ToMont

func (z *E2) ToMont() *E2

ToMont converts to mont form

type E24

type E24 struct {
	D0, D1 E12
}

E24 is a degree two finite field extension of fp6

func BatchDecompress added in v0.5.1

func BatchDecompress(x []E24) []E24

BatchDecompress multiple Karabina's cyclotomic square results

func (*E24) Add

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

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

func (*E24) Bytes

func (z *E24) Bytes() (r [SizeOfGT]byte)

func (*E24) Conjugate

func (z *E24) Conjugate(x *E24) *E24

Conjugate set z to x conjugated and return z

func (*E24) CyclotomicSquare

func (z *E24) CyclotomicSquare(x *E24) *E24

Granger-Scott's cyclotomic square https://eprint.iacr.org/2009/565.pdf, 3.2

func (*E24) CyclotomicSquareCompressed added in v0.5.1

func (z *E24) CyclotomicSquareCompressed(x *E24) *E24

Karabina's compressed cyclotomic square https://eprint.iacr.org/2010/542.pdf Th. 3.2 with minor modifications to fit our tower

func (*E24) Decompress added in v0.5.1

func (z *E24) Decompress(x *E24) *E24

Decompress Karabina's cyclotomic square result

func (*E24) Double

func (z *E24) Double(x *E24) *E24

Double sets z=2*x and returns z

func (*E24) Equal

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

Equal returns true if z equals x, fasle otherwise

func (*E24) Exp

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

Exp sets z=x**e and returns it

func (*E24) Expt

func (z *E24) Expt(x *E24) *E24

Expt set z to x^t in E24 and return z (t is the seed of the curve) -2**32+2**30+2**22-2**20+1

func (*E24) Frobenius

func (z *E24) Frobenius(x *E24) *E24

Frobenius set z to Frobenius(x), return z

func (*E24) FrobeniusQuad

func (z *E24) FrobeniusQuad(x *E24) *E24

FrobeniusQuad set z to Frobenius^4(x), return z

func (*E24) FrobeniusSquare

func (z *E24) FrobeniusSquare(x *E24) *E24

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

func (*E24) FromMont

func (z *E24) FromMont() *E24

FromMont converts from Mont form

func (*E24) Inverse

func (z *E24) Inverse(x *E24) *E24

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

func (*E24) InverseUnitary

func (z *E24) InverseUnitary(x *E24) *E24

InverseUnitary inverse a unitary element

func (*E24) IsInSubGroup

func (z *E24) IsInSubGroup() bool

IsInSubGroup ensures GT/E24 is in correct sugroup

func (*E24) Marshal

func (z *E24) Marshal() []byte

Marshal converts z to a byte slice

func (*E24) Mul

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

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

func (*E24) MulBy034 added in v0.6.0

func (z *E24) MulBy034(c0, c3, c4 *E4) *E24

MulBy034 multiplication by sparse element (c0,0,0,c3,c4,0)

func (*E24) Set

func (z *E24) Set(x *E24) *E24

Set copies x into z and returns z

func (*E24) SetBytes

func (z *E24) SetBytes(e []byte) error

SetBytes interprets e as the bytes of a big-endian GT sets z to that value (in Montgomery form), and returns z.

func (*E24) SetOne

func (z *E24) SetOne() *E24

SetOne sets z to 1 in Montgomery form and returns z

func (*E24) SetRandom

func (z *E24) SetRandom() (*E24, error)

SetRandom used only in tests

func (*E24) SetString

func (z *E24) SetString(s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19, s20, s21, s22, s23 string) *E24

SetString sets a E24 from string

func (*E24) Square

func (z *E24) Square(x *E24) *E24

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

func (*E24) String

func (z *E24) String() string

String puts E24 in string form

func (*E24) Sub

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

Sub sets z to x sub y and return z

func (*E24) ToMont

func (z *E24) ToMont() *E24

ToMont converts to Mont form

func (*E24) Unmarshal

func (z *E24) Unmarshal(buf []byte) error

Unmarshal is an allias to SetBytes()

type E4

type E4 struct {
	B0, B1 E2
}

E4 is a degree two finite field extension of fp2

func BatchInvert added in v0.5.1

func BatchInvert(a []E4) []E4

BatchInvert returns a new slice with every element inverted. Uses Montgomery batch inversion trick

func (*E4) Add

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

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

func (*E4) Cmp

func (z *E4) Cmp(x *E4) int

Cmp compares (lexicographic order) z and x and returns:

-1 if z <  x
 0 if z == x
+1 if z >  x

func (*E4) Conjugate

func (z *E4) Conjugate(x *E4) *E4

Conjugate set z to x conjugated and return z

func (*E4) Double

func (z *E4) Double(x *E4) *E4

Double sets z=2*x and returns z

func (*E4) Equal

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

Equal returns true if z equals x, fasle otherwise

func (*E4) Exp

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

Exp sets z=x**e and returns it

func (*E4) Frobenius

func (z *E4) Frobenius(x *E4) *E4

Frobenius sets z in E4 to x^q, returns z

func (*E4) FromMont

func (z *E4) FromMont() *E4

FromMont converts from Mont form

func (*E4) Halve added in v0.5.2

func (z *E4) Halve()

func (*E4) Inverse

func (z *E4) Inverse(x *E4) *E4

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

func (*E4) IsZero

func (z *E4) IsZero() bool

IsZero returns true if the element is zero, fasle otherwise

func (*E4) Legendre

func (z *E4) Legendre() int

Legendre returns the Legendre symbol of z

func (*E4) LexicographicallyLargest

func (z *E4) LexicographicallyLargest() bool

LexicographicallyLargest returns true if this element is strictly lexicographically larger than its negation, false otherwise

func (*E4) Mul

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

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

func (*E4) MulByElement

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

MulByElement multiplies an element in E4 by an element in fp

func (*E4) MulByNonResidue

func (z *E4) MulByNonResidue(x *E4) *E4

MulByNonResidue mul x by (0,1)

func (*E4) MulByNonResidueInv

func (z *E4) MulByNonResidueInv(x *E4) *E4

MulByNonResidueInv mul x by (0,1)^{-1}

func (*E4) MulBybTwistCurveCoeff added in v0.6.0

func (z *E4) MulBybTwistCurveCoeff(x *E4) *E4

MulBybTwistCurveCoeff multiplies by 1/(0,1)

func (*E4) Neg

func (z *E4) Neg(x *E4) *E4

Neg negates an E4 element

func (*E4) Set

func (z *E4) Set(x *E4) *E4

Set copies x into z and returns z

func (*E4) SetOne

func (z *E4) SetOne() *E4

SetOne sets z to 1 in Montgomery form and returns z

func (*E4) SetRandom

func (z *E4) SetRandom() (*E4, error)

SetRandom used only in tests

func (*E4) SetString

func (z *E4) SetString(s0, s1, s2, s3 string) *E4

SetString sets a E4 from string

func (*E4) SetZero

func (z *E4) SetZero() *E4

SetZero sets an E4 elmt to zero

func (*E4) Sqrt

func (z *E4) Sqrt(x *E4) *E4

Sqrt sets z to the square root of and returns z The function does not test wether the square root exists or not, it's up to the caller to call Legendre beforehand. cf https://eprint.iacr.org/2012/685.pdf (algo 10)

func (*E4) Square

func (z *E4) Square(x *E4) *E4

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

func (*E4) String

func (z *E4) String() string

String puts E4 in string form

func (*E4) Sub

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

Sub sets z to x sub y and return z

func (*E4) ToMont

func (z *E4) ToMont() *E4

ToMont converts to Mont form

Jump to

Keyboard shortcuts

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