Documentation

CslibFrontier.Crypto.Computational.Pseudoentropy.Basic

Samplable pseudoentropy pairs #

A pair consists of a public observation and a hidden bit. The observation has a finite type at each parameter and an injective word encoding, so its conditional entropy is unambiguous. A strict PPT sampler realizes the joint law exactly.

SamplablePair.HasGap says that every uniform PPT predictor, playing Cslib.Crypto.predictionExperiment on a draw (x, b) of the pair, eventually has signed correlation at most 1 - H(b | x) - gap. This is the entropy threshold used in the OWF-to-PRG construction; merely being hard to predict is not sufficient.

Predictors are typed: a SamplablePair.Predictor reads the security parameter and an observation of pair.Observation n. Encodings appear only in SamplablePair.Predictor.IsPPT, whose machine reads (1ⁿ, encode n x).

SamplablePair.HasGapWithAdvice gives every predictor an advice word from a fixed family. The extraction and generator theorems built on this module are stated relative to such a family; their uniform cases follow at empty advice from hasGap_iff_hasGapWithAdvice_nil and computationallyIndistinguishable_iff_indistinguishableWithAdvice_nil. SamplablePair.hasGapWithAdvice_iff_word restates the advised gap for word predictors on encAdvisedInput in the word game predictionGame, the form used by the word-level extraction pipeline. Its machines read the same words as the typed ones (encAdvisedPredictorInput).

This interface records the joint law and its sampler. The shared saved-coin interface exposes a strict PPT sampler's fair-bit tape as a uniform seed, including unused randomness.

Main definitions #

Main results #

References #

Adapted from Crypto/Computational/Pseudoentropy/Basic.lean on the cslib crypto branch at 5ff69ca93402e7c947208dc56396d6d86203ccd8, using the shared nonnegative game API and tidy machine certificates. Existence of a pair with a positive gap is a separate security theorem.

The word prediction game: Cslib.Crypto.predictionExperiment on a word sampler of observation words and hidden bits.

The input fields every advised predictor reads before its observation: the security parameter and the advice word.

  • parameter : ℕ

    The security parameter, given to machines in unary.

  • advice : List Bool

    The advice word for this parameter.

theorem Cslib.Crypto.Pseudoentropy.encAdvisedParameter_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 : γ → ℕ} {x1 : γ → List Bool} {T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encUnary T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encBits T1 S1) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { parameter := x0 x, advice := x1 x }) encIn encAdvisedParameter (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
theorem Cslib.Crypto.Pseudoentropy.encAdvisedParameter_advice_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → AdvisedParameter} :

The encoding of an advised parameter: (1ⁿ, advice), as in encAdvisedInput.

theorem Cslib.Crypto.Pseudoentropy.encAdvisedParameter_parameter_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → AdvisedParameter} :
theorem Cslib.Crypto.Pseudoentropy.encAdvisedParameter_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget x0 : γ → ℕ} {x1 : γ → List Bool} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn Turing.MultiTapeTM.encUnary budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encBits budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { parameter := x0 x, advice := x1 x }) encIn encAdvisedParameter budget

A finite joint law together with its exact strict PPT word sampler.

Recover the latent draw by relabelling the existing sampler. This is a mathematical program, with no efficiency claim for decoding arbitrary observation encodings.

The recovered sample has exactly the joint law, including its hidden label.

Typed predictors #

The input of a uniform predictor: the security parameter and an observation.

  • parameter : ℕ

    The security parameter, given to machines in unary.

  • observation : pair.Observation self.parameter

    The observation at this parameter.

theorem Cslib.Crypto.Pseudoentropy.SamplablePair.encPredictorInput_mk_budget (pair : SamplablePair) {γ : Type} {encIn : γ ↪ List Bool} {budget x0 : γ → ℕ} {x1 : (c : γ) → pair.Observation (x0 c)} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn Turing.MultiTapeTM.encUnary budget) (h1 : Turing.MultiTapeTM.ComputableInSpace (fun (c : γ) => (pair.encode (x0 c)) (x1 c)) encIn Turing.MultiTapeTM.encBits budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { parameter := x0 x, observation := x1 x }) encIn pair.encPredictorInput budget
theorem Cslib.Crypto.Pseudoentropy.SamplablePair.encPredictorInput_mk_polyTime (pair : SamplablePair) {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → ℕ} {x1 : (c : γ) → pair.Observation (x0 c)} (h0 : Turing.MultiTapeTM.ComputableInPolyTime x0 encIn Turing.MultiTapeTM.encUnary) (h1 : Turing.MultiTapeTM.ComputableInPolyTime (fun (c : γ) => (pair.encode (x0 c)) (x1 c)) encIn Turing.MultiTapeTM.encBits) :
Turing.MultiTapeTM.ComputableInPolyTime (fun (x : γ) => { parameter := x0 x, observation := x1 x }) encIn pair.encPredictorInput

