gf256

package
v0.0.0-...-76ae421 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2019 License: MIT, BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package gf256 implements arithmetic over the Galois Field GF(256).

Index

Constants

View Source
const ReedSolomonGenerator = 0x02

ReedSolomonGenerator is the generator for the finit field for reed-solomon codes

View Source
const ReedSolomonPolynomial = 0x11d

ReedSolomonPolynomial is the polynomial commonly used for finite field construction for Reed-Solomon-Codes (100011101)

View Source
const RijndaelGenerator = 0x03

RijndaelGenerator is the generator for Rijndael's finite field

View Source
const RijndaelPolynomial = 0x11b

RijndaelPolynomial is the Rijndael-Polynomial for finite field construction (100011011)

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(256) defined by a specific polynomial.

func NewField

func NewField(poly, a int) *Field

NewField returns a new field corresponding to the polynomial poly and generator a. The Reed-Solomon encoding in QR codes uses polynomial 0x11d with generator 2.

The choice of generator a only affects the Exp and Log operations.

func (*Field) Add

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

type RSEncoder

type RSEncoder struct {
	// contains filtered or unexported fields
}

An RSEncoder implements Reed-Solomon encoding over a given field using a given number of error correction bytes.

func NewRSEncoder

func NewRSEncoder(f *Field, c int) *RSEncoder

NewRSEncoder returns a new Reed-Solomon encoder over the given field and number of error correction bytes.

func (*RSEncoder) ECC

func (rs *RSEncoder) ECC(data []byte, check []byte)

ECC writes to check the error correcting code bytes for data using the given Reed-Solomon parameters.

Jump to

Keyboard shortcuts

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