Expand description
Arithmetic in GF(2⁸) — the Galois field with 256 elements.
Uses the standard AES irreducible polynomial: p(x) = x⁸ + x⁴ + x³ + x + 1 (0x11b)
§Operations
add— addition = XOR (free)mul— multiplication via Russian-peasant (8 iterations, no lookup tables)inv— multiplicative inverse via Fermat: a⁻¹ = a²⁵⁴div— division = mul(a, inv(b))
Element 0 is the additive identity. Element 1 is the multiplicative identity.
Calling inv or div with b=0 panics (division by zero).
Functions§
- add
- Addition in GF(2⁸) — identical to XOR.
- div
- Division in GF(2⁸):
a / b = a · b⁻¹. - inv
- Multiplicative inverse of
avia Fermat’s little theorem: a⁻¹ = a^254. - mul
- Multiplication in GF(2⁸) using the Russian-peasant algorithm. Runs in exactly 8 iterations regardless of input values.
- mul_acc
acc[i] ^= coeff * symbol[i]over GF(2⁸) — the inner loop of RLNC encoding.