field

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package field provides modular operations over very high integers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func String2Int

func String2Int(s string) big.Int

String2Int returns a big.Int representation of the integer s.

Types

type Field

type Field struct {
	// contains filtered or unexported fields
}

Field represents a Gaulois Field.

func NewField

func NewField(prime *big.Int) Field

NewField returns a newly instantiated field for the given prime order.

func (Field) Add

func (f Field) Add(res, x, y *big.Int)

Add sets res to x + y modulo the field order.

func (Field) AreEqual

func (f Field) AreEqual(f1, f2 *big.Int) bool

AreEqual returns whether both elements are equal.

func (Field) BitLen

func (f Field) BitLen() int

BitLen of the order.

func (Field) CondMov

func (f Field) CondMov(res, x, y *big.Int, b bool)

CondMov sets res to y if b true, and to x otherwise.

func (Field) CondNeg

func (f Field) CondNeg(res, x *big.Int, cond int)

CondNeg sets res to -x if cond == 1.

func (Field) Exponent

func (f Field) Exponent(res, x, n *big.Int) *big.Int

Exponent returns x^n mod field order.

func (Field) Inv

func (f Field) Inv(res, x *big.Int)

Inv sets res to the modular inverse of x mod field order.

func (Field) IsEqual

func (f Field) IsEqual(f2 *Field) bool

IsEqual returns whether the two fields have the same order.

func (Field) IsSquare

func (f Field) IsSquare(e *big.Int) bool

IsSquare returns whether e is a quadratic square.

func (Field) IsZero

func (f Field) IsZero(e *big.Int) bool

IsZero returns whether the big.Int is equivalent to zero.

func (Field) LegendreSymbol

func (f Field) LegendreSymbol(a *big.Int) *big.Int

LegendreSymbol applies the Legendre symbole on (a/p) and returns either {-1, 0, 1} mod field order.

func (Field) Lsh

func (f Field) Lsh(res, x *big.Int, n uint)

Lsh sets res to the left shift of n bits on x modulo the field order.

func (Field) Mod

func (f Field) Mod(x *big.Int) *big.Int

Mod reduces x modulo the field order.

func (Field) Mul

func (f Field) Mul(res, x, y *big.Int)

Mul sets res to the multiplication of x and y modulo the field order.

func (Field) Neg

func (f Field) Neg(res, x *big.Int) *big.Int

Neg sets res to the -x modulo the field order.

func (Field) One

func (f Field) One() *big.Int

One returns one big.Int of the finite Field.

func (Field) Order

func (f Field) Order() *big.Int

Order returns the size of the Field.

func (Field) Random

func (f Field) Random(res *big.Int) *big.Int

Random sets res to a random big.Int in the Field.

func (Field) Sgn0

func (f Field) Sgn0(x *big.Int) int

Sgn0 returns the first bit in the big-endian representation.

func (Field) SqrtRatio

func (f Field) SqrtRatio(res, zMapConstant, e, v *big.Int) bool

SqrtRatio res result to the square root of (e/v), and indicates whether (e/v) is a square.

func (Field) Square

func (f Field) Square(res, x *big.Int)

Square sets res to the square of x modulo the field order.

func (Field) SquareRoot

func (f Field) SquareRoot(res, e *big.Int) *big.Int

SquareRoot sets res to a square root of e mod the field's order, if such a square root exists.

func (Field) Sub

func (f Field) Sub(res, x, y *big.Int) *big.Int

Sub sets res to x - y modulo the field order.

func (Field) Zero

func (f Field) Zero() *big.Int

Zero returns the zero big.Int of the finite Field.

Jump to

Keyboard shortcuts

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