Documentation

CslibFrontier.Crypto.Primitives.PRG.ReadOnceBias

Space-bounded pseudorandom generators are small-bias generators #

The parity of the bits of a word in a set S of positions is computed by a read-once branching program with two states (Cslib.Crypto.PRG.isReadOnceTest_parityOn). A generator that fools the read-once programs of width 2 ^ s, s ≥ 1, with error ε (an (s, ε)-pseudorandom generator in the sense of Goldreich, Definition 8.20) is therefore a 2ε-bias generator (Cslib.Crypto.PRG.Generator.Secure.isSmallBias): the bias at S is 2 |Pr[⊕_S G(U) = 1] - 1/2| (Goldreich's Eq. (8.18)), twice the advantage of the parity test. With the limitation on small-bias generators of Exercise 8.37 (Cslib.BitString.card_lt_card_of_isSmallBias), an (s, ε)-pseudorandom generator with s ≥ 1 and ε < 1/2 has stretch ℓ(k) < 2^k (Cslib.Crypto.PRG.Generator.Secure.lt_two_pow).

Source qualification. Goldreich, Exercise 8.38 states that an (s, ε)-pseudorandom generator with s ≥ 1 is an ε-bias generator, and Exercise 8.25(2) that it has ℓ(k) < 2^k whenever ε(k) < 1, by combining Exercises 8.37 and 8.38. Both printed claims are false under the source's own definitions: the generator σ ↦ σσ on one seed bit is (s, 1/2)-pseudorandom for every s (its output is at statistical distance 1/2 from uniform, so no test whatsoever has advantage above 1/2), yet its two output bits always have even parity, bias 1 > 1/2, and its stretch is 2 = 2^1 (Cslib.Crypto.PRG.exists_secure_not_isSmallBias). The factor 2 above is necessary, and the corrected endpoints are 2ε-bias for Exercise 8.38 and ε < 1/2 for Exercise 8.25(2).

Main results #

References #

theorem Cslib.Crypto.PRG.isReadOnceTest_countMod {L m w : ℕ} (hm : 0 < m) (hw : m ≤ w) (S : Finset (Fin L)) (r : ℕ) :
IsReadOnceTest w fun (x : Fin L → Bool) => PMF.pure (decide ({i ∈ S | x i = true}.card % m = r))

Counting the ones at the positions of S modulo m and comparing the count with r is a read-once test of every width w ≥ m > 0: m states hold the count of the bits read so far.

theorem Cslib.Crypto.PRG.isReadOnceTest_parityOn {L w : ℕ} (hw : 2 ≤ w) (S : Finset (Fin L)) :
IsReadOnceTest w fun (x : Fin L → Bool) => PMF.pure (parityOn S x)

The parity of the bits in a set S of positions is a read-once test of every width w ≥ 2: two states hold the parity of the bits read so far.

theorem Cslib.Crypto.PRG.Generator.Secure.isSmallBias {k ℓ s : ℕ} {G : Generator (Fin k → Bool) (Fin ℓ → Bool)} {ε : NNReal} (hs : 1 ≤ s) (hG : G.Secure (IsReadOnceTest (2 ^ s)) ε) :

Space-bounded pseudorandom generators are small-bias generators (Goldreich, Exercise 8.38, corrected): a generator G : {0,1}^k → {0,1}^ℓ that fools the read-once programs of width 2 ^ s, s ≥ 1, with error ε is a 2ε-bias generator. The printed bound ε is false (exists_secure_not_isSmallBias).

theorem Cslib.Crypto.PRG.Generator.Secure.lt_two_pow {k ℓ s : ℕ} {G : Generator (Fin k → Bool) (Fin ℓ → Bool)} {ε : NNReal} (hs : 1 ≤ s) (hε : ↑ε < 1 / 2) (hG : G.Secure (IsReadOnceTest (2 ^ s)) ε) :
ℓ < 2 ^ k

The stretch of space-bounded pseudorandom generators (Goldreich, Exercise 8.25(2), corrected): a generator G : {0,1}^k → {0,1}^ℓ that fools the read-once programs of width 2 ^ s, s ≥ 1, with error ε < 1/2 has ℓ < 2^k. The printed hypothesis ε < 1 does not suffice (exists_secure_not_isSmallBias).

theorem Cslib.Crypto.PRG.exists_secure_not_isSmallBias :
∃ (G : Generator (Fin 1 → Bool) (Fin (2 ^ 1) → Bool)), G.Secure (fun (x : Adversary (Fin (2 ^ 1) → Bool)) => True) (1 / 2) ∧ ¬BitString.IsSmallBias (1 / 2) G.outputDist

Counterexample to the printed Exercises 8.38 and 8.25(2) Goldreich: the generator σ ↦ σσ on one seed bit fools every test, however large its space, with error 1/2, but it is not 1/2-biased (its two output bits always have even parity), and its stretch is 2 = 2^1.