The field GF(2⁸): elements and addition #
An element of GF(2⁸) is a byte, read as a polynomial of degree < 8 over GF(2): bit i is the
coefficient of xⁱ. Addition (and subtraction) is XOR.
GF256 is a structure wrapping UInt8, not an abbrev. That way + and * on
GF256 can only ever mean field operations, never byte arithmetic mod 256. Lean represents a
one-field structure as the bare field at runtime, so this costs nothing.
An element of GF(2⁸) with the AES reduction polynomial x⁸ + x⁴ + x³ + x + 1 (0x11B).
- val : UInt8
The underlying byte. Bit
iis the coefficient ofxⁱ.
Instances For
Equations
- QedShare.instReprGF256 = { reprPrec := QedShare.instReprGF256.repr }
Equations
- QedShare.instReprGF256.repr x✝ prec✝ = Std.Format.bracket "{ " (Std.Format.nil ++ Std.Format.text "val" ++ Std.Format.text " := " ++ (Std.Format.nest 7 (repr x✝.val)).group) " }"
Instances For
Equations
Instances For
Equations
The multiplicative identity, the constant polynomial 1.
Equations
- QedShare.GF256.one = { val := 1 }
Instances For
Equations
- QedShare.GF256.instZero = { zero := QedShare.GF256.zero }
Equations
- QedShare.GF256.instOne = { one := QedShare.GF256.one }
Equations
- QedShare.GF256.instAdd = { add := QedShare.GF256.add }
Subtraction equals addition in characteristic 2.
Equations
- QedShare.GF256.instSub = { sub := QedShare.GF256.add }
Negation is the identity in characteristic 2.
Equations
- QedShare.GF256.instNeg = { neg := id }
Every element is its own negative (characteristic 2).
Every element is its own additive inverse: a + a = 0.