Documentation ¶
Overview ¶
Package fp (generated by goff) contains field arithmetics operations
Index ¶
- Constants
- type Element
- func (z *Element) Add(x, y *Element) *Element
- func (z *Element) AddAssign(x *Element) *Element
- func (z *Element) Div(x, y *Element) *Element
- func (z *Element) Double(x *Element) *Element
- func (z *Element) Equal(x *Element) bool
- func (z *Element) Exp(x Element, exponent ...uint64) *Element
- func (z *Element) FromMont() *Element
- func (z *Element) Inverse(x *Element) *Element
- func (z *Element) IsZero() bool
- func (z *Element) Legendre() int
- func (z *Element) Mul(x, y *Element) *Element
- func (z *Element) MulAssign(x *Element) *Element
- func (z *Element) Neg(x *Element) *Element
- func (z *Element) Set(x *Element) *Element
- func (z *Element) SetBigInt(v *big.Int) *Element
- func (z *Element) SetOne() *Element
- func (z *Element) SetRandom() *Element
- func (z *Element) SetString(s string) *Element
- func (z *Element) SetUint64(v uint64) *Element
- func (z *Element) SetZero() *Element
- func (z *Element) Sqrt(x *Element) *Element
- func (z *Element) Square(x *Element) *Element
- func (z *Element) String() string
- func (z *Element) Sub(x, y *Element) *Element
- func (z *Element) SubAssign(x *Element) *Element
- func (z *Element) ToBigInt(res *big.Int) *big.Int
- func (z Element) ToBigIntRegular(res *big.Int) *big.Int
- func (z *Element) ToMont() *Element
- func (z Element) ToRegular() Element
Constants ¶
const ElementBits = 377
ElementBits number bits needed to represent Element
const ElementLimbs = 6
ElementLimbs number of 64 bits words needed to represent Element
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element [6]uint64
Element represents a field element stored on 6 words (uint64) Element are assumed to be in Montgomery form in all methods
func FromInterface ¶
func FromInterface(i1 interface{}) Element
func (*Element) Exp ¶
Exp z = x^exponent mod q (not optimized) exponent (non-montgomery form) is ordered from least significant word to most significant word
func (*Element) FromMont ¶
FromMont converts z in place (i.e. mutates) from Montgomery to regular representation sets and returns z = z * 1
func (*Element) Inverse ¶
Inverse z = x^-1 mod q Algorithm 16 in "Efficient Software-Implementation of Finite Fields with Applications to Cryptography" if x == 0, sets and returns z = x
func (*Element) Mul ¶
Mul z = x * y mod q see https://hackmd.io/@zkteam/modular_multiplication
func (*Element) MulAssign ¶
MulAssign z = z * x mod q see https://hackmd.io/@zkteam/modular_multiplication
func (*Element) SetString ¶
SetString creates a big.Int with s (in base 10) and calls SetBigInt on z
func (*Element) SetUint64 ¶
SetUint64 z = v, sets z LSB to v (non-Montgomery form) and convert z to Montgomery form
func (*Element) Sqrt ¶
Sqrt z = √x mod q if the square root doesn't exist (x is not a square mod q) Sqrt leaves z unchanged and returns nil
func (*Element) Square ¶
Square z = x * x mod q see https://hackmd.io/@zkteam/modular_multiplication
func (Element) ToBigIntRegular ¶
ToBigIntRegular returns z as a big.Int in regular form