Documentation

CslibFrontier.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, Section 12.7, and Exercise 12.27, printed pp. 488–493, 501–502, 521–522, over an arbitrary associated-data type AD : Type) 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 (the hops cramerShoupGame3 $\to$ cramerShoupGame3Half $\to$ cramerShoupGame4 $\to$ cramerShoupGame5, covering Games 4 $\to$ 5 $\to$ 6 in the proof of Theorem 12.9, printed pp. 492–493) against an adaptive ADCCA2AdversaryOf Msg AD. 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, 12.7 & Exercise 12.27) #

Verbatim from [BS23], Section 12.7, Definition 12.7 (printed pp. 501–502):

Definition 12.7 (CCA and 1CCA security with associated data). The definition of CCA security for ordinary public-key encryption schemes carries over naturally to AD public-key encryption schemes. Attack Game 12.1 is modified as follows. For encryption queries, in addition to a pair of messages $(m_{i0}, m_{i1})$, the adversary also submits associated data $d_i$, and the challenger computes $c_i \xleftarrow{R} E(pk, m_{ib}, d_i)$. For decryption queries, in addition to a ciphertext $\hat{c}_j$, the adversary submits associated data $\hat{d}_j$, and the challenger computes $\hat{m}_j \leftarrow D(sk, \hat{c}_j, \hat{d}_j)$. The restriction is that the pair $(\hat{c}_j, \hat{d}_j)$ may not be among the pairs $(c_1, d_1), (c_2, d_2), \ldots$ corresponding to previous encryption queries. An adversary $\mathcal{A}$'s advantage in this game is denoted $\text{CCA}^{\text{ad}}\text{adv}[\mathcal{A}, \mathcal{E}]$, and the scheme is said to be CCA secure if this advantage is negligible for all efficient adversaries $\mathcal{A}$. If we restrict the adversary to a single encryption query, as in Definition 12.2, the advantage is denoted $\text{1CCA}^{\text{ad}}\text{adv}[\mathcal{A}, \mathcal{E}]$, and the scheme is said to be 1CCA secure if this advantage is negligible for all efficient adversaries $\mathcal{A}$.

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 #

Domain records and canonical bit-string encodings #

A 6-exponent Cramer–Shoup secret key (s, t, s₁, t₁, s₂, t₂) over exponent type α ([BS23], Section 12.5.3, printed p. 489).

  • s : α

    First payload projective-hash exponent s (written σ in the group).

  • t : α

    Second payload projective-hash exponent t (written τ in the group).

  • s₁ : α

    First verification projective-hash exponent s₁ (written σ₁ in the group).

  • t₁ : α

    Second verification projective-hash exponent t₁ (written τ₁ in the group).

  • s₂ : α

    Third verification projective-hash exponent s₂ (written σ₂ in the group).

  • t₂ : α

    Fourth verification projective-hash exponent t₂ (written τ₂ in the group).

