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 #
closeTo_uniform_sampleModNat: uniform residues are close to the actual sampled residues.Cslib.Crypto.Game.advantage_bind_sampleModNat_fin_le: replacing a uniform draw onFin MbyProbComp.sampleModNat width Mchanges the advantage of any continuation by at mostM / 2 ^ width.Cslib.Crypto.Game.advantage_bind_sampleModNat_fin_fin_le: the same for two successive draws, with bound(M + N) / 2 ^ width.
theorem Cslib.Probability.closeTo_uniform_sampleModNat (width q : ℕ) [NeZero q] :
CloseTo (PMF.uniformOfFintype (ZMod q)) (PMF.map Nat.cast (ProbComp.sampleModNat width q).eval) (↑q / 2 ^ width)
sampleModNat width q read in ZMod q is within q / 2 ^ width of uniform in CloseTo.