Expand description
Kernel algebra for the prime field 𝔽_q of ML-KEM / ML-DSA — the certified arithmetic substrate (F2 seed).
Every identity here is discharged by the kernel’s OWN decision procedures — the ring
canonicalizer for polynomial identities (which hold for ALL values, not a ≤16-bit
sample), and Fourier-Motzkin lia for the modular-reduction range bounds — with no Z3.
This is the layer the NTT’s correctness and its symmetry-derived speed rewrites build
on: a rewrite that cuts multiplies (or collapses a symmetric butterfly) is only safe once
the kernel certifies it computes the same polynomial.
Constants§
- KYBER_Q
- Kyber / ML-KEM’s modulus — prime, so ℤ/qℤ is the field 𝔽_q.
- MLDSA_
MONT_ R - Montgomery radix
R = 2³²andqinv = q⁻¹ mod R = 58728449(the SUBTRACT convention: the reduction isredc(a) = (a − ((a·qinv) mod R)·q) / R, matchingmldsa::montgomery_reduce). The exact integer cofactor(qinv·q − 1) / Rmakes the numerator a clean multiple ofR. - MLDSA_Q
- Dilithium’s modulus — prime, so ℤ/qℤ is the field 𝔽_q.
- MLDSA_
QINV - MONT_R
- Montgomery radix
R = 2¹⁶andqinv' = −q⁻¹ mod R = 3327, with the exact integer cofactor(qinv'·q + 1) / R = 169. These are the constants of the division-free reductionredc(x) = (x + ((x·qinv') mod R)·q) / Rused by the (SIMD) ML-KEM NTT. - NEG_
QINV_ MOD_ R
Functions§
- conditional_
subtract_ in_ range - Certify that conditional-subtract reduction keeps a modular-ADD result in range. After an
addition in 𝔽_q the value
alies in[0, 2q); the reduction iscsub(a) = if a ≥ q { a − q } else { a }, and the result must lie in[0, q). The two non-trivial bounds (thea ≥ qbranch) are discharged by Fourier-Motzkin: a goal is valid iff its negation’s constraints are UNSAT. - gauss_
three_ multiply_ identity - Gauss’s three-multiplication identity — the symmetry that turns a 4-multiply bilinear
form
ad + bcinto 3 multiplies(a+b)(c+d) − ac − bd. It is the archetypal “spend an add to save a multiply” rewrite behind fast complex / polynomial / NTT-butterfly multiplication. Certified as a polynomial identity over any commutative ring by the kernel’sringcanonicalizer, so a codegen pass may apply it knowing it is sound. - mldsa_
montgomery_ congruence - Certify the ML-DSA Montgomery CONGRUENCE:
(a − lo·q) − a = −q·lo, so the reduction numeratorredc·R = a − lo·qdiffers fromaby a multiple ofq⇒redc·R ≡ a (mod q)⇒redc ≡ a·R⁻¹ (mod q). A ring identity in the free variablesa,lo, certified for all values. - mldsa_
montgomery_ divisibility - Certify the ML-DSA Montgomery DIVISIBILITY:
a·qinv·q − a = cofactor·R·a, i.e. the reduction’s numeratora − (a·qinv)·q = −cofactor·R·ais an EXACT multiple ofR(so/Ris a shift, never a rounding divide). This holds becauseqinv·q ≡ 1 (mod R); theringcanonicalizer reduces both sides toa·(qinv·q − 1), certifying it for ALLa. - mldsa_
montgomery_ reduction_ certified - The full ML-DSA Montgomery reduction is kernel-certified: the numerator is an exact multiple of
R(divisibility) and the result isa·R⁻¹ mod q(congruence). Together these provemldsa::montgomery_reduce— hence the AVX2montmul32that shares its formula — computes the right field element, with no Z3, for ALL inputs (not a sampled bit-width). - montgomery_
reduction_ certified - The full Montgomery reduction is kernel-certified: the constant divides exactly (so
/Ris a shift), the result isx·R⁻¹ mod q(congruence), and the final conditional subtract keeps it in[0, q)(range). A single gate over the three procedures. - montgomery_
reduction_ congruence - Certify the Montgomery CONGRUENCE:
(x + lo·q) − x = q·lo, so the reduction numerator differs fromxby a multiple ofq⇒redc·R ≡ x (mod q)⇒redc ≡ x·R⁻¹ (mod q)(Ris a unit in 𝔽_q). A ring identity in the free variablesx,lo, certified for all values. - montgomery_
reduction_ divisibility - Certify the Montgomery DIVISIBILITY:
x + (x·qinv')·q = x·169·R, i.e. the reduction’s numerator (with the un-reducedlo = x·qinv') is an EXACT multiple ofR— soredc’s/ Ris an exact shift, never a rounding division. This is what makesqinv' = 3327the RIGHT constant (qinv'·q ≡ −1 mod R): the kernelringcanonicalizer reduces both sides tox·11075584, certifying it for ALLx, not a sampled width.