Documentation

CslibFrontier.Crypto.Computational.Encryption.MessageRecovery

Message-recovery security from semantic security (Boneh–Shoup §2.2.3) #

A semantically secure cipher is secure against message recovery ([BS23], Section 2.2.3, Attack Game 2.2, p. 18; Definition 2.3 and Theorem 2.7, p. 19). We formalize both the concrete exact advantage identity for a typed symmetric cipher Cipher K M C and the asymptotic theorem for a cipher with message space {0, 1}^{msgLen n}, whose semantic security admits exactly the challenge pairs of two msgLen n-bit messages, together with the uniform strict PPT certificate of the reduction.

Relative to [BS23], §2.2.3, pp. 18–19, this formalization makes two hypotheses explicit:

Main definitions #

Main results #

References #

noncomputable def Cslib.Crypto.Encryption.messageRecoveryExperiment {K M C : Type} (E : Cipher K M C) [Fintype M] [Nonempty M] [DecidableEq M] (sampleKey : ProbComp K) (A : C → ProbComp M) :

Message-recovery attack game ([BS23], Attack Game 2.2, p. 18): sample a uniform message m from M and key k ← sampleKey, encrypt c ← E.encrypt k m, run A c, and win iff mHat == m.

noncomputable def Cslib.Crypto.Encryption.messageRecoveryAdvantage {K M C : Type} (E : Cipher K M C) [Fintype M] [Nonempty M] [DecidableEq M] (sampleKey : ProbComp K) (A : C → ProbComp M) :

Message-recovery advantage MRadv[A, E] := |Pr[W] - 1 / |M|| ([BS23], Attack Game 2.2, p. 18).

noncomputable def Cslib.Crypto.Encryption.messageRecoveryReduction {M C : Type} [BEq M] (sampleMsg : ProbComp M) (A : C → ProbComp M) :

Explicit semantic-security reduction B from a message-recovery adversary A given a message sampler sampleMsg ([BS23], Theorem 2.7, p. 19): sample independent m₀, m₁ ← sampleMsg, submit (m₀, m₁), run mHat ← A c on the challenge ciphertext, and output mHat == m₁. Concrete finite theorems instantiate sampleMsg := ProbComp.uniform M; word-level reductions instantiate sampleMsg := BitString.sampleList (msgLen n).

theorem Cslib.Crypto.Encryption.messageRecoveryAdvantage_eq_advantage_messageRecoveryReduction {K M C : Type} (E : Cipher K M C) [Fintype M] [Nonempty M] [DecidableEq M] (sampleKey : ProbComp K) {valid : M → M → Bool} (hvalid : ∀ (m₀ m₁ : M), valid m₀ m₁ = true) (A : C → ProbComp M) :

Concrete advantage equality for Theorem 2.7 ([BS23], p. 19): MRadv[A, E] = SSadv[messageRecoveryReduction (ProbComp.uniform M) A, E] whenever valid admits every message pair in M. Display (2.5), MRadv[A, E] ≤ SSadv[B, E], is the .le projection of this equality.

noncomputable def Cslib.Crypto.Encryption.messageRecoveryWordExperiment (msgLen keyLen : ℕ → ℕ) (encryptSym : ℕ → List Bool → List Bool → ProbComp (List Bool)) (A : ℕ → List Bool → ProbComp (List Bool)) (n : ℕ) :

Word-level message-recovery experiment over {0, 1}^{msgLen n} with uniform keyLen n-bit keys ([BS23], Attack Game 2.2, p. 18).

noncomputable def Cslib.Crypto.Encryption.messageRecoveryWordAdvantage (msgLen keyLen : ℕ → ℕ) (encryptSym : ℕ → List Bool → List Bool → ProbComp (List Bool)) (A : ℕ → List Bool → ProbComp (List Bool)) (n : ℕ) :

Word-level message-recovery advantage |Pr[W] - 1 / 2^(msgLen n)| ([BS23], Attack Game 2.2, p. 18).

Explicit WordAdversary reduction for message recovery on {0, 1}^{msgLen n} ([BS23], Theorem 2.7, p. 19).

theorem Cslib.Crypto.Encryption.messageRecoveryWordAdvantage_eq_demKeyGameOn (msgLen keyLen : ℕ → ℕ) (encryptSym : ℕ → List Bool → List Bool → ProbComp (List Bool)) (A : ℕ → List Bool → ProbComp (List Bool)) (hA_len : ∀ (n : ℕ) (ct mHat : List Bool), mHat ∈ (A n ct).eval.support → mHat.length = msgLen n) (n : ℕ) :
messageRecoveryWordAdvantage msgLen keyLen encryptSym A n = Game.advantage (demKeyGameOn (fun (n : ℕ) (x m₀ m₁ : List Bool) => m₀.length == msgLen n && m₁.length == msgLen n) keyLen encryptSym (messageRecoveryWordToDEMAdversary msgLen A) false n).eval (demKeyGameOn (fun (n : ℕ) (x m₀ m₁ : List Bool) => m₀.length == msgLen n && m₁.length == msgLen n) keyLen encryptSym (messageRecoveryWordToDEMAdversary msgLen A) true n).eval

Exact word-level advantage equality of the proof of Theorem 2.7 ([BS23], p. 19): MRadv[A, E](n) = SSadv[B, E](n) for B := messageRecoveryWordToDEMAdversary msgLen A, in Attack Game 2.1 with challenge pairs of two msgLen n-bit messages. Derived from the concrete equality messageRecoveryAdvantage_eq_advantage_messageRecoveryReduction over BitString (msgLen n). The length hypothesis hA_len models Attack Game 2.2's requirement mHat ∈ M.

theorem Cslib.Crypto.Encryption.DEMOneTimeKeyINDCPAOn.negligible_messageRecoveryWordAdvantage {msgLen keyLen : ℕ → ℕ} {encryptSym : ℕ → List Bool → List Bool → ProbComp (List Bool)} (hsec : DEMOneTimeKeyINDCPAOn (fun (n : ℕ) (x m₀ m₁ : List Bool) => m₀.length == msgLen n && m₁.length == msgLen n) Turing.MultiTapeTM.encBits keyLen encryptSym) (hmsgLen : Turing.MultiTapeTM.ComputableInPolyTime msgLen Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) {A : ℕ → List Bool → ProbComp (List Bool)} (hA : Probability.IsPPTOn (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBits fun (x : ℕ × List Bool) => match x with | (n, ct) => A n ct) (hA_len : ∀ (n : ℕ) (ct mHat : List Bool), mHat ∈ (A n ct).eval.support → mHat.length = msgLen n) :
Negligible (messageRecoveryWordAdvantage msgLen keyLen encryptSym A)

Theorem 2.7, for the message space {0, 1}^L ([BS23], Section 2.2.3.1, p. 19): a semantically secure cipher is secure against message recovery. The book states Theorem 2.7 for any message space M, but its reduction submits two independent uniform messages, which Attack Game 2.1 admits only when all messages of M have one length, as they do in {0, 1}^L. Here L = msgLen n at security parameter n, with msgLen computable in polynomial time in unary. The premise is semantic security in Attack Game 2.1 (Definition 2.2, p. 16) with a uniform keyLen n-bit key, against uniform strict PPT two-stage adversaries, for exactly the challenge pairs of the message space: two msgLen n-bit messages. The conclusion: every uniform strict PPT adversary A that outputs words of length msgLen n (hA_len, Attack Game 2.2's mHat ∈ M), given 1ⁿ and the ciphertext of a uniform msgLen n-bit message, has negligible advantage |Pr[W] - 1 / 2^(msgLen n)| (messageRecoveryWordAdvantage, Attack Game 2.2 and Definition 2.3, pp. 18–19). The reduction messageRecoveryWordToDEMAdversary is certified by isPPT_messageRecoveryWordToDEMAdversary, and messageRecoveryWordAdvantage_eq_demKeyGameOn is the proof's exact equation.