Documentation ¶
Overview ¶
Package config provides Golang code generation for efficient field arithmetic operations.
Index ¶
- func CoordNameForExtensionDegree(degree uint8) string
- func NewElement(s []string) []big.Int
- type Element
- type Extension
- func (f *Extension) Add(x Element, y Element) Element
- func (f *Extension) Div(u, v Element) Element
- func (f *Extension) Equal(x Element, y Element) bool
- func (f *Extension) Exp(x Element, exp *big.Int) Element
- func (f *Extension) FromInt64(i ...int64) Element
- func (f *Extension) Halve(z Element)
- func (f *Extension) Inverse(x Element) Element
- func (f *Extension) IsZero(u Element) bool
- func (f *Extension) Mul(x Element, y Element) Element
- func (f *Extension) MulScalar(c *big.Int, x Element) Element
- func (f *Extension) Neg(x Element) Element
- func (f *Extension) Sqrt(x Element) Element
- func (f *Extension) ToMont(x Element) Element
- type FieldConfig
- func (f *FieldConfig) Add(z *big.Int, x *big.Int, y *big.Int) *FieldConfig
- func (f *FieldConfig) Exp(res *big.Int, x *big.Int, pow *big.Int) *FieldConfig
- func (f *FieldConfig) FromMont(nonMont *big.Int, mont *big.Int) *FieldConfig
- func (f *FieldConfig) Mul(z *big.Int, x *big.Int, y *big.Int) *FieldConfig
- func (f *FieldConfig) StringToMont(str string) big.Int
- func (f *FieldConfig) ToMont(nonMont big.Int) big.Int
- func (f *FieldConfig) ToMontSlice(x []big.Int) []big.Int
- func (f *FieldConfig) WriteElement(element Element) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CoordNameForExtensionDegree ¶
TODO: Spaghetti Alert: Okay to have codegen functions here?
func NewElement ¶
Types ¶
type Extension ¶
type Extension struct { Base *FieldConfig //Fp Size big.Int //q Degree int //n such that q = pⁿ TODO: Make uint8 so forced to be positive and small RootOf int64 //α }
Extension is a simple radical extension, obtained by adjoining ⁿ√α to Fp
type FieldConfig ¶
type FieldConfig struct { PackageName string ElementName string ModulusBig *big.Int Modulus string ModulusHex string NbWords int NbBits int NbBytes int NbWordsLastIndex int NbWordsIndexesNoZero []int NbWordsIndexesFull []int P20InversionCorrectiveFac []uint64 P20InversionNbIterations int UsingP20Inverse bool IsMSWSaturated bool // indicates if the most significant word is 0xFFFFF...FFFF Q []uint64 QInverse []uint64 QMinusOneHalvedP []uint64 // ((q-1) / 2 ) + 1 ASM bool RSquare []uint64 One, Thirteen []uint64 LegendreExponent string // big.Int to base16 string NoCarry bool NoCarrySquare bool // used if NoCarry is set, but some op may overflow in square optimization SqrtQ3Mod4 bool SqrtAtkin bool SqrtTonelliShanks bool SqrtE uint64 SqrtS []uint64 SqrtAtkinExponent string // big.Int to base16 string SqrtSMinusOneOver2 string // big.Int to base16 string SqrtQ3Mod4Exponent string // big.Int to base16 string SqrtG []uint64 // NonResidue ^ SqrtR (montgomery form) NonResidue big.Int // (montgomery form) LegendreExponentData *addchain.AddChainData SqrtAtkinExponentData *addchain.AddChainData SqrtSMinusOneOver2Data *addchain.AddChainData SqrtQ3Mod4ExponentData *addchain.AddChainData UseAddChain bool }
FieldConfig precomputed values used in template for code generation of field element APIs
func NewFieldConfig ¶
func NewFieldConfig(packageName, elementName, modulus string, useAddChain bool) (*FieldConfig, error)
NewFieldConfig returns a data structure with needed information to generate apis for field element
See field/generator package
func (*FieldConfig) Add ¶
func (f *FieldConfig) Add(z *big.Int, x *big.Int, y *big.Int) *FieldConfig
func (*FieldConfig) Exp ¶
func (f *FieldConfig) Exp(res *big.Int, x *big.Int, pow *big.Int) *FieldConfig
func (*FieldConfig) FromMont ¶
func (f *FieldConfig) FromMont(nonMont *big.Int, mont *big.Int) *FieldConfig
func (*FieldConfig) Mul ¶
func (f *FieldConfig) Mul(z *big.Int, x *big.Int, y *big.Int) *FieldConfig
func (*FieldConfig) StringToMont ¶
func (f *FieldConfig) StringToMont(str string) big.Int
StringToMont takes an element written in string form, and returns it in Montgomery form Useful for hard-coding in implementation field elements from standards documents
func (*FieldConfig) ToMontSlice ¶
func (f *FieldConfig) ToMontSlice(x []big.Int) []big.Int
func (*FieldConfig) WriteElement ¶
func (f *FieldConfig) WriteElement(element Element) string
Click to show internal directories.
Click to hide internal directories.