field

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 1 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

This section is empty.

Types

type Field

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

Field represents a Galois 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) 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) 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) 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) 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) 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.

Jump to

Keyboard shortcuts

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