r/crypto • • Oct 24 '26

Machine-checked HQC polynomial multiplication: SAW + Isabelle/HOL, all three parameter sets

HQC is NIST's code-based backup to ML-KEM. Its reference implementation relies heavily on binary polynomial multiplication mod xn − 1, with n up to 57,637.

I've proved the unmodified HQC v5.0.0 C implementation correct for hqc-1, hqc-3 and hqc-5.

  • SAW proves vect_mul equivalent to a Cryptol model, using compositional Karatsuba proofs without expanding the full product. Scratch-buffer bounds are also verified.
  • Isabelle/HOL proves the model implements the intended polynomial arithmetic. No sorry, smt or eval; oracle dependencies are checked.
  • Also verified GF(2⁸) operations and the Reed–Solomon encoder's algebraic properties.
  • All 63 SAW mutation tests fail as expected.

An interesting solver finding: the schoolbook leaf and Karatsuba model produce very different XOR/AND circuits. ABC, Z3, Yices and cvc5 couldn't finish in 10 minutes. SAW's Reed–Muller (rme) backend completed the proof in 6 seconds.

For GF(2) arithmetic, solver representation can make the difference between a practical proof and an intractable one.

Scope: This proves specific reference arithmetic, not HQC security. Decoders, sampling, hashing, KEM and constant-time behaviour are not covered. The GF(2⁸) results apply to v5.0.0, before the October specification change.

Reproducible with make hqc (~20 min) and make hqc-isabelle (~20 sec).

https://github.com/amarshat/pqc-assay

Criticism welcome, particularly on the property specifications.

Next: the AVX2 multiplier (PCLMULQDQ + Toom-3), which is closer to what actually runs in production.

9 Upvotes

5 comments sorted by

5

u/voracious-ladder Oct 24 '26

I'd be interested to see if you can verify this: https://eprint.iacr.org/2026/014

2

u/Humble-Replacement-2 Oct 25 '26

Had a look. Their multiplier is an additive FFT over GF(2^64) (Frobenius variant, Cantor basis, CRT for the length above 2^14), with portable reference C next to the AVX2/NEON/GFNI versions, public domain. Everything in it is F2-linear or bilinear, so the SAW half (C equals a stage-by-stage model, GF(2^64) multiply as the leaf) should go the same way as the Karatsuba/Toom proofs. Isabelle half is gonna be hard: proving the additive-FFT-plus-CRT model is the product needs the subspace-evaluation math, which nobody has mechanized in Isabelle yet. So - yes, and it is next on the list after the current write-up, starting with their gf264 reference for hqc-1.

1

u/Humble-Replacement-2 Oct 27 '26

Update on 2026/014: I verified the portable reference C from the authors' artifact (gf264_ref, commit c94c84d) with SAW. At all three HQC sizes the C matches a Cryptol model of the additive FFT: encode, butterflies, pointwise GF(2^64) multiply, inverse FFT, decode and the basis conversions. Each step also has mutants that the tool rejects. Reproduce with make hqc-fft, make hqc-fft-3, make hqc-fft-5 in the repo.
Still open is the other half: a proof that the model really computes the polynomial product mod x^n - 1. That's the Isabelle step, which I haven't done yet. So right now this is "the C does what the model says", not yet "the model is multiplication". The AVX2 and NEON variants aren't covered.
The proofs turned up one minor issue, which I've reported to the authors. I'll post details once they've had time to look.

1

u/voracious-ladder Oct 27 '26

Something about an invalid stack read?

1

u/Humble-Replacement-2 Oct 27 '26

No, not that. It's minor and doesn't affect the results.