Documentation

CslibFrontier.Crypto.Computational.Encryption.Authenticated

Authenticated Encryption and Adaptive Chosen-Ciphertext Security #

This module formalizes symmetric authenticated encryption (AuthenticatedEncryption) and adaptive chosen-ciphertext security (INDCCA) following Boneh and Shoup, A Graduate Course in Applied Cryptography, Version 0.6, Chapter 5 (Sections 5.3 and 5.10) and Chapter 9 (Sections 9.1 and 9.2.2–9.2.3):

  1. Symmetric ciphers and adaptive/one-time CPA security (SymmetricCipher, cpaGame, INDCPA, cpaOneTimeGame, OneTimeINDCPA, not_indcpa_of_deterministic, not_indcpa_of_ciphertext_length_eq) ([BS23], Section 2.2, Attack Game 2.1 and Definition 2.2; Section 5.3, Attack Game 5.2, Definition 5.2, and Example 5.1, printed pp. 181–182; Exercise 5.10(a), printed p. 211): a uniform symmetric cipher on n-bit messages at security parameter n consists of strict PPT key generation keyGen, strict PPT encryption encrypt, and deterministic polynomial-time decryption decrypt returning Option (List Bool) (encoded via encOption encBits). In cpaGame, an adaptive OracleDistinguisher submits left-or-right pairs (m0, m1) of n-bit messages and receives encrypt n k (if bit then m1 else m0); cpaOneTimeGame and OneTimeINDCPA restrict the oracle to at most one valid encryption query. We also formalize Example 5.1 (not_indcpa_of_deterministic) for any cipher deterministic on 0^n with arbitrary polynomial ciphertext expansion via the 2-query distinguisher detCPAAdversary ctBound, and deduce Exercise 5.10(a) (not_indcpa_of_ciphertext_length_eq) as its zero-expansion corollary.
  2. Ciphertext integrity and authenticated encryption (ciGame, CiphertextIntegrity, AuthenticatedEncryption, ciOneTimeGame, OneTimeCiphertextIntegrity, OneTimeAuthenticatedEncryption) ([BS23], Section 9.1, Attack Game 9.1 and Definitions 9.1–9.4, printed pp. 358–360): in ciGame (and its single-query counterpart ciOneTimeGame), an adaptive CIAdversary queries an encryption oracle on n-bit messages (logging returned ciphertexts in queriedCiphertexts) and wins by outputting a candidate ciphertext ct such that !queriedCiphertexts.contains ct and (decrypt n k ct).isSome. A cipher provides AuthenticatedEncryption when it satisfies both INDCPA and CiphertextIntegrity, and OneTimeAuthenticatedEncryption (1AE) when it satisfies both OneTimeINDCPA and OneTimeCiphertextIntegrity.
  3. Adaptive chosen-ciphertext security, AE $\Rightarrow$ CCA, 1AE $\Rightarrow$ 1CCA, and encryption-query preservation (ccaGame, INDCCA, ccaOneTimeGame, OneTimeINDCCA, ccaToCPAAdversary, ccaToCIAdversary, ccaToCIHiddenBitAdversary, IsEncryptionQueryBounded, IsDecryptionQueryBounded, isQueryBounded_ccaToCPAAdversary_of_isEncryptionQueryBounded, isQueryBounded_ccaToCIAdversary_of_isEncryptionQueryBounded, advantage_ccaGame_le, advantage_ccaGame_le_two_mul, guessingAdvantage_guessBit_ccaGame_le, guessingAdvantage_guessBit_ccaGame_le_two_mul, AuthenticatedEncryption.indcca, advantage_ccaOneTimeGame_le, advantage_ccaOneTimeGame_le_two_mul, guessingAdvantage_guessBit_ccaOneTimeGame_le, OneTimeAuthenticatedEncryption.oneTimeINDCCA) ([BS23], Sections 9.2.2–9.2.3, Attack Game 9.2, Definitions 9.5–9.6, and Theorem 9.1, printed pp. 362–365): in ccaGame (and its single-encryption-query counterpart ccaOneTimeGame), a two-channel CCAAdversary (Operation = Bool) may interleave left-or-right encryption queries (false, recording challenge ciphertexts) with decryption queries (true, rejecting recorded challenge ciphertexts and returning encOption encBits (decrypt n k ct) on all other ciphertexts). Using the difference lemma (OracleComp.IdenticalUntilBad.advantage_le, [BS23], Theorem 4.7) between ccaGame and ccaRejectGame (and between ccaOneTimeGame and ccaOneTimeRejectGame), we prove both AE ⇒ CCA (AuthenticatedEncryption.indcca) and 1AE ⇒ 1CCA (OneTimeAuthenticatedEncryption.oneTimeINDCCA) with the book's bounds (9.3) and (9.4) in the number Qd of decryption queries, up to a power-of-two factor (see below), as well as encryption-query count preservation for the reductions $B_{\mathrm{cpa}}$ and $B_{\mathrm{ci}}$.

The generic Encrypt-then-MAC composition ([BS23], Section 9.4.1, Theorem 9.2, printed pp. 367–368) and its concrete non-vacuous PRF-based cipher instance ([BS23], Section 5.4.1, Example 5.2 and Theorem 5.2, printed pp. 183–187) are formalized in CslibFrontier.Crypto.Computational.Encryption.EncryptThenMAC.

Specializations and losses relative to Boneh–Shoup Chapter 9 #

Main definitions #

Main results #

References #

@[reducible, inline]

An adaptive ciphertext-integrity adversary receives the unary security parameter and an auxiliary word, queries an encryption oracle on chosen messages, and outputs a candidate ciphertext.

@[reducible, inline]

An adaptive chosen-ciphertext distinguisher receives the unary security parameter and an auxiliary word, queries a left-or-right encryption oracle (false) and a decryption oracle (true), and outputs a distinguishing bit.

A uniform symmetric cipher on n-bit messages at security parameter n, with strict probabilistic polynomial-time key generation and encryption, deterministic polynomial-time decryption (returning Option (List Bool)), a ciphertext space ctSpace outside which decryption rejects, and perfect decryption completeness on supported keys, n-bit messages, and ciphertexts ([BS23], Sections 5.3 and 9.1).

A source cipher defined over (K, M, C) ([BS23], Section 2.3.2, Definition 2.10, printed p. 31) decrypts only words of C. It is encoded with ctSpace n deciding C at parameter n and with decrypt rejecting every other word, which decrypt_eq_none_of_ctSpace_eq_false requires. The integrity and chosen-ciphertext games then match the source's games on C (ciGame and ccaOracle say how). Both fields have defaults, every word and its trivial proof, for a cipher whose decryption is meant for all words. Definition 2.10 also requires C to be efficiently recognizable; ctSpace carries no complexity certificate, since no theorem here needs one.

E.keyGen composed with a plain polynomial-time parameter selector is uniformly strict PPT.

E.encrypt composed with plain polynomial-time parameter, key, and message selectors is uniformly strict PPT.

E.decrypt composed with plain polynomial-time parameter, key, and ciphertext selectors is computable in plain polynomial time.

Adaptive Chosen-Plaintext Security (cpaGame, INDCPA) #

