gf127

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package gf127 implements the GF(2^127) arithmetic modulo reduction polynomial x^127 + x^63 + 1 . gf127.go contains common definitions. Other files contain architecture-specific implementations.

Package gf127 implements the GF(2^127) arithmetic modulo reduction polynomial x^127 + x^63 + 1 . This is rather straight-forward re-implementation of C library available here https://github.com/srijs/hwsl2-core . Interfaces are highly influenced by math/big .

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(a, b, c *GF127)

Add sets c to a+b.

func And

func And(a, b, c *GF127)

And sets c to a & b (bitwise-and).

func CombineTo

func CombineTo(a *GF127, b *GF127, c *GF127x2)

CombineTo 2 elements of GF(2^127) to the respective components of pair.

func Inv

func Inv(a, b *GF127)

Inv sets b to a^-1 Algorithm is based on Extended Euclidean Algorithm and is described by Hankerson, Hernandez, Menezes in https://link.springer.com/content/pdf/10.1007/3-540-44499-8_1.pdf

func Mul

func Mul(a, b, c *GF127)

Mul sets c to a*b.

func Mul1

func Mul1(a, b *GF127)

Mul1 copies b into a.

func Mul10

func Mul10(a, b *GF127)

Mul10 sets b to a*x.

func Mul10x2

func Mul10x2(a, b *GF127x2)

Mul10x2 sets (b1, b2) to (a1*x, a2*x)

func Mul11

func Mul11(a, b *GF127)

Mul11 sets b to a*(x+1).

func Mul11x2

func Mul11x2(a, b *GF127x2)

Mul11x2 sets (b1, b2) to (a1*(x+1), a2*(x+1))

func Split

func Split(a *GF127x2) (*GF127, *GF127)

Split returns 2 components of pair without additional allocations.

Types

type GF127

type GF127 [2]uint64

GF127 represents element of GF(2^127)

func New

func New(lo, hi uint64) *GF127

New constructs new element of GF(2^127) as hi*x^64 + lo. It is assumed that hi has zero MSB.

func Random

func Random() *GF127

Random returns random element from GF(2^127). Is used mostly for testing.

func (*GF127) Bytes

func (c *GF127) Bytes() [16]byte

Bytes represents element of GF(2^127) as byte array of length 16.

func (*GF127) Equals

func (c *GF127) Equals(b *GF127) bool

Equals checks if two reduced (zero MSB) elements of GF(2^127) are equal

func (*GF127) MarshalBinary

func (c *GF127) MarshalBinary() (data []byte, err error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*GF127) String

func (c *GF127) String() string

String returns hex-encoded representation, starting with MSB.

func (*GF127) UnmarshalBinary

func (c *GF127) UnmarshalBinary(data []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

type GF127x2

type GF127x2 [2]GF127

GF127x2 represents a pair of elements of GF(2^127) stored together.

func (*GF127x2) Bytes

func (a *GF127x2) Bytes() (buf [32]byte)

Bytes represents element of GF(2^127) as byte array of length 32.

func (*GF127x2) Equal

func (a *GF127x2) Equal(b *GF127x2) bool

Equal checks if both elements of GF(2^127) pair are equal.

func (*GF127x2) String

func (a *GF127x2) String() string

String returns hex-encoded representation, starting with MSB. Elements of pair are separated by comma.

Jump to

Keyboard shortcuts

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