gf251

package
v1.1.31 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	Modulus = 251
)

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 added in v1.1.15

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 2 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) Equals added in v1.1.17

func (x Element) Equals(o Element) bool

Equals implementation for hash.Hasher interface

func (Element) Half

func (x Element) Half() Element

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

func (Element) Hash added in v1.1.17

func (x Element) Hash() uint64

Hash implementation for hash.Hasher interface

func (Element) Inverse

func (x Element) Inverse() Element

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

func (Element) IsOne added in v1.1.15

func (x Element) IsOne() bool

func (Element) IsZero added in v1.1.15

func (x Element) IsZero() bool

func (Element) Modulus added in v1.1.17

func (x Element) Modulus() *big.Int

Modulus implementation for the Element interface

func (Element) Mul

func (x Element) Mul(y Element) Element

Mul x * y

func (Element) SetBytes added in v1.1.17

func (x Element) SetBytes(bs []byte) Element

SetBytes implementation for word.Word interface.

func (Element) SetUint64 added in v1.1.17

func (x Element) SetUint64(val uint64) Element

SetUint64 implementation for word.Word interface

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.

func (Element) Uint64 added in v1.1.17

func (x Element) Uint64() uint64

Uint64 implementation for word.Word interface.

Jump to

Keyboard shortcuts

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