@[reducible, inline]
noncomputable abbrev Cslib.Crypto.SymmetricCipher.cpaGame (E : SymmetricCipher) (adversary : OracleDistinguisher) (bit : Bool) (n : ℕ) :

The adaptive symmetric IND-CPA experiment ([BS23], Section 5.3, Attack Game 5.2): symmetricCPAGameOn for E.keyGen and E.encrypt, admitting a pair (m₀, m₁) exactly when both messages have n bits. A key k ← E.keyGen n is sampled, and each query on an admitted pair is answered with E.encrypt n k (if bit then m₁ else m₀); any other query is answered with [].

Every encryption of an n-bit message under a key supported by E.keyGen n has exactly len bits. Encrypt-then-MAC needs this to frame (ciphertext, tag) pairs canonically.

Every encryption of an n-bit message under a key supported by E.keyGen n has at most bound bits; exists_ciphertext_length_bound_of_length_eq supplies a polynomial bound.

A unary polynomial-time ciphertext bound indexed separately by security parameter and message length. The key is sampled at parameter n; the bound covers every message of length ℓ, even outside the cipher's correctness and security domain of n-bit messages.

A unary polynomial-time ciphertext bound on n-bit messages at security parameter n, derived as the diagonal of exists_ciphertext_length_bound.

A polynomial-time bound on encoded decryption replies, uniform over the actual key sampler. It bounds rejection and successful empty messages without identifying their encodings.

The symmetric CPA experiment is uniformly strict PPT in the unary security parameter.

The symmetric CPA experiment is uniformly strict PPT, independently of unused auxiliary input.

@[reducible, inline]

Adaptive chosen-plaintext security (INDCPA) for a symmetric cipher ([BS23], Section 5.3, Attack Game 5.2 and Definition 5.2): SymmetricINDCPAOn on pairs of n-bit messages, so every uniform strict IsOraclePPT encBool distinguisher has negligible advantage between E.cpaGame adversary false and E.cpaGame adversary true.

Stateful one-time left-or-right CPA encryption oracle ([BS23], Section 2.2, Attack Game 2.1 and Definition 2.2; Section 9.1.1, Definition 9.4, printed p. 360): answers at most one valid n-bit left-or-right encryption query (!alreadyQueried && m0.length == n && m1.length == n), transitioning alreadyQueried from false to true, and returns [] on all subsequent or malformed queries.

The one-time symmetric CPA (semantic security) experiment ([BS23], Section 2.2, Attack Game 2.1 and Section 9.1.1, Definition 9.4): sample k ← E.keyGen n and run adversary n [] against E.oneTimeCPAEncryptionOracle n k bit starting from alreadyQueried = false.

The one-time symmetric CPA experiment is uniformly strict PPT in the unary security parameter.

The one-time symmetric CPA experiment is uniformly strict PPT, independently of unused auxiliary input.

One-time chosen-plaintext security (semantic security under a single encryption query, OneTimeINDCPA) for a symmetric cipher ([BS23], Section 2.2, Attack Game 2.1 and Definition 2.2; Section 9.1.1, Definition 9.4, printed p. 360): every uniform strict IsOraclePPT encBool distinguisher has negligible advantage between E.cpaOneTimeGame adversary false and E.cpaOneTimeGame adversary true.

Stateful filter handler that forwards at most one valid n-bit CPA query to an external multi-query CPA encryption oracle (truncating replies to ctBound).

Reduction from cpaOneTimeGame to cpaGame: run adversary n [] against cpaOneTimeFilterHandler n (ctBound n) starting from alreadyQueried = false.

theorem Cslib.Crypto.SymmetricCipher.isOraclePPT_oneTimeFilter {β : Type} {encOut : β ↪ List Bool} {accept : ℕ → List Bool → Bool} {ctBound : ℕ → ℕ} {post : List Bool → List Bool} (haccept : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : ℕ × List Bool) => accept p.1 p.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBool) (hctBound : Turing.MultiTapeTM.ComputableInPolyTime ctBound Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hpost : Turing.MultiTapeTM.ComputableInPolyTime post Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) {adversary : ℕ → List Bool → Probability.WordOracleComp Unit β} (hadversary : Probability.IsOraclePPT encOut adversary) :
Probability.IsOraclePPT encOut fun (n : ℕ) (x : List Bool) => do let out ← (OracleComp.interpret (OracleComp.sumHandler (fun (m : ℕ) => StateT.lift (ProbOracleComp.sample (ProbComp.unifFin m))) fun (request : Unit × List Bool) (alreadyQueried : Bool) => if (!alreadyQueried && accept n request.2) = true then (fun (ct : List Bool) => (post ct, true)) <$> List.take (ctBound n) <$> ProbOracleComp.query ((), request.2) else pure ([], alreadyQueried)) (adversary n [])).run false pure out.1

Running a WordOracleComp Unit adversary through a single-query Bool-state filter oracle that forwards a request when !alreadyQueried && accept n req, truncates the oracle reply to ctBound n bits, and applies a polynomial-time postprocessing map post preserves strict oracle-PPT admissibility (IsOraclePPT).

theorem Cslib.Crypto.SymmetricCipher.eval_cpaGame_cpaLimitToOneQuery (E : SymmetricCipher) (ctBound : ℕ → ℕ) (adversary : OracleDistinguisher) (bit : Bool) (n : ℕ) (hctBound : E.CiphertextLengthLE n (ctBound n)) :
(E.cpaGame (cpaLimitToOneQuery ctBound adversary) bit n).eval = (E.cpaOneTimeGame adversary bit n).eval

When ctBound n bounds all ciphertext lengths produced by E.encrypt n k on n-bit messages, running cpaLimitToOneQuery ctBound adversary in cpaGame has the exact same output distribution as cpaOneTimeGame adversary.

Multi-query INDCPA security implies one-time OneTimeINDCPA security.

Impossibility of Zero-Expansion CPA Security (Boneh–Shoup Example 5.1 & Exercise 5.10(a)) #

theorem Cslib.Crypto.SymmetricCipher.encrypt_eq_of_ciphertext_length_eq (E : SymmetricCipher) {n : ℕ} {ke : List Bool} (hke : ke ∈ (E.keyGen n).eval.support) (hctLen : ∀ (msg : List Bool), msg.length = n → ∀ c ∈ (E.encrypt n ke msg).eval.support, c.length = n) {msg : List Bool} (hmsg : msg.length = n) {c₁ c₂ : List Bool} (hc₁ : c₁ ∈ (E.encrypt n ke msg).eval.support) (hc₂ : c₂ ∈ (E.encrypt n ke msg).eval.support) :
c₁ = c₂

Zero ciphertext expansion forces deterministic encryption ([BS23], Exercise 5.10(a), printed p. 211): if every supported ciphertext of an n-bit message under a supported key ke at parameter n has length n, then decryption completeness (E.decrypt_encrypt) gives an injection from the 2^n plaintexts BitString n into BitString n by choosing one supported ciphertext per plaintext; by finiteness of BitString n, this map is surjective, forcing all supported ciphertexts of any n-bit plaintext msg under ke to coincide.

