Documentation

CslibFrontier.Crypto.Computational.Pseudoentropy.WordExtraction

Executable extraction of repeated labels #

The program samples a flat Boolean matrix, hashes the labels, and retains every observation and the matrix seed. Its exact law agrees with the finite two-universal family used by the extraction theorems. The supplied input width also defines behavior on malformed sample lists: labels are truncated or padded with false before hashing.

Main definitions #

Main results #

References #

Adapted from the cslib crypto branch at 5ff69ca93402e7c947208dc56396d6d86203ccd8.

@[reducible, inline]

Output (xs, seed, digest) of word-label extraction: the list of retained observation words, then the hash seed and the digest as bit words. The list and the seed are framed; within the list, each observation is framed.

noncomputable def Cslib.Crypto.Pseudoentropy.extractWordLabels (count outputBits : ℕ) (samples : List (List Bool × Bool)) :

Extract labels using an explicitly sampled matrix, retaining observations and the full seed.

The comparison experiment keeps the observations and independently samples the hash seed and output bits.

theorem Cslib.Crypto.Pseudoentropy.isPPTOn_extractWordLabels {α : Type} {input : α ↪ List Bool} {count outputBits : α → ℕ} {samples : α → List (List Bool × Bool)} (hcount : Turing.MultiTapeTM.ComputableInPolyTime count input Turing.MultiTapeTM.encUnary) (houtput : Turing.MultiTapeTM.ComputableInPolyTime outputBits input Turing.MultiTapeTM.encUnary) (hsamples : Turing.MultiTapeTM.ComputableInPolyTime samples input encLabeledSamples) :
Probability.IsPPTOn input encWordExtractionOutput fun (a : α) => extractWordLabels (count a) (outputBits a) (samples a)

Runtime dimensions and sample lists compose into a strict PPT extractor.

theorem Cslib.Crypto.Pseudoentropy.eval_extractWordLabels (count outputBits : ℕ) (samples : List (List Bool × Bool)) :
(extractWordLabels count outputBits samples).eval = PMF.map (fun (result : List (List Bool) × (Fin (outputBits * count) → Bool) × (Fin outputBits → Bool)) => (result.1, List.ofFn (extractedSeed result), List.ofFn (extractedDigest result))) (extractLabels (ProbComp.uniform (BitString (outputBits * count))) (fun (seed : BitString (outputBits * count)) (bits : List Bool) => BitString.LinearHash.hash (BitString.blocksEquiv seed) (BitString.ofList count bits)) samples).eval

The finite and word extractors have exactly the same law, even on malformed sample lists.

theorem Cslib.Crypto.Pseudoentropy.eval_extractWordLabelsIdeal (source : ProbComp (List Bool)) (count outputBits : ℕ) :
(extractWordLabelsIdeal source count outputBits).eval = PMF.map (fun (result : List (List Bool) × (Fin (outputBits * count) → Bool) × (Fin outputBits → Bool)) => (result.1, List.ofFn (extractedSeed result), List.ofFn (extractedDigest result))) (extractLabelsIdeal source count (ProbComp.uniform (BitString (outputBits * count))))

The ideal word program agrees with the finite ideal distribution and retains the full seed.

theorem Cslib.Crypto.Pseudoentropy.isPPTOn_extractedWordTest {α : Type} {input : α ↪ List Bool} {count outputBits : α → ℕ} (test : α → List (List Bool) × List Bool × List Bool → ProbComp Bool) (htest : Probability.IsPPTOn (Turing.MultiTapeTM.encPair input encWordExtractionOutput) Turing.MultiTapeTM.encBool fun (input : α × List (List Bool) × List Bool × List Bool) => test input.1 input.2) (hcount : Turing.MultiTapeTM.ComputableInPolyTime count input Turing.MultiTapeTM.encUnary) (houtput : Turing.MultiTapeTM.ComputableInPolyTime outputBits input Turing.MultiTapeTM.encUnary) :
Probability.IsPPTOn (Turing.MultiTapeTM.encPair input encLabeledSamples) Turing.MultiTapeTM.encBool fun (input : α × List (List Bool × Bool)) => do let result ← extractLabels (ProbComp.uniform (BitString (outputBits input.1 * count input.1))) (fun (seed : BitString (outputBits input.1 * count input.1)) (bits : List Bool) => BitString.LinearHash.hash (BitString.blocksEquiv seed) (BitString.ofList (count input.1) bits)) input.2 test input.1 (result.1, List.ofFn (extractedSeed result), List.ofFn (extractedDigest result))

An ordinary word test after extraction gives the finite test required by the security theorem. Sampling, padding, hashing, and encoding the public data are all charged to PPT. The test and dimensions may depend on any encoded runtime parameter.

