Documentation

CslibFrontier.Crypto.Primitives.HQC.Syndrome

Parity-constrained quasi-cyclic syndrome distributions #

The real and comparison laws are the finite distributions in [GAMA+26], Definitions 2.3.6–2.3.9, pp. 12–13. A public vector represents its circulant matrix, using Mathlib's Matrix.circulant. The two-block syndrome is x + circulant h *ᵥ y. The three-block law uses the same third sparse vector in both syndrome components and retains only a prefix of the second component. Here m is the retained length, equal to the source's n - ℓ.

Public blocks and the first comparison syndrome have the prescribed parities. The second comparison component is uniform on all m bits. These are distributions, not hardness assumptions: no adversary class, efficient sampler, seed expansion, or security reduction is asserted. Zero and full weights and zero/full retained length are admitted as explicit finite extensions; source security claims use their stated positive parameters and primitive primes.

Main definitions #

Main results #

References #

The source's ideal support sampler, converted to a Boolean indicator, is exactly the uniform fixed-weight bit-string law used in the syndrome distributions.

A systematic binary syndrome, with public block circulant h and two secret blocks.

The parity obtained when both secret blocks have weight w and the public block parity b. This is the source's w + b*w mod 2, expressed in the Boolean ring.

theorem Cslib.Crypto.HQC.parity_syndrome {n : ℕ} [NeZero n] (h x y : BitString n) :
parity n (syndrome h x y) = (parity n x ^^ parity n h && parity n y)

Circulant multiplication forces the indicated parity relation.

theorem Cslib.Crypto.HQC.parity_syndrome_of_weight {n w : ℕ} [NeZero n] (h x y : BitString n) (b : Bool) (hh : parity n h = b) (hx : BitString.weight x = w) (hy : BitString.weight y = w) :

Fixed weights in both secret blocks determine the syndrome parity.

A sample for the two-block problem, retaining its public circulant generator.

  • publicBlock : BitString n

    Generator of the public circulant matrix.

  • value : BitString n

    The syndrome of the two secret blocks.

A sample for the three-block problem, with a prefix of its second syndrome.

  • firstBlock : BitString n

    Generator of the first public circulant.

  • secondBlock : BitString n

    Generator of the second public circulant.

  • firstValue : BitString n

    The entire first syndrome, whose parity is public.

  • secondValue : BitString m

    The retained prefix of the second syndrome.

noncomputable def Cslib.Crypto.HQC.realSyndromeLaw (n w : ℕ) [NeZero n] (hw : w ≤ n) (b : Bool) :

The 2-QCSD-P real distribution: independent uniform fixed-weight secret blocks.

noncomputable def Cslib.Crypto.HQC.uniformSyndromeLaw (n w : ℕ) [NeZero n] (b : Bool) :

The 2-DQCSD-P comparison distribution retains both public parity constraints.

noncomputable def Cslib.Crypto.HQC.realTruncatedSyndromeLaw (n m w : ℕ) [NeZero n] (hm : m ≤ n) (hw : w ≤ n) (b₁ b₂ : Bool) :

The 3-QCSD-PT real law. Both syndromes use the same sampled third secret block z.

noncomputable def Cslib.Crypto.HQC.uniformTruncatedSyndromeLaw (n m w : ℕ) [NeZero n] (b₁ b₂ : Bool) :

The 3-DQCSD-PT comparison law: constrain the first syndrome's parity and draw the retained second block independently and uniformly, as in the source distribution.

theorem Cslib.Crypto.HQC.mem_support_realTruncatedSyndromeLaw_iff {n m w : ℕ} [NeZero n] (hm : m ≤ n) (hw : w ≤ n) (b₁ b₂ : Bool) (sample : TruncatedSyndromeSample n m) :
sample ∈ (realTruncatedSyndromeLaw n m w hm hw b₁ b₂).support ↔ parity n sample.firstBlock = b₁ ∧ parity n sample.secondBlock = b₂ ∧ ∃ (x : BitString n) (y : BitString n) (z : BitString n), BitString.weight x = w ∧ BitString.weight y = w ∧ BitString.weight z = w ∧ sample.firstValue = syndrome sample.firstBlock x z ∧ sample.secondValue = syndrome sample.secondBlock y z ∘ ⇑(Fin.castLEEmb hm)

Support characterization of the three-block real law. In particular, the same witness z appears in both syndrome equations; replacing it by two independent vectors changes the law.

theorem Cslib.Crypto.HQC.parity_of_mem_support_realSyndromeLaw {n w : ℕ} [NeZero n] (hw : w ≤ n) (b : Bool) {sample : SyndromeSample n} (hs : sample ∈ (realSyndromeLaw n w hw b).support) :

All real two-block samples satisfy both parity constraints.

theorem Cslib.Crypto.HQC.parity_of_mem_support_realTruncatedSyndromeLaw {n m w : ℕ} [NeZero n] (hm : m ≤ n) (hw : w ≤ n) (b₁ b₂ : Bool) {sample : TruncatedSyndromeSample n m} (hs : sample ∈ (realTruncatedSyndromeLaw n m w hm hw b₁ b₂).support) :
parity n sample.firstBlock = b₁ ∧ parity n sample.secondBlock = b₂ ∧ parity n sample.firstValue = syndromeParity w b₁

The three-block law preserves both public-block parities and the first syndrome parity. No parity is asserted for the truncated second component.

theorem Cslib.Crypto.HQC.map_parity_realSyndromeLaw {n w : ℕ} [NeZero n] (hw : w ≤ n) (b : Bool) :
PMF.map (fun (sample : SyndromeSample n) => parity n sample.value) (realSyndromeLaw n w hw b) = PMF.pure (syndromeParity w b)

The public parity test is deterministic on real two-block samples. This is why their comparison distribution must also constrain the syndrome parity.

The comparison law preserves the same deterministic syndrome parity as the real law.