Documentation

CslibFrontier.Crypto.Computational.Encryption.Hybrid.DEMCCA

The symmetric-cipher leg of hybrid CCA security #

This intermediate experiment uses the symmetric cipher's actual key distribution. Its distinguished encapsulation component is redirected to that key before and after the challenge. Its security is the DEM hop of [BS23], Exercise 12.5(a): a step toward that exercise, not the exercise itself. Cslib.Crypto.Encryption.hybrid_indcca2On adds the two KEM hops. On the DEM side, SymmetricCipher.ctSpace models the ciphertext space C and OneTimeINDCCA answers decryption queries outside C with the rejection [] (decrypt_eq_none_of_ctSpace_eq_false), so on an efficiently recognizable C it matches Attack Game 9.2 (Definition 9.6, printed pp. 362–363). On the KEM side, ctSpace models the KEM ciphertext space C_kem, while the full exercise stays open because the KEM games give pk to the distinguisher (#5293).

Main definitions #

Main results #

References #

noncomputable def Cslib.Crypto.Encryption.hybridDEMGame (E : SymmetricCipher) (ctSpace : ℕ → List Bool → Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encaps : ℕ → List Bool → ProbComp (List Bool × List Bool)) (decaps : ℕ → List Bool → List Bool → Option (List Bool)) (adversary : WordCCA2Adversary) (bit : Bool) (n : ℕ) :

The DEM intermediate game. Original KEM keys and encapsulation retain their joint law; the independently sampled DEM key is used for the distinguished component in both phases when that component lies in ctSpace. The source symmetric experiment admits n-bit challenge messages.

noncomputable def Cslib.Crypto.Encryption.hybridDEMHandler (E : SymmetricCipher) (ctSpace : ℕ → List Bool → Bool) (decaps : ℕ → List Bool → List Bool → Option (List Bool)) (decBound : ℕ → List Bool → ℕ) (n : ℕ) (sk ctK : List Bool) (request : Unit × List Bool) :

Forward only canonical ciphertexts whose KEM component lies in ctSpace and equals the distinguished KEM component. All other in-space canonical ciphertexts use local decapsulation and decryption. A bounded raw reply preserves the distinction between rejection ([]) and a successful empty message ([true]).

noncomputable def Cslib.Crypto.Encryption.hybridDEMContinuation (E : SymmetricCipher) (ctSpace : ℕ → List Bool → Bool) (decaps : ℕ → List Bool → List Bool → Option (List Bool)) (ctBound : ℕ → ℕ) (decBound : ℕ → List Bool → ℕ) (adversary : WordCCA2Adversary) (n : ℕ) (pk sk ctK : List Bool) :

Both CCA phases for fixed original KEM keys and encapsulation. The hidden symmetric key is owned by the external oracle and is never an argument to this continuation.

noncomputable def Cslib.Crypto.Encryption.hybridToOneTimeCCAAdversary (E : SymmetricCipher) (ctSpace : ℕ → List Bool → Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encaps : ℕ → List Bool → ProbComp (List Bool × List Bool)) (decaps : ℕ → List Bool → List Bool → Option (List Bool)) (ctBound : ℕ → ℕ) (decBound : ℕ → List Bool → ℕ) (adversary : WordCCA2Adversary) :

Simulate both public-key CCA phases, making exactly one valid symmetric encryption query when the selected messages have length n. In particular, an empty encryption reply is a legitimate ciphertext, not a rejection marker. The original encapsulated key is not exposed.

