Documentation

Complexity.Crypto.Computational.GeneratorPadding

Padding expanding generators to a common input length #

Run an expander on the required seed prefix, retain the unused input bits, and truncate the result to one bit more than the common input length. Independent uniform padding preserves the distinguishing advantage exactly through an efficient reduction.

This is used to give the entropy guesses in the OWF-to-PRG construction a common seed length before amplification and XOR combination.

Main definitions #

Main results #

References #

Thomas Holenstein, Pseudorandom Generators from One-Way Functions: A Simple Construction for Any Hardness, TCC 2006, Section 5, final proof of Theorem 1, [Hol06].

Adapted from the cslib crypto branch at 5ff69ca93402e7c947208dc56396d6d86203ccd8.

def Cslib.Crypto.GeneratorPadding.generate (seedBits commonBits : ℕ) (generator : List Bool → List Bool) (seed : List Bool) :

Retain the unused uniform input bits and keep exactly one bit of stretch.

Instances For

    Padding uses only the supplied generator, word slicing, and concatenation.

    theorem Cslib.Crypto.GeneratorPadding.length_generate {seedBits commonBits : ℕ} {generator : List Bool → List Bool} (hfits : seedBits ≤ commonBits) (hexpands : ∀ (seed : List Bool), seed.length = seedBits → seedBits < (generator seed).length) {seed : List Bool} (hseed : seed.length = commonBits) :
    (generate seedBits commonBits generator seed).length = commonBits + 1

    One bit of raw expansion suffices, also when no padding is needed.

    theorem Cslib.Crypto.GeneratorPadding.generate_distribution {seedBits commonBits : ℕ} (generator : List Bool → List Bool) (hfits : seedBits ≤ commonBits) :
    PMF.map (generate seedBits commonBits generator) (BitString.uniformList commonBits) = do let word ← PMF.map generator (BitString.uniformList seedBits) PMF.map (fun (padding : List Bool) => List.take (commonBits + 1) (word ++ padding)) (BitString.uniformList (commonBits - seedBits))

    The unused suffix of a uniform padded seed is fresh independent randomness.

    theorem Cslib.Crypto.GeneratorPadding.ideal_distribution {seedBits outputBits commonBits : ℕ} (hexpands : seedBits < outputBits) :
    (do let word ← BitString.uniformList outputBits PMF.map (fun (padding : List Bool) => List.take (commonBits + 1) (word ++ padding)) (BitString.uniformList (commonBits - seedBits))) = BitString.uniformList (commonBits + 1)

    Uniform raw output and independent padding give exactly the desired uniform output.

    noncomputable def Cslib.Crypto.GeneratorPadding.test (seedBits commonBits : ℕ) (adversary : List Bool → ProbComp Bool) (word : List Bool) :

    A distinguisher for padded output is an ordinary randomized postprocessing of raw output.

    Instances For
      theorem Cslib.Crypto.GeneratorPadding.isPPTOn_test {α : Type} {input : α ↪ List Bool} {seedBits commonBits : α → ℕ} {adversary : α → List Bool → ProbComp Bool} {word : α → List Bool} (hseedBits : Turing.MultiTapeTM.ComputableTidilyInPolyTime seedBits input Turing.MultiTapeTM.encUnary) (hcommon : Turing.MultiTapeTM.ComputableTidilyInPolyTime commonBits input Turing.MultiTapeTM.encUnary) (hadversary : Probability.IsPPTOn (Turing.MultiTapeTM.encPair input Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBool fun (a : α × List Bool) => adversary a.1 a.2) (hword : Turing.MultiTapeTM.ComputableTidilyInPolyTime word input Turing.MultiTapeTM.encBits) :
      Probability.IsPPTOn input Turing.MultiTapeTM.encBool fun (a : α) => test (seedBits a) (commonBits a) (adversary a) (word a)

      The reduction charges the padding and the call to the captured adversary.

      theorem Cslib.Crypto.GeneratorPadding.advantage_eq {seedBits outputBits commonBits : ℕ} (generator : List Bool → List Bool) (adversary : List Bool → ProbComp Bool) (hfits : seedBits ≤ commonBits) (hexpands : seedBits < outputBits) :
      Game.advantage ((PMF.map (generate seedBits commonBits generator) (BitString.uniformList commonBits)).bind fun (word : List Bool) => (adversary word).eval) ((BitString.uniformList (commonBits + 1)).bind fun (word : List Bool) => (adversary word).eval) = Game.advantage ((PMF.map generator (BitString.uniformList seedBits)).bind fun (word : List Bool) => (test seedBits commonBits adversary word).eval) ((BitString.uniformList outputBits).bind fun (word : List Bool) => (test seedBits commonBits adversary word).eval)

      Padding preserves the tested distinguishing advantage exactly.