Documentation

CslibFrontier.Crypto.Game.CloseTo.UniformNat

All-event approximation for bounded modular sampling #

The existing finite statistical-distance bound for ProbComp.sampleModNat also controls all events after arbitrary postprocessing. The sampler remains the existing bounded fair-bit program; no exact uniform sampler for arbitrary moduli is asserted.

Main results #

sampleModNat width q read in ZMod q is within q / 2 ^ width of uniform in CloseTo.

theorem Cslib.Crypto.Game.advantage_bind_sampleModNat_fin_le (width M : ℕ) [NeZero M] (k : ℕ → Game) :
advantage ((ProbComp.sampleModNat width M).eval.bind k) ((Probability.PMF.uniformOfFintype (Fin M)).bind fun (i : Fin M) => k ↑i) ≤ ↑M / 2 ^ width

Replacing an exact uniform draw on Fin M by ProbComp.sampleModNat width M changes Game.advantage of any Boolean continuation by at most (M : ℝ≥0) / 2 ^ width.

theorem Cslib.Crypto.Game.advantage_bind_sampleModNat_fin_fin_le (width M N : ℕ) [NeZero M] [NeZero N] (k : ℕ → ℕ → Game) :
advantage ((ProbComp.sampleModNat width M).eval.bind fun (i : ℕ) => (ProbComp.sampleModNat width N).eval.bind fun (j : ℕ) => k i j) ((Probability.PMF.uniformOfFintype (Fin M)).bind fun (i : Fin M) => (Probability.PMF.uniformOfFintype (Fin N)).bind fun (j : Fin N) => k ↑i ↑j) ≤ ↑(M + N) / 2 ^ width

Replacing exact uniform draws on Fin M and then Fin N by two sampleModNat width draws changes Game.advantage of any Boolean continuation by at most (M + N) / 2 ^ width.