Documentation

CatCryptCore.Examples.PRG

Bijection PRG: Perfect Security #

A pseudorandom generator that is a bijection from seeds to outputs has perfect security. Following Rosulek, The Joy of Cryptography, §5 (pseudorandom generators).

If the stretch map s ↦ stretch s is a bijection from the seed space onto the output space, then over a uniform seed the generator output is itself uniform on the output space. Hence the PRG real game (stretch a uniform seed) and the PRG ideal game (a fresh uniform output) are perfectly indistinguishable: the PRG advantage of every adversary is exactly 0.

Overview #

This mirrors the one-time-pad and bijection-PRF arguments (CatCrypt.Examples.OTP, CatCrypt.Examples.PRF): the security proof is the bijection-coupling technique. liftR_uniform_bij couples the uniform seed with the uniform output through the bijection bij : SeedOutput; liftR_bind/liftR_pure push the coupling through the sample-then-pure structure of the real game; and PRG_Adv_zero_of_rHoare collapses the advantage to 0.

A bijection forces |Seed| = |Output|, so a bijection generator is not length-extending. This is the information-theoretic boundary of Rosulek §5: a genuinely length-extending PRG has an image that is a vanishing subset of the output space, so it can only be computationally secure. The corresponding reduction — the triple-from-double bound Adv(G₃) ≤ 2·Adv(G) — is proved computationally elsewhere (CatCrypt.Examples.TriplePRG).

Main definitions #

Main results #

References #

PRG Scheme and Game #

A pseudorandom generator: a deterministic map stretch from a seed space to an output space.

Security asks that, for a uniform seed, stretch s is indistinguishable from a uniform element of Output.