theorem Cslib.Crypto.SymmetricCipher.exists_eval_encrypt_eq_pure_of_ciphertext_length_eq (E : SymmetricCipher) {n : ℕ} (hctLen : E.CiphertextLength n n) {ke : List Bool} (hke : ke ∈ (E.keyGen n).eval.support) {msg : List Bool} (hmsg : msg.length = n) :
∃ (c₀ : List Bool), (E.encrypt n ke msg).eval = PMF.pure c₀

Under zero ciphertext expansion (E.CiphertextLength n n), encryption of any n-bit plaintext msg under any supported key ke evaluates to a point mass PMF.pure c₀ ([BS23], Section 5.8, Exercise 5.10(a), printed p. 211).

Two-query CPA distinguisher ([BS23], Section 5.3, Example 5.1, printed p. 182): queries (0^n, 1^n) followed by (0^n, 0^n), truncates each reply to ctBound n bits, and outputs true iff the two truncated replies coincide (c₁ == c₂).

theorem Cslib.Crypto.SymmetricCipher.advantage_cpaGame_detCPAAdversary (E : SymmetricCipher) (ctBound : ℕ → ℕ) {n : ℕ} (hn : 1 ≤ n) (hctLen : E.CiphertextLengthLE n (ctBound n)) (hdet : ∀ k ∈ (E.keyGen n).eval.support, ∃ (c : List Bool), (E.encrypt n k (List.replicate n false)).eval = PMF.pure c) :

At any security parameter 1 ≤ n where ctBound n bounds ciphertext lengths on n-bit messages and E.encrypt n k (0^n) is deterministic under every supported key k, detCPAAdversary ctBound achieves CPA advantage 1 ([BS23], Section 5.3, Example 5.1, printed p. 182).

theorem Cslib.Crypto.SymmetricCipher.not_indcpa_of_deterministic (E : SymmetricCipher) (n₀ : ℕ) (hdet : ∀ (n : ℕ), n₀ ≤ n → ∀ k ∈ (E.keyGen n).eval.support, ∃ (c : List Bool), (E.encrypt n k (List.replicate n false)).eval = PMF.pure c) :

No deterministic symmetric cipher is CPA-secure ([BS23], Section 5.3, Example 5.1, printed p. 182): if from some security parameter n₀ onward, E.encrypt n k (0^n) is a point mass for every key k in the support of E.keyGen n, then E cannot satisfy INDCPA.