theorem Cslib.Crypto.Encryption.run_hybridDEMHandler_before (E : SymmetricCipher) (ctSpace : ℕ → List Bool → Bool) (decaps : ℕ → List Bool → List Bool → Option (List Bool)) (decBound : ℕ → List Bool → ℕ) (n : ℕ) (sk ctK k : List Bool) (bit : Bool) (hbound : ∀ (ct : List Bool), ((Turing.MultiTapeTM.encOption Turing.MultiTapeTM.encBits) (E.decrypt n k ct)).length ≤ decBound n ct) (request : Unit × List Bool) :
(OracleComp.interpret (OracleComp.sumHandler (fun (m : ℕ) => StateT.lift (ProbComp.unifFin m)) (E.oneTimeCCAOracle n k bit)) (hybridDEMHandler E ctSpace decaps decBound n sk ctK request)).run [] = pure ((Turing.MultiTapeTM.encOption Turing.MultiTapeTM.encBits) (hybridDecrypt ctSpace (fun (n : ℕ) (sk ct : List Bool) => if (ct == ctK) = true then some k else decaps n sk ct) E.decrypt n sk request.2), [])

Before the challenge, the distinguished component uses the hidden DEM key when in ctSpace, including queries made before the adversary has selected its messages.

theorem Cslib.Crypto.Encryption.run_hybridDEMHandler_after (E : SymmetricCipher) (ctSpace : ℕ → List Bool → Bool) (decaps : ℕ → List Bool → List Bool → Option (List Bool)) (decBound : ℕ → List Bool → ℕ) (n : ℕ) (sk ctK k ctD : List Bool) (bit : Bool) (hbound : ∀ (ct : List Bool), ((Turing.MultiTapeTM.encOption Turing.MultiTapeTM.encBits) (E.decrypt n k ct)).length ≤ decBound n ct) (request : Unit × List Bool) :
(OracleComp.interpret (OracleComp.sumHandler (fun (m : ℕ) => StateT.lift (ProbComp.unifFin m)) (E.oneTimeCCAOracle n k bit)) (hybridDEMHandler E ctSpace decaps decBound n sk ctK request)).run [ctD] = pure (if (request.2 == (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) (ctK, ctD)) = true then [] else (Turing.MultiTapeTM.encOption Turing.MultiTapeTM.encBits) (hybridDecrypt ctSpace (fun (n : ℕ) (sk ct : List Bool) => if (ct == ctK) = true then some k else decaps n sk ct) E.decrypt n sk request.2), [ctD])

After the challenge, symmetric challenge rejection agrees with exact hybrid-word rejection. Canonical framing and ctSpace membership are checked before reaching the symmetric oracle.

theorem Cslib.Crypto.Encryption.eval_hybridDEMGame (E : SymmetricCipher) (ctSpace : ℕ → List Bool → Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encaps : ℕ → List Bool → ProbComp (List Bool × List Bool)) (decaps : ℕ → List Bool → List Bool → Option (List Bool)) (ctBound : ℕ → ℕ) (decBound : ℕ → List Bool → ℕ) (adversary : WordCCA2Adversary) (bit : Bool) (n : ℕ) (hct : E.CiphertextLengthLE n (ctBound n)) (hdec : ∀ k ∈ (E.keyGen n).eval.support, ∀ (ct : List Bool), ((Turing.MultiTapeTM.encOption Turing.MultiTapeTM.encBits) (E.decrypt n k ct)).length ≤ decBound n ct) :
(hybridDEMGame E ctSpace keyGen encaps decaps adversary bit n).eval = (E.ccaOneTimeGame (hybridToOneTimeCCAAdversary E ctSpace keyGen encaps decaps ctBound decBound adversary) bit n).eval

Exact, loss-one DEM game identity. Bounds apply only to keys in the actual symmetric key sampler's support and to valid n-bit encryption inputs. Neither uniform encoded keys nor KEM correctness is assumed for this intermediate-game identity.

Native bounded-read implementation of the canonical forwarding handler.

