Yao's next-bit theorem for uniform pseudorandom generators #
CslibFrontier/Crypto/Primitives/PRG/NextBit.lean relates prediction to distinguishing for
arbitrary tests and predictors on finite output types, without bounding the cost of the tests and
predictors that its reductions build. This module lifts that argument to uniform strict-PPT
PseudorandomGenerators over arbitrary bit strings: the reductions are explicit programs with
strict-PPT certificates, and no closure hypothesis or non-uniform advice is used.
Two standard uniform next-bit formulations are covered and proved equivalent to
PseudorandomGenerator:
- Random-index prediction (
NextBitUnpredictableRandomIndex): a single-stageDistinguisherreceives the security parameter1ⁿand a prefix(G s).take ifor a uniformly sampled bit indexi < length n, and attempts to guess(G s)[i]. Note that(G s).take ihas lengthi, so the predictor observes the index from the prefix itself. - Adversary-chosen index (
NextBitUnpredictable, Boneh–Shoup Attack Game 3.2): a two-stage adversaryTwoStage Unit ℕ (List Bool) Bool σfirst chooses an indexi(with saved stateσ) and then, given a prefix(G s).take iof the generated word, attempts to guess(G s)[i]; iflength n ≤ i, the challenger outputs a fair coin so out-of-range guesses yield zero advantage.
Both reductions (wordNextBitPredictor / wordNextBitTwoStage and nextBitDistinguisher /
twoStageNextBitDistinguisher) are certified strict PPT for a unary polynomial-time length,
which PRG.polyTime_length supplies for a polynomial-time length-regular generator. They reuse
ProbComp.sampleDyadicIndex (isPPTOn_sampleDyadicIndex) for padded uniform index sampling, and
the finite hybrid/predictor theorem
PRG.Generator.toReal_predictionExperiment_nextBitPredictor from
CslibFrontier/Crypto/Primitives/PRG/NextBit.lean.
Main definitions #
Cslib.Crypto.nextBitPredictionGame: random-index next-bit game for a single-stage predictor.Cslib.Crypto.NextBitUnpredictableRandomIndex: uniform PPT unpredictability at a random bit.Cslib.Crypto.wordNextBitPredictor: uniform PPT next-bit predictor built from a PRG distinguisher, padding suffix bits uniformly.Cslib.Crypto.nextBitDistinguisher: uniform PPT PRG distinguisher built from a random-index predictor viaProbComp.sampleDyadicIndex.Cslib.Crypto.nextBitExperiment: Boneh–Shoup Attack Game 3.2 for two-stage predictors.Cslib.Crypto.NextBitUnpredictable: uniform PPT unpredictability against two-stage predictors.Cslib.Crypto.wordNextBitTwoStage,Cslib.Crypto.twoStageNextBitDistinguisher: uniform strict PPT two-stage reductions in both directions.
Main results #
Cslib.Crypto.isPPT_wordNextBitPredictor,Cslib.Crypto.isPPT_nextBitDistinguisher,Cslib.Crypto.isPPT_wordNextBitTwoStage,Cslib.Crypto.isPPT_twoStageNextBitDistinguisher: uniform strict-PPT certificates for all four reductions, for a unary polynomial-timelength(whichPRG.polyTime_lengthsupplies for a polynomial-time length-regular generator).Cslib.Crypto.guessingAdvantage_nextBitPredictionGame_wordNextBitPredictor,Cslib.Crypto.advantage_nextBitDistinguisher_eq,Cslib.Crypto.guessingAdvantage_nextBitExperiment_wordNextBitTwoStage,Cslib.Crypto.guessingAdvantage_nextBitExperiment_eq: exact concrete advantage relations.Cslib.Crypto.pseudorandomGenerator_iff_nextBitUnpredictableRandomIndex,Cslib.Crypto.pseudorandomGenerator_iff_nextBitUnpredictable: Yao's next-bit equivalence theorem in both the random-index and two-stage Attack Game 3.2 formulations.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Version 0.6, Section 3.5 (Attack Game 3.2, Theorems 3.4 and 3.6).
- S. Arora, B. Barak, Computational Complexity: A Modern Approach, Chapter 9.
Uniformity, binary-splitting, and padded-average helpers #
Polynomial-time and PPT helper certificates #
Section 1: Random-Index Next-Bit Prediction #
Random-index next-bit prediction game: draw a uniform n-bit seed s, set word := generator s, draw a uniform bit position i < length n, run predictor n (word.take i), and
accept when the guess matches bit i of word. If length n = 0, output a fair coin.
Uniform strict-PPT next-bit unpredictability at a random bit position. This is the
random-position form of [BS23], Attack Game 3.2 and Definition 3.3 (printed p. 64), not
Definition 3.3 as printed: the challenger draws the position uniformly, and the single-stage
predictor does not choose it. Every uniform strict PPT predictor Distinguisher has negligible
guessing advantage in nextBitPredictionGame.
The uniform strict-PPT next-bit predictor constructed from a PRG distinguisher adversary:
given (n, prefixBits) with prefixBits.length < length n, sample a candidate bit candidate
and uniform suffix suffix ← BitString.sampleList (length n - (prefixBits.length + 1)), run
adversary n (prefixBits ++ candidate :: suffix), and output candidate if it accepts or
!candidate if it rejects.
wordNextBitPredictor length adversary is uniformly strict PPT whenever length is unary
polynomial-time computable and adversary is uniformly strict PPT.
Exact quantitative advantage of wordNextBitPredictor: when 0 < length n, the random-index
prediction advantage is 1 / length n times the distinguisher's PRG advantage.
Uniform strict-PPT random-index next-bit distinguisher built from a single-stage predictor:
when 0 < length n, draw a padded uniform index i ← ProbComp.sampleDyadicIndex (length n - 1);
if i < length n, output decide ((← predictor n (word.take i)) = word.getD i false), else output
a fair coin.
nextBitDistinguisher length predictor is uniformly strict PPT whenever length is unary
polynomial-time computable and predictor is uniformly strict PPT.
On uniform ideal inputs, nextBitDistinguisher length predictor accepts with probability
exactly 1 / 2.
Exact quantitative advantage of nextBitDistinguisher: when 0 < length n, its PRG advantage
equals (length n / dyadicSize (length n - 1)) times predictor's random-index guessing
advantage.
Consequently nextBitDistinguisher loses at most a factor of 2 in advantage relative to
nextBitPredictionGame.
Every PseudorandomGenerator is random-index next-bit unpredictable.
A polynomial-time length-stretching generator that is random-index next-bit unpredictable is a
PseudorandomGenerator.
Yao's next-bit theorem for a challenger-chosen uniform position. For a deterministic
polynomial-time generator that maps every n-bit seed to exactly length n bits with
n < length n, security against uniform strict PPT distinguishers is equivalent to random-index
next-bit unpredictability. This variant of [BS23], Section 3.5, Theorems 3.4 and 3.6
(pp. 64 and 67), samples the position uniformly from the whole output. The predictor built from a
distinguisher loses exactly a factor of length n.
Section 2: Two-Stage Next-Bit Prediction (Boneh–Shoup Attack Game 3.2) #
Boneh–Shoup Attack Game 3.2 next-bit prediction experiment for a two-stage predictor: stage 1
chooses a bit position i and state state; stage 2 receives state and the generated prefix
word.take i and guesses bit i of word. Out-of-range positions (length n ≤ i) return a
fair coin so they yield zero advantage.
Uniform strict-PPT next-bit unpredictability ([BS23], Attack Game 3.2 and
Definition 3.3, printed p. 64): every uniform strict PPT two-stage predictor choosing a position
i : ℕ (binary encoded) has negligible guessing advantage in nextBitExperiment.
The uniform strict-PPT two-stage next-bit predictor built from a PRG distinguisher adversary:
stage 1 draws a padded uniform bit index i ← ProbComp.sampleDyadicIndex (length n - 1); stage 2
forwards prefix queries to wordNextBitPredictor length adversary.
wordNextBitTwoStage length adversary is uniformly strict PPT whenever length is unary
polynomial-time computable and adversary is uniformly strict PPT.
Exact quantitative advantage of wordNextBitTwoStage: when 0 < length n, its two-stage
next-bit guessing advantage is 1 / dyadicSize (length n - 1) times adversary's PRG
advantage.
The uniform strict-PPT PRG distinguisher constructed from a two-stage next-bit predictor
adversary: run stage 1 (i, state) ← (adversary n).choose (), cap idx := min (length n) i to
a unary bound in polynomial time, and if idx < length n run stage 2 on word.take idx and
compare with bit idx; otherwise flip a fair coin.
twoStageNextBitDistinguisher length adversary is uniformly strict PPT whenever length is
unary polynomial-time computable and adversary is uniformly strict PPT.
On uniform ideal inputs, twoStageNextBitDistinguisher accepts with probability 1 / 2.
On generated inputs, twoStageNextBitDistinguisher agrees identically with
nextBitExperiment.
Exact zero-loss quantitative identity between Attack Game 3.2 and PRG distinguishing for
twoStageNextBitDistinguisher.
Every PseudorandomGenerator is two-stage next-bit unpredictable (NextBitUnpredictable,
Boneh–Shoup Attack Game 3.2).
A polynomial-time length-stretching generator that is two-stage next-bit unpredictable is a
PseudorandomGenerator.
Yao's next-bit theorem for an adversary-chosen position. For a deterministic
polynomial-time generator that maps every n-bit seed to exactly length n bits with
n < length n, security against uniform strict PPT distinguishers is equivalent to two-stage
next-bit unpredictability. This is the stretching case of [BS23], Section 3.5, Attack
Game 3.2, Definition 3.3 and Theorems 3.4 and 3.6 (pp. 64 and 67). The predictor built from a
distinguisher samples a padded dyadic range to keep a strict clock and loses a factor of
dyadicSize (length n - 1).