type poly
= int
The type for degree 8 polynomials, using 0x1FF bits. The i
th zero-based bit index represents the coefficient (0 or 1) of the i
th degree variable.
type byte
= int
The type for bytes, the elements of GF(28).
type t
A galois field instance for a given polynomial and generator.
val create : r:poly -> g:byte -> t
create ~r ~g
is a field modulo polynomial r
(must be irreducible) and generator g
. g
is the base for exp
and log
.
val add : byte -> byte -> byte
add x y
is y
added (xored) to x
.
val sub : byte -> byte -> byte
sub x y
is y
subtracted (xored) to x
.
val exp : t -> byte -> byte
exp f x
is the base g
exponential g
x
in f
.
val log : t -> byte -> byte
log f x
is y
the base g
logarithm of x
, i.e. g
y
= x
. This is 255
if x = 0
.
val mul : t -> byte -> byte -> byte
mul f x y
multiples x
by y
modulo f
's r
polynomial.
val inv : t -> byte -> byte
inv f x
is x
-1, the multiplicative inverse of x
. This is 0
if x
is 0
.