Instances For
    @[instance_reducible]

    Apply f componentwise to the six secret exponents of a CramerShoupSK.

    Encoding of a 6-exponent natural-number secret key CramerShoupSK ℕ as the grouped pair of pairs ((s, t), ((s₁, t₁), (s₂, t₂))), preserving the exact wire layout of three framed (ℕ × ℕ) projective-hash key pairs.

    A 4-component Cramer–Shoup public key (u, h, h₁, h₂) over carrier or word type α ([BS23], Section 12.5.3, printed p. 489).

    • u : α

      Base element u = α • g.

    • h : α

      Payload projective-hash key h = σ • g + τ • u.

    • h₁ : α

      First verification projective-hash key h₁ = σ₁ • g + τ₁ • u.

    • h₂ : α

      Second verification projective-hash key h₂ = σ₂ • g + τ₂ • u.

    Instances For

      Apply f componentwise to the four components of a CramerShoupPublicKey.

      theorem Cslib.Crypto.PrimeOrderGroupFamily.encCramerShoupPublicKeyWords_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → List Bool} {T0 S0 : γ → ℕ} {x1 : γ → List Bool} {T1 S1 : γ → ℕ} {x2 : γ → List Bool} {T2 S2 : γ → ℕ} {x3 : γ → List Bool} {T3 S3 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encBits T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encBits T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn Turing.MultiTapeTM.encBits T2 S2) (h3 : Turing.MultiTapeTM.ComputableInO x3 encIn Turing.MultiTapeTM.encBits T3 S3) :
      Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { u := x0 x, h := x1 x, h₁ := x2 x, h₂ := x3 x }) encIn encCramerShoupPublicKeyWords (fun (x : γ) => T0 x + (T1 x + (T2 x + T3 x))) fun (x : γ) => S0 x + (S1 x + (S2 x + S3 x))

      Canonical right-nested framing of a 4-component word public key CramerShoupPublicKey (List Bool): u, h, and h₁ are framed, followed by h₂.

      A 4-component Multiplicative Cramer–Shoup ciphertext (v, w, e, z') over carrier or word type α ([BS23], Exercise 12.27, printed pp. 521–522).

      • v : α

        First ephemeral element v = β • g.

      • w : α

        Second ephemeral element w = β • u.

      • e : α

        Masked message element e = β • h + m.

      • z' : α

        Verification tag z' = β • (h₁ + ρ • h₂).

      Instances For

        Apply f componentwise to the four components of a CramerShoupCiphertext.

        theorem Cslib.Crypto.PrimeOrderGroupFamily.encCramerShoupCiphertextWords_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → List Bool} {T0 S0 : γ → ℕ} {x1 : γ → List Bool} {T1 S1 : γ → ℕ} {x2 : γ → List Bool} {T2 S2 : γ → ℕ} {x3 : γ → List Bool} {T3 S3 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encBits T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encBits T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn Turing.MultiTapeTM.encBits T2 S2) (h3 : Turing.MultiTapeTM.ComputableInO x3 encIn Turing.MultiTapeTM.encBits T3 S3) :
        Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { v := x0 x, w := x1 x, e := x2 x, z' := x3 x }) encIn encCramerShoupCiphertextWords (fun (x : γ) => T0 x + (T1 x + (T2 x + T3 x))) fun (x : γ) => S0 x + (S1 x + (S2 x + S3 x))

        Canonical right-nested framing of a 4-component word ciphertext CramerShoupCiphertext (List Bool): v, w, and e are framed, followed by z'.

        A 3-tuple of sampled natural-number exponents (a, b, c) for Cramer–Shoup reductions.

        • a : ℕ

          Public-key base exponent a.

        • b : ℕ

          First challenge exponent b.

        • c : ℕ

          Second challenge exponent c.

        Instances For
          theorem Cslib.Crypto.PrimeOrderGroupFamily.encCramerShoupTripleExponents_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 x1 T1 S1 x2 T2 S2 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encNat T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encNat T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn Turing.MultiTapeTM.encNat T2 S2) :
          Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { a := x0 x, b := x1 x, c := x2 x }) encIn encCramerShoupTripleExponents (fun (x : γ) => T0 x + (T1 x + T2 x)) fun (x : γ) => S0 x + (S1 x + S2 x)

          Framing for 4-tuples of bit strings #

          Unpack a canonically framed 4-tuple of bit strings.

          @[simp]
          theorem Cslib.Crypto.PrimeOrderGroupFamily.decodeCramerShoupPublicKeyWords_encBits4 (u h h₁ h₁' : List Bool) :
          decodeCramerShoupPublicKeyWords (encBits4 (u, h, h₁, h₁')) = { u := u, h := h, h₁ := h₁, h₂ := h₁' }

          Extract the framed (v, w, e, ad) 4-tuple from an encoded 4-component ciphertext ct and associated-data bit string ad.

          Unpack a decryption-oracle query req into (ct, ad): when hasAD = true, unpack the framed pair (unframe req, dropFrame req); when hasAD = false, treat req as ct with empty associated data [].

          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).

          Encode a triple of group elements (v, w, e) : F.Carrier d × F.Carrier d × F.Carrier d together with an encoded associated-data word ad : List Bool as a framed 4-tuple bit string.

          The well-formed inputs of the hash cramerShoupHashMod H d: the words of $\mathbb{G}^3 \times \mathcal{D}$, the domain of $H'$ in [BS23], Exercise 12.27 (printed p. 521). A word is accepted when it is a canonically framed 4-tuple encBits4 (v, w, e, ad) whose first three components isElem accepts as group elements of d. With associated data (hasAD = true) the component ad may be any word, since decryption accepts any associated-data word; without it (hasAD = false) it must be [], the only associated data the scheme then hashes. isCramerShoupHashInput_iff shows that these are exactly the words encodeCramerShoupTuple d v w e ad.

          theorem Cslib.Crypto.PrimeOrderGroupFamily.isCramerShoupHashInput_iff (F : PrimeOrderGroupFamily) (hasAD : 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) (x : List Bool) :
          F.isCramerShoupHashInput hasAD isElem d x = true ↔ ∃ (v : F.Carrier d) (w : F.Carrier d) (e : F.Carrier d) (ad : List Bool), (hasAD = true ∨ ad = []) ∧ F.encodeCramerShoupTuple d v w e ad = x

          When isElem accepts exactly the group-element words, isCramerShoupHashInput accepts exactly the encoded tuples encodeCramerShoupTuple d v w e ad of $\mathbb{G}^3 \times \mathcal{D}$, with ad = [] when hasAD = false.

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

          Algebraic Multiplicative Cramer–Shoup encryption $E(pk, m, ad; \beta) = (v, w, e, z')$ ([BS23], Exercise 12.27, printed p. 521).

          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) (ad : List Bool) :
          F.cramerShoupEncrypt H d (F.cramerShoupPublicKey d α σ τ σ₁ τ₁ σ₂ τ₂) m ad β = 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.encodeCramerShoupTuple d v w e ad); have z' := ProjectiveHash.projHash2 F d σ₁ τ₁ σ₂ τ₂ ρ v w; { v := v, w := w, e := e, z' := 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).

          Algebraic Multiplicative Cramer–Shoup decryption $D(sk, (v, w, e, z'), ad)$ ([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, ad)$, and if so output some (e - f_{σ,τ}(v, w)).

          @[simp]
          theorem Cslib.Crypto.PrimeOrderGroupFamily.cramerShoupDecrypt_cramerShoupEncrypt (F : PrimeOrderGroupFamily) (H : F.Desc × List Bool → List Bool) (d : F.Desc) (α σ τ σ₁ τ₁ σ₂ τ₂ β : ZMod (F.order d)) (m : F.Carrier d) (ad : List Bool) :
          F.cramerShoupDecrypt H d { s := σ, t := τ, s₁ := σ₁, t₁ := τ₁, s₂ := σ₂, t₂ := τ₂ } (F.cramerShoupEncrypt H d (F.cramerShoupPublicKey d α σ τ σ₁ τ₁ σ₂ τ₂) m ad β) ad = 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 ⟨σ, τ, σ₁, τ₁, σ₂, τ₂⟩ and the same associated data ad recovers some m.

          Word-level polynomial-time Cramer–Shoup operations #

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

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

          @[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.

          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).

          @[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 CramerShoupPublicKey (F.Carrier d) together with d : F.Desc as the public key word presented to a 1CCA adversary.

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

          Word-level Cramer–Shoup encryption from the word public key pk, encoded message m, encoded associated data ad, and randomness b : ℕ.

          Word-level Game 1 challenge encryption from (v, w) (encoded group elements), secret key sk, encoded message m, and encoded associated data ad ([BS23], Section 12.5.3, Game 1, printed p. 490, and Exercise 12.27, printed pp. 521–522).

          @[simp]
          theorem Cslib.Crypto.PrimeOrderGroupFamily.encodeCramerShoupChallenge_encode (F : PrimeOrderGroupFamily) (H : F.Desc × List Bool → List Bool) (d : F.Desc) (sk : CramerShoupSK ℕ) (v w m : F.Carrier d) (ad : List Bool) :
          F.encodeCramerShoupChallenge H d sk (F.encode d v) (F.encode d w) (F.encode d m) ad = have e := ProjectiveHash.projHash F d (↑sk.s) (↑sk.t) v w + m; have ρ := F.cramerShoupHashMod H d (F.encodeCramerShoupTuple d v w e ad); have z' := ProjectiveHash.projHash2 F d (↑sk.s₁) (↑sk.t₁) (↑sk.s₂) (↑sk.t₂) ρ v w; F.encodeCramerShoupCiphertext d { v := v, w := w, e := e, z' := 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, ad), unpack parts := decodeCramerShoupCiphertextWords ct, check canonical framing encCramerShoupCiphertextWords parts == ct, check group membership isElem (d, parts.v) && isElem (d, parts.w) && isElem (d, parts.e), and check encodeProjHash2 d s₁ t₁ s₂ t₂ r parts.v parts.w == parts.z' where r = ofBits (H (d, encBits4 (parts.v, parts.w, parts.e, ad))); if all pass, return some (encode (e - f_{s,t}(v, w))), else none.

          theorem Cslib.Crypto.PrimeOrderGroupFamily.decodeCramerShoup_encode (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 : CramerShoupSK ℕ) (ct : CramerShoupCiphertext (F.Carrier d)) (ad : List Bool) :

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

          Decryption rejects every ciphertext whose hashed tuple extractCramerShoupTuple ct ad is not a well-formed hash input: a ciphertext that decrypts has group-element components v, w, e.

          @[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 : CramerShoupSK ℕ) (m : F.Carrier d) (ad : List Bool) :
          F.decodeCramerShoup H isElem d sk (F.encodeCramerShoupCiphertext d (F.cramerShoupEncrypt H d (F.cramerShoupPublicKey d α ↑sk.s ↑sk.t ↑sk.s₁ ↑sk.t₁ ↑sk.s₂ ↑sk.t₂) m ad β)) ad = 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 (ct_q, ad_q) yields a cramerShoupHashMod H d collision with the challenge (ct, ad) on their (v, w, e, ad) tuples.

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

          Stateless Phase 1 decryption reply for Cramer–Shoup (hasAD = true for cca2ADPhase1Oracle, hasAD = false for cca2Phase1Oracle).

          Stateless Phase 2 decryption reply that rejects the challenge (ct, ad) and any query (ct_q, ad_q) colliding with (ct, ad) under cramerShoupHashMod H d.

          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⟩.

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

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

          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 ad : List Bool) :

          Decryption helper for cramerShoupGame4 (Game 5 of [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).

          def Cslib.Crypto.PrimeOrderGroupFamily.cramerShoupDHPhase1Reply (F : PrimeOrderGroupFamily) (hasAD : Bool) (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.

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

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

          Bad-event predicate for cramerShoupGame3 $\to$ cramerShoupGame4 (Games 4 $\to$ 5 of [BS23], Section 12.5.3, equations (12.26)–(12.27), printed pp. 492–493): ct_q = encCramerShoupCiphertextWords ⟨v', w', e', z'⟩ is a syntactically well-formed non-DH ciphertext (w' != F.smul (d, α.val, v')) whose tag z' matches encodeProjHash2 on (v', w', e', ad_q).

          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.

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

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

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

          Game 3.5 (intermediate hybrid between cramerShoupGame3 and cramerShoupGame4, which correspond to Games 4 and 5 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).

          theorem Cslib.Crypto.PrimeOrderGroupFamily.advantage_cramerShoupGame3_game3Half_le (F : PrimeOrderGroupFamily) (hasAD : Bool) {Msg AD : Type} (encodeMsg : F.Desc × Msg → List Bool) (encodeAD : F.Desc × AD → 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.ADCCA2AdversaryOf Msg AD) (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 hasAD encodeMsg encodeAD setup H isElem adversary bit n).advantage (F.cramerShoupGame3Half hasAD encodeMsg encodeAD 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) (hasAD : Bool) {Msg AD : Type} (encodeMsg : F.Desc × Msg → List Bool) (encodeAD : F.Desc × AD → List Bool) (setup : ℕ → PMF F.Desc) (H : F.Desc × List Bool → List Bool) (isElem : F.Desc × List Bool → Bool) (adversary : Encryption.ADCCA2AdversaryOf Msg AD) (bit : Bool) (n : ℕ) :

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

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

          Game 3 $\to$ Game 4 bound (Games 4 $\to$ 5 of [BS23], Section 12.5.3, equations (12.26)–(12.27), printed pp. 492–493, using Lemma 12.8, printed p. 488): if isElem accepts exactly the encodings of group elements, every supported group has order at least m > 0, and Phase 1 and Phase 2 make at most Q₁ and Q₂ queries on honest inputs (HonestPhase1QueryBound, HonestPhase2QueryBound), then 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) (hasAD : Bool) {Msg AD : Type} (encodeMsg : F.Desc × Msg → List Bool) (encodeAD : F.Desc × AD → List Bool) (setup : ℕ → PMF F.Desc) (H : F.Desc × List Bool → List Bool) (isElem : F.Desc × List Bool → Bool) (adversary : Encryption.ADCCA2AdversaryOf Msg AD) (_bit : Bool) (n : ℕ) :

          Game 5 (corresponding to Game 6 of [BS23], Section 12.5.3, printed p. 493, adapted to $\mathcal{E}_{\mathrm{MCS}}$ with associated data): 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.

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

          Game 4 $\to$ Game 5 bound (Games 5 $\to$ 6 of [BS23], Section 12.5.3, with the non-DH-triple step of its Game 3 folded in; equations (12.23) and (12.28), printed pp. 492–493, using Lemma 12.6, printed p. 486): suppose isElem accepts exactly the encodings of group elements and every supported group has order at least m > 0. 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.