1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//! GF(2^8) arithmetic over the field ISA-L uses: the polynomial
//! x^8 + x^4 + x^3 + x^2 + 1 (0x11d), generator 2.
//!
//! Two independent constructions live here on purpose:
//!
//! - [`mul`]/[`inv`] — log/exp table lookups, tables **const-generated at
//! compile time** from the polynomial (no runtime init, no `OnceLock`).
//! - [`mul_shift`] — carry-less shift-and-XOR multiply reduced by the
//! polynomial, table-free. The slow in-crate twin.
//!
//! The conformance tests pin both against ISA-L's own `gf_mul_table_base` /
//! `gf_inv_table_base` (checked in as golden data, all 65,536 products and all
//! 256 inverses), so the field — polynomial included — is proven, not trusted.
/// The reduction byte of the field polynomial: overflow of a doubling is
/// folded back with `^ 0x1d` (the low 8 bits of 0x11d).
pub const POLY_REDUCTION: u8 = 0x1d;
/// Double a field element (multiply by the generator, 2).
const
/// Exponent table, doubled to 510 entries so `log(a) + log(b)` (max 508)
/// indexes directly with no modulo and no branch.
const
const
const EXP: = build_exp;
const LOG: = build_log;
/// Multiply two field elements. Byte-identical to ISA-L's `gf_mul` for every
/// input pair (proven exhaustively against the golden table).
pub const
/// Multiplicative inverse of a field element.
///
/// Faithful to ISA-L's `gf_inv`: **`inv(0)` returns 0** rather than being an
/// error — zero has no inverse, and callers that could reach it must guard
/// (the Cauchy construction and the pivot logic in `matrix` never do).
pub const
/// Table-free multiply: carry-less shift-and-XOR reduced by the polynomial.
///
/// The independent slow twin of [`mul`], kept forever as an in-crate oracle
/// (the tests pin `mul_shift == mul` over all 65,536 pairs, so the const
/// tables can never silently drift from the polynomial).
pub const