mersenne31

package
v1.2.23 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Modulus = 2147483647
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element [1]uint32 // defined as an array to prevent mistaken use of arithmetic operators, or naive assignments.

Element of a prime order field, represented in Montgomery form to speed up multiplications.

func New

func New(x uint32) Element

New returns an element of the field f corresponding to the natural number x.

func (Element) Add

func (x Element) Add(y Element) Element

Add x + y

func (Element) AddBytes

func (x Element) AddBytes(b []byte) Element

AddBytes adds the Element to the given big-endian value. It expects exactly 4 input bytes.

func (Element) AddUint32

func (x Element) AddUint32(y uint32) Element

AddUint32 x + y

func (Element) Bytes

func (x Element) Bytes() []byte

Bytes returns the big-endian encoded value of the Element, possibly with leading zeros.

func (Element) Cmp

func (x Element) Cmp(y Element) int

Cmp compares the numerical values of x and y.

func (Element) Double

func (x Element) Double() Element

Double x -> 2x

func (Element) Half

func (x Element) Half() Element

Half x -> x/2 (mod m).

func (Element) Inverse

func (x Element) Inverse() Element

Inverse x -> x⁻¹ (mod m) or 0 if x = 0

func (Element) IsOne

func (x Element) IsOne() bool

func (Element) IsZero

func (x Element) IsZero() bool

func (Element) Mul

func (x Element) Mul(y Element) Element

Mul x * y

func (Element) String

func (x Element) String() string

String returns the value of x based 10.

func (Element) Sub

func (x Element) Sub(y Element) Element

Sub x - y

func (Element) Text

func (x Element) Text(base int) string

Text returns the value of x in the given base.

func (Element) ToUint32

func (x Element) ToUint32() uint32

ToUint32 returns the numerical (non-Montgomery) value of x.

Jump to

Keyboard shortcuts

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