field

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2024 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 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) BitLen

func (f Field) BitLen() int

BitLen of the order.

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

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

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

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