gf2n

package module
v0.0.0-...-ebf459e Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: LGPL-3.0 Imports: 1 Imported by: 0

README

Binary Extension Field

Introduction

This is an experimental implementation of binary extension field operations.

To construct a binary extension finite field GF(2^n), an irreducible polynomial f(x) over GF(2) of degree n is used. In current implementation, it requires that the degree must be strictly less than 64.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GF2nElement

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

func (*GF2nElement) Add

func (z *GF2nElement) Add(x, y *GF2nElement) *GF2nElement

Add will add two field elements and return their sum

func (*GF2nElement) Equal

func (z *GF2nElement) Equal(x *GF2nElement) bool

return whether two elements are equal

func (*GF2nElement) Field

func (z *GF2nElement) Field() *GF2nField

func (*GF2nElement) Mul

func (z *GF2nElement) Mul(x, y *GF2nElement) *GF2nElement

Multiply two field elements and return their product

func (*GF2nElement) Pow

func (z *GF2nElement) Pow(n uint64) *GF2nElement

Return the power of a field element to a power

func (*GF2nElement) SetFromElement

func (z *GF2nElement) SetFromElement(x *GF2nElement) *GF2nElement

func (*GF2nElement) SetFromValues

func (z *GF2nElement) SetFromValues(v uint64, field *GF2nField) *GF2nElement

func (*GF2nElement) Sub

func (z *GF2nElement) Sub(x, y *GF2nElement) *GF2nElement

Substract a field element from another element and return their difference

func (*GF2nElement) Value

func (z *GF2nElement) Value() uint64

type GF2nField

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

arithmetic over GF(2^n) n must be less than 64 x^n + irre must be a irreducible polynomial over GF(2^n) where irre is a polynomial over GF(2) of degree less than n

func NewGF2nField

func NewGF2nField(n uint8, irre uint64) (*GF2nField, error)

generate a binary extension field we do not check whether x^n + irre is irreducible

func (*GF2nField) Equal

func (f *GF2nField) Equal(e *GF2nField) bool

func (*GF2nField) ExtDegree

func (f *GF2nField) ExtDegree() uint8

return the degree of extension

func (*GF2nField) IrrePolyWithoutHighest

func (f *GF2nField) IrrePolyWithoutHighest() uint64

return irreducible polynomial wo/ the highest order term

func (*GF2nField) NewGF2nElement

func (f *GF2nField) NewGF2nElement(v uint64) *GF2nElement

func (*GF2nField) NewGF2nPoly

func (f *GF2nField) NewGF2nPoly(coeff []*GF2nElement) *GF2nPoly

type GF2nPoly

type GF2nPoly struct {
	Coeff []*GF2nElement
	Field *GF2nField
}

func (*GF2nPoly) Eval

func (f *GF2nPoly) Eval(x *GF2nElement) *GF2nElement

Jump to

Keyboard shortcuts

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