theorem Cslib.Crypto.Encryption.isOraclePPTOn_hybridDEMContinuation (E : SymmetricCipher) {ctSpace : ℕ → List Bool → Bool} (hctSpace : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : ℕ × List Bool) => ctSpace p.1 p.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBool) {decaps : ℕ → List Bool → List Bool → Option (List Bool)} (hdecaps : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : ℕ × List Bool × List Bool) => decaps p.1 p.2.1 p.2.2) (encKeyedInput Turing.MultiTapeTM.encBits) (Turing.MultiTapeTM.encOption Turing.MultiTapeTM.encBits)) {ctBound : ℕ → ℕ} (hctBound : Turing.MultiTapeTM.ComputableInPolyTime ctBound Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) {decBound : ℕ → List Bool → ℕ} (hdecBound : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : ℕ × List Bool) => decBound p.1 p.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encUnary) {adversary : WordCCA2Adversary} (hA : adversary.IsPPT) {α : Type} {input : α ↪ List Bool} {n : α → ℕ} {pk sk ctK : α → List Bool} (hn : Turing.MultiTapeTM.ComputableInPolyTime n input Turing.MultiTapeTM.encUnary) (hpk : Turing.MultiTapeTM.ComputableInPolyTime pk input Turing.MultiTapeTM.encBits) (hsk : Turing.MultiTapeTM.ComputableInPolyTime sk input Turing.MultiTapeTM.encBits) (hctK : Turing.MultiTapeTM.ComputableInPolyTime ctK input Turing.MultiTapeTM.encBits) :
Probability.IsOraclePPTOn input Turing.MultiTapeTM.encBool fun (a : α) => hybridDEMContinuation E ctSpace decaps ctBound decBound adversary (n a) (pk a) (sk a) (ctK a)

Native implementation of both phases with a captured KEM environment. External replies are read only up to the supplied unary-computable limits.

theorem Cslib.Crypto.Encryption.isOraclePPT_hybridToOneTimeCCAAdversary (E : SymmetricCipher) {ctSpace : ℕ → List Bool → Bool} {keyGen : ℕ → ProbComp (List Bool × List Bool)} {encaps : ℕ → List Bool → ProbComp (List Bool × List Bool)} {decaps : ℕ → List Bool → List Bool → Option (List Bool)} (hctSpace : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : ℕ × List Bool) => ctSpace p.1 p.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBool) (hkeyGen : Probability.IsPPTOn Turing.MultiTapeTM.encUnary (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) keyGen) (hencaps : Probability.IsPPTOn (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) fun (p : ℕ × List Bool) => encaps p.1 p.2) (hdecaps : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : ℕ × List Bool × List Bool) => decaps p.1 p.2.1 p.2.2) (encKeyedInput Turing.MultiTapeTM.encBits) (Turing.MultiTapeTM.encOption Turing.MultiTapeTM.encBits)) {ctBound : ℕ → ℕ} (hctBound : Turing.MultiTapeTM.ComputableInPolyTime ctBound Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) {decBound : ℕ → List Bool → ℕ} (hdecBound : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : ℕ × List Bool) => decBound p.1 p.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encUnary) {adversary : WordCCA2Adversary} (hA : adversary.IsPPT) :
Probability.IsOraclePPT Turing.MultiTapeTM.encBool (hybridToOneTimeCCAAdversary E ctSpace keyGen encaps decaps ctBound decBound adversary)

The complete reduction is uniform strict oracle PPT. Key generation, encapsulation, ciphertext-space recognition, local decapsulation/decryption, both adaptive phases, and bounded external reads are charged.

One-time symmetric CCA security of E makes the two DEM intermediate games hybridDEMGame indistinguishable with loss one: the DEM hop toward [BS23], Exercise 12.5(a), not the cited result, which also needs the two KEM hops (#5293).

Cslib.Crypto.Encryption.hybrid_indcca2On composes this hop with the two KEM hops. On the KEM side, ctSpace represents C_kem, and hybridDEMGame rejects ciphertexts whose KEM component fails ctSpace. On the DEM side, the source's 1CCA security (Definition 9.6, printed p. 363) rests on Attack Game 9.2, whose decryption queries lie in the ciphertext space C (printed p. 362); here SymmetricCipher.ctSpace represents C, and decrypt_eq_none_of_ctSpace_eq_false forces rejection ([] = encOption encBits none) on words outside C. When E.ctSpace is efficiently recognizable, an adversary can simulate those rejections itself, so OneTimeINDCCA matches the source's 1CCA game on C (ctSpace defaults to fun _ _ => true unless specialized).