The encoding of a predictor input: (1ⁿ, encode n x).

theorem Cslib.Crypto.Pseudoentropy.SamplablePair.encPredictorInput_parameter_budget (pair : SamplablePair) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → pair.PredictorInput} :
theorem Cslib.Crypto.Pseudoentropy.SamplablePair.encPredictorInput_observation_budget (pair : SamplablePair) {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → pair.PredictorInput} :
Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ pair.encPredictorInput S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (pair.encode (g✝ c).parameter) (g✝ c).observation) encIn✝ Turing.MultiTapeTM.encBits S✝
theorem Cslib.Crypto.Pseudoentropy.SamplablePair.encPredictorInput_mk_inO (pair : SamplablePair) {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 : γ → ℕ} {x1 : (c : γ) → pair.Observation (x0 c)} {T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encUnary T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO (fun (c : γ) => (pair.encode (x0 c)) (x1 c)) encIn Turing.MultiTapeTM.encBits T1 S1) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { parameter := x0 x, observation := x1 x }) encIn pair.encPredictorInput (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x

The input of an advised predictor: the security parameter, the advice word and an observation.

theorem Cslib.Crypto.Pseudoentropy.SamplablePair.encAdvisedPredictorInput_mk_budget (pair : SamplablePair) {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → AdvisedParameter} {x1 : (c : γ) → pair.Observation (x0 c).parameter} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn encAdvisedParameter budget) (h1 : Turing.MultiTapeTM.ComputableInSpace (fun (c : γ) => (pair.encode (x0 c).parameter) (x1 c)) encIn Turing.MultiTapeTM.encBits budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { toAdvisedParameter := x0 x, observation := x1 x }) encIn pair.encAdvisedPredictorInput budget
theorem Cslib.Crypto.Pseudoentropy.SamplablePair.encAdvisedPredictorInput_mk_polyTime (pair : SamplablePair) {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → AdvisedParameter} {x1 : (c : γ) → pair.Observation (x0 c).parameter} (h0 : Turing.MultiTapeTM.ComputableInPolyTime x0 encIn encAdvisedParameter) (h1 : Turing.MultiTapeTM.ComputableInPolyTime (fun (c : γ) => (pair.encode (x0 c).parameter) (x1 c)) encIn Turing.MultiTapeTM.encBits) :
Turing.MultiTapeTM.ComputableInPolyTime (fun (x : γ) => { toAdvisedParameter := x0 x, observation := x1 x }) encIn pair.encAdvisedPredictorInput
theorem Cslib.Crypto.Pseudoentropy.SamplablePair.encAdvisedPredictorInput_mk_inO (pair : SamplablePair) {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → AdvisedParameter} {T0 S0 : γ → ℕ} {x1 : (c : γ) → pair.Observation (x0 c).parameter} {T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn encAdvisedParameter T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO (fun (c : γ) => (pair.encode (x0 c).parameter) (x1 c)) encIn Turing.MultiTapeTM.encBits T1 S1) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { toAdvisedParameter := x0 x, observation := x1 x }) encIn pair.encAdvisedPredictorInput (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x

The encoding of an advised predictor input: ((1ⁿ, advice), encode n x), the layout of encAdvisedInput.

@[reducible, inline]

A uniform predictor: given the security parameter and an observation, guess the hidden bit. Predictor.IsPPT states its efficiency on encodings.

@[reducible, inline]

An advised predictor: a predictor that also reads an advice word. AdvisedPredictor.IsPPT states its efficiency on encodings.

A predictor is PPT when one uniform strict PPT machine reads encPredictorInput.

An advised predictor is PPT when one uniform strict PPT machine reads encAdvisedPredictorInput.

theorem Cslib.Crypto.Pseudoentropy.SamplablePair.Predictor.IsPPT.dropAdvice {pair : SamplablePair} {predictor : pair.Predictor} (h : predictor.IsPPT) :
AdvisedPredictor.IsPPT fun (n : ℕ) (x : List Bool) (x_1 : pair.Observation n) => predictor n x_1

A uniform PPT predictor is a PPT advised predictor that ignores its advice.

theorem Cslib.Crypto.Pseudoentropy.SamplablePair.AdvisedPredictor.IsPPT.nilAdvice {pair : SamplablePair} {predictor : pair.AdvisedPredictor} (h : predictor.IsPPT) :
Predictor.IsPPT fun (n : ℕ) (x : pair.Observation n) => predictor n [] x

A PPT advised predictor run on empty advice is a uniform PPT predictor.

The prediction gap #

Every uniform PPT predictor stays below the conditional-entropy threshold by this gap: drawing (x, b) from the pair and giving the predictor x, its signed correlation with b is eventually at most 1 - H(b | x) - gap. The threshold beyond which the inequality holds may depend on the predictor.

The prediction gap relative to fixed advice: every uniform strict PPT predictor that also reads the advice word advice n stays below the conditional-entropy threshold by gap. The advice family is not bounded here; its length is charged to the predictor's clock. With empty advice this is HasGap (hasGap_iff_hasGapWithAdvice_nil).

theorem Cslib.Crypto.Pseudoentropy.SamplablePair.eval_predictionGame_sample (pair : SamplablePair) (adversary : Distinguisher) (n : ℕ) :
(predictionGame pair.sample adversary n).eval = (predictionExperiment (pair.latentSample n) Prod.fst Prod.snd fun (x : pair.Observation n) => adversary n ((pair.encode n) x)).eval

The word prediction game on the pair's sampler is the prediction experiment on its latent draw, with the predictor reading the observation's encoding.

theorem Cslib.Crypto.Pseudoentropy.SamplablePair.hasGapWithAdvice_iff_word {pair : SamplablePair} {gap : ℕ → ℝ} {advice : ℕ → List Bool} :
pair.HasGapWithAdvice gap advice ↔ ∀ (adversary : (ℕ × List Bool) × List Bool → ProbComp Bool), Probability.IsPPTOn encAdvisedInput Turing.MultiTapeTM.encBool adversary → ∀ᶠ (n : ℕ) in Filter.atTop, 2 * ((predictionGame pair.sample (fun (n : ℕ) (word : List Bool) => adversary ((n, advice n), word)) n).eval true).toReal - 1 ≤ 1 - Probability.PMF.conditionalEntropy (pair.joint n) - gap n

HasGapWithAdvice is the word-level advised gap. Quantifying over word predictors that read ((1ⁿ, advice), encode n x) with one uniform strict PPT machine on encAdvisedInput, in the word game predictionGame, gives the same assumption as quantifying over typed advised predictors. A typed predictor's machine reads exactly that layout; conversely, a word predictor is typed by encoding its observation, and a typed one is a word predictor on that layout run on the encoded observation (IsPPTOn.exists_bool_factor), since its output is a single bit.

The uniform gap is the empty-advice case. A uniform predictor is an advice predictor that ignores its advice, and an advice predictor run on empty advice is a uniform predictor.

theorem Cslib.Crypto.Pseudoentropy.SamplablePair.HasGapWithAdvice.mono {pair : SamplablePair} {gap smaller : ℕ → ℝ} {advice : ℕ → List Bool} (h : pair.HasGapWithAdvice gap advice) (hle : ∀ (n : ℕ), smaller n ≤ gap n) :
pair.HasGapWithAdvice smaller advice

A smaller requested gap follows from any larger proved gap, with the same advice.

theorem Cslib.Crypto.Pseudoentropy.SamplablePair.HasGapWithAdvice.eventually_error_ge {pair : SamplablePair} {gap : ℕ → ℝ} {advice : ℕ → List Bool} (hgap : pair.HasGapWithAdvice gap advice) (predictor : pair.AdvisedPredictor) (hefficient : predictor.IsPPT) :

The pseudoentropy threshold relative to fixed advice equivalently lower-bounds each efficient advised predictor's error.

theorem Cslib.Crypto.Pseudoentropy.SamplablePair.HasGap.eventually_error_ge {pair : SamplablePair} {gap : ℕ → ℝ} (hgap : pair.HasGap gap) (predictor : pair.Predictor) (hefficient : predictor.IsPPT) :

The pseudoentropy threshold equivalently lower-bounds each efficient predictor's error.

A fair-bit predictor has zero correlation, so entropy plus the prediction gap relative to fixed advice cannot eventually exceed one.

A fair-bit predictor has zero correlation, so entropy plus the prediction gap cannot eventually exceed one.

theorem Cslib.Crypto.Pseudoentropy.SamplablePair.HasGap.mono {pair : SamplablePair} {gap smaller : ℕ → ℝ} (h : pair.HasGap gap) (hle : ∀ (n : ℕ), smaller n ≤ gap n) :
pair.HasGap smaller

A smaller requested gap follows from any larger proved gap.

@[reducible, inline]

A list of labeled samples (x, b), such as repeated draws of SamplablePair.sample: each sample is an observation word x paired with its label bit b, with x framed. The samples are framed and concatenated in order.