No zero-expansion symmetric cipher is CPA-secure ([BS23], Section 5.8, Exercise 5.10(a), printed p. 211): if for every security parameter n, every supported key ke, and every n-bit message msg, every supported ciphertext of msg has length n, then E cannot satisfy INDCPA (proved via Example 5.1's deterministic-cipher attack not_indcpa_of_deterministic).

Ciphertext Integrity and Authenticated Encryption (ciGame, CiphertextIntegrity, #

AuthenticatedEncryption)

Stateful encryption oracle for the ciphertext-integrity game ([BS23], Section 9.1, Attack Game 9.1): if request.2.length == n, encrypt request.2 under k, prepend the resulting ciphertext to queriedCiphertexts, and return it; otherwise return [] without modifying the ciphertext log.

The ciphertext-integrity experiment ([BS23], Section 9.1, Attack Game 9.1): sample k ← E.keyGen n, run adversary n [] with oracle access to E.ciEncryptionOracle n k, and accept when the adversary outputs a candidate ciphertext ct that was never returned by the encryption oracle (!out.2.contains out.1) and decrypts without rejection ((E.decrypt n k out.1).isSome).

This is Attack Game 9.1 on the ciphertext space C = E.ctSpace n: a candidate outside C decrypts to none (decrypt_eq_none_of_ctSpace_eq_false) and loses, so the adversary wins exactly when it outputs a fresh word of C that decrypts, which is the source's winning event. The same holds for ciOneTimeGame.

Encryption-admission policies #

The full-query and one-time ciphertext-integrity and chosen-ciphertext games differ only in when an encryption query is answered: always, or only while no ciphertext has been returned. The private oracles ciEncryptionOracleOn, ccaOracleOn and ccaRejectOracleOn take this admission policy allow on the ciphertext log as a parameter, so that the PPT certificates and the bad-event argument of Theorem 9.1 are proved once. The public full-query oracles are the instances at fun _ => true by definition, and the one-time oracles are equal to the instances at List.isEmpty.

Running an oracle-PPT adversary against a stateful encryption oracle gated by allow log && (request.2.length == n) that encrypts request.2 and prepends logEntry request.2 ct to the word log is uniformly strict PPT in (n, k) whenever allow and logEntry are computable in polynomial time.

The ciphertext-integrity experiment is uniformly strict PPT in the unary security parameter.

The ciphertext-integrity experiment is uniformly strict PPT, independently of unused auxiliary input.

Ciphertext integrity (CiphertextIntegrity, or CI) for a symmetric cipher ([BS23], Section 9.1, Attack Game 9.1 and Definition 9.1): every uniform strict IsOraclePPT encBits adversary has negligible probability of outputting a fresh valid ciphertext.

Ciphertext integrity gives negligible winning probability in ciGame for every oracle-PPT CI adversary.

Establish CiphertextIntegrity by bounding every oracle-PPT CI adversary's winning probability.

Authenticated encryption (AuthenticatedEncryption, or AE-security) for a symmetric cipher ([BS23], Section 9.1, Definition 9.2): the cipher satisfies both INDCPA and CiphertextIntegrity.

Stateful one-time encryption oracle for the one-time ciphertext-integrity game ([BS23], Section 9.1.1, Definition 9.3, printed p. 360): if no ciphertext has been returned yet (queriedCiphertexts.isEmpty) and request.2.length == n, encrypt request.2 under k, record [ct], and return ct; otherwise return [] without modifying queriedCiphertexts.

The one-time ciphertext-integrity experiment ([BS23], Section 9.1.1, Definition 9.3, printed p. 360): sample k ← E.keyGen n, run adversary n [] with oracle access to E.oneTimeCIEncryptionOracle n k, and accept when the adversary outputs a candidate ciphertext ct that was not returned by the encryption oracle (!out.2.contains out.1) and decrypts without rejection ((E.decrypt n k out.1).isSome).

The one-time ciphertext-integrity experiment is uniformly strict PPT in the unary security parameter.

The one-time ciphertext-integrity experiment is uniformly strict PPT, independently of unused auxiliary input.

One-time ciphertext integrity (OneTimeCiphertextIntegrity, or 1CI) for a symmetric cipher ([BS23], Section 9.1.1, Definition 9.3, printed p. 360): every uniform strict IsOraclePPT encBits adversary has negligible probability of outputting a fresh valid ciphertext in ciOneTimeGame.

One-time ciphertext integrity gives negligible winning probability in ciOneTimeGame for every oracle-PPT CI adversary.

Stateful filter handler that forwards at most one valid n-bit CI encryption query to an external multi-query CI encryption oracle (truncating replies to ctBound).

noncomputable def Cslib.Crypto.SymmetricCipher.ciLimitToOneQuery (ctBound : ℕ → ℕ) (adversary : CIAdversary) :

Reduction from ciOneTimeGame to ciGame: run adversary n [] against ciOneTimeFilterHandler n (ctBound n) starting from alreadyQueried = false.

theorem Cslib.Crypto.SymmetricCipher.eval_ciGame_ciLimitToOneQuery (E : SymmetricCipher) (ctBound : ℕ → ℕ) (adversary : CIAdversary) (n : ℕ) (hctBound : E.CiphertextLengthLE n (ctBound n)) :
(E.ciGame (ciLimitToOneQuery ctBound adversary) n).eval = (E.ciOneTimeGame adversary n).eval

When ctBound n bounds all ciphertext lengths produced by E.encrypt n k on n-bit messages, running ciLimitToOneQuery ctBound adversary in ciGame has the exact same output distribution as ciOneTimeGame adversary.

One-time authenticated encryption (OneTimeAuthenticatedEncryption, or 1AE-security) for a symmetric cipher ([BS23], Section 9.1.1, Definition 9.4, printed p. 360): the cipher satisfies both OneTimeINDCPA (semantic security under a single encryption query) and OneTimeCiphertextIntegrity.

Adaptive Chosen-Ciphertext Security (ccaGame, ccaRejectGame, INDCCA) #

noncomputable def Cslib.Crypto.SymmetricCipher.ccaOracle (E : SymmetricCipher) (n : ℕ) (k : List Bool) (bit : Bool) (request : Bool × List Bool) :

Stateful two-channel oracle for the adaptive chosen-ciphertext experiment ([BS23], Section 9.2.2, Attack Game 9.2):

  • On an encryption query (false, req): decode m0 = unframe req and m1 = dropFrame req; if both have length n, encrypt if bit then m1 else m0 under k, prepend the resulting ciphertext ct to queriedCiphertexts, and return ct; otherwise return [].
  • On a decryption query (true, ct): if queriedCiphertexts.contains ct is true, return [] (prohibited challenge ciphertext); otherwise return encOption encBits (E.decrypt n k ct).

Attack Game 9.2 takes decryption queries from the ciphertext space C = E.ctSpace n. A query outside C is answered here with the rejection [] = encOption encBits none (decrypt_eq_none_of_ctSpace_eq_false), and a query inside C as in the source, so an adversary that asks only the source's queries sees the source's oracle and INDCCA implies CCA security on C. Conversely, when C is efficiently recognizable, as [BS23], Definition 2.10 requires, an adversary can answer its queries outside C itself, so CCA security on C implies INDCCA. The same holds for oneTimeCCAOracle.

noncomputable def Cslib.Crypto.SymmetricCipher.ccaGame (E : SymmetricCipher) (adversary : CCAAdversary) (bit : Bool) (n : ℕ) :

The adaptive chosen-ciphertext experiment ([BS23], Section 9.2.2, Attack Game 9.2): sample k ← E.keyGen n and run adversary n [] against E.ccaOracle n k bit.

The adaptive CCA experiment is uniformly strict PPT in the unary security parameter.

The adaptive CCA experiment is uniformly strict PPT, independently of unused auxiliary input.

Adaptive chosen-ciphertext security (INDCCA, or CCA-security) for a symmetric cipher ([BS23], Section 9.2.2, Attack Game 9.2 and Definition 9.5, printed p. 362): every uniform strict IsOraclePPT encBool CCA adversary has negligible advantage between E.ccaGame adversary false and E.ccaGame adversary true.

In [BS23], Section 9.2.2, Definition 9.5 defines adaptive multi-query CCA security, whereas one-time CCA security (OneTimeINDCCA, or 1CCA) is defined in Definition 9.6 (printed p. 363).

Stateful two-channel oracle for the one-time adaptive chosen-ciphertext experiment ([BS23], Section 9.2.2, Attack Game 9.2 and Definition 9.6, printed pp. 362–363):

  • On an encryption query (false, req): decode m0 = unframe req and m1 = dropFrame req; if no challenge ciphertext has been returned yet (queriedCiphertexts.isEmpty) and both messages have length n, encrypt if bit then m1 else m0 under k, record [ct], and return ct; otherwise return [].
  • On a decryption query (true, ct): if queriedCiphertexts.contains ct is true, return [] (prohibited challenge ciphertext); otherwise return encOption encBits (E.decrypt n k ct).

The one-time adaptive chosen-ciphertext experiment ([BS23], Section 9.2.2, Attack Game 9.2 and Definition 9.6, printed pp. 362–363): sample k ← E.keyGen n and run adversary n [] against E.oneTimeCCAOracle n k bit.

The one-time adaptive CCA experiment is uniformly strict PPT in the unary security parameter.

The one-time adaptive CCA experiment is uniformly strict PPT, independently of unused auxiliary input.

One-time adaptive chosen-ciphertext security (OneTimeINDCCA, or 1CCA-security) for a symmetric cipher ([BS23], Section 9.2.2, Attack Game 9.2 and Definition 9.6, printed p. 363): every uniform strict IsOraclePPT encBool CCA adversary has negligible advantage between E.ccaOneTimeGame adversary false and E.ccaOneTimeGame adversary true.

Stateful filter handler that forwards all decryption queries (true, ct) (truncating replies to decBound n ct) and at most one valid n-bit encryption query (false, req) (truncating replies to ctBound) to an external multi-query CCA oracle.

noncomputable def Cslib.Crypto.SymmetricCipher.ccaLimitToOneEncryptionQuery (ctBound : ℕ → ℕ) (decBound : ℕ → List Bool → ℕ) (adversary : CCAAdversary) :

Reduction from ccaOneTimeGame to ccaGame: run adversary n [] against ccaOneTimeFilterHandler n (ctBound n) decBound starting from alreadyEncrypted = false.

theorem Cslib.Crypto.SymmetricCipher.eval_ccaGame_ccaLimitToOneEncryptionQuery (E : SymmetricCipher) (ctBound : ℕ → ℕ) (decBound : ℕ → List Bool → ℕ) (adversary : CCAAdversary) (bit : Bool) (n : ℕ) (hctBound : E.CiphertextLengthLE n (ctBound n)) (hdecBound : ∀ k ∈ (E.keyGen n).eval.support, ∀ (ct : List Bool), ((Turing.MultiTapeTM.encOption Turing.MultiTapeTM.encBits) (E.decrypt n k ct)).length ≤ decBound n ct) :
(E.ccaGame (ccaLimitToOneEncryptionQuery ctBound decBound adversary) bit n).eval = (E.ccaOneTimeGame adversary bit n).eval

When ctBound n bounds all ciphertext lengths produced by E.encrypt n k on n-bit messages and decBound n ct bounds all encoded decryption replies encOption encBits (E.decrypt n k ct), running ccaLimitToOneEncryptionQuery ctBound decBound adversary in ccaGame has the exact same output distribution as ccaOneTimeGame adversary.

Multi-query INDCCA security implies one-time OneTimeINDCCA security.

Authenticated Encryption Implies Adaptive CCA Security (Boneh–Shoup Theorem 9.1) #

@[reducible, inline]

Structural encryption-query bound for a two-channel CCA computation (Operation = Bool, where false is the encryption channel and true is the decryption channel): every execution path makes at most Qe encryption-oracle queries ((false, _)), while allowing arbitrary random-coin queries and decryption-oracle queries ([BS23], Section 9.2.3, Theorem 9.1, printed p. 363).

Every total-query bound program.IsQueryBounded Q implies the encryption-query bound IsEncryptionQueryBounded program Q.

@[reducible, inline]

Structural decryption-query bound for a two-channel CCA computation: every execution path makes at most Qd decryption-oracle queries ((true, _)), while allowing arbitrary random-coin queries and encryption-oracle queries. This is the budget Q_d of [BS23], Section 9.2.3, Theorem 9.1, printed p. 363.

Every total-query bound program.IsQueryBounded Q implies the decryption-query bound IsDecryptionQueryBounded program Q.

Hybrid two-channel oracle for Game 1 in the proof of [BS23], Theorem 9.1 (Section 9.2.3, printed pp. 363–364): encryption queries (false, req) behave identically to ccaOracle, whereas every decryption query (true, _) immediately returns [] (rejection) without invoking decrypt.

noncomputable def Cslib.Crypto.SymmetricCipher.ccaRejectGame (E : SymmetricCipher) (adversary : CCAAdversary) (bit : Bool) (n : ℕ) :

The all-reject hybrid CCA experiment (Game 1 in [BS23], Section 9.2.3, Theorem 9.1): sample k ← E.keyGen n and run adversary n [] against E.ccaRejectOracle n k bit.

Stateful handler for ccaToCPAAdversary ([BS23], Section 9.2.3, Theorem 9.1): reject all decryption queries (true, _) with [], and forward valid left-or-right encryption queries (false, req) to the external CPA encryption oracle (truncating replies to ctBound).

Reduction from the all-reject hybrid ccaRejectGame to the adaptive CPA experiment cpaGame ([BS23], Section 9.2.3, adversary $B_{\mathrm{cpa}}$ in Theorem 9.1): run adversary n [] against ccaToCPAHandler n (ctBound n).

theorem Cslib.Crypto.SymmetricCipher.eval_cpaGame_ccaToCPAAdversary (E : SymmetricCipher) (ctBound : ℕ → ℕ) (adversary : CCAAdversary) (bit : Bool) (n : ℕ) (hctBound : E.CiphertextLengthLE n (ctBound n)) :
(E.cpaGame (ccaToCPAAdversary ctBound adversary) bit n).eval = (E.ccaRejectGame adversary bit n).eval

When ctBound n bounds all ciphertext lengths produced by E.encrypt n k on n-bit messages, running ccaToCPAAdversary ctBound adversary in cpaGame has the exact same output distribution as ccaRejectGame adversary ([BS23], Section 9.2.3, equation (9.7) in the proof of Theorem 9.1, printed p. 365).

Multi-tape encoding of ProbOracleComp.PlantedState (List Bool), matching the right-nested tuple layout encPair encUnary (encPair encBool encBits) definitionally (rfl).

theorem Cslib.Crypto.SymmetricCipher.encCCAToCIState_rem_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → ProbOracleComp.PlantedState (List Bool)} :
theorem Cslib.Crypto.SymmetricCipher.encCCAToCIState_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget x0 : γ → ℕ} {x1 : γ → Bool} {x2 : γ → List Bool} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn Turing.MultiTapeTM.encUnary budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encBool budget) (h2 : Turing.MultiTapeTM.ComputableInSpace x2 encIn Turing.MultiTapeTM.encBits budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { rem := x0 x, hasCaptured := x1 x, candidate := x2 x }) encIn encCCAToCIState budget
theorem Cslib.Crypto.SymmetricCipher.encCCAToCIState_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 : γ → ℕ} {x1 : γ → Bool} {T1 S1 : γ → ℕ} {x2 : γ → List Bool} {T2 S2 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encUnary T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encBool T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn Turing.MultiTapeTM.encBits T2 S2) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { rem := x0 x, hasCaptured := x1 x, candidate := x2 x }) encIn encCCAToCIState (fun (x : γ) => T0 x + (T1 x + T2 x)) fun (x : γ) => S0 x + (S1 x + S2 x)

