galois

package
v0.0.0-...-f80e208 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(a, b uint8) uint8

Add combines two numbers in GF(2^8)

GF(2^8) addition and subtraction are performed by the exclusive or operation. The two operations are the same; there is no difference between addition and subtraction.

func Div

func Div(a, b uint8) uint8

Div divides two numbers in GF(2^8)

GF(2^8) division can be done quickly with a 256-byte log and exponentiation tables. To divide `a` by `b` using the tables: - Look up `a` on the log table. - Look up `b` on the log table. - Subtract `b`s table value from `a`s mod 255. (normal, not GF(2^8) subtraction) - Look up the difference on the exp table, this is the GF(2^8) quotient.

func InterpolatePolynomial

func InterpolatePolynomial(xSamples, ySamples []uint8, x uint8) uint8

InterpolatePolynomial takes N sample points and returns the value at a given x using a lagrange interpolation.

func Mult

func Mult(a, b uint8) uint8

Mult multiplies two numbers in GF(2^8)

GF(2^8) multiplication can be done quickly with a 256-byte log and exponentiation tables. To multiply `a` by `b` using the tables: - Look up `a` on the log table. - Look up `b` on the log table. - Add up the two table values (using normal, not GF(2^8), addition) mod 255 - Look up the sum on the exponentiation table, this is the GF(2^8) product.

Types

type Polynomial

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

Polynomial represents a polynomial of arbitrary degree

func MakePolynomial

func MakePolynomial(intercept, degree uint8) Polynomial

MakePolynomial constructs a random polynomial of the given degree but with the provided intercept value.

func (*Polynomial) Evaluate

func (p *Polynomial) Evaluate(x uint8) uint8

Evaluate returns the value of the polynomial for the given x

Jump to

Keyboard shortcuts

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