fptower

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const SizeOfGT = 32 * 12

SizeOfGT represents the size in bytes that a GT element need in binary form

Variables

This section is empty.

Functions

This section is empty.

Types

type E12

type E12 struct {
	C0, C1 E6
}

E12 is a degree two finite field extension of fp6

func BatchDecompress added in v0.5.1

func BatchDecompress(x []E12) []E12

BatchDecompress multiple Karabina's cyclotomic square results

func (*E12) Add

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

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

func (*E12) Bytes

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

Bytes returns the regular (non montgomery) value of z as a big-endian byte array. z.C1.B2.A1 | z.C1.B2.A0 | z.C1.B1.A1 | ...

func (*E12) Conjugate

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

Conjugate set z to x conjugated and return z

func (*E12) CyclotomicSquare

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

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

func (*E12) CyclotomicSquareCompressed added in v0.5.1

func (z *E12) CyclotomicSquareCompressed(x *E12) *E12

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

func (*E12) Decompress added in v0.5.1

func (z *E12) Decompress(x *E12) *E12

Decompress Karabina's cyclotomic square result

func (*E12) Double

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

Double sets z=2*x and returns z

func (*E12) Equal

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

Equal returns true if z equals x, fasle otherwise

func (*E12) Exp

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

Exp sets z=x**e and returns it

func (*E12) Expt

func (z *E12) Expt(x *E12) *E12

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

func (*E12) Frobenius

func (z *E12) Frobenius(x *E12) *E12

Frobenius set z to Frobenius(x), return z

func (*E12) FrobeniusCube

func (z *E12) FrobeniusCube(x *E12) *E12

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

func (*E12) FrobeniusSquare

func (z *E12) FrobeniusSquare(x *E12) *E12

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

func (*E12) FromMont

func (z *E12) FromMont() *E12

FromMont converts from Mont form

func (*E12) Inverse

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

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

func (*E12) InverseUnitary

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

InverseUnitary inverse a unitary element

func (*E12) IsInSubGroup

func (z *E12) IsInSubGroup() bool

IsInSubGroup ensures GT/E12 is in correct sugroup

func (*E12) Marshal

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

Marshal converts z to a byte slice

func (*E12) Mul

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

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

func (*E12) MulBy034

func (z *E12) MulBy034(c0, c3, c4 *E2) *E12

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

func (*E12) Set

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

Set copies x into z and returns z

func (*E12) SetBytes

func (z *E12) 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. size(e) == 32 * 12 z.C1.B2.A1 | z.C1.B2.A0 | z.C1.B1.A1 | ...

func (*E12) SetOne

func (z *E12) SetOne() *E12

SetOne sets z to 1 in Montgomery form and returns z

func (*E12) SetRandom

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

SetRandom used only in tests

func (*E12) SetString

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

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

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

func (*E12) String

func (z *E12) String() string

String puts E12 in string form

func (*E12) Sub

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

Sub sets z to x sub y and return z

func (*E12) ToMont

func (z *E12) ToMont() *E12

ToMont converts to Mont form

func (*E12) Unmarshal

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

Unmarshal is an allias to SetBytes()

type E2

type E2 struct {
	A0, A1 fp.Element
}

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

func BatchInvert added in v0.5.1

func BatchInvert(a []E2) []E2

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

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 (9,1)

func (*E2) MulByNonResidue1Power1

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

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

func (*E2) MulByNonResidue1Power2

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

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

func (*E2) MulByNonResidue1Power3

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

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

func (*E2) MulByNonResidue1Power4

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

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

func (*E2) MulByNonResidue1Power5

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

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

func (*E2) MulByNonResidue2Power1

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

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

func (*E2) MulByNonResidue2Power2

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

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

func (*E2) MulByNonResidue2Power3

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

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

func (*E2) MulByNonResidue2Power4

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

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

func (*E2) MulByNonResidue2Power5

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

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

func (*E2) MulByNonResidue3Power1

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

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

func (*E2) MulByNonResidue3Power2

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

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

func (*E2) MulByNonResidue3Power3

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

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

func (*E2) MulByNonResidue3Power4

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

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

func (*E2) MulByNonResidue3Power5

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

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

func (*E2) MulByNonResidueInv

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

MulByNonResidueInv multiplies a E2 by (9,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 9)

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 E6

type E6 struct {
	B0, B1, B2 E2
}

E6 is a degree three finite field extension of fp2

func (*E6) Add

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

Add adds two elements of E6

func (*E6) Double

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

Double doubles an element in E6

func (*E6) Equal

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

Equal returns true if z equals x, fasle otherwise

func (*E6) FromMont

func (z *E6) FromMont() *E6

FromMont converts from Mont form

func (*E6) Inverse

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

Inverse an element in E6

func (*E6) Mul

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

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

func (*E6) MulBy01 added in v0.5.0

func (z *E6) MulBy01(c0, c1 *E2) *E6

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

func (*E6) MulBy1 added in v0.5.0

func (z *E6) MulBy1(c1 *E2) *E6

MulBy1 multiplication of E6 by sparse element (0, c1, 0)

func (*E6) MulByE2 added in v0.5.0

func (z *E6) MulByE2(x *E6, y *E2) *E6

MulByE2 multiplies an element in E6 by an element in E2

func (*E6) MulByNonResidue

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

MulByNonResidue mul x by (0,1,0)

func (*E6) Neg

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

Neg negates the E6 number

func (*E6) Set

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

Set Sets a E6 elmt form another E6 elmt

func (*E6) SetOne

func (z *E6) SetOne() *E6

SetOne sets z to 1 in Montgomery form and returns z

func (*E6) SetRandom

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

SetRandom set z to a random elmt

func (*E6) SetString

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

SetString sets a E6 elmt from stringf

func (*E6) Square

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

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

func (*E6) String

func (z *E6) String() string

String puts E6 elmt in string form

func (*E6) Sub

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

Sub two elements of E6

func (*E6) ToMont

func (z *E6) ToMont() *E6

ToMont converts to Mont form

Jump to

Keyboard shortcuts

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