gf127

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2019 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Copyright 2018 (c) NSPCC

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 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 y to a*x.

func Mul11

func Mul11(a, b *GF127)

Mul11 sets y 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 (*GF127) Add

func (c *GF127) Add(a, b *GF127) *GF127

Add sets c to the sum a+b and returns c.

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

func (c *GF127) Mul(a, b *GF127) *GF127

Mul sets c to the product a*b and returns c.

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.

Jump to

Keyboard shortcuts

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