Documentation

CslibFrontier.Crypto.Computational.PseudorandomGenerator.ModReduction

Pseudorandom residues from pseudorandom words #

Boneh–Shoup Example 3.3 ([BS23], pp. 86–87) reduces an L-bit pseudorandom word modulo m to obtain an element of {0, ..., m - 1} that is computationally indistinguishable from uniform when m / 2 ^ L is negligible.

Here modWord m word reads word most significant bit first (BitString.binaryValue) and encodes the residue modulo m with encNat. The reduction modDistinguisher m adversary evaluates modWord (m n) on its challenge word before running adversary n.

Compared with [BS23], pp. 86–87: 2 ^ L ≥ m is not assumed (for m > 2 ^ L the bound exceeds 1); the bound is ≤ m / 2 ^ L where Example 3.2 proves <; the modulus m may depend on the security parameter n and must then be computable in polynomial time (hm), which is what makes the reduction modDistinguisher efficient; and the generator's security is used only as indistinguishability of its output from uniform words.

Main definitions #

Main results #

References #

Read word as a binary number, most significant bit first (BitString.binaryValue), and write its residue modulo m with encNat, least significant bit first. For m = 0 the value is not reduced.

Reducing a uniform word of L bits is the bounded residue sampler sampleModNat L m.

The residue modulo m of a uniform word of L bits is within m / 2 ^ L of a uniform residue ([BS23], Example 3.2, p. 86, on binary words).

The reduction of [BS23], Example 3.3, p. 86: reduce the challenge word modulo m n, then run the given distinguisher on the residue.

The reduction is uniform strict PPT when the modulus is computable in polynomial time from the unary security parameter and the given distinguisher is PPT.

theorem Cslib.Crypto.distinguishingGame_map_modWord (m : ℕ → ℕ) (adversary : Distinguisher) (n : ℕ) (D : PMF (List Bool)) :
distinguishingGame (PMF.map (modWord (m n)) D) (adversary n) = distinguishingGame D (modDistinguisher m adversary n)

Running a distinguisher on residues is running the reduction on the words.

theorem Cslib.Crypto.advantage_distinguishingGame_map_modWord_le (m : ℕ → ℕ) [∀ (n : ℕ), NeZero (m n)] (adversary : Distinguisher) (n L : ℕ) (D : PMF (List Bool)) :
(distinguishingGame (PMF.map (modWord (m n)) D) (adversary n)).advantage (distinguishingGame (PMF.map (fun (i : Fin (m n)) => Turing.MultiTapeTM.encNat ↑i) (Probability.PMF.uniformOfFintype (Fin (m n)))) (adversary n)) ≤ (distinguishingGame D (modDistinguisher m adversary n)).advantage (distinguishingGame (BitString.uniformList L) (modDistinguisher m adversary n)) + ↑(m n) / 2 ^ L

Example 3.3, concrete bound ([BS23], p. 87): the advantage in telling residues of samples of D from uniform residues is at most the advantage of the reduction in telling D from uniform L-bit words, plus m n / 2 ^ L.

theorem Cslib.Crypto.ComputationallyIndistinguishable.map_modWord {X : ℕ → PMF (List Bool)} {length m : ℕ → ℕ} [∀ (n : ℕ), NeZero (m n)] (hX : ComputationallyIndistinguishable X fun (n : ℕ) => BitString.uniformList (length n)) (hm : Turing.MultiTapeTM.ComputableInPolyTime m Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encNat) (hneg : Negligible fun (n : ℕ) => ↑(m n) / 2 ^ length n) :
ComputationallyIndistinguishable (fun (n : ℕ) => PMF.map (modWord (m n)) (X n)) fun (n : ℕ) => PMF.map (fun (i : Fin (m n)) => Turing.MultiTapeTM.encNat ↑i) (Probability.PMF.uniformOfFintype (Fin (m n)))

Example 3.3 ([BS23], pp. 86–87): if an ensemble of words is computationally indistinguishable from uniform words of length n bits, the modulus is efficiently computable and m n / 2 ^ length n is negligible, then the residues modulo m n are computationally indistinguishable from uniform residues. The efficiency hypothesis hm is present for the PPT certificate of the reduction modDistinguisher (isPPT_modDistinguisher), and no failing case without hm is known.

theorem Cslib.Crypto.advantage_generatorEnsemble_map_modWord_le (generator : List Bool → List Bool) (length m : ℕ → ℕ) [∀ (n : ℕ), NeZero (m n)] (adversary : Distinguisher) (n : ℕ) :
(distinguishingGame (PMF.map (modWord (m n)) (generatorEnsemble generator n)) (adversary n)).advantage (distinguishingGame (PMF.map (fun (i : Fin (m n)) => Turing.MultiTapeTM.encNat ↑i) (Probability.PMF.uniformOfFintype (Fin (m n)))) (adversary n)) ≤ Game.advantage (prgRealGame generator (modDistinguisher m adversary) n).eval (prgIdealGame length (modDistinguisher m adversary) n).eval + ↑(m n) / 2 ^ length n

Example 3.3, the book's inequality ([BS23], p. 87): Distadv[A, P₀, P₁] ≤ PRGadv[B, G] + m / N, where P₀ is the generator's output reduced modulo m n, P₁ is the uniform residue, N = 2 ^ length n and B is modDistinguisher m A, run in the two programs of the generator's attack game. No hypothesis on the generator is used.

theorem Cslib.Crypto.PseudorandomGenerator.indistinguishable_map_modWord {generator : List Bool → List Bool} {length m : ℕ → ℕ} [∀ (n : ℕ), NeZero (m n)] (h : PseudorandomGenerator generator length) (hm : Turing.MultiTapeTM.ComputableInPolyTime m Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encNat) (hneg : Negligible fun (n : ℕ) => ↑(m n) / 2 ^ length n) :
ComputationallyIndistinguishable (fun (n : ℕ) => PMF.map (modWord (m n)) (generatorEnsemble generator n)) fun (n : ℕ) => PMF.map (fun (i : Fin (m n)) => Turing.MultiTapeTM.encNat ↑i) (Probability.PMF.uniformOfFintype (Fin (m n)))

Example 3.3 for a pseudorandom generator: the generated word reduced modulo m n is computationally indistinguishable from a uniform residue. The efficiency hypothesis hm is present for the PPT certificate of the reduction modDistinguisher, and no failing case without hm is known.