Stateful handler for ccaToCIAtIndexAdversary and ccaToCIAdversary ([BS23], Section 9.2.3, adversary $B_{\mathrm{ci}}$ in Theorem 9.1): execute one CCA-to-CI query against the external CI encryption oracle, maintaining a named countdown-and-capture record ProbOracleComp.PlantedState (List Bool).

  • Once state.hasCaptured = true, all subsequent queries return [] without calling the external CI encryption oracle and leave state unchanged.
  • While state.hasCaptured = false, a decryption query (true, ct) is answered with [] (reject); it captures ⟨0, true, ct⟩ if state.rem == 0 and otherwise steps to ⟨state.rem - 1, false, []⟩. So the countdown runs over decryption queries only, and starting from rem = j captures the decryption query with zero-based index j.
  • While state.hasCaptured = false, an encryption query (false, req) with (unframe req).length == n && (dropFrame req).length == n queries the external CI encryption oracle on if bit then dropFrame req else unframe req (truncating the reply to its first ctBound bits), and any other encryption query returns []; neither changes state.
noncomputable def Cslib.Crypto.SymmetricCipher.ccaToCIAtIndexAdversary (ctBound : ℕ → ℕ) (j : ℕ) (bit : Bool) (adversary : CCAAdversary) :

Deterministic-index ciphertext-integrity reduction at decryption-query index j ([BS23], Section 9.2.3, Theorem 9.1): run adversary n [] against ccaToCIHandler n (ctBound n) bit starting from ProbOracleComp.PlantedState.init j [] and output the captured ciphertext candidate out.2.candidate, which is the decryption query with zero-based index j when there is one and [] otherwise.

noncomputable def Cslib.Crypto.SymmetricCipher.ccaToCIAdversary (ctBound Qd : ℕ → ℕ) (bit : Bool) (adversary : CCAAdversary) :

Reduction from decryption-oracle forgery in ccaRejectGame to the ciphertext-integrity game ciGame for fixed challenge bit bit ([BS23], Section 9.2.3, adversary $B_{\mathrm{ci}}$ in Theorem 9.1): for a decryption-query budget Qd, sample a decryption-query index uniformly from {0, ..., dyadicSize (Qd n - 1) - 1} with ProbOracleComp.sample (ProbComp.sampleDyadicIndex (Qd n - 1)) and run ccaToCIAtIndexAdversary ctBound j bit adversary. The book samples from {1, ..., Qd}; with fair coins a fixed-time sampler draws from a power-of-two range, and dyadicSize (Qd - 1) is the least power of two that is at least Qd when 2 ≤ Qd.

noncomputable def Cslib.Crypto.SymmetricCipher.ccaToCIHiddenBitAdversary (ctBound Qd : ℕ → ℕ) (adversary : CCAAdversary) :

Single-adversary ciphertext-integrity reduction that samples a hidden challenge bit uniformly via BitString.sampleList 1 and invokes ccaToCIAdversary ([BS23], Section 9.2.3, proof of Theorem 9.1, printed p. 364).

Difference-Lemma Hop and Query-Budget Induction for Theorem 9.1 #

