gf256

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package gf256 represents elements in the Galois Field GF(2^8)

Index

Constants

View Source
const IrreduciblePolynomial uint8 = 0x1B

IrreduciblePolynomial use the irreducible polynomial x^8 + x^4 + x^3 + x + 1 (0x11B in hex)

Variables

This section is empty.

Functions

func Add

func Add(a, b uint8) uint8

Add performs addition in GF(2^8), which is just XOR

func Divide

func Divide(a, b uint8) uint8

Divide performs division in GF(2^8): a/b = a * b^(-1)

func GenerateInverseTable

func GenerateInverseTable() [256]uint8

GenerateInverseTable creates a 256-element lookup table for multiplicative inverses

func GenerateMultiplicationTable

func GenerateMultiplicationTable() [256][256]uint8

GenerateMultiplicationTable creates a 256x256 lookup table for multiplication

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 Inverse

func Inverse(a uint8) uint8

Inverse returns multiplicative inverse in GF(2^8) using the Extended Euclidean Algorithm

func InverseDo

func InverseDo(a uint8) uint8

InverseDo calculates the multiplicative inverse in GF(2^8) using the Extended Euclidean Algorithm

func Multiply

func Multiply(a, b uint8) uint8

Multiply performs multiplication in GF(2^8)

func MultiplyDo

func MultiplyDo(a, b uint8) uint8

func PolynomialEvaluate

func PolynomialEvaluate(coefficients PolynomialCoefficients, x uint8) uint8

PolynomialEvaluate returns the value of the polynomial for the given x using Horner's method for efficient computation.

func Subtract

func Subtract(a, b uint8) uint8

Subtract in GF(2^8) is the same as addition (XOR)

Types

type PolynomialCoefficients

type PolynomialCoefficients = []uint8

func NewPolynomial

func NewPolynomial(intercept uint8, degree uint8, random io.Reader) (PolynomialCoefficients, error)

Jump to

Keyboard shortcuts

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