Documentation

CslibFrontier.Crypto.Primitives.HQC.SupportCircuit

Boolean circuits for HQC support sampling #

The candidate circuit implements the multiply-high expression in SampleSupport2 using the existing modular multiplier and carry-lookahead adder. It widens intermediate products before selecting the high bits, so its correctness theorem requires no overflow approximation.

Main definitions #

Main results #

References #

The candidate formula is HQC version 5.1, SampleSupport2, p. 19, line 5. The circuit construction and its costs are original bridges to the existing Boolean compiler.

Compute one source candidate from its fair input word. Constants and zero padding use the existing shared two-gate constant-word circuit. The total circuit truncates to bits outputs.

theorem Cslib.Crypto.HQC.val_eval_candidateCircuit {width bits n offset : ℕ} (hoff : offset < n) (hn : n < 2 ^ bits) (x : BitString width) :
↑((BitString.equivFin bits) ((candidateCircuit width bits n offset).eval Circuits.Boolean.interpretation x)) = offset + ↑((BitString.equivFin width) x) * (n - offset) / 2 ^ width

With a wide enough output word and a valid shrinking interval, the circuit computes the source's exact multiply-high candidate, not a modular-reduction approximation.

There are three two-gate constant words, plus the existing multiplier and adder. Output selections and input copies are free wires in the Boolean circuit model.

theorem Cslib.Crypto.HQC.size_candidateCircuit_le (width bits n offset : ℕ) :
(candidateCircuit width bits n offset).size ≤ 63 * (width + bits + 1) ^ 2 + 21 * (bits + 1) ^ 2 + 6

Every constant, multiplier and adder gate is charged; output selections are free wires.