Documentation

Complexity.Crypto.Computational.CramerShoup.Reductions

Certified PPT Reductions and Probabilistic Operations for Cramer–Shoup #

This module constructs the uniform strict-PPT (IsPPTOn) operations and security reductions for the Multiplicative Cramer–Shoup public-key encryption scheme ($\mathcal{E}_{\mathrm{MCS}}$, Boneh and Shoup, Exercise 12.27, printed pp. 521–522, specialized to associated data $\mathcal{D} = \mathrm{Unit}$) over a PrimeOrderGroupFamily, following the Games 0–4 reduction structure of Boneh and Shoup, Section 12.5.3, Theorem 12.9, printed pp. 488–493:

  1. Approximate exponent sampling via sampleModNat: sampleExp, sampleCramerShoupPair, sampleCramerShoupTripleExponents, and sampleCramerShoupSK, together with their IsPPTOn certificates and Game.advantage bounds (1 / 2 ^ n per exponent draw) relative to exact uniform sampling on ZMod (F.order d).
  2. Phase 1/2 and collision-tracking decryption oracle handlers: cramerShoupPhase1Oracle, cramerShoupPhase2Reply, cramerShoupPhase2Oracle, and cramerShoupCollisionPhase2Oracle.
  3. Certified strict-PPT DDH distinguishers (Game 1 → Game 2, eq. (12.22), printed p. 492): cramerShoupMsgToDDHDistinguisher and cramerShoupToDDHDistinguisher, with IsPPTOn certificates isPPTOn_cramerShoupMsgToDDHDistinguisher and isPPTOn_cramerShoupToDDHDistinguisher.
  4. Certified strict-PPT CRHF collision finders (Game 3 → Game 4, eqs. (12.24)–(12.25), printed p. 492): cramerShoupMsgToCollisionFinder and cramerShoupToCollisionFinder, with IsPPTOn certificates isPPTOn_cramerShoupMsgToCollisionFinder and isPPTOn_cramerShoupToCollisionFinder.
  5. Certified strict-PPT Encryption.cca2GameOn operations: cramerShoupValid, cramerShoupKeyGenProb, cramerShoupEncryptProb, and cramerShoupDecryptOpt, together with their ComputableInPolyTime and IsPPTOn certificates.

Approximate exponent sampling via sampleModNat #

Sample a pair of approximate exponents modulo F.order d.

Instances For

    Sample a 3-tuple of approximate exponents (a, b, c) modulo F.order d.

    Instances For

      Sample a 6-tuple secret key ((s, t), ((s₁, t₁), (s₂, t₂))) of approximate exponents modulo F.order d.

      Instances For
        theorem Cslib.Crypto.PrimeOrderGroupFamily.advantage_bind_sampleCramerShoupPair_le (F : PrimeOrderGroupFamily) (n : ℕ) (d : F.Desc) (k : ZMod (F.order d) → ZMod (F.order d) → Game) :
        Game.advantage ((F.sampleCramerShoupPair n d).eval.bind fun (p : ℕ × ℕ) => k ↑p.1 ↑p.2) ((Probability.PMF.uniformOfFintype (ZMod (F.order d))).bind fun (σ : ZMod (F.order d)) => (Probability.PMF.uniformOfFintype (ZMod (F.order d))).bind fun (τ : ZMod (F.order d)) => k σ τ) ≤ 2 / 2 ^ n

        Replacing sampleCramerShoupPair n d by two independent uniform draws on ZMod (F.order d) changes Game.advantage by at most 2 / 2 ^ n.

        theorem Cslib.Crypto.PrimeOrderGroupFamily.advantage_bind_sampleCramerShoupTripleExponents_le (F : PrimeOrderGroupFamily) (n : ℕ) (d : F.Desc) (k : ZMod (F.order d) → ZMod (F.order d) → ZMod (F.order d) → Game) :
        Game.advantage ((F.sampleCramerShoupTripleExponents n d).eval.bind fun (p : ℕ × ℕ × ℕ) => k ↑p.1 ↑p.2.1 ↑p.2.2) ((Probability.PMF.uniformOfFintype (ZMod (F.order d))).bind fun (α : ZMod (F.order d)) => (Probability.PMF.uniformOfFintype (ZMod (F.order d))).bind fun (β : ZMod (F.order d)) => (Probability.PMF.uniformOfFintype (ZMod (F.order d))).bind fun (γ : ZMod (F.order d)) => k α β γ) ≤ 3 / 2 ^ n

        Replacing sampleCramerShoupTripleExponents n d by three independent uniform draws on ZMod (F.order d) changes Game.advantage by at most 3 / 2 ^ n.

        theorem Cslib.Crypto.PrimeOrderGroupFamily.advantage_bind_sampleCramerShoupSK_le (F : PrimeOrderGroupFamily) (n : ℕ) (d : F.Desc) (k : (ℕ × ℕ) × (ℕ × ℕ) × ℕ × ℕ → Game) (kZMod : ZMod (F.order d) → ZMod (F.order d) → ZMod (F.order d) → ZMod (F.order d) → ZMod (F.order d) → ZMod (F.order d) → Game) (hcast : ∀ (s t s₁ t₁ s₂ t₂ : ℕ), k ((s, t), (s₁, t₁), s₂, t₂) = kZMod ↑s ↑t ↑s₁ ↑t₁ ↑s₂ ↑t₂) :
        Game.advantage ((F.sampleCramerShoupSK n d).eval.bind k) ((Probability.PMF.uniformOfFintype (ZMod (F.order d))).bind fun (σ : ZMod (F.order d)) => (Probability.PMF.uniformOfFintype (ZMod (F.order d))).bind fun (τ : ZMod (F.order d)) => (Probability.PMF.uniformOfFintype (ZMod (F.order d))).bind fun (σ₁ : ZMod (F.order d)) => (Probability.PMF.uniformOfFintype (ZMod (F.order d))).bind fun (τ₁ : ZMod (F.order d)) => (Probability.PMF.uniformOfFintype (ZMod (F.order d))).bind fun (σ₂ : ZMod (F.order d)) => (Probability.PMF.uniformOfFintype (ZMod (F.order d))).bind fun (τ₂ : ZMod (F.order d)) => kZMod σ τ σ₁ τ₁ σ₂ τ₂) ≤ 6 / 2 ^ n

        Replacing sampleCramerShoupSK n d by six independent uniform draws on ZMod (F.order d) changes Game.advantage by at most 6 / 2 ^ n.

        Phase 1 decryption oracle handler for Cramer–Shoup.

        Instances For

          Stateless Phase 2 decryption reply for Cramer–Shoup, rejecting the challenge ciphertext ct with [].

          Instances For

            Phase 2 decryption oracle handler for Cramer–Shoup, rejecting the challenge ciphertext ct.

            Instances For

              Phase 2 collision-tracking oracle handler for cramerShoupToCollisionFinder: replies with cramerShoupCollisionPhase2Reply and records some (extractCramerShoupTriple request.2) whenever isCramerShoupCollision H d request.2 ct holds.

              Instances For
                noncomputable def Cslib.Crypto.PrimeOrderGroupFamily.cramerShoupMsgToDDHDistinguisher (F : PrimeOrderGroupFamily) {Msg : Type} (encodeMsg : F.Desc × Msg → List Bool) (H : F.Desc × List Bool → List Bool) (isElem : F.Desc × List Bool → Bool) (adversary : Encryption.CCA2AdversaryOf Msg) (bit : Bool) (n : ℕ) (input : F.Desc × List Bool × List Bool × List Bool) :

                The DDH distinguisher constructed from a CCA2AdversaryOf Msg with message-to-group-word encoding encodeMsg : F.Desc × Msg → List Bool ([BS23], proof of Theorem 12.9, Game 1 $\to$ Game 2, equation (12.22), printed pp. 490, 492, adapted to $\mathcal{E}_{\mathrm{MCS}}$).

                Instances For
                  @[reducible, inline]

                  The DDH distinguisher constructed from a group-message 1CCA adversary (Msg = List Bool, encodeMsg = Prod.snd).

                  Instances For
                    noncomputable def Cslib.Crypto.PrimeOrderGroupFamily.cramerShoupMsgToCollisionFinder (F : PrimeOrderGroupFamily) {Msg : Type} (encodeMsg : F.Desc × Msg → List Bool) (H : F.Desc × List Bool → List Bool) (isElem : F.Desc × List Bool → Bool) (adversary : Encryption.CCA2AdversaryOf Msg) (bit : Bool) :

                    The setup-parameterized collision finder constructed from a CCA2AdversaryOf Msg with message-to-group-word encoding encodeMsg : F.Desc × Msg → List Bool ([BS23], proof of Theorem 12.9, Game 4, equations (12.24)–(12.25), printed p. 492, adapted to $\mathcal{E}_{\mathrm{MCS}}$).

                    Instances For
                      @[reducible, inline]

                      The setup-parameterized collision finder constructed from a group-message 1CCA adversary (Msg = List Bool, encodeMsg = Prod.snd).

                      Instances For
                        theorem Cslib.Crypto.PrimeOrderGroupFamily.encodeCramerShoupPublicKey_eq_skNatOfZMod (F : PrimeOrderGroupFamily) (d : F.Desc) (α : ZMod (F.order d)) (sk : (ℕ × ℕ) × (ℕ × ℕ) × ℕ × ℕ) :
                        F.encodeCramerShoupPublicKey d (F.encode d (α • F.generator d)) sk = F.encodeCramerShoupPublicKey d (F.encode d (α • F.generator d)) (F.skNatOfZMod d ↑sk.1.1 ↑sk.1.2 ↑sk.2.1.1 ↑sk.2.1.2 ↑sk.2.2.1 ↑sk.2.2.2)

                        encodeCramerShoupPublicKey depends on sk only through its residues modulo F.order d.

                        theorem Cslib.Crypto.PrimeOrderGroupFamily.encodeCramerShoupChallenge_eq_skNatOfZMod (F : PrimeOrderGroupFamily) (H : F.Desc × List Bool → List Bool) (d : F.Desc) (sk : (ℕ × ℕ) × (ℕ × ℕ) × ℕ × ℕ) (v w : F.Carrier d) (m : List Bool) :
                        F.encodeCramerShoupChallenge H d sk (F.encode d v) (F.encode d w) m = F.encodeCramerShoupChallenge H d (F.skNatOfZMod d ↑sk.1.1 ↑sk.1.2 ↑sk.2.1.1 ↑sk.2.1.2 ↑sk.2.2.1 ↑sk.2.2.2) (F.encode d v) (F.encode d w) m

                        encodeCramerShoupChallenge depends on sk only through its residues modulo F.order d.

                        theorem Cslib.Crypto.PrimeOrderGroupFamily.decodeCramerShoup_eq_skNatOfZMod (F : PrimeOrderGroupFamily) (H : F.Desc × List Bool → List Bool) (isElem : F.Desc × List Bool → Bool) (hmem : ∀ (d : F.Desc) (x : List Bool), isElem (d, x) = true ↔ x ∈ Set.range (F.encode d)) (d : F.Desc) (sk : (ℕ × ℕ) × (ℕ × ℕ) × ℕ × ℕ) (ct : List Bool) :
                        F.decodeCramerShoup H isElem d sk ct = F.decodeCramerShoup H isElem d (F.skNatOfZMod d ↑sk.1.1 ↑sk.1.2 ↑sk.2.1.1 ↑sk.2.1.2 ↑sk.2.2.1 ↑sk.2.2.2) ct

                        decodeCramerShoup depends on sk only through its residues modulo F.order d.

                        theorem Cslib.Crypto.PrimeOrderGroupFamily.cramerShoupPhase1Oracle_eq_skNatOfZMod (F : PrimeOrderGroupFamily) (H : F.Desc × List Bool → List Bool) (isElem : F.Desc × List Bool → Bool) (hmem : ∀ (d : F.Desc) (x : List Bool), isElem (d, x) = true ↔ x ∈ Set.range (F.encode d)) (d : F.Desc) (sk : (ℕ × ℕ) × (ℕ × ℕ) × ℕ × ℕ) :
                        F.cramerShoupPhase1Oracle H isElem d sk = F.cramerShoupPhase1Oracle H isElem d (F.skNatOfZMod d ↑sk.1.1 ↑sk.1.2 ↑sk.2.1.1 ↑sk.2.1.2 ↑sk.2.2.1 ↑sk.2.2.2)

                        cramerShoupPhase1Oracle depends on sk only through its residues modulo F.order d.

                        theorem Cslib.Crypto.PrimeOrderGroupFamily.cramerShoupPhase2Oracle_eq_skNatOfZMod (F : PrimeOrderGroupFamily) (H : F.Desc × List Bool → List Bool) (isElem : F.Desc × List Bool → Bool) (hmem : ∀ (d : F.Desc) (x : List Bool), isElem (d, x) = true ↔ x ∈ Set.range (F.encode d)) (d : F.Desc) (sk : (ℕ × ℕ) × (ℕ × ℕ) × ℕ × ℕ) (ct : List Bool) :
                        F.cramerShoupPhase2Oracle H isElem d sk ct = F.cramerShoupPhase2Oracle H isElem d (F.skNatOfZMod d ↑sk.1.1 ↑sk.1.2 ↑sk.2.1.1 ↑sk.2.1.2 ↑sk.2.2.1 ↑sk.2.2.2) ct

                        cramerShoupPhase2Oracle depends on sk only through its residues modulo F.order d.

                        theorem Cslib.Crypto.PrimeOrderGroupFamily.cramerShoupCollisionPhase2Oracle_eq_skNatOfZMod (F : PrimeOrderGroupFamily) (H : F.Desc × List Bool → List Bool) (isElem : F.Desc × List Bool → Bool) (hmem : ∀ (d : F.Desc) (x : List Bool), isElem (d, x) = true ↔ x ∈ Set.range (F.encode d)) (d : F.Desc) (sk : (ℕ × ℕ) × (ℕ × ℕ) × ℕ × ℕ) (ct : List Bool) :
                        F.cramerShoupCollisionPhase2Oracle H isElem d sk ct = F.cramerShoupCollisionPhase2Oracle H isElem d (F.skNatOfZMod d ↑sk.1.1 ↑sk.1.2 ↑sk.2.1.1 ↑sk.2.1.2 ↑sk.2.2.1 ↑sk.2.2.2) ct

                        cramerShoupCollisionPhase2Oracle depends on sk only through its residues modulo F.order d.

                        @[simp]
                        theorem Cslib.Crypto.PrimeOrderGroupFamily.encodeCramerShoupEncrypt_publicKey_eq_challenge (F : PrimeOrderGroupFamily) (H : F.Desc × List Bool → List Bool) (d : F.Desc) (α β σ τ σ₁ τ₁ σ₂ τ₂ : ZMod (F.order d)) (m : List Bool) :
                        have pkVal := F.cramerShoupPublicKey d α σ τ σ₁ τ₁ σ₂ τ₂; F.encodeCramerShoupEncrypt H d (F.encode d pkVal.1, F.encode d pkVal.2.1, F.encode d pkVal.2.2.1, F.encode d pkVal.2.2.2) m β.val = F.encodeCramerShoupChallenge H d (F.skNatOfZMod d σ τ σ₁ τ₁ σ₂ τ₂) (F.encode d (β • F.generator d)) (F.encode d ((α * β) • F.generator d)) m

                        Word-level public-key encryption under cramerShoupPublicKey d α σ τ σ₁ τ₁ σ₂ τ₂ coincides with encodeCramerShoupChallenge on (v, w) = (β • g, (α * β) • g) ([BS23], Section 12.5.3, Game 0 $\to$ Game 1, equation (12.21), printed p. 490).

                        Encryption.cca2GameOn and Encryption.INDCCA2On instantiation #

                        Unpack a canonically framed 6-tuple secret key ((s, t), ((s₁, t₁), (s₂, t₂))) of natural numbers.

                        Instances For
                          def Cslib.Crypto.PrimeOrderGroupFamily.cramerShoupValid (F : PrimeOrderGroupFamily) (isElem : F.Desc × List Bool → Bool) (d : ℕ → F.Desc) (n : ℕ) (_pk m₀ m₁ : List Bool) :

                          Challenge-pair group-membership admissibility predicate for Encryption.cca2GameOn ([BS23], Section 12.5.3 & Exercise 12.27): both challenge words m₀ and m₁ must belong to the group F.Carrier (d n).

                          Instances For

                            Probabilistic polynomial-time Cramer–Shoup key generation for a group family d : ℕ → F.Desc, sampling approximate uniform exponents via sampleModNat.

                            Instances For

                              Probabilistic polynomial-time Cramer–Shoup encryption for a group family d : ℕ → F.Desc, sampling the encryption exponent via sampleModNat.

                              Instances For

                                Deterministic polynomial-time Cramer–Shoup decryption for Encryption.cca2GameOn.

                                Instances For
                                  @[simp]

                                  Extracting the 4-tuple of public-key group words from encodeCramerShoupPublicKey.

                                  theorem Cslib.Crypto.PrimeOrderGroupFamily.encodeCramerShoupEncrypt_skNatOfZMod (F : PrimeOrderGroupFamily) (H : F.Desc × List Bool → List Bool) (d : F.Desc) (α σ τ σ₁ τ₁ σ₂ τ₂ : ZMod (F.order d)) (m : List Bool) (b : ℕ) :
                                  have u := F.encode d (α • F.generator d); have sk := F.skNatOfZMod d σ τ σ₁ τ₁ σ₂ τ₂; have pkVal := F.cramerShoupPublicKey d α σ τ σ₁ τ₁ σ₂ τ₂; F.encodeCramerShoupEncrypt H d (u, F.encodeProjHashAux d sk.1.1 sk.1.2 u, F.encodeProjHashAux d sk.2.1.1 sk.2.1.2 u, F.encodeProjHashAux d sk.2.2.1 sk.2.2.2 u) m b = F.encodeCramerShoupEncrypt H d (F.encode d pkVal.1, F.encode d pkVal.2.1, F.encode d pkVal.2.2.1, F.encode d pkVal.2.2.2) m (↑b).val

                                  encodeCramerShoupEncrypt on the public-key words generated by skNatOfZMod agrees with cramerShoupPublicKey.