Instances For

    PRG real game: stretch a uniformly random seed.

    Equations
    Instances For

      PRG ideal game: return a uniformly random output.

      Equations
      Instances For

        PRG advantage: distinguishing the stretched seed from a uniform output.

        Equations
        Instances For

          If a PRG's real game is perfectly indistinguishable from the ideal game, the PRG advantage is 0 for every adversary.

          Bijection PRG #

          A PRG given by a bijection bij : SeedOutput.

          For a uniform seed, bij maps the uniform seed distribution onto the uniform output distribution, which is the source of perfect security.

          Instances For

            The PRGScheme induced by a bijection: stretch s = bij s.

            Equations
            Instances For

              Perfect Security #

              Coupling: for a bijection PRG the real and ideal games are equidistributed.

              Over a uniform seed s, the real game returns bij s while the ideal game returns a fresh uniform output r; liftR_uniform_bij B.bij couples them so that bij s = r, so the two games agree pointwise.

              A bijection PRG has perfect security: every adversary has PRG advantage exactly 0.

              Example: the XOR PRG over Bool #

              G(s) = s ⊕ c for a fixed mask c is the bijection boolXorBij c; it is a (non-extending) bijection generator and inherits perfect security.

              The XOR generator over Bool as a bijection PRG: bij = boolXorBij c.

              Equations
              Instances For

                The XOR generator over Bool has perfect PRG security.

                PRG security assumption #

                The bijection results above are perfect (ε = 0). A genuinely length-extending generator can only be computationally secure, so the reduction below takes the base generator's security as a hypothesis. PRGAssumption is the PRG analogue of CatCrypt.Crypto.PRFAssumption: it packages the standard "G is an ε-secure PRG" hypothesis that reductions consume.

                The PRG security assumption: G is an ε-secure pseudorandom generator. The field bound witnesses that no adversary beats advantage ε at distinguishing PRG_Real G from PRG_Ideal G.

                Instances For

                  The packaged advantage bound of a PRG assumption.

                  A perfectly secure PRG (every adversary has advantage exactly 0) satisfies the PRG assumption with ε = 0.

                  Equations
                  Instances For

                    bind_vcgen witness for the ε = 0 case #

                    For a bijection PRG the real and ideal games are the same SPComp distribution. We discharge this exact hop with the bind_vcgen run-to-completion tactic: through the supplied change-of-variables bijection B.bij it collapses sample s; return bij s to a fresh uniform sample. This is the perfect (ε = 0) base case that instantiates PRGAssumption.

                    The real and ideal PRG games for a bijection PRG are the same SPComp computation. Proved by bind_vcgen using B.bij: the change-of-variables through the bijection rewrites the stretched seed into a plain uniform sample.

                    A bijection PRG has PRG advantage 0, re-proved through the bind_vcgen game-equality bijPRG_game_eq (an alternative to the relational coupling of bijPRG_perfect).

                    Triple-from-double PRG: the computational bound #

                    Given a length-doubling base generator G : SeedSeed × Seed, the length-tripling construction

                    `G₃(s) = let (a, b) := G(s); let (c, d) := G(a); (c, d, b)`
                    

                    satisfies Adv_PRG(G₃) ≤ 2·ε under a PRG-security assumption on G (Rosulek, The Joy of Cryptography, §5.3). This mirrors the cascade-PRF upgrade (CatCrypt.Examples.PRF.cascade_prf_bound): a computational bound composed from two named per-hop assumptions via the advantage triangle inequality, keeping the perfect (ε = 0) corollary.

                    The reduction runs the decomposed hybrid (Rosulek §5.3), which uses independent seeds for the two G calls to break their correlation:

                    StepTransitionBound
                    0→1inner G(s₁) (produces c,d) → randomε (PRG assumption)
                    1→2outer G(s₂).2 (produces b) → randomε (PRG assumption)

                    The hop bounds are the cryptographic hypotheses; the theorem composes them into the total bound by the advantage triangle inequality.

                    A length-doubling base generator stretch : SeedSeed × Seed, the input to the triple construction.

                    Instances For

                      The length-tripling construction: apply G twice, rearrange outputs.

                      Equations
                      Instances For

                        The base doubling generator as a PRGScheme (Output = Seed × Seed), whose security is the inner-hop assumption.

                        Equations
                        Instances For

                          The projected doubling generator as a PRGScheme (Output = Seed, the second component), whose security is the outer-hop assumption.

                          Equations
                          Instances For

                            Decomposed hybrid game (independent seeds per G call).

                            • i ≥ 2: everything uniform (ideal G₃);
                            • i = 1: inner G call replaced by random, outer G still real;
                            • i = 0: both G calls real but with independent seeds.
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For

                              Hybrid 2 is the ideal G₃: three independent uniform seeds, independent of the base generator's stretch.

                              theorem CatCrypt.Examples.PRG.triple_prg_hybrid_bound {α : Type} (H : Core.SPComp α) (A : αCore.SPComp Bool) (ε : ENNReal) (h01 : Crypto.AdvantageA (H 0) (H 1) A ε) (h12 : Crypto.AdvantageA (H 1) (H 2) A ε) :
                              Crypto.AdvantageA (H 0) (H 2) A 2 * ε

                              Triple-from-double hybrid bound (the composition core).

                              For any 3-game hybrid sequence H realising the 2-hop ladder, if both hops are bounded by ε, then Adv(H₀, H₂) ≤ 2·ε. The composition is the advantage triangle inequality — the PRG analogue of cascade_prf_bound.

                              theorem CatCrypt.Examples.PRG.triple_prg_uniform_bound (G : DoublePRG) (ε : ENNReal) (A : G.Seed × G.Seed × G.SeedCore.SPComp Bool) (h_inner : Crypto.AdvantageA (G.hyb 0) (G.hyb 1) A ε) (h_outer : Crypto.AdvantageA (G.hyb 1) (G.hyb 2) A ε) :
                              Crypto.AdvantageA (G.hyb 0) (G.hyb 2) A 2 * ε

                              Triple PRG uniform bound: when both decomposed hybrid hops have advantage at most ε, the triple construction advantage is at most 2·ε.

                              This is the tight reduction Adv_PRG(G₃) ≤ 2·Adv_PRG(G), mirroring the dev CatCrypt.Examples.TriplePRG.triple_prg_uniform_bound.

                              theorem CatCrypt.Examples.PRG.triple_prg_bound_of_assumption (G : DoublePRG) (Hin : PRGAssumption G.toInnerPRG) (Hout : PRGAssumption G.toOuterPRG) ( : Hout.ε Hin.ε) (A : G.Seed × G.Seed × G.SeedCore.SPComp Bool) (Ain : G.toInnerPRG.OutputCore.SPComp Bool) (Aout : G.toOuterPRG.OutputCore.SPComp Bool) (h_inner : Crypto.AdvantageA (G.hyb 0) (G.hyb 1) A PRG_Adv G.toInnerPRG Ain) (h_outer : Crypto.AdvantageA (G.hyb 1) (G.hyb 2) A PRG_Adv G.toOuterPRG Aout) :
                              Crypto.AdvantageA (G.hyb 0) (G.hyb 2) A 2 * Hin.ε

                              Triple PRG bound from a base-PRG security assumption.

                              If the inner and outer decomposed hops are bounded by the corresponding base-PRG advantages (h_inner, h_outer — the reduction's soundness, whose reduction adversaries Ain/Aout are exposed as hypotheses), and the base generator satisfies a PRGAssumption on each induced scheme (with Hout.ε ≤ Hin.ε), then the triple advantage is at most 2·Hin.ε.

                              theorem CatCrypt.Examples.PRG.triple_prg_perfect (G : DoublePRG) (A : G.Seed × G.Seed × G.SeedCore.SPComp Bool) (h_inner : Crypto.AdvantageA (G.hyb 0) (G.hyb 1) A 0) (h_outer : Crypto.AdvantageA (G.hyb 1) (G.hyb 2) A 0) :
                              Crypto.AdvantageA (G.hyb 0) (G.hyb 2) A = 0

                              Perfect triple corollary. When both hops are perfectly indistinguishable (ε = 0, e.g. a bijection base generator via bijPRG_assumption), the triple advantage is exactly 0.