Documentation

CslibFrontier.Crypto.Primitives.PRG.ModThreeBias

A small-bias distribution that space-bounded automata distinguish #

The uniform distribution on the words of n bits whose weight is divisible by three (Cslib.Crypto.PRG.modThreeWords), presented as the output of the generator Cslib.Crypto.PRG.modThreeGenerator whose seed is such a word, has exponentially small bias but is distinguished from uniform by a read-once automaton with three states. This is Goldreich, Exercise 8.39: there exist exp(-Ω(n))-bias distributions on {0,1}^n that are not (2, 0.666)-pseudorandom in the sense of Definition 8.20. It contrasts with Exercise 8.38, by which space-bounded pseudorandomness does imply small bias (Cslib.Crypto.PRG.Generator.Secure.isSmallBias).

Bias. The character χ_S summed against z ^ weight x over the cube factors coordinatewise into (1 - z) ^ |S| (1 + z) ^ (n - |S|) (Cslib.BitString.sum_chi_mul_pow_weight). Averaging this over the cube roots of unity 1, ω, ω² filters the words whose weight is divisible by three. For nonempty S the term of 1 vanishes, and |1 - ω| = √3, |1 + ω| = 1, so three times the sum of χ_S over these words has absolute value at most 2 √3 ^ |S|. For S = ∅ the same identity counts the words: 3 |A| = 2 ^ n ± 2 up to an error of absolute value at most 2. Hence |bias S| (2 ^ n - 2) ≤ 2 √3 ^ |S| (Cslib.Crypto.PRG.abs_bias_modThreeGenerator_mul_le), and the distribution is 4 (√3 / 2) ^ n-biased for every n (Cslib.Crypto.PRG.isSmallBias_modThreeGenerator), with √3 / 2 < 1.

Distinguisher. Counting the ones modulo three is a read-once program with three states (Cslib.Crypto.PRG.isReadOnceTest_countMod), so the test Cslib.Crypto.PRG.modThreeTest is computed by an automaton of space 2, with at most 2 ^ 2 states per layer as in Definition 8.20. It accepts every generated word, and a uniform word with probability at most 1/3 + 2/(3 · 2 ^ n); its distinguishing gap is at least 2/3 - 2/(3 · 2 ^ n) (Cslib.Crypto.PRG.two_div_three_sub_le_advantage_modThreeTest), which exceeds 0.666 for n ≥ 10 (Cslib.Crypto.PRG.not_secure_modThreeGenerator).

Source mapping. Goldreich states the exercise for distributions on {0,1}^n; here the distribution is the output distribution of a generator whose seed set is the set of words itself, as Cslib.Crypto.PRG.Generator.Secure and Cslib.BitString.IsSmallBias are stated for output distributions. Definition 8.20 calls an ensemble (s, ε)-pseudorandom if every non-uniform automaton of space s has distinguishing gap at most ε; IsReadOnceTest (2 ^ s) gives these automata as read-once programs with 2 ^ s states per layer and time-dependent transitions, and Generator.Secure bounds the gap by ε. The source's bias (Eq. (8.18)) is 2 |Pr[⊕_S = 1] - 1/2|, the absolute value of Cslib.BitString.bias. The exercise asks for the bias bound exp(-Ω(n)); it is proved with the explicit base √3 / 2, and the distinguisher works for every n ≥ 10, so the ensemble fails Definition 8.20 at every such length.

Main definitions #

Main results #

References #

theorem Cslib.BitString.sum_chi_mul_pow_weight {ι : Type u_1} {R : Type u_2} [Fintype ι] [DecidableEq ι] [CommRing R] (S : Finset ι) (z : R) :
∑ x : ι → Bool, chi R S x * z ^ weight x = (1 - z) ^ S.card * (1 + z) ^ (Fintype.card ι - S.card)

The weight enumerator of a character: summing the character χ_S against z ^ weight x over the cube gives (1 - z) ^ |S| (1 + z) ^ (n - |S|), one factor per coordinate.

The words of n bits whose weight, the number of ones, is divisible by three.

The uniform distribution on the words of weight divisible by three, as a generator: its seed is such a word and its output is the word itself Goldreich, Exercise 8.39.

noncomputable def Cslib.Crypto.PRG.modThreeTest (n : ℕ) :

The test whether the weight of a word is divisible by three.

The roots-of-unity filter #

Three times the number of words of weight divisible by three is within 2 of 2 ^ n.

Small bias #

The bias of the mod-3 distribution: at every nonempty set S of coordinates, |bias S| (2 ^ n - 2) ≤ 2 √3 ^ |S|.

√3 / 2 < 1: the bias bound 4 (√3 / 2) ^ n decays exponentially.

The mod-3 distribution has exponentially small bias: it is 4 (√3 / 2) ^ n-biased for every n Goldreich, Exercise 8.39.

The distinguisher #

The test whether the weight is divisible by three is a read-once test of width 2 ^ 2: three states count the ones modulo three.

The gap of the mod-3 test: it accepts every word of the distribution and a uniform word with probability at most 1/3 + 2/(3 · 2 ^ n).

The mod-3 distribution is not (2, 0.666)-pseudorandom for n ≥ 10: a read-once automaton with 2 ^ 2 states per layer distinguishes it from uniform with gap above 0.666 Goldreich, Exercise 8.39.

Small bias does not imply space-bounded pseudorandomness (Goldreich, Exercise 8.39): for some c < 1, the uniform distributions on the words of weight divisible by three are 4 c ^ n-biased and, for every n ≥ 10, not (2, 0.666)-pseudorandom.