The argument is the same for the full-query and the one-time games, so it is proved for an admission policy allow and instantiated at fun _ => true here and at List.isEmpty in the one-time section below.

theorem Cslib.Crypto.SymmetricCipher.advantage_ccaGame_ccaRejectGame_le_sum (E : SymmetricCipher) (ctBound Qd : ℕ → ℕ) (adversary : CCAAdversary) (bit : Bool) (n : ℕ) (hq : IsDecryptionQueryBounded (adversary n []) (Qd n)) (hctBound : E.CiphertextLengthLE n (ctBound n)) :
↑(Game.advantage (E.ccaGame adversary bit n).eval (E.ccaRejectGame adversary bit n).eval) ≤ ∑ j ∈ Finset.range (Qd n), ↑(Game.succProbability (E.ciGame (ccaToCIAtIndexAdversary ctBound j bit adversary) n).eval)

Decryption-rejection hop. If a CCA adversary makes at most Qd n decryption queries and ctBound n bounds the ciphertext lengths of n-bit messages, its advantage between ccaGame and ccaRejectGame (which rejects every decryption query) at bit bit is at most the sum over j < Qd n of the CI winning probabilities of ccaToCIAtIndexAdversary ctBound j bit adversary ([BS23], Section 9.2.3, the bound $|\Pr[W_0] - \Pr[W_1]| \leq \Pr[Z]$ in the proof of Theorem 9.1, printed p. 364, for a fixed bit). Use it with sum_succProbability_ccaToCIAtIndexAdversary_le to remove the decryption oracle from a reduction to CiphertextIntegrity.

theorem Cslib.Crypto.SymmetricCipher.eval_ciGame_ccaToCIAdversary (E : SymmetricCipher) (ctBound Qd : ℕ → ℕ) (bit : Bool) (adversary : CCAAdversary) (n : ℕ) :
(E.ciGame (ccaToCIAdversary ctBound Qd bit adversary) n).eval = (Probability.PMF.uniformOfFintype (Fin (Probability.dyadicSize (Qd n - 1)))).bind fun (i : Fin (Probability.dyadicSize (Qd n - 1))) => (E.ciGame (ccaToCIAtIndexAdversary ctBound (↑i) bit adversary) n).eval

Running ccaToCIAdversary in ciGame averages ccaToCIAtIndexAdversary uniformly over Fin (dyadicSize (Qd n - 1)).

theorem Cslib.Crypto.SymmetricCipher.sum_succProbability_ccaToCIAtIndexAdversary_le (E : SymmetricCipher) (ctBound Qd : ℕ → ℕ) (bit : Bool) (adversary : CCAAdversary) (n : ℕ) :
∑ j ∈ Finset.range (Qd n), ↑(Game.succProbability (E.ciGame (ccaToCIAtIndexAdversary ctBound j bit adversary) n).eval) ≤ ↑(Probability.dyadicSize (Qd n - 1)) * ↑(Game.succProbability (E.ciGame (ccaToCIAdversary ctBound Qd bit adversary) n).eval)

The sum of CI winning probabilities over the decryption-query indices j < Qd n is at most dyadicSize (Qd n - 1) times the CI winning probability of the single adversary ccaToCIAdversary, which samples the index uniformly below dyadicSize (Qd n - 1) ≥ Qd n. Use it after advantage_ccaGame_ccaRejectGame_le_sum to bound the decryption-rejection hop by one CI adversary.

theorem Cslib.Crypto.SymmetricCipher.advantage_ccaGame_le (E : SymmetricCipher) (ctBound Qd : ℕ → ℕ) (adversary : CCAAdversary) (n : ℕ) (hq : IsDecryptionQueryBounded (adversary n []) (Qd n)) (hctBound : E.CiphertextLengthLE n (ctBound n)) :
↑(Game.advantage (E.ccaGame adversary false n).eval (E.ccaGame adversary true n).eval) ≤ ↑(Probability.dyadicSize (Qd n - 1)) * ↑(Game.succProbability (E.ciGame (ccaToCIAdversary ctBound Qd false adversary) n).eval) + ↑(Game.advantage (E.cpaGame (ccaToCPAAdversary ctBound adversary) false n).eval (E.cpaGame (ccaToCPAAdversary ctBound adversary) true n).eval) + ↑(Probability.dyadicSize (Qd n - 1)) * ↑(Game.succProbability (E.ciGame (ccaToCIAdversary ctBound Qd true adversary) n).eval)

Quantitative AE $\Rightarrow$ CCA bound with one CI adversary per bit ([BS23], Section 9.2.3, Theorem 9.1, printed pp. 363–365): for any CCAAdversary making at most Qd n decryption queries at security parameter n, the adaptive CCA distinguishing advantage is bounded by the CPA advantage of ccaToCPAAdversary plus dyadicSize (Qd n - 1) times the ciphertext-integrity winning probabilities of ccaToCIAdversary for bit = false and bit = true.

theorem Cslib.Crypto.SymmetricCipher.eval_ciGame_ccaToCIHiddenBitAdversary (E : SymmetricCipher) (ctBound Qd : ℕ → ℕ) (adversary : CCAAdversary) (n : ℕ) :
(E.ciGame (ccaToCIHiddenBitAdversary ctBound Qd adversary) n).eval = (Probability.PMF.uniformOfFintype Bool).bind fun (bit : Bool) => (E.ciGame (ccaToCIAdversary ctBound Qd bit adversary) n).eval

Running ccaToCIHiddenBitAdversary in ciGame averages ccaToCIAdversary uniformly over bit : Bool.

theorem Cslib.Crypto.SymmetricCipher.advantage_ccaGame_le_two_mul (E : SymmetricCipher) (ctBound Qd : ℕ → ℕ) (adversary : CCAAdversary) (n : ℕ) (hq : IsDecryptionQueryBounded (adversary n []) (Qd n)) (hctBound : E.CiphertextLengthLE n (ctBound n)) :
↑(Game.advantage (E.ccaGame adversary false n).eval (E.ccaGame adversary true n).eval) ≤ ↑(Game.advantage (E.cpaGame (ccaToCPAAdversary ctBound adversary) false n).eval (E.cpaGame (ccaToCPAAdversary ctBound adversary) true n).eval) + 2 * ↑(Probability.dyadicSize (Qd n - 1)) * ↑(Game.succProbability (E.ciGame (ccaToCIHiddenBitAdversary ctBound Qd adversary) n).eval)

Quantitative AE $\Rightarrow$ CCA bound ([BS23], Section 9.2.3, Theorem 9.1, equation (9.3), printed p. 363): for any CCAAdversary making at most Qd n decryption queries at security parameter n, CCAadv ≤ CPAadv[ccaToCPAAdversary] + 2 * dyadicSize (Qd n - 1) * CIadv[ccaToCIHiddenBitAdversary]. The book's factor 2 Qd becomes 2 * dyadicSize (Qd n - 1): ccaToCIHiddenBitAdversary draws its decryption-query index uniformly from fair coins, so the range is 2 when Qd n ≤ 1, and otherwise the least power of two that is at least Qd n (at most 2 * Qd n once Qd n ≥ 1).

theorem Cslib.Crypto.SymmetricCipher.guessingAdvantage_guessBit_ccaGame_le (E : SymmetricCipher) (ctBound Qd : ℕ → ℕ) (adversary : CCAAdversary) (n : ℕ) (hq : IsDecryptionQueryBounded (adversary n []) (Qd n)) (hctBound : E.CiphertextLengthLE n (ctBound n)) :

Bit-guessing AE $\Rightarrow$ CCA bound ([BS23], Section 9.2.3, Theorem 9.1, equation (9.4), printed p. 364): for any CCAAdversary making at most Qd n decryption queries at security parameter n, CCAadv* ≤ CPAadv*[ccaToCPAAdversary] + dyadicSize (Qd n - 1) * CIadv[ccaToCIHiddenBitAdversary], where the starred advantages are the guessing advantages of the bit-guessing games Experiment.guessBit. The book's factor Qd becomes dyadicSize (Qd n - 1), which is 2 when Qd n ≤ 1, and otherwise the least power of two that is at least Qd n, because the CI adversary draws its index uniformly from fair coins.

theorem Cslib.Crypto.SymmetricCipher.guessingAdvantage_guessBit_ccaGame_le_two_mul (E : SymmetricCipher) (ctBound Qd : ℕ → ℕ) (adversary : CCAAdversary) (n : ℕ) (hq : IsDecryptionQueryBounded (adversary n []) (Qd n)) (hctBound : E.CiphertextLengthLE n (ctBound n)) :
↑(Game.guessingAdvantage (ProbComp.eval (Experiment.guessBit fun (b : Bool) => E.ccaGame adversary b n))) ≤ ↑(Game.guessingAdvantage (ProbComp.eval (Experiment.guessBit fun (b : Bool) => E.cpaGame (ccaToCPAAdversary ctBound adversary) b n))) + 2 * ↑(Qd n) * ↑(Game.succProbability (E.ciGame (ccaToCIHiddenBitAdversary ctBound Qd adversary) n).eval)

Bit-guessing AE $\Rightarrow$ CCA bound with factor 2 * Qd: equation (9.4) of [BS23], Theorem 9.1 (printed p. 364), with the book's factor Qd replaced by 2 * Qd n, CCAadv* ≤ CPAadv*[ccaToCPAAdversary] + 2 * Qd n * CIadv[ccaToCIHiddenBitAdversary]. For Qd n ≥ 1 this follows from guessingAdvantage_guessBit_ccaGame_le and dyadicSize (Qd n - 1) ≤ 2 * Qd n. For Qd n = 0 that factor is 2, so the proof uses instead that an adversary without decryption queries has the same advantage in ccaGame as in ccaRejectGame.

Authenticated encryption implies adaptive CCA security ([BS23], Section 9.2.3, Theorem 9.1, printed pp. 363–365): every symmetric cipher satisfying AuthenticatedEncryption (INDCPA ∧ CiphertextIntegrity) also satisfies INDCCA.

Encryption-Query Preservation for Theorem 9.1 Reductions #

Encryption-query preservation for ccaToCPAAdversary ([BS23], Section 9.2.3, Theorem 9.1, printed p. 363): if adversary n [] makes at most Qe encryption queries, then ccaToCPAAdversary ctBound adversary n aux makes at most Qe CPA encryption queries.

theorem Cslib.Crypto.SymmetricCipher.isQueryBounded_ccaToCPAAdversary (ctBound : ℕ → ℕ) (adversary : CCAAdversary) (n : ℕ) (aux : List Bool) {Q : ℕ} (hq : ProbOracleComp.IsQueryBounded (adversary n []) Q) :

If adversary n [] makes at most Q total oracle queries, then ccaToCPAAdversary ctBound adversary n aux makes at most Q CPA encryption queries.

theorem Cslib.Crypto.SymmetricCipher.isQueryBounded_ccaToCIAtIndexAdversary_of_isEncryptionQueryBounded (ctBound : ℕ → ℕ) (j : ℕ) (bit : Bool) (adversary : CCAAdversary) (n : ℕ) (aux : List Bool) {Qe : ℕ} (hq : IsEncryptionQueryBounded (adversary n []) Qe) :
ProbOracleComp.IsQueryBounded (ccaToCIAtIndexAdversary ctBound j bit adversary n aux) Qe

Encryption-query preservation for ccaToCIAtIndexAdversary ([BS23], Section 9.2.3, Theorem 9.1, printed p. 363): if adversary n [] makes at most Qe encryption queries, then ccaToCIAtIndexAdversary ctBound j bit adversary n aux makes at most Qe CI encryption queries.

theorem Cslib.Crypto.SymmetricCipher.isQueryBounded_ccaToCIAtIndexAdversary (ctBound : ℕ → ℕ) (j : ℕ) (bit : Bool) (adversary : CCAAdversary) (n : ℕ) (aux : List Bool) {Q : ℕ} (hq : ProbOracleComp.IsQueryBounded (adversary n []) Q) :
ProbOracleComp.IsQueryBounded (ccaToCIAtIndexAdversary ctBound j bit adversary n aux) Q

If adversary n [] makes at most Q total oracle queries, then ccaToCIAtIndexAdversary ctBound j bit adversary n aux makes at most Q CI encryption queries.

theorem Cslib.Crypto.SymmetricCipher.isQueryBounded_ccaToCIAdversary_of_isEncryptionQueryBounded (ctBound Qd : ℕ → ℕ) (bit : Bool) (adversary : CCAAdversary) (n : ℕ) (aux : List Bool) {Qe : ℕ} (hq : IsEncryptionQueryBounded (adversary n []) Qe) :
ProbOracleComp.IsQueryBounded (ccaToCIAdversary ctBound Qd bit adversary n aux) Qe

Encryption-query preservation for ccaToCIAdversary ([BS23], Section 9.2.3, Theorem 9.1, printed p. 363): if adversary n [] makes at most Qe encryption queries, then ccaToCIAdversary ctBound Qd bit adversary n aux makes at most Qe CI encryption queries.

theorem Cslib.Crypto.SymmetricCipher.isQueryBounded_ccaToCIAdversary (ctBound Qd : ℕ → ℕ) (bit : Bool) (adversary : CCAAdversary) (n : ℕ) (aux : List Bool) {Q : ℕ} (hq : ProbOracleComp.IsQueryBounded (adversary n []) Q) :
ProbOracleComp.IsQueryBounded (ccaToCIAdversary ctBound Qd bit adversary n aux) Q

If adversary n [] makes at most Q total oracle queries, then ccaToCIAdversary ctBound Qd bit adversary n aux makes at most Q CI encryption queries.

Encryption-query preservation for ccaToCIHiddenBitAdversary ([BS23], Section 9.2.3, Theorem 9.1, printed p. 363): if adversary n [] makes at most Qe encryption queries, then ccaToCIHiddenBitAdversary ctBound Qd adversary n aux makes at most Qe CI encryption queries.

theorem Cslib.Crypto.SymmetricCipher.isQueryBounded_ccaToCIHiddenBitAdversary (ctBound Qd : ℕ → ℕ) (adversary : CCAAdversary) (n : ℕ) (aux : List Bool) {Q : ℕ} (hq : ProbOracleComp.IsQueryBounded (adversary n []) Q) :

If adversary n [] makes at most Q total oracle queries, then ccaToCIHiddenBitAdversary ctBound Qd adversary n aux makes at most Q CI encryption queries.

One-Time Authenticated Encryption Implies One-Time CCA Security (Boneh–Shoup Theorem 9.1) #

Hybrid two-channel oracle for the one-time Game 1 in the proof of [BS23], Theorem 9.1 (Section 9.2.3, printed pp. 363–364): encryption queries (false, req) behave identically to oneTimeCCAOracle, whereas every decryption query (true, _) immediately returns [] (rejection) without invoking decrypt.

The one-time all-reject hybrid CCA experiment (one-time Game 1 in [BS23], Section 9.2.3, Theorem 9.1): sample k ← E.keyGen n and run adversary n [] against E.oneTimeCCARejectOracle n k bit.

theorem Cslib.Crypto.SymmetricCipher.eval_cpaOneTimeGame_ccaToCPAAdversary (E : SymmetricCipher) (ctBound : ℕ → ℕ) (adversary : CCAAdversary) (bit : Bool) (n : ℕ) (hctBound : E.CiphertextLengthLE n (ctBound n)) :
(E.cpaOneTimeGame (ccaToCPAAdversary ctBound adversary) bit n).eval = (E.ccaOneTimeRejectGame adversary bit n).eval

When ctBound n bounds all ciphertext lengths produced by E.encrypt n k on n-bit messages, running ccaToCPAAdversary ctBound adversary in cpaOneTimeGame has the exact same output distribution as ccaOneTimeRejectGame adversary ([BS23], Section 9.2.3, Theorem 9.1).

theorem Cslib.Crypto.SymmetricCipher.eval_ciOneTimeGame_ccaToCIAdversary (E : SymmetricCipher) (ctBound Qd : ℕ → ℕ) (bit : Bool) (adversary : CCAAdversary) (n : ℕ) :
(E.ciOneTimeGame (ccaToCIAdversary ctBound Qd bit adversary) n).eval = (Probability.PMF.uniformOfFintype (Fin (Probability.dyadicSize (Qd n - 1)))).bind fun (i : Fin (Probability.dyadicSize (Qd n - 1))) => (E.ciOneTimeGame (ccaToCIAtIndexAdversary ctBound (↑i) bit adversary) n).eval

Running ccaToCIAdversary in ciOneTimeGame averages ccaToCIAtIndexAdversary uniformly over Fin (dyadicSize (Qd n - 1)).

theorem Cslib.Crypto.SymmetricCipher.advantage_ccaOneTimeGame_le (E : SymmetricCipher) (ctBound Qd : ℕ → ℕ) (adversary : CCAAdversary) (n : ℕ) (hq : IsDecryptionQueryBounded (adversary n []) (Qd n)) (hctBound : E.CiphertextLengthLE n (ctBound n)) :
↑(Game.advantage (E.ccaOneTimeGame adversary false n).eval (E.ccaOneTimeGame adversary true n).eval) ≤ ↑(Probability.dyadicSize (Qd n - 1)) * ↑(Game.succProbability (E.ciOneTimeGame (ccaToCIAdversary ctBound Qd false adversary) n).eval) + ↑(Game.advantage (E.cpaOneTimeGame (ccaToCPAAdversary ctBound adversary) false n).eval (E.cpaOneTimeGame (ccaToCPAAdversary ctBound adversary) true n).eval) + ↑(Probability.dyadicSize (Qd n - 1)) * ↑(Game.succProbability (E.ciOneTimeGame (ccaToCIAdversary ctBound Qd true adversary) n).eval)

Quantitative 1AE $\Rightarrow$ 1CCA bound ([BS23], Section 9.2.3, Theorem 9.1, printed pp. 363–365): for any CCAAdversary making at most Qd n decryption queries at security parameter n, the one-time CCA distinguishing advantage in ccaOneTimeGame is bounded by the one-time CPA advantage of ccaToCPAAdversary in cpaOneTimeGame plus dyadicSize (Qd n - 1) times the one-time ciphertext-integrity winning probabilities of ccaToCIAdversary in ciOneTimeGame for bit = false and bit = true.

theorem Cslib.Crypto.SymmetricCipher.advantage_ccaOneTimeGame_le_two_mul (E : SymmetricCipher) (ctBound Qd : ℕ → ℕ) (adversary : CCAAdversary) (n : ℕ) (hq : IsDecryptionQueryBounded (adversary n []) (Qd n)) (hctBound : E.CiphertextLengthLE n (ctBound n)) :
↑(Game.advantage (E.ccaOneTimeGame adversary false n).eval (E.ccaOneTimeGame adversary true n).eval) ≤ ↑(Game.advantage (E.cpaOneTimeGame (ccaToCPAAdversary ctBound adversary) false n).eval (E.cpaOneTimeGame (ccaToCPAAdversary ctBound adversary) true n).eval) + 2 * ↑(Probability.dyadicSize (Qd n - 1)) * ↑(Game.succProbability (E.ciOneTimeGame (ccaToCIHiddenBitAdversary ctBound Qd adversary) n).eval)

Single-adversary quantitative 1AE $\Rightarrow$ 1CCA bound ([BS23], Section 9.2.3, Theorem 9.1, equation (9.3) for one-time security, printed pp. 363–364): for any CCAAdversary making at most Qd n decryption queries, the one-time games satisfy 1CCAadv ≤ 1CPAadv + 2 * dyadicSize (Qd n - 1) * 1CIadv, where the CPA and CI adversaries are ccaToCPAAdversary and ccaToCIHiddenBitAdversary. As in advantage_ccaGame_le_two_mul, the book's factor 2 Qd becomes 2 * dyadicSize (Qd n - 1) because the CI adversary samples its index from fair coins.

theorem Cslib.Crypto.SymmetricCipher.guessingAdvantage_guessBit_ccaOneTimeGame_le (E : SymmetricCipher) (ctBound Qd : ℕ → ℕ) (adversary : CCAAdversary) (n : ℕ) (hq : IsDecryptionQueryBounded (adversary n []) (Qd n)) (hctBound : E.CiphertextLengthLE n (ctBound n)) :

Bit-guessing 1AE $\Rightarrow$ 1CCA bound ([BS23], Section 9.2.3, Theorem 9.1, equation (9.4) for one-time security, printed p. 364): for any CCAAdversary making at most Qd n decryption queries, 1CCAadv* ≤ 1CPAadv*[ccaToCPAAdversary] + dyadicSize (Qd n - 1) * 1CIadv[ccaToCIHiddenBitAdversary], where the starred advantages are the guessing advantages of the bit-guessing one-time games Experiment.guessBit. The book's factor Qd becomes dyadicSize (Qd n - 1) as in guessingAdvantage_guessBit_ccaGame_le.

One-time authenticated encryption implies one-time adaptive CCA security ([BS23], Section 9.2.3, Theorem 9.1, printed pp. 363–365): every symmetric cipher satisfying OneTimeAuthenticatedEncryption (OneTimeINDCPA ∧ OneTimeCiphertextIntegrity, Definition 9.4) also satisfies OneTimeINDCCA (1CCA, Definition 9.6).