theorem Cslib.Crypto.Pseudoentropy.SamplablePair.HasGapWithAdvice.extract_indexed_word_labels {pair : SamplablePair} {gap : ℕ → ℝ} {advice : ℕ → List Bool} (hpair : pair.HasGapWithAdvice gap advice) (realization : pair.SeedRealization) (choose : ℕ → ℕ) {candidates inverseSlack densityBound : ℕ → ℕ} {outputBits numerator : ℕ → ℕ → ℕ} (hcandidates : Turing.MultiTapeTM.ComputableInPolyTime candidates Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (houtput : Turing.MultiTapeTM.ComputableInPolyTime (fun (input : ℕ × ℕ) => outputBits input.1 input.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) Turing.MultiTapeTM.encUnary) (hslack : Turing.MultiTapeTM.ComputableInPolyTime inverseSlack Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hnumerator : Turing.MultiTapeTM.ComputableInPolyTime (fun (input : ℕ × ℕ) => numerator input.1 input.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) Turing.MultiTapeTM.encUnary) (hdensity : Turing.MultiTapeTM.ComputableInPolyTime densityBound Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hchoose : ∀ᶠ (n : ℕ) in Filter.atTop, choose n < candidates n) (hvalid : ∀ᶠ (n : ℕ) in Filter.atTop, 0 < numerator n (choose n) ∧ numerator n (choose n) ≤ Probability.dyadicSize (densityBound n) ∧ ↑(numerator n (choose n)) / ↑(Probability.dyadicSize (densityBound n)) ≤ Probability.PMF.conditionalEntropy (pair.joint n) + gap n) (hbudget : ∀ᶠ (n : ℕ) in Filter.atTop, ↑(outputBits n (choose n)) + 2 * ↑(realization.sampleSlack inverseSlack n) ≤ ↑(realization.sampleCount inverseSlack n) * (↑(numerator n (choose n)) / ↑(Probability.dyadicSize (densityBound n)))) (test : ℕ × List Bool → ℕ → List (List Bool) × List Bool × List Bool → ProbComp Bool) (htest : Probability.IsPPTOn (Turing.MultiTapeTM.encPair (Turing.MultiTapeTM.encPair (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encUnary) encWordExtractionOutput) Turing.MultiTapeTM.encBool fun (x : ((ℕ × List Bool) × ℕ) × List (List Bool) × List Bool × List Bool) => match x with | ((a, i), result) => test a i result) :
have count := realization.sampleCount inverseSlack; Negligible fun (n : ℕ) => Game.advantage (do let samples ← OracleComp.replicate (count n) (pair.sample n) let result ← extractWordLabels (count n) (outputBits n (choose n)) samples test (n, advice n) (choose n) result).eval (extractWordLabelsIdeal (Prod.fst <$> pair.sample n) (count n) (outputBits n (choose n)) >>= test (n, advice n) (choose n)).eval

An efficient indexed family of word extractors is computationally uniform relative to fixed advice along any bounded choice satisfying the entropy budget. The choice is used only in the proof and need not be efficient; the reduction certifies the whole family of tests.

theorem Cslib.Crypto.Pseudoentropy.SamplablePair.HasGapWithAdvice.extract_word_labels {pair : SamplablePair} {gap : ℕ → ℝ} {advice : ℕ → List Bool} (hpair : pair.HasGapWithAdvice gap advice) (realization : pair.SeedRealization) {outputBits inverseSlack numerator densityBound : ℕ → ℕ} (houtput : Turing.MultiTapeTM.ComputableInPolyTime outputBits Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hslack : Turing.MultiTapeTM.ComputableInPolyTime inverseSlack Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hnumerator : Turing.MultiTapeTM.ComputableInPolyTime numerator Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hdensity : Turing.MultiTapeTM.ComputableInPolyTime densityBound Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hvalid : ∀ᶠ (n : ℕ) in Filter.atTop, 0 < numerator n ∧ numerator n ≤ Probability.dyadicSize (densityBound n) ∧ ↑(numerator n) / ↑(Probability.dyadicSize (densityBound n)) ≤ Probability.PMF.conditionalEntropy (pair.joint n) + gap n) (hbudget : ∀ᶠ (n : ℕ) in Filter.atTop, ↑(outputBits n) + 2 * ↑(realization.sampleSlack inverseSlack n) ≤ ↑(realization.sampleCount inverseSlack n) * (↑(numerator n) / ↑(Probability.dyadicSize (densityBound n)))) (test : ℕ × List Bool → List (List Bool) × List Bool × List Bool → ProbComp Bool) (htest : Probability.IsPPTOn (Turing.MultiTapeTM.encPair (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) encWordExtractionOutput) Turing.MultiTapeTM.encBool fun (input : (ℕ × List Bool) × List (List Bool) × List Bool × List Bool) => test input.1 input.2) :
have count := realization.sampleCount inverseSlack; Negligible fun (n : ℕ) => Game.advantage (do let samples ← OracleComp.replicate (count n) (pair.sample n) let result ← extractWordLabels (count n) (outputBits n) samples test (n, advice n) result).eval (extractWordLabelsIdeal (Prod.fst <$> pair.sample n) (count n) (outputBits n) >>= test (n, advice n)).eval

Computational label extraction relative to fixed advice as two ordinary word programs. The client supplies the entropy budget and a certified test; matrix sampling, finite representations, and the uniform prediction reduction are discharged by the library.