gf

package
v0.0.0-...-61b8281 Latest Latest

Go to latest
Published: Feb 25, 2020 License: AGPL-3.0, BSD-3-Clause

Documentation ¶

Overview ¶

Package gf implements arithmetic over Galois Fields. Generalized for any valid order.

Constants ¶

This section is empty.

Variables ¶

This section is empty.

Functions ¶

This section is empty.

Types ¶

type Field ¶

```type Field struct {
// contains filtered or unexported fields
}```

A Field represents an instance of GF(order) defined by a specific polynomial.

func NewField ¶

`func NewField(order, poly, α int) *Field`

NewField returns a new field corresponding to the polynomial poly and generator α. The choice of generator α only affects the Exp and Log operations.

`func (f *Field) Add(x, y byte) byte`

Add returns the sum of x and y in the field.

func (*Field) Exp ¶

`func (f *Field) Exp(e int) byte`

Exp returns the base-α exponential of e in the field. If e < 0, Exp returns 0.

func (*Field) Inv ¶

`func (f *Field) Inv(x byte) byte`

Inv returns the multiplicative inverse of x in the field. If x == 0, Inv returns 0.

func (*Field) Log ¶

`func (f *Field) Log(x byte) int`

Log returns the base-α logarithm of x in the field. If x == 0, Log returns -1.

func (*Field) Mul ¶

`func (f *Field) Mul(x, y byte) byte`

Mul returns the product of x and y in the field.

func (*Field) Syndrome ¶

`func (f *Field) Syndrome(message []byte, paritySymbolCount, offset int) (syndrome []byte)`

Calculate syndrome for a message encoded using the field generated for a particular Reed-Solomon polynomial. Offset defines the coefficient offset.