gf127

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Copyright 2019 (c) NSPCC

Package gf127 implements the GF(2^127) arithmetic modulo reduction polynomial x^127 + x^63 + 1 . Implementation is in pure Go.

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

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 a to b.

func Mul10

func Mul10(a, b *GF127)

Mul10 sets b to a*x.

func Mul11

func Mul11(a, b *GF127)

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

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

func Random() *GF127

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

func (*GF127) ByteArray

func (c *GF127) ByteArray() (buf []byte)

ByteArray 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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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