Documentation

CslibFrontier.Crypto.Primitives.HQC.SupportDensity

Finite-bit density bounds for HQC support sampling #

Main definitions #

Main results #

References #

noncomputable def Cslib.Crypto.HQC.supportLowerDensity (width n offset count : ℕ) :

Product of the minimum fibre counts, divided by the ideal uniform point masses. For M = 2^width and d = n - (offset + j), each factor is 1 - (M % d) / M.

noncomputable def Cslib.Crypto.HQC.supportUpperDensity (width n offset count : ℕ) :

Product of the upper fibre counts, divided by the ideal uniform point masses. Each factor is 1 + (d - (M % d)) / M, including the source's slack when the remainder is zero.

theorem Cslib.Crypto.HQC.sampleCandidate_density_bounds {width n offset : ℕ} (h : offset < n) (r : ℕ) :
↑(2 ^ width / (n - offset) * (n - offset)) / ↑(2 ^ width) * (idealCandidate n offset).eval r ≤ (sampleCandidate width n offset).eval r ∧ (sampleCandidate width n offset).eval r ≤ ↑((2 ^ width / (n - offset) + 1) * (n - offset)) / ↑(2 ^ width) * (idealCandidate n offset).eval r

Exact fibre bounds for one actual word, compared with its ideal interval draw.

theorem Cslib.Crypto.HQC.sampleSupportFrom_density_bounds {width n offset count : ℕ} (h : offset + count ≤ n) (S : Finset ℕ) :
supportLowerDensity width n offset count * (sampleSupportFrom (idealCandidate n) offset count).eval S ≤ (sampleSupportFrom (sampleCandidate width n) offset count).eval S ∧ (sampleSupportFrom (sampleCandidate width n) offset count).eval S ≤ supportUpperDensity width n offset count * (sampleSupportFrom (idealCandidate n) offset count).eval S

The independent word factors multiply through the actual collision-replacement program.

HQC Proposition 6.2.1: actual fixed-width sampling is sandwiched between the two explicit product factors times the uniform fixed-weight law. This also covers weight zero.

theorem Cslib.Crypto.HQC.supportUpperDensity_ne_top (width n offset count : ℕ) :
supportUpperDensity width n offset count ≠ ⊤

The upper density is finite, so converting its bounds to real probabilities is sound.

theorem Cslib.Crypto.HQC.sampleSupport2_expect_bounds {width n count : ℕ} (h : count ≤ n) (V : Finset ℕ → ENNReal) :
supportLowerDensity width n 0 count * (sampleSupportFrom (idealCandidate n) 0 count).expect V ≤ (sampleSupport2 width n count).expect V ∧ (sampleSupport2 width n count).expect V ≤ supportUpperDensity width n 0 count * (sampleSupportFrom (idealCandidate n) 0 count).expect V

Corrected HQC Lemma 6.5: the density bounds transfer to every nonnegative payoff. Using extended nonnegative values also permits unbounded payoffs without summability premises.

theorem Cslib.Crypto.HQC.sampleSupport2_event_bounds {width n count : ℕ} (h : count ≤ n) (E : Set (Finset ℕ)) [DecidablePred fun (x : Finset ℕ) => x ∈ E] :
(supportLowerDensity width n 0 count).toReal * (((fun (S : Finset ℕ) => decide (S ∈ E)) <$> sampleSupportFrom (idealCandidate n) 0 count).eval true).toReal ≤ (((fun (S : Finset ℕ) => decide (S ∈ E)) <$> sampleSupport2 width n count).eval true).toReal ∧ (((fun (S : Finset ℕ) => decide (S ∈ E)) <$> sampleSupport2 width n count).eval true).toReal ≤ (supportUpperDensity width n 0 count).toReal * (((fun (S : Finset ℕ) => decide (S ∈ E)) <$> sampleSupportFrom (idealCandidate n) 0 count).eval true).toReal

Every event probability obeys the same bounds, stated with the program-level probability notation. No event-specific sampling or cryptographic hypothesis is required.

theorem Cslib.Crypto.HQC.sampleSupport2_payoff_bounds {width n count : ℕ} (h : count ≤ n) (V : Finset ℕ → ℝ) (hV : ∀ S ∈ Finset.powersetCard count (Finset.range n), 0 ≤ V S) :
(supportLowerDensity width n 0 count).toReal * ∑ S ∈ Finset.powersetCard count (Finset.range n), (((fun (x : Finset ℕ) => x == S) <$> sampleSupportFrom (idealCandidate n) 0 count).eval true).toReal * V S ≤ ∑ S ∈ Finset.powersetCard count (Finset.range n), (((fun (x : Finset ℕ) => x == S) <$> sampleSupport2 width n count).eval true).toReal * V S ∧ ∑ S ∈ Finset.powersetCard count (Finset.range n), (((fun (x : Finset ℕ) => x == S) <$> sampleSupport2 width n count).eval true).toReal * V S ≤ (supportUpperDensity width n 0 count).toReal * ∑ S ∈ Finset.powersetCard count (Finset.range n), (((fun (x : Finset ℕ) => x == S) <$> sampleSupportFrom (idealCandidate n) 0 count).eval true).toReal * V S

The finite real-valued expectation form of corrected Lemma 6.5. Only values on valid supports must be nonnegative, since both samplers are supported there.

theorem Cslib.Crypto.HQC.supportLowerDensity_toReal (width n offset count : ℕ) :
(supportLowerDensity width n offset count).toReal = ∏ j : Fin count, (1 - ↑(2 ^ width % (n - (offset + ↑j))) / 2 ^ width)

The proved lower factors are exactly the remainder factors printed in Equation (16).

theorem Cslib.Crypto.HQC.supportUpperDensity_toReal {width n offset count : ℕ} (h : offset + count ≤ n) :
(supportUpperDensity width n offset count).toReal = ∏ j : Fin count, (1 + (↑(n - (offset + ↑j)) - ↑(2 ^ width % (n - (offset + ↑j)))) / 2 ^ width)

The proved upper factors retain precisely the slack printed in Equation (16).