bls377

package
v0.2.3 Latest Latest
Warning

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

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

Documentation

Overview

Package bls377 contains field arithmetic operations

Package bls377 contains field arithmetic operations

Package bls377 contains field arithmetic operations

Package bls377 contains field arithmetic operations

Index

Constants

View Source
const ElementBits = 377

ElementBits number bits needed to represent Element

View Source
const ElementLimbs = 6

ElementLimbs number of 64 bits words needed to represent Element

Variables

This section is empty.

Functions

func ElementModulus

func ElementModulus() *big.Int

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 field modulus q =

258664426012969094010652733694893533536393512754914660539884262666720468348340822774968888139573360124440321458177

func FromInterface

func FromInterface(i1 interface{}) Element

FromInterface converts i1 from uint64, int, string, or Element, big.Int into Element panic if provided type is not supported

func One

func One() Element

One returns 1 (in montgommery form)

func (*Element) Add

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

Add z = x + y mod q

func (*Element) AddAssign

func (z *Element) AddAssign(x *Element) *Element

AddAssign z = z + x mod q

func (*Element) Bytes

func (z *Element) Bytes() []byte

Bytes returns the regular (non montgomery) value of z as a big-endian byte slice.

func (*Element) Div

func (z *Element) Div(x, y *Element) *Element

Div z = x*y^-1 mod q

func (*Element) Double

func (z *Element) Double(x *Element) *Element

Double z = x + x mod q, aka Lsh 1

func (*Element) Equal

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

Equal returns z == x

func (*Element) Exp

func (z *Element) Exp(x Element, exponent ...uint64) *Element

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

func (z *Element) FromMont() *Element

FromMont converts z in place (i.e. mutates) from Montgomery to regular representation sets and returns z = z * 1

func (*Element) Inverse

func (z *Element) Inverse(x *Element) *Element

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) IsZero

func (z *Element) IsZero() bool

IsZero returns z == 0

func (*Element) Legendre

func (z *Element) Legendre() int

Legendre returns the Legendre symbol of z (either +1, -1, or 0.)

func (*Element) Mul

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

Mul z = x * y mod q see https://hackmd.io/@zkteam/modular_multiplication

func (*Element) MulAssign

func (z *Element) MulAssign(x *Element) *Element

MulAssign z = z * x mod q see https://hackmd.io/@zkteam/modular_multiplication

func (*Element) Neg

func (z *Element) Neg(x *Element) *Element

Neg z = q - x

func (*Element) Set

func (z *Element) Set(x *Element) *Element

Set z = x

func (*Element) SetBigInt

func (z *Element) SetBigInt(v *big.Int) *Element

SetBigInt sets z to v (regular form) and returns z in Montgomery form

func (*Element) SetBytes

func (z *Element) SetBytes(e []byte) *Element

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

func (*Element) SetOne

func (z *Element) SetOne() *Element

SetOne z = 1 (in Montgomery form)

func (*Element) SetRandom

func (z *Element) SetRandom() *Element

SetRandom sets z to a random element < q

func (*Element) SetString

func (z *Element) SetString(s string) *Element

SetString creates a big.Int with s (in base 10) and calls SetBigInt on z

func (*Element) SetUint64

func (z *Element) SetUint64(v uint64) *Element

SetUint64 z = v, sets z LSB to v (non-Montgomery form) and convert z to Montgomery form

func (*Element) SetZero

func (z *Element) SetZero() *Element

SetZero z = 0

func (*Element) Sqrt

func (z *Element) Sqrt(x *Element) *Element

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

func (z *Element) Square(x *Element) *Element

Square z = x * x mod q see https://hackmd.io/@zkteam/modular_multiplication

func (*Element) String

func (z *Element) String() string

String returns the string form of an Element in Montgomery form

func (*Element) Sub

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

Sub z = x - y mod q

func (*Element) SubAssign

func (z *Element) SubAssign(x *Element) *Element

SubAssign z = z - x mod q

func (*Element) ToBigInt

func (z *Element) ToBigInt(res *big.Int) *big.Int

ToBigInt returns z as a big.Int in Montgomery form

func (Element) ToBigIntRegular

func (z Element) ToBigIntRegular(res *big.Int) *big.Int

ToBigIntRegular returns z as a big.Int in regular form

func (*Element) ToMont

func (z *Element) ToMont() *Element

ToMont converts z to Montgomery form sets and returns z = z * r^2

func (Element) ToRegular

func (z Element) ToRegular() Element

ToRegular returns z in regular form (doesn't mutate z)

Jump to

Keyboard shortcuts

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