Documentation

Complexity.Crypto.Computational.CramerShoup.Scheme

Multiplicative Cramer–Shoup Encryption Scheme and Adaptive Projective-Hash Rejection #

This module formalizes the Multiplicative Cramer–Shoup public-key encryption scheme ($\mathcal{E}_{\mathrm{MCS}}$, Boneh and Shoup, Section 12.5.3 and Exercise 12.27, printed pp. 488–493, 521–522, specialized to associated data $\mathcal{D} = \mathrm{Unit}$) over a PrimeOrderGroupFamily, proves its algebraic and word-level decryption correctness and polynomial-time computability certificates, and establishes the adaptive Lemma 12.8 projective-hash rejection bound and Lemma 12.6 one-time group-mask challenge blindness (Games 3 $\to$ 3.5 $\to$ 4 $\to$ 5 of Theorem 12.9, printed pp. 492–493) against an adaptive CCA2AdversaryOf Msg. Groups are written additively as ZMod (F.order d)-modules (matching DiscreteLog, DiffieHellman, ElGamal, and ProjectiveHash).

Source Statements ([BS23], Sections 12.5.1–12.5.3 & Exercise 12.27) #

Verbatim from [BS23], Sections 12.5.1–12.5.2 (Lemma 12.6 in §12.5.1, printed p. 486; Lemma 12.8 in §12.5.2, printed p. 488):

Lemma 12.6. In Attack Game 12.4, $\Pr[W_0] = \Pr[W_1]$ for all adversaries $\mathcal{A}$. … Lemma 12.8. In Attack Game 12.5, for any adversary $\mathcal{A}$ that outputs at most $Q$ tuples, the probability that it wins is at most $Q/q$.

Verbatim from [BS23], Section 12.5.3 (printed pp. 488–493):

  • the key generation algorithm runs as follows: $$\begin{aligned} G() :=\quad & \alpha \xleftarrow{R} \mathbb{Z}_q,\; u \leftarrow g^\alpha,\; \sigma, \tau \xleftarrow{R} \mathbb{Z}_q,\; h \leftarrow g^\sigma u^\tau \\ & \sigma_1, \tau_1, \sigma_2, \tau_2 \xleftarrow{R} \mathbb{Z}_q,\; h_1 \leftarrow g^{\sigma_1} u^{\tau_1},\; h_2 \leftarrow g^{\sigma_2} u^{\tau_2} \\ & pk \leftarrow (u, h, h_1, h_2),\; sk \leftarrow (\sigma, \tau, \sigma_1, \tau_1, \sigma_2, \tau_2),\; \text{output } (pk, sk); \end{aligned}$$ … Game 5. We again widen the rejection rule at line (5), replacing it with: $$(5) \qquad \text{if } \hat{v}^\alpha \ne \hat{w} \text{ or } \mathit{Coll}_{u,v}(\hat{u}, \hat{v}) \text{ or } z' \ne f'(\hat{v}, \hat{w}, \hat{\rho})$$ So this rule will reject the ciphertext if $(\hat{v}, \hat{w}) \notin L_u$. Let $Z_5$ be the event that in Game 5, some decryption query, which would not have triggered the rejection rule of Game 4, does trigger the wider rejection rule in Game 5. Clearly, Games 4 and 5 proceed identically unless event $Z_5$ occurs. By the Difference Lemma, we have $$|\Pr[W_4] - \Pr[W_5]| \le \Pr[Z_5]. \quad (12.26)$$ We will argue that $\Pr[Z_5] \le Q_d / q$. $(12.27)$ … Game 6. Everything we did so far was leading to this point, which is the crux of the proof. We replace line (2) in Fig. 12.3 with $z \xleftarrow{R} \mathbb{G}$. We claim that $\Pr[W_6] = \Pr[W_5]$. $(12.28)$ This follows from Lemma 12.6, and the fact that in processing decryption queries in Game 5, we only need to evaluate $f(\hat{v}, \hat{w})$ at points $(\hat{v}, \hat{w}) \in L_u$. … Remark 12.3 (Group membership verification). For reasons similar to that discussed in Remark 12.1, it is essential that given a ciphertext $(v, w, z', c)$, the decryption algorithm for $\mathcal{E}_{\mathrm{CS}}$ verifies that $v$ and $w$ are in $\mathbb{G}$. It is not necessary to explicitly check that $z'$ is in $\mathbb{G}$, since the check that $v^{\sigma_1 + \rho \sigma_2} w^{\tau_1 + \rho \tau_2} = z'$ implies that $z'$ is in $\mathbb{G}$.

Verbatim from [BS23], Exercise 12.27 (printed pp. 521–522):

12.27 (Multiplicative Cramer-Shoup encryption). Consider the following multiplicative version of the Cramer-Shoup encryption scheme (presented in Section 12.5) that supports associated data (see Section 12.7) coming from a set $\mathcal{D}$. Let $\mathbb{G}$ be a cyclic group of prime order $q$ with generator $g \in \mathbb{G}$. Let $H' : \mathbb{G}^3 \times \mathcal{D} \to \mathbb{Z}_q$ be a hash function. The encryption scheme $\mathcal{E}_{\mathrm{MCS}} = (G, E, D)$ is defined over $(\mathbb{G}, \mathcal{D}, \mathbb{G}^4)$ as follows. Key generation is exactly as in $\mathcal{E}_{\mathrm{CS}}$. For a given public key $pk = (u, h, h_1, h_2) \in \mathbb{G}^4$ message $m \in \mathbb{G}$, and associated data $d \in \mathcal{D}$, the encryption algorithm runs as follows: $$E(pk, m, d) := \beta \xleftarrow{R} \mathbb{Z}_q,\; v \leftarrow g^\beta,\; w \leftarrow u^\beta,\; e \leftarrow h^\beta \cdot m,\; \rho \leftarrow H'(v, w, e, d),\; z' \leftarrow (h_1 h_2^\rho)^\beta,\; \text{output } (v, w, e, z').$$ For a given secret key $sk = (\sigma, \tau, \sigma_1, \tau_1, \sigma_2, \tau_2) \in \mathbb{Z}_q^6$ and a ciphertext $(v, w, e, z') \in \mathbb{G}^4$, and associated data $d \in \mathcal{D}$, the decryption algorithm runs as follows: $$D(sk, (v, w, e, z', d)) := \rho \leftarrow H'(v, w, e, d);\; \text{if } v^{\sigma_1 + \rho \sigma_2} w^{\tau_1 + \rho \tau_2} = z' \text{ then output } e / (v^\sigma w^\tau) \text{ else output reject}.$$ Show that $\mathcal{E}_{\mathrm{MCS}}$ is CCA secure, provided $H'$ is collision resistant and the DDH assumption holds for $\mathbb{G}$.

Existing Notions Considered #

Main definitions and results #

Framing for 3-tuples and 4-tuples of bit strings #

Canonical framing of a 3-tuple of bit strings.

Instances For

    Unpack a canonically framed 3-tuple of bit strings.

    Instances For

      Canonical framing of a 4-tuple of bit strings.

      Instances For

        Unpack a canonically framed 4-tuple of bit strings.

        Instances For

          Extract the framed (v, w, e) triple from an encoded 4-tuple ciphertext ct.

          Instances For

            Algebraic Multiplicative Cramer–Shoup ([BS23], Section 12.5.3 & Exercise 12.27) #

            The $\mathbb{Z}_q$-valued hash family $H'_d(x) = (\mathrm{ofBits}(H(d, x)) : \mathbb{Z}_q)$ induced by a word-level hash function H : F.Desc × List Bool → List Bool ([BS23], Exercise 12.27, printed p. 521).

            Instances For

              Encode a triple of group elements (v, w, e) : F.Carrier d × F.Carrier d × F.Carrier d as a framed bit string.

              Instances For
                def Cslib.Crypto.PrimeOrderGroupFamily.cramerShoupPublicKey (F : PrimeOrderGroupFamily) (d : F.Desc) (α σ τ σ₁ τ₁ σ₂ τ₂ : ZMod (F.order d)) :

                Algebraic Cramer–Shoup public key pk = (u, h, h₁, h₂) ∈ G⁴ generated from secret exponents (α, σ, τ, σ₁, τ₁, σ₂, τ₂) ([BS23], Section 12.5.3, printed p. 489).

                Instances For

                  Algebraic Multiplicative Cramer–Shoup encryption $E(pk, m; \beta) = (v, w, e, z')$ ([BS23], Exercise 12.27, printed p. 521, with $\mathcal{D} = \mathrm{Unit}$).

                  Instances For
                    theorem Cslib.Crypto.PrimeOrderGroupFamily.cramerShoupEncrypt_cramerShoupPublicKey (F : PrimeOrderGroupFamily) (H : F.Desc × List Bool → List Bool) (d : F.Desc) (α σ τ σ₁ τ₁ σ₂ τ₂ β : ZMod (F.order d)) (m : F.Carrier d) :
                    F.cramerShoupEncrypt H d (F.cramerShoupPublicKey d α σ τ σ₁ τ₁ σ₂ τ₂) m β = have v := β • F.generator d; have w := (α * β) • F.generator d; have e := ProjectiveHash.projHash F d σ τ v w + m; have ρ := F.cramerShoupHashMod H d (F.encodeCramerShoupTriple d v w e); have z' := ProjectiveHash.projHash2 F d σ₁ τ₁ σ₂ τ₂ ρ v w; (v, w, e, z')

                    Under a genuine public key cramerShoupPublicKey d α σ τ σ₁ τ₁ σ₂ τ₂, the components of cramerShoupEncrypt coincide with projective hash evaluation (Game 0 = Game 1, [BS23], Section 12.5.3, equation (12.21), printed p. 490).

                    def Cslib.Crypto.PrimeOrderGroupFamily.cramerShoupDecrypt (F : PrimeOrderGroupFamily) [(d : F.Desc) → DecidableEq (F.Carrier d)] (H : F.Desc × List Bool → List Bool) (d : F.Desc) (sk : (ZMod (F.order d) × ZMod (F.order d)) × (ZMod (F.order d) × ZMod (F.order d)) × ZMod (F.order d) × ZMod (F.order d)) (ct : F.Carrier d × F.Carrier d × F.Carrier d × F.Carrier d) :

                    Algebraic Multiplicative Cramer–Shoup decryption $D(sk, (v, w, e, z'))$ ([BS23], Exercise 12.27, printed p. 522): check $f'_{\sigma_1,\tau_1,\sigma_2,\tau_2}(v, w, \rho) = z'$ where $\rho = H'(v, w, e)$, and if so output some (e - f_{σ,τ}(v, w)).

                    Instances For
                      @[simp]
                      theorem Cslib.Crypto.PrimeOrderGroupFamily.cramerShoupDecrypt_cramerShoupEncrypt (F : PrimeOrderGroupFamily) [(d : F.Desc) → DecidableEq (F.Carrier d)] (H : F.Desc × List Bool → List Bool) (d : F.Desc) (α σ τ σ₁ τ₁ σ₂ τ₂ β : ZMod (F.order d)) (m : F.Carrier d) :
                      F.cramerShoupDecrypt H d ((σ, τ), (σ₁, τ₁), σ₂, τ₂) (F.cramerShoupEncrypt H d (F.cramerShoupPublicKey d α σ τ σ₁ τ₁ σ₂ τ₂) m β) = some m

                      Algebraic Cramer–Shoup decryption correctness ([BS23], Section 12.5.3 & Exercise 12.27, printed pp. 489, 521–522): decrypting an honest encryption under cramerShoupPublicKey d α σ τ σ₁ τ₁ σ₂ τ₂ with ((σ, τ), ((σ₁, τ₁), (σ₂, τ₂))) recovers some m.

                      Word-level polynomial-time Cramer–Shoup operations #

                      @[reducible, inline]

                      Encoding of a 6-tuple secret key ((s, t), ((s₁, t₁), (s₂, t₂))) of natural-number exponents.

                      Instances For

                        Encoded group negation -x = (q - 1) • x computed via F.smul (d, F.order d - 1, z).

                        Instances For

                          Word-level universal projective hash f_{s,t}(v, w) = s • v + t • w.

                          Instances For
                            @[simp]
                            theorem Cslib.Crypto.PrimeOrderGroupFamily.encodeProjHash_encode (F : PrimeOrderGroupFamily) (d : F.Desc) (s t : ℕ) (v w : F.Carrier d) :
                            F.encodeProjHash d s t (F.encode d v) (F.encode d w) = F.encode d (ProjectiveHash.projHash F d (↑s) (↑t) v w)

                            Word-level public projection h = f_{s,t}(g, u) = s • g + t • u.

                            Instances For

                              Word-level $\text{universal}_2$ projective hash f'_{s₁,t₁,s₂,t₂}(v, w, r) = f_{s₁,t₁}(v, w) + r • f_{s₂,t₂}(v, w).

                              Instances For
                                @[simp]
                                theorem Cslib.Crypto.PrimeOrderGroupFamily.encodeProjHash2_encode (F : PrimeOrderGroupFamily) (d : F.Desc) (s₁ t₁ s₂ t₂ r : ℕ) (v w : F.Carrier d) :
                                F.encodeProjHash2 d s₁ t₁ s₂ t₂ r (F.encode d v) (F.encode d w) = F.encode d (ProjectiveHash.projHash2 F d (↑s₁) (↑t₁) (↑s₂) (↑t₂) (↑r) v w)

                                Encode a 4-tuple of group elements (u, h, h₁, h₂) together with d : F.Desc as the public key word presented to a 1CCA adversary.

                                Instances For

                                  Word-level Cramer–Shoup public key generation from d : F.Desc, an encoded u = encode (α • g), and natural-number secret exponents sk = ((s, t), ((s₁, t₁), (s₂, t₂))).

                                  Instances For
                                    @[simp]
                                    theorem Cslib.Crypto.PrimeOrderGroupFamily.encodeCramerShoupPublicKey_encode (F : PrimeOrderGroupFamily) (d : F.Desc) (α : ZMod (F.order d)) (sk : (ℕ × ℕ) × (ℕ × ℕ) × ℕ × ℕ) :
                                    F.encodeCramerShoupPublicKey d (F.encode d (α • F.generator d)) sk = F.encodeCramerShoupPublicKeyValues d (F.cramerShoupPublicKey d α ↑sk.1.1 ↑sk.1.2 ↑sk.2.1.1 ↑sk.2.1.2 ↑sk.2.2.1 ↑sk.2.2.2)

                                    Encode a 4-tuple ciphertext (v, w, e, z') : (F.Carrier d)⁴ as a canonically framed bit string.

                                    Instances For

                                      Word-level Cramer–Shoup encryption from the public key (u, h, h₁, h₂), encoded message m, and randomness b : ℕ.

                                      Instances For
                                        @[simp]
                                        theorem Cslib.Crypto.PrimeOrderGroupFamily.encodeCramerShoupEncrypt_encode (F : PrimeOrderGroupFamily) (H : F.Desc × List Bool → List Bool) (d : F.Desc) (pk : F.Carrier d × F.Carrier d × F.Carrier d × F.Carrier d) (m : F.Carrier d) (b : ℕ) :
                                        F.encodeCramerShoupEncrypt H d (F.encode d pk.1, F.encode d pk.2.1, F.encode d pk.2.2.1, F.encode d pk.2.2.2) (F.encode d m) b = F.encodeCramerShoupCiphertext d (F.cramerShoupEncrypt H d pk m ↑b)

                                        Word-level Game 1 challenge encryption from (v, w) (encoded group elements), secret key sk, and encoded message m ([BS23], Section 12.5.3, Game 1, printed p. 490).

                                        Instances For
                                          @[simp]
                                          theorem Cslib.Crypto.PrimeOrderGroupFamily.encodeCramerShoupChallenge_encode (F : PrimeOrderGroupFamily) (H : F.Desc × List Bool → List Bool) (d : F.Desc) (sk : (ℕ × ℕ) × (ℕ × ℕ) × ℕ × ℕ) (v w m : F.Carrier d) :
                                          F.encodeCramerShoupChallenge H d sk (F.encode d v) (F.encode d w) (F.encode d m) = have e := ProjectiveHash.projHash F d (↑sk.1.1) (↑sk.1.2) v w + m; have ρ := F.cramerShoupHashMod H d (F.encodeCramerShoupTriple d v w e); have z' := ProjectiveHash.projHash2 F d (↑sk.2.1.1) (↑sk.2.1.2) (↑sk.2.2.1) (↑sk.2.2.2) ρ v w; F.encodeCramerShoupCiphertext d (v, w, e, z')

                                          Word-level Cramer–Shoup decryption ([BS23], Section 12.5.3, Remark 12.3, and Exercise 12.27, printed pp. 489, 493, 522): given (d, sk, ct), unpack (v, w, e, z') := decodeBits4 ct, check canonical framing encBits4 (v, w, e, z') == ct, check group membership isElem (d, v) && isElem (d, w) && isElem (d, e), and check encodeProjHash2 d s₁ t₁ s₂ t₂ r v w == z'; if all pass, return some (encode (e - f_{s,t}(v, w))), else none.

                                          Instances For
                                            theorem Cslib.Crypto.PrimeOrderGroupFamily.decodeCramerShoup_encode (F : PrimeOrderGroupFamily) [(d : F.Desc) → DecidableEq (F.Carrier d)] (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 : F.Carrier d × F.Carrier d × F.Carrier d × F.Carrier d) :
                                            F.decodeCramerShoup H isElem d sk (F.encodeCramerShoupCiphertext d ct) = Option.map (F.encode d) (F.cramerShoupDecrypt H d ((↑sk.1.1, ↑sk.1.2), (↑sk.2.1.1, ↑sk.2.1.2), ↑sk.2.2.1, ↑sk.2.2.2) ct)

                                            Word-level Cramer–Shoup decryption matches algebraic cramerShoupDecrypt on encoded ciphertexts.

                                            @[simp]
                                            theorem Cslib.Crypto.PrimeOrderGroupFamily.decodeCramerShoup_cramerShoupEncrypt (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) (α β : ZMod (F.order d)) (sk : (ℕ × ℕ) × (ℕ × ℕ) × ℕ × ℕ) (m : F.Carrier d) :
                                            F.decodeCramerShoup H isElem d sk (F.encodeCramerShoupCiphertext d (F.cramerShoupEncrypt H d (F.cramerShoupPublicKey d α ↑sk.1.1 ↑sk.1.2 ↑sk.2.1.1 ↑sk.2.1.2 ↑sk.2.2.1 ↑sk.2.2.2) m β)) = some (F.encode d m)

                                            Word-level Cramer–Shoup decryption of an honest encryption recovers some (F.encode d m).

                                            Polynomial-time certificates for word-level operations #

                                            Collision detection and decryption oracle replies #

                                            Test whether a Phase 2 ciphertext query req yields a cramerShoupHashMod H d collision with the challenge ciphertext ct on their (v, w, e) prefixes.

                                            Instances For

                                              isCramerShoupCollision coincides with isCollisionFor (F.cramerShoupHashMod H) on the extracted (v, w, e) triples.

                                              Stateless Phase 1 decryption reply for Cramer–Shoup.

                                              Instances For

                                                Stateless Phase 2 decryption reply that rejects the challenge ciphertext ct and any query req colliding with ct under cramerShoupHashMod H d.

                                                Instances For

                                                  Canonical secret-key conversion and hybrid Games 3–5 #

                                                  def Cslib.Crypto.PrimeOrderGroupFamily.skNatOfZMod (F : PrimeOrderGroupFamily) (d : F.Desc) (σ τ σ₁ τ₁ σ₂ τ₂ : ZMod (F.order d)) :

                                                  Convert six ZMod (F.order d) exponents (σ, τ, σ₁, τ₁, σ₂, τ₂) into their canonical natural number representatives ((σ.val, τ.val), ((σ₁.val, τ₁.val), (σ₂.val, τ₂.val))).

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

                                                    Game 3 (corresponding to Game 4 of [BS23], Section 12.5.3, printed p. 492, adapted to $\mathcal{E}_{\mathrm{MCS}}$): Phase 1 uses cramerShoupPhase1Reply and Phase 2 rejects both ct and any ciphertext query req whose (v, w, e) prefix collides with ct under cramerShoupHashMod H d (cramerShoupCollisionPhase2Reply).

                                                    Instances For

                                                      Projective-hash rejection (Games 3.5, 4, and 5) and concrete 1CCA bound #

                                                      def Cslib.Crypto.PrimeOrderGroupFamily.decodeCramerShoupDH (F : PrimeOrderGroupFamily) (H : F.Desc × List Bool → List Bool) (isElem : F.Desc × List Bool → Bool) (d : F.Desc) (α δ δ₁ δ₂ : ZMod (F.order d)) (ct : List Bool) :

                                                      Decryption helper for Game 4 ([BS23], Section 12.5.3, printed p. 492): on the fiber σ = δ - α * τ, σ₁ = δ₁ - α * τ₁, σ₂ = δ₂ - α * τ₂, reject any ciphertext whose (v', w') pair does not satisfy w' == F.smul (d, α.val, v'), and otherwise decrypt using (δ, 0, δ₁, 0, δ₂, 0) (which agrees with (σ, τ, σ₁, τ₁, σ₂, τ₂) on all Diffie–Hellman queries by projHash_fiber_eq and projHash2_fiber_dh).

                                                      Instances For
                                                        def Cslib.Crypto.PrimeOrderGroupFamily.cramerShoupDHPhase1Reply (F : PrimeOrderGroupFamily) (H : F.Desc × List Bool → List Bool) (isElem : F.Desc × List Bool → Bool) (d : F.Desc) (α δ δ₁ δ₂ : ZMod (F.order d)) (req : List Bool) :

                                                        Stateless Phase 1 decryption reply for Game 3.5 and Game 4, rejecting non-DH queries.

                                                        Instances For
                                                          def Cslib.Crypto.PrimeOrderGroupFamily.cramerShoupDHPhase2Reply (F : PrimeOrderGroupFamily) (H : F.Desc × List Bool → List Bool) (isElem : F.Desc × List Bool → Bool) (d : F.Desc) (α δ δ₁ δ₂ : ZMod (F.order d)) (ct req : List Bool) :

                                                          Stateless Phase 2 decryption reply for Game 4, rejecting ct, H'-collisions with ct, and non-DH queries.

                                                          Instances For

                                                            Bad-event predicate for Game 3 $\to$ Game 4 ([BS23], Section 12.5.3, equations (12.26)–(12.27), printed pp. 492–493): req = encBits4 (v', w', e', z') is a syntactically well-formed non-DH ciphertext (w' != F.smul (d, α.val, v')) whose tag z' matches encodeProjHash2.

                                                            Instances For
                                                              theorem Cslib.Crypto.PrimeOrderGroupFamily.div_order_le_div_of_le (F : PrimeOrderGroupFamily) {d : F.Desc} {Q m : ℕ} (hm0 : 0 < m) (hm : m ≤ F.order d) :
                                                              ↑Q / ↑(F.order d) ≤ ↑Q / ↑m

                                                              Phase 1 query bound on honest public keys at security parameter n.

                                                              Instances For
                                                                def Cslib.Crypto.PrimeOrderGroupFamily.HonestPhase2QueryBound (F : PrimeOrderGroupFamily) {Msg : Type} (setup : ℕ → PMF F.Desc) (H : F.Desc × List Bool → List Bool) (isElem : F.Desc × List Bool → Bool) (adversary : Encryption.CCA2AdversaryOf Msg) (n Q₂ : ℕ) :

                                                                Phase 2 query bound on honest Phase 1 states and challenge ciphertexts at parameter n.

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

                                                                  Game 3.5 (intermediate hybrid between Game 3 and Game 4 of [BS23], Section 12.5.3, printed pp. 491–492): under the fiber change of variables σ = δ - α * τ, σ₁ = δ₁ - α * τ₁, σ₂ = δ₂ - α * τ₂, replace Phase 1's decryption oracle cramerShoupPhase1Reply with cramerShoupDHPhase1Reply (rejecting non-DH queries in Phase 1).

                                                                  Instances For
                                                                    theorem Cslib.Crypto.PrimeOrderGroupFamily.advantage_cramerShoupGame3_game3Half_le (F : PrimeOrderGroupFamily) {Msg : Type} (encodeMsg : F.Desc × Msg → List Bool) (setup : ℕ → PMF F.Desc) (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)) (adversary : Encryption.CCA2AdversaryOf Msg) (bit : Bool) (n Q₁ m : ℕ) (hm0 : 0 < m) (hm : ∀ d ∈ (setup n).support, m ≤ F.order d) (hQ₁ : F.HonestPhase1QueryBound setup adversary n Q₁) :
                                                                    (F.cramerShoupGame3 encodeMsg setup H isElem adversary bit n).advantage (F.cramerShoupGame3Half encodeMsg setup H isElem adversary bit n) ≤ ↑Q₁ / ↑m

                                                                    Game 3 $\to$ Game 3.5 bound: replacing cramerShoupPhase1Reply with cramerShoupDHPhase1Reply changes the game advantage by at most Q₁ / m whenever Phase 1 makes at most Q₁ queries on every honest public key.

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

                                                                    Game 4 (corresponding to Game 5 of [BS23], Section 12.5.3, printed p. 492, adapted to $\mathcal{E}_{\mathrm{MCS}}$): both Phase 1 and Phase 2 decryption oracles reject any non-DH ciphertext query (w' != F.smul (d, α.val, v')) via decodeCramerShoupDH.

                                                                    Instances For
                                                                      theorem Cslib.Crypto.PrimeOrderGroupFamily.advantage_cramerShoupGame3Half_game4_le (F : PrimeOrderGroupFamily) {Msg : Type} (encodeMsg : F.Desc × Msg → List Bool) (setup : ℕ → PMF F.Desc) (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)) (adversary : Encryption.CCA2AdversaryOf Msg) (bit : Bool) (n Q₂ m : ℕ) (hm0 : 0 < m) (hm : ∀ d ∈ (setup n).support, m ≤ F.order d) (hQ₂ : F.HonestPhase2QueryBound setup H isElem adversary n Q₂) :
                                                                      (F.cramerShoupGame3Half encodeMsg setup H isElem adversary bit n).advantage (F.cramerShoupGame4 encodeMsg setup H isElem adversary bit n) ≤ ↑Q₂ / ↑m

                                                                      Game 3.5 $\to$ Game 4 bound: replacing cramerShoupCollisionPhase2Reply with cramerShoupDHPhase2Reply changes the game advantage by at most Q₂ / m whenever Phase 2 makes at most Q₂ queries on every honest Phase 1 state and challenge ciphertext.

                                                                      theorem Cslib.Crypto.PrimeOrderGroupFamily.advantage_cramerShoupGame3_game4_le (F : PrimeOrderGroupFamily) {Msg : Type} (encodeMsg : F.Desc × Msg → List Bool) (setup : ℕ → PMF F.Desc) (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)) (adversary : Encryption.CCA2AdversaryOf Msg) (bit : Bool) (n Q₁ Q₂ m : ℕ) (hm0 : 0 < m) (hm : ∀ d ∈ (setup n).support, m ≤ F.order d) (hQ₁ : F.HonestPhase1QueryBound setup adversary n Q₁) (hQ₂ : F.HonestPhase2QueryBound setup H isElem adversary n Q₂) :
                                                                      (F.cramerShoupGame3 encodeMsg setup H isElem adversary bit n).advantage (F.cramerShoupGame4 encodeMsg setup H isElem adversary bit n) ≤ ↑(Q₁ + Q₂) / ↑m

                                                                      Game 3 $\to$ Game 4 bound ([BS23], Section 12.5.3, equations (12.26)–(12.27), printed pp. 492–493, using Lemma 12.8, printed p. 488): replacing both Phase 1 and Phase 2 decryption oracles with their DH-restricted counterparts changes the game advantage by at most (Q₁ + Q₂) / m.

                                                                      noncomputable def Cslib.Crypto.PrimeOrderGroupFamily.cramerShoupGame5 (F : PrimeOrderGroupFamily) {Msg : Type} (encodeMsg : F.Desc × Msg → List Bool) (setup : ℕ → PMF F.Desc) (H : F.Desc × List Bool → List Bool) (isElem : F.Desc × List Bool → Bool) (adversary : Encryption.CCA2AdversaryOf Msg) (_bit : Bool) (n : ℕ) :

                                                                      Game 5 (corresponding to Game 6 of [BS23], Section 12.5.3, printed p. 493, adapted to $\mathcal{E}_{\mathrm{MCS}}$): replace the masked challenge component e = projHash F d (δ - α * τ) τ v w + m by a uniform independent group element ζ • g, making the entire experiment independent of the challenge bit bit.

                                                                      Instances For
                                                                        theorem Cslib.Crypto.PrimeOrderGroupFamily.cramerShoupGame5_false_eq_true (F : PrimeOrderGroupFamily) {Msg : Type} (encodeMsg : F.Desc × Msg → List Bool) (setup : ℕ → PMF F.Desc) (H : F.Desc × List Bool → List Bool) (isElem : F.Desc × List Bool → Bool) (adversary : Encryption.CCA2AdversaryOf Msg) (n : ℕ) :
                                                                        F.cramerShoupGame5 encodeMsg setup H isElem adversary false n = F.cramerShoupGame5 encodeMsg setup H isElem adversary true n

                                                                        In cramerShoupGame5, the challenge bit is unused, so the false and true experiments are identical.

                                                                        theorem Cslib.Crypto.PrimeOrderGroupFamily.advantage_cramerShoupGame4_game5_le (F : PrimeOrderGroupFamily) {Msg : Type} (encodeMsg : F.Desc × Msg → List Bool) (setup : ℕ → PMF F.Desc) (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)) (adversary : Encryption.CCA2AdversaryOf Msg) (bit : Bool) (n m : ℕ) (hm0 : 0 < m) (hm : ∀ d ∈ (setup n).support, m ≤ F.order d) :
                                                                        (F.cramerShoupGame4 encodeMsg setup H isElem adversary bit n).advantage (F.cramerShoupGame5 encodeMsg setup H isElem adversary bit n) ≤ 1 / ↑m

                                                                        Game 4 $\to$ Game 5 bound ([BS23], Section 12.5.3, equations (12.23) and (12.28), printed pp. 492–493, using Lemma 12.6, printed p. 486): whenever γ ≠ α * β, projHash F d (δ - α * τ) τ (β • g) (γ • g) + m is uniformly distributed over F.Carrier d by uniform_projHash_fiber_add (Lemma 12.6), so cramerShoupGame4 and cramerShoupGame5 differ only on the event γ = α * β of probability 1 / F.order d ≤ 1 / m.