Documentation

CslibFrontier.Crypto.Computational.Encryption.CCA.Interleaved

Fully adaptive interleaved-query multi-challenge CCA security (Attack Game 12.1) #

Cslib.Crypto.Encryption.CCA2AdversaryOf and Cslib.Crypto.Encryption.MultiCCA2AdversaryOf in CslibFrontier.Crypto.Computational.Encryption.CCA formalize the single-challenge (1CCA, Definition 12.2) and two-phase batch-challenge (Phased Multi-CCA2) chosen-ciphertext security experiments. In full generality, Boneh and Shoup, Section 12.1, Attack Game 12.1, Definition 12.1, and Theorem 12.1, printed pp. 467–469 (see also Katz and Lindell, Section 12.2) allow the adversary to adaptively interleave encryption (challenge) queries and decryption queries in arbitrary order:

Main definitions #

Main results #

The Multiplicative Cramer–Shoup instance Cslib.Crypto.PrimeOrderGroupFamily.DDH.indcca2InterleavedOn_cramerShoup is in CslibFrontier.Crypto.Computational.CramerShoup.Interleaved.

References #

Combined encryption-and-decryption CCA queries and responses #

inductive Cslib.Crypto.Encryption.CCAQuery (Plaintext Ciphertext : Type) :

A single query to the combined interleaved CCA challenger ([BS23], Section 12.1, Attack Game 12.1, printed pp. 467–468): either an encryption / challenge query .challenge m₀ m₁ on a pair of candidate plaintexts, or a decryption query .decrypt c on a candidate ciphertext.

  • challenge {Plaintext Ciphertext : Type} (m₀ m₁ : Plaintext) : CCAQuery Plaintext Ciphertext

    Submit a challenge plaintext pair (m₀, m₁) to the left-or-right encryption oracle.

  • decrypt {Plaintext Ciphertext : Type} (c : Ciphertext) : CCAQuery Plaintext Ciphertext

    Submit a candidate ciphertext c to the decryption oracle.

Instances For
    @[instance_reducible]
    instance Cslib.Crypto.Encryption.instDecidableEqCCAQuery {Plaintext✝ Ciphertext✝ : Type} [DecidableEq Plaintext✝] [DecidableEq Ciphertext✝] :
    DecidableEq (CCAQuery Plaintext✝ Ciphertext✝)
    def Cslib.Crypto.Encryption.instDecidableEqCCAQuery.decEq {Plaintext✝ Ciphertext✝ : Type} [DecidableEq Plaintext✝] [DecidableEq Ciphertext✝] (x✝ x✝¹ : CCAQuery Plaintext✝ Ciphertext✝) :
    Decidable (x✝ = x✝¹)
    def Cslib.Crypto.Encryption.instReprCCAQuery.repr {Plaintext✝ Ciphertext✝ : Type} [Repr Plaintext✝] [Repr Ciphertext✝] :
    CCAQuery Plaintext✝ Ciphertext✝ → ℕ → Std.Format
    @[instance_reducible]
    instance Cslib.Crypto.Encryption.instReprCCAQuery {Plaintext✝ Ciphertext✝ : Type} [Repr Plaintext✝] [Repr Ciphertext✝] :
    Repr (CCAQuery Plaintext✝ Ciphertext✝)
    @[reducible, inline]
    abbrev Cslib.Crypto.Encryption.CCAResponse (Plaintext Ciphertext : Type) :

    Response from the combined interleaved CCA challenger: Sum.inl (some c*) (or Sum.inl none on an inadmissible challenge pair) for an encryption query, and Sum.inr (some m) (or Sum.inr none on decryption rejection or a forbidden challenge ciphertext c ∈ S) for a decryption query.

    Represent a CCAQuery Msg (List Bool) as Option (Msg × Msg) × List Bool, mapping .challenge m₀ m₁ to (some (m₀, m₁), []) and .decrypt c to (none, c).

    def Cslib.Crypto.Encryption.CCAQuery.isChallenge {Plaintext Ciphertext : Type} :
    CCAQuery Plaintext Ciphertext → Bool

    Test whether a CCAQuery is an encryption / challenge query.

    def Cslib.Crypto.Encryption.CCAQuery.challengePair {Plaintext Ciphertext : Type} [Inhabited Plaintext] :
    CCAQuery Plaintext Ciphertext → Plaintext × Plaintext

    Extract the challenge message pair (m₀, m₁) from .challenge m₀ m₁, or (default, default) on .decrypt _.

    Extract the ciphertext c from .decrypt c, or [] on .challenge _ _.

    @[simp]
    theorem Cslib.Crypto.Encryption.CCAQuery.isChallenge_challenge {Plaintext Ciphertext : Type} (m₀ m₁ : Plaintext) :
    @[simp]
    theorem Cslib.Crypto.Encryption.CCAQuery.isChallenge_decrypt {Plaintext Ciphertext : Type} (c : Ciphertext) :
    @[simp]
    theorem Cslib.Crypto.Encryption.CCAQuery.challengePair_challenge {Plaintext Ciphertext : Type} [Inhabited Plaintext] (m₀ m₁ : Plaintext) :
    (challenge m₀ m₁).challengePair = (m₀, m₁)
    @[simp]
    theorem Cslib.Crypto.Encryption.CCAQuery.challengePair_decrypt {Plaintext Ciphertext : Type} [Inhabited Plaintext] (c : Ciphertext) :
    @[simp]
    theorem Cslib.Crypto.Encryption.CCAQuery.decryptCiphertext_challenge {Plaintext : Type} (m₀ m₁ : Plaintext) :

    Injective bit-string encoding of CCAQuery Msg (List Bool) via CCAQuery.toOptionPair and encPair (encOption (encPair encMsg encMsg)) encBits.

    Encode the payload of a CCAResponse Out (List Bool) as an optional bit word (encOption encBits on encryption responses and encOption encOut on decryption responses).

    @[simp]
    theorem Cslib.Crypto.Encryption.encodeCCAResponseWord_inr {Out : Type} (encOut : Out ↪ List Bool) (outOpt : Option Out) :

    Constructing .challenge m₀ m₁ from (m₀, m₁) is computable in plain polynomial time.

    Stateful interleaved CCA oracle (interleavedCcaOracle) #

    @[simp]
    theorem Cslib.Crypto.Encryption.cca2MultiPhase2Oracle_nil {Out : Type} (encOut : Out ↪ List Bool) (decrypt : ℕ → List Bool → List Bool → Option Out) (n : ℕ) (sk : List Bool) :
    cca2MultiPhase2Oracle encOut decrypt n sk [] = cca2Phase1Oracle encOut decrypt n sk

    On the empty challenge-ciphertext list [], cca2MultiPhase2Oracle coincides with the unrestricted Phase 1 decryption oracle cca2Phase1Oracle.

    noncomputable def Cslib.Crypto.Encryption.interleavedCcaOracle {Msg Out : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option Out) (n : ℕ) (pk sk : List Bool) (bit : Bool) (query : CCAQuery Msg (List Bool)) :

    Stateful combined encryption-and-decryption oracle for the interleaved multi-challenge CCA experiment ([BS23], Section 12.1, Attack Game 12.1, printed pp. 467–468), tracking the list S : List (List Bool) of challenge ciphertexts produced so far:

    • On .challenge m₀ m₁: if valid n pk m₀ m₁ holds, encrypt if bit then m₁ else m₀ under pk, prepend the resulting challenge ciphertext ct to S, and return Sum.inl (some ct); otherwise return Sum.inl none with S unchanged.
    • On .decrypt c: if c ∈ S (among challenge ciphertexts generated so far), reject with Sum.inr none and leave S unchanged; otherwise return Sum.inr (decrypt n sk c) with S unchanged.
    noncomputable def Cslib.Crypto.Encryption.interleavedCcaWordOracle {Msg Out : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encOut : Out ↪ List Bool) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option Out) (n : ℕ) (pk sk : List Bool) (bit : Bool) (query : CCAQuery Msg (List Bool)) :

    Word-encoded response wrapper around interleavedCcaOracle, returning the bit-encoded reply encodeCCAResponseWord encOut resp alongside the updated challenge-ciphertext list S'.

    @[simp]
    theorem Cslib.Crypto.Encryption.interleavedCcaOracle_challenge_valid {Msg Out : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option Out) (n : ℕ) (pk sk : List Bool) (bit : Bool) (m₀ m₁ : Msg) (S : List (List Bool)) (hvalid : valid n pk m₀ m₁ = true) :
    interleavedCcaOracle valid encrypt decrypt n pk sk bit (CCAQuery.challenge m₀ m₁) S = do let ct ← encrypt n pk (if bit = true then m₁ else m₀) pure (Sum.inl (some ct), ct :: S)
    @[simp]
    theorem Cslib.Crypto.Encryption.interleavedCcaOracle_challenge_invalid {Msg Out : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option Out) (n : ℕ) (pk sk : List Bool) (bit : Bool) (m₀ m₁ : Msg) (S : List (List Bool)) (hvalid : valid n pk m₀ m₁ = false) :
    interleavedCcaOracle valid encrypt decrypt n pk sk bit (CCAQuery.challenge m₀ m₁) S = pure (Sum.inl none, S)
    @[simp]
    theorem Cslib.Crypto.Encryption.interleavedCcaOracle_decrypt_mem {Msg Out : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option Out) (n : ℕ) (pk sk : List Bool) (bit : Bool) (c : List Bool) (S : List (List Bool)) (hmem : c ∈ S) :
    interleavedCcaOracle valid encrypt decrypt n pk sk bit (CCAQuery.decrypt c) S = pure (Sum.inr none, S)
    @[simp]
    theorem Cslib.Crypto.Encryption.interleavedCcaOracle_decrypt_not_mem {Msg Out : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option Out) (n : ℕ) (pk sk : List Bool) (bit : Bool) (c : List Bool) (S : List (List Bool)) (hmem : c ∉ S) :
    interleavedCcaOracle valid encrypt decrypt n pk sk bit (CCAQuery.decrypt c) S = pure (Sum.inr (decrypt n sk c), S)

    Adaptive interleaved-query multi-challenge CCA adversaries and experiments #

    An adaptive interleaved-query multi-challenge CCA adversary over challenge message space Msg ([BS23], Section 12.1, Attack Game 12.1, printed pp. 467–468):

    • numRounds n is the number of adaptive combined-oracle rounds at security parameter n.
    • In each round, step n pk state lastReply receives the unary security parameter n, the public key pk, the adversary's saved state word state, and the encoded response lastReply from the previous round ([] in round 0), may make adaptive decryption queries against the current forbidden challenge-ciphertext list S, and outputs (query, nextState) : CCAQuery Msg (List Bool) × List Bool, where query is either .challenge m₀ m₁ or .decrypt c.
    • After numRounds n rounds, finish n pk state lastReply receives (n, pk, state, lastReply), may make adaptive decryption queries against the final forbidden list S, and outputs a distinguishing bit Bool.
    @[reducible, inline]

    An adaptive interleaved-query multi-challenge CCA adversary for single-bit messages (Bool).

    @[reducible, inline]

    An adaptive interleaved-query multi-challenge CCA adversary for bit-word messages (List Bool).

    Uniform strict PPT admissibility for an InterleavedCCA2AdversaryOf Msg over message encoding encMsg:

    • numRounds is computable in polynomial time on the unary security parameter n.
    • step is uniformly strict oracle PPT on (n, pk, state, lastReply).
    • finish is uniformly strict oracle PPT on (n, pk, state, lastReply).
    • step_length_le: the encoded (query, nextState) output of step n pk state lastReply is bounded by a polynomial in (n, pk.length) (ensuring that the state passed across polynomially many adaptive rounds remains polynomially bounded without telescope blowup).
    @[reducible, inline]

    Native uniform strict oracle PPT admissibility for a bit interleaved CCA adversary.

    @[reducible, inline]

    Native uniform strict oracle PPT admissibility for a bit-word interleaved CCA adversary.

    Per-stage query bound for an InterleavedCCA2AdversaryOf Msg: at security parameter n, the number of rounds is at most qRounds n, each step call makes at most qStep n inner decryption queries, and finish makes at most qFinish n inner decryption queries.

    @[reducible, inline]

    Loop state (state, lastReply, S) carried between adaptive rounds of interleavedCca2GameOn:

    • state : List Bool is the adversary's saved state word,
    • lastReply : List Bool is the encoded oracle response from the previous round, and
    • S : List (List Bool) is the list of challenge ciphertexts generated so far.
    @[reducible, inline]

    The adversary's saved state word in an InterleavedLoopState.

    @[reducible, inline]

    The encoded oracle response from the previous round in an InterleavedLoopState.

    @[reducible, inline]

    The list of forbidden challenge ciphertexts generated so far in an InterleavedLoopState.

    Initial loop state ([], [], []) before round 0.

    noncomputable def Cslib.Crypto.Encryption.interleavedRoundStep {Msg Out : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encOut : Out ↪ List Bool) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option Out) (adversary : InterleavedCCA2AdversaryOf Msg) (n : ℕ) (pk sk : List Bool) (roundBit : Bool) (st : InterleavedLoopState) :

    One closed adaptive round of the interleaved CCA experiment at challenge bit roundBit:

    1. Run adversary.step n pk st.state st.lastReply against cca2MultiPhase2Oracle encOut decrypt n sk st.forbidden (which rejects any decryption query in the current forbidden challenge set S = st.forbidden).
    2. Execute the returned combined query q : CCAQuery Msg (List Bool) against interleavedCcaWordOracle valid encOut encrypt decrypt n pk sk roundBit q st.forbidden to obtain the encoded response reply and updated forbidden challenge set S'.
    3. Return the updated loop state (state', reply, S').
    noncomputable def Cslib.Crypto.Encryption.interleavedCca2GameOn {Msg Out : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encOut : Out ↪ List Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option Out) (adversary : InterleavedCCA2AdversaryOf Msg) (bit : Bool) (n : ℕ) :

    The fully adaptive interleaved-query multi-challenge CCA experiment ([BS23], Section 12.1, Attack Game 12.1 and Definition 12.1, printed pp. 467–468): sample (pk, sk) ← keyGen n, iterate interleavedRoundStep for adversary.numRounds n rounds from ([], [], []), and run adversary.finish against cca2MultiPhase2Oracle with the final forbidden challenge-ciphertext set S.

    @[reducible, inline]
    noncomputable abbrev Cslib.Crypto.Encryption.interleavedCca2Game {Msg Out : Type} (encOut : Out ↪ List Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option Out) (adversary : InterleavedCCA2AdversaryOf Msg) (bit : Bool) (n : ℕ) :

    Unrestricted interleaved-query multi-challenge CCA experiment (valid := fun _ _ _ _ => true).

    def Cslib.Crypto.Encryption.INDCCA2InterleavedOn {Msg Out : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encMsg : Msg ↪ List Bool) (encOut : Out ↪ List Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option Out) :

    Fully adaptive interleaved-query multi-challenge CCA security ([BS23], Section 12.1, Attack Game 12.1 and Definition 12.1, printed pp. 467–468; [KL20], Section 12.2) with respect to challenge-pair admissibility predicate valid, message encoding encMsg, and decryption output encoding encOut: every round-structured InterleavedCCA2AdversaryOf Msg satisfying InterleavedCCA2AdversaryOf.IsPPT encMsg has negligible advantage between the two experiments of interleavedCca2GameOn.

    @[reducible, inline]
    abbrev Cslib.Crypto.Encryption.INDCCA2InterleavedOf {Msg Out : Type} (encMsg : Msg ↪ List Bool) (encOut : Out ↪ List Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option Out) :

    Unrestricted interleaved-query multi-challenge CCA security (valid := fun _ _ _ _ => true).

    @[reducible, inline]
    abbrev Cslib.Crypto.Encryption.INDCCA2Interleaved (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → Bool → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option Bool) :

    Interleaved-query multi-challenge CCA security for single-bit encryption (Msg = Bool, Out = Bool).

    @[reducible, inline]
    abbrev Cslib.Crypto.Encryption.WordINDCCA2Interleaved (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → List Bool → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option (List Bool)) :

    Interleaved-query multi-challenge CCA security for bit-word encryption (Msg = List Bool, Out = List Bool) under Attack Game 12.1's equal-length challenge rule m₀.length == m₁.length.

    Relationship 1: Interleaved CCA2 implies single-challenge 1CCA and phased Multi-CCA2 #

    Embed a single-challenge CCA2AdversaryOf Msg as a 1-round InterleavedCCA2AdversaryOf Msg ([BS23], Section 12.1, Definition 12.2, printed p. 468):

    • In Round 0 (S = []), step runs adversary.choose n pk (which makes Phase 1 decryption queries against cca2MultiPhase2Oracle ... [] = cca2Phase1Oracle) and submits .challenge (ChoiceOut.msg₀ choice) (ChoiceOut.msg₁ choice) along with the saved state ChoiceOut.state choice.
    • In finish (S = [ct] when valid n pk m₀ m₁ = true), if lastReply begins with true (lastReply = true :: ct), finish runs adversary.guess n state lastReply.tail against cca2MultiPhase2Oracle ... [ct] = cca2Phase2Oracle ... ct; otherwise (lastReply = []), finish returns false.
    theorem Cslib.Crypto.Encryption.isPPT_toInterleaved {Msg : Type} {encMsg : Msg ↪ List Bool} {adversary : CCA2AdversaryOf Msg} (hA : CCA2AdversaryOf.IsPPT encMsg adversary) :

    CCA2AdversaryOf.toInterleaved preserves uniform strict oracle PPT admissibility.

    theorem Cslib.Crypto.Encryption.eval_interleavedCca2GameOn_toInterleaved {Msg Out : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encOut : Out ↪ List Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option Out) (adversary : CCA2AdversaryOf Msg) (bit : Bool) (n : ℕ) :
    (interleavedCca2GameOn valid encOut keyGen encrypt decrypt adversary.toInterleaved bit n).eval = (cca2GameOn valid encOut keyGen encrypt decrypt adversary bit n).eval

    Running interleavedCca2GameOn on adversary.toInterleaved has the exact same output distribution as running cca2GameOn on adversary.

    theorem Cslib.Crypto.Encryption.INDCCA2InterleavedOn.indcca2On {Msg Out : Type} {valid : ℕ → List Bool → Msg → Msg → Bool} {encMsg : Msg ↪ List Bool} {encOut : Out ↪ List Bool} {keyGen : ℕ → ProbComp (List Bool × List Bool)} {encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)} {decrypt : ℕ → List Bool → List Bool → Option Out} (h : INDCCA2InterleavedOn valid encMsg encOut keyGen encrypt decrypt) :
    INDCCA2On valid encMsg encOut keyGen encrypt decrypt

    Interleaved multi-challenge CCA security implies single-challenge 1CCA security ([BS23], Section 12.1, Definition 12.2, printed p. 468).

    theorem Cslib.Crypto.Encryption.INDCCA2InterleavedOn.indcca2MultiOn {Msg Out : Type} [Inhabited Msg] {valid : ℕ → List Bool → Msg → Msg → Bool} {encMsg : Msg ↪ List Bool} {encOut : Out ↪ List Bool} {keyGen : ℕ → ProbComp (List Bool × List Bool)} {encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)} {decrypt : ℕ → List Bool → List Bool → Option Out} (hvalid : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ℕ × List Bool × Msg × Msg) => match x with | (n, pk, m₀, m₁) => valid n pk m₀ m₁) (encChallengePairInput encMsg) Turing.MultiTapeTM.encBool) (hkeyGen : Probability.IsPPTOn Turing.MultiTapeTM.encUnary (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) keyGen) (hencrypt : Probability.IsPPTOn (encKeyedInput encMsg) Turing.MultiTapeTM.encBits fun (x : ℕ × List Bool × Msg) => match x with | (n, pk, m) => encrypt n pk m) (hdecrypt : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ℕ × List Bool × List Bool) => match x with | (n, sk, ct) => decrypt n sk ct) (encKeyedInput Turing.MultiTapeTM.encBits) (Turing.MultiTapeTM.encOption encOut)) (h : INDCCA2InterleavedOn valid encMsg encOut keyGen encrypt decrypt) :
    INDCCA2MultiOn valid encMsg encOut keyGen encrypt decrypt

    Interleaved multi-challenge CCA security implies phased batch-challenge multi-challenge CCA security ([BS23], Section 12.1, Attack Game 12.1 and Theorem 12.1, printed pp. 467–468) whenever valid, keyGen, encrypt, and decrypt are polynomial-time / strict PPT: the proof passes through single-challenge 1CCA security (INDCCA2InterleavedOn.indcca2On) and the hybrid reduction INDCCA2On.indcca2MultiOn.

    Relationship 2: Single-challenge 1CCA implies Interleaved Multi-CCA2 (Theorem 12.1) #

    noncomputable def Cslib.Crypto.Encryption.interleavedHybridGameOn {Msg Out : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encOut : Out ↪ List Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option Out) (adversary : InterleavedCCA2AdversaryOf Msg) (split n : ℕ) :

    Hybrid interleaved CCA experiment at round index split : ℕ ([BS23], Section 12.1, Theorem 12.1, printed p. 468): run the first min split (adversary.numRounds n) rounds with roundBit = true, the remaining adversary.numRounds n - split rounds with roundBit = false, and adversary.finish against the resulting forbidden challenge set S.

    @[simp]
    theorem Cslib.Crypto.Encryption.eval_interleavedHybridGameOn_zero {Msg Out : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encOut : Out ↪ List Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option Out) (adversary : InterleavedCCA2AdversaryOf Msg) (n : ℕ) :
    (interleavedHybridGameOn valid encOut keyGen encrypt decrypt adversary 0 n).eval = (interleavedCca2GameOn valid encOut keyGen encrypt decrypt adversary false n).eval

    At split = 0, interleavedHybridGameOn coincides with interleavedCca2GameOn ... false.

    theorem Cslib.Crypto.Encryption.eval_interleavedHybridGameOn_of_le {Msg Out : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encOut : Out ↪ List Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option Out) (adversary : InterleavedCCA2AdversaryOf Msg) (split n : ℕ) (hle : adversary.numRounds n ≤ split) :
    (interleavedHybridGameOn valid encOut keyGen encrypt decrypt adversary split n).eval = (interleavedCca2GameOn valid encOut keyGen encrypt decrypt adversary true n).eval

    Whenever adversary.numRounds n ≤ split, interleavedHybridGameOn at split coincides with interleavedCca2GameOn ... true.

    noncomputable def Cslib.Crypto.Encryption.interleavedToSingleAt {Msg : Type} [Inhabited Msg] (valid : ℕ → List Bool → Msg → Msg → Bool) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decBound : ℕ → List Bool → ℕ) (adversary : InterleavedCCA2AdversaryOf Msg) (split : ℕ) :

    Single-challenge CCA2AdversaryOf Msg reduction at fixed hybrid round index split : ℕ ([BS23], Section 12.1, Theorem 12.1, printed p. 468):

    • In Phase 1 (choose), if split < adversary.numRounds n, simulate the first split rounds using roundBit = true (interleavedOpenRoundStep ... true), then run adversary.step for round split through multiPhase2FilterHandler: if round split emits .challenge m₀ m₁ with valid n pk m₀ m₁ = true, output ((m₀, m₁), encInterleavedSingleState ⟨true, pk, adversary.numRounds n - 1 - split, state', S⟩); otherwise output rejectInterleavedSingleState.
    • In Phase 2 (guess), if active = true, prepend the external challenge ciphertext ct to S, simulate the remaining remRounds rounds using roundBit = false (interleavedOpenRoundStep ... false) starting from (state', true :: ct, ct :: S), and run adversary.finish through multiPhase2FilterHandler.
    noncomputable def Cslib.Crypto.Encryption.interleavedToSingle {Msg : Type} [Inhabited Msg] (valid : ℕ → List Bool → Msg → Msg → Bool) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decBound : ℕ → List Bool → ℕ) (Q : ℕ → ℕ) (adversary : InterleavedCCA2AdversaryOf Msg) :

    Single-challenge CCA2AdversaryOf Msg reduction that samples a uniform dyadic round index split ← ProbOracleComp.sample (sampleDyadicIndex (Q n)) in Phase 1 and runs interleavedToSingleAt valid encrypt decBound adversary split ([BS23], Section 12.1, Theorem 12.1, printed p. 468).

    theorem Cslib.Crypto.Encryption.isPPT_interleavedToSingleAt {Msg : Type} [Inhabited Msg] {encMsg : Msg ↪ List Bool} {valid : ℕ → List Bool → Msg → Msg → Bool} {encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)} {decBound : ℕ → List Bool → ℕ} {adversary : InterleavedCCA2AdversaryOf Msg} (hvalid : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ℕ × List Bool × Msg × Msg) => match x with | (n, pk, m₀, m₁) => valid n pk m₀ m₁) (encChallengePairInput encMsg) Turing.MultiTapeTM.encBool) (hencrypt : Probability.IsPPTOn (encKeyedInput encMsg) Turing.MultiTapeTM.encBits fun (x : ℕ × List Bool × Msg) => match x with | (n, pk, m) => encrypt n pk m) (hdecBound : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ℕ × List Bool) => match x with | (n, req) => decBound n req) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encUnary) (hA : InterleavedCCA2AdversaryOf.IsPPT encMsg adversary) (split : ℕ) :
    CCA2AdversaryOf.IsPPT encMsg (interleavedToSingleAt valid encrypt decBound adversary split)

    interleavedToSingleAt preserves strict oracle PPT admissibility (CCA2AdversaryOf.IsPPT).

    theorem Cslib.Crypto.Encryption.isPPT_interleavedToSingle {Msg : Type} [Inhabited Msg] {encMsg : Msg ↪ List Bool} {valid : ℕ → List Bool → Msg → Msg → Bool} {encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)} {decBound : ℕ → List Bool → ℕ} {Q : ℕ → ℕ} {adversary : InterleavedCCA2AdversaryOf Msg} (hvalid : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ℕ × List Bool × Msg × Msg) => match x with | (n, pk, m₀, m₁) => valid n pk m₀ m₁) (encChallengePairInput encMsg) Turing.MultiTapeTM.encBool) (hencrypt : Probability.IsPPTOn (encKeyedInput encMsg) Turing.MultiTapeTM.encBits fun (x : ℕ × List Bool × Msg) => match x with | (n, pk, m) => encrypt n pk m) (hdecBound : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ℕ × List Bool) => match x with | (n, req) => decBound n req) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encUnary) (hQ : Turing.MultiTapeTM.ComputableInPolyTime Q Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hA : InterleavedCCA2AdversaryOf.IsPPT encMsg adversary) :
    CCA2AdversaryOf.IsPPT encMsg (interleavedToSingle valid encrypt decBound Q adversary)

    interleavedToSingle preserves strict oracle PPT admissibility (CCA2AdversaryOf.IsPPT).

    theorem Cslib.Crypto.Encryption.interleavedHybridGameOn_step_gap {Msg Out : Type} [Inhabited Msg] (valid : ℕ → List Bool → Msg → Msg → Bool) (encOut : Out ↪ List Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option Out) (decBound : ℕ → List Bool → ℕ) (adversary : InterleavedCCA2AdversaryOf Msg) (split n : ℕ) (hdecBound : ∀ keys ∈ (keyGen n).eval.support, ∀ (req : List Bool), ((Turing.MultiTapeTM.encOption encOut) (decrypt n keys.2 req)).length ≤ decBound n req) :
    ((interleavedHybridGameOn valid encOut keyGen encrypt decrypt adversary split n).eval true).toReal - ((interleavedHybridGameOn valid encOut keyGen encrypt decrypt adversary (split + 1) n).eval true).toReal = ((cca2GameOn valid encOut keyGen encrypt decrypt (interleavedToSingleAt valid encrypt decBound adversary split) false n).eval true).toReal - ((cca2GameOn valid encOut keyGen encrypt decrypt (interleavedToSingleAt valid encrypt decBound adversary split) true n).eval true).toReal

    Single-step hybrid identity for interleaved multi-challenge CCA ([BS23], Theorem 12.1, printed p. 468): at any round index split : ℕ, the signed success-probability gap between interleavedHybridGameOn ... split and interleavedHybridGameOn ... (split + 1) equals the signed 1CCA gap of interleavedToSingleAt ... split.

    theorem Cslib.Crypto.Encryption.eval_cca2GameOn_interleavedToSingle {Msg Out : Type} [Inhabited Msg] (valid : ℕ → List Bool → Msg → Msg → Bool) (encOut : Out ↪ List Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option Out) (decBound : ℕ → List Bool → ℕ) (Q : ℕ → ℕ) (adversary : InterleavedCCA2AdversaryOf Msg) (bit : Bool) (n : ℕ) :
    (cca2GameOn valid encOut keyGen encrypt decrypt (interleavedToSingle valid encrypt decBound Q adversary) bit n).eval = (Probability.PMF.uniformOfFintype (Fin (Probability.dyadicSize (Q n)))).bind fun (i : Fin (Probability.dyadicSize (Q n))) => (cca2GameOn valid encOut keyGen encrypt decrypt (interleavedToSingleAt valid encrypt decBound adversary ↑i) bit n).eval

    Running interleavedToSingle in cca2GameOn averages interleavedToSingleAt uniformly over Fin (dyadicSize (Q n)).

    theorem Cslib.Crypto.Encryption.interleavedCca2GameOn_gap {Msg Out : Type} [Inhabited Msg] (valid : ℕ → List Bool → Msg → Msg → Bool) (encOut : Out ↪ List Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option Out) (decBound : ℕ → List Bool → ℕ) (Q : ℕ → ℕ) (adversary : InterleavedCCA2AdversaryOf Msg) (n : ℕ) (hdecBound : ∀ keys ∈ (keyGen n).eval.support, ∀ (req : List Bool), ((Turing.MultiTapeTM.encOption encOut) (decrypt n keys.2 req)).length ≤ decBound n req) (hQ : adversary.numRounds n ≤ Q n) :
    ((interleavedCca2GameOn valid encOut keyGen encrypt decrypt adversary false n).eval true).toReal - ((interleavedCca2GameOn valid encOut keyGen encrypt decrypt adversary true n).eval true).toReal = ↑(Probability.dyadicSize (Q n)) * (((cca2GameOn valid encOut keyGen encrypt decrypt (interleavedToSingle valid encrypt decBound Q adversary) false n).eval true).toReal - ((cca2GameOn valid encOut keyGen encrypt decrypt (interleavedToSingle valid encrypt decBound Q adversary) true n).eval true).toReal)

    Quantitative signed hybrid gap for interleaved multi-challenge CCA ([BS23], Theorem 12.1, printed p. 468): when adversary.numRounds n ≤ Q n, the signed success-probability gap of interleavedCca2GameOn equals dyadicSize (Q n) times the signed 1CCA gap of interleavedToSingle.

    theorem Cslib.Crypto.Encryption.advantage_interleavedCca2GameOn {Msg Out : Type} [Inhabited Msg] (valid : ℕ → List Bool → Msg → Msg → Bool) (encOut : Out ↪ List Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → Option Out) (decBound : ℕ → List Bool → ℕ) (Q : ℕ → ℕ) (adversary : InterleavedCCA2AdversaryOf Msg) (n : ℕ) (hdecBound : ∀ keys ∈ (keyGen n).eval.support, ∀ (req : List Bool), ((Turing.MultiTapeTM.encOption encOut) (decrypt n keys.2 req)).length ≤ decBound n req) (hQ : adversary.numRounds n ≤ Q n) :
    Game.advantage (interleavedCca2GameOn valid encOut keyGen encrypt decrypt adversary false n).eval (interleavedCca2GameOn valid encOut keyGen encrypt decrypt adversary true n).eval = ↑(Probability.dyadicSize (Q n)) * Game.advantage (cca2GameOn valid encOut keyGen encrypt decrypt (interleavedToSingle valid encrypt decBound Q adversary) false n).eval (cca2GameOn valid encOut keyGen encrypt decrypt (interleavedToSingle valid encrypt decBound Q adversary) true n).eval

    Quantitative hybrid advantage bound for interleaved multi-challenge CCA ([BS23], Theorem 12.1, printed p. 468): when adversary.numRounds n ≤ Q n, the interleaved multi-challenge CCA advantage equals dyadicSize (Q n) times the single-challenge 1CCA advantage of interleavedToSingle.

    theorem Cslib.Crypto.Encryption.INDCCA2On.indcca2InterleavedOn {Msg Out : Type} [Inhabited Msg] {valid : ℕ → List Bool → Msg → Msg → Bool} {encMsg : Msg ↪ List Bool} {encOut : Out ↪ List Bool} {keyGen : ℕ → ProbComp (List Bool × List Bool)} {encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)} {decrypt : ℕ → List Bool → List Bool → Option Out} (hvalid : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ℕ × List Bool × Msg × Msg) => match x with | (n, pk, m₀, m₁) => valid n pk m₀ m₁) (encChallengePairInput encMsg) Turing.MultiTapeTM.encBool) (hkeyGen : Probability.IsPPTOn Turing.MultiTapeTM.encUnary (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) keyGen) (hencrypt : Probability.IsPPTOn (encKeyedInput encMsg) Turing.MultiTapeTM.encBits fun (x : ℕ × List Bool × Msg) => match x with | (n, pk, m) => encrypt n pk m) (hdecrypt : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ℕ × List Bool × List Bool) => match x with | (n, sk, ct) => decrypt n sk ct) (encKeyedInput Turing.MultiTapeTM.encBits) (Turing.MultiTapeTM.encOption encOut)) (h : INDCCA2On valid encMsg encOut keyGen encrypt decrypt) :
    INDCCA2InterleavedOn valid encMsg encOut keyGen encrypt decrypt

    Single-challenge 1CCA security implies fully adaptive interleaved-query multi-challenge CCA security ([BS23], Section 12.1, Theorem 12.1, printed p. 468) whenever valid, keyGen, encrypt, and decrypt are polynomial-time / strict PPT.

    theorem Cslib.Crypto.Encryption.indcca2InterleavedOn_iff_indcca2On {Msg Out : Type} [Inhabited Msg] {valid : ℕ → List Bool → Msg → Msg → Bool} {encMsg : Msg ↪ List Bool} {encOut : Out ↪ List Bool} {keyGen : ℕ → ProbComp (List Bool × List Bool)} {encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)} {decrypt : ℕ → List Bool → List Bool → Option Out} (hvalid : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ℕ × List Bool × Msg × Msg) => match x with | (n, pk, m₀, m₁) => valid n pk m₀ m₁) (encChallengePairInput encMsg) Turing.MultiTapeTM.encBool) (hkeyGen : Probability.IsPPTOn Turing.MultiTapeTM.encUnary (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) keyGen) (hencrypt : Probability.IsPPTOn (encKeyedInput encMsg) Turing.MultiTapeTM.encBits fun (x : ℕ × List Bool × Msg) => match x with | (n, pk, m) => encrypt n pk m) (hdecrypt : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ℕ × List Bool × List Bool) => match x with | (n, sk, ct) => decrypt n sk ct) (encKeyedInput Turing.MultiTapeTM.encBits) (Turing.MultiTapeTM.encOption encOut)) :
    INDCCA2InterleavedOn valid encMsg encOut keyGen encrypt decrypt ↔ INDCCA2On valid encMsg encOut keyGen encrypt decrypt

    Equivalence of single-challenge 1CCA and fully adaptive interleaved-query multi-challenge CCA security ([BS23], Section 12.1, Theorem 12.1 together with Definition 12.2, printed p. 468).

    theorem Cslib.Crypto.Encryption.indcca2InterleavedOn_iff_indcca2MultiOn {Msg Out : Type} [Inhabited Msg] {valid : ℕ → List Bool → Msg → Msg → Bool} {encMsg : Msg ↪ List Bool} {encOut : Out ↪ List Bool} {keyGen : ℕ → ProbComp (List Bool × List Bool)} {encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)} {decrypt : ℕ → List Bool → List Bool → Option Out} (hvalid : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ℕ × List Bool × Msg × Msg) => match x with | (n, pk, m₀, m₁) => valid n pk m₀ m₁) (encChallengePairInput encMsg) Turing.MultiTapeTM.encBool) (hkeyGen : Probability.IsPPTOn Turing.MultiTapeTM.encUnary (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) keyGen) (hencrypt : Probability.IsPPTOn (encKeyedInput encMsg) Turing.MultiTapeTM.encBits fun (x : ℕ × List Bool × Msg) => match x with | (n, pk, m) => encrypt n pk m) (hdecrypt : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ℕ × List Bool × List Bool) => match x with | (n, sk, ct) => decrypt n sk ct) (encKeyedInput Turing.MultiTapeTM.encBits) (Turing.MultiTapeTM.encOption encOut)) :
    INDCCA2InterleavedOn valid encMsg encOut keyGen encrypt decrypt ↔ INDCCA2MultiOn valid encMsg encOut keyGen encrypt decrypt

    Equivalence of phased batch-challenge multi-challenge CCA and fully adaptive interleaved-query multi-challenge CCA security ([BS23], Section 12.1, Attack Game 12.1 and Theorem 12.1, printed pp. 467–468).

    theorem Cslib.Crypto.Encryption.INDCCA2Of.indcca2InterleavedOf {Msg Out : Type} [Inhabited Msg] {encMsg : Msg ↪ List Bool} {encOut : Out ↪ List Bool} {keyGen : ℕ → ProbComp (List Bool × List Bool)} {encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)} {decrypt : ℕ → List Bool → List Bool → Option Out} (hkeyGen : Probability.IsPPTOn Turing.MultiTapeTM.encUnary (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) keyGen) (hencrypt : Probability.IsPPTOn (encKeyedInput encMsg) Turing.MultiTapeTM.encBits fun (x : ℕ × List Bool × Msg) => match x with | (n, pk, m) => encrypt n pk m) (hdecrypt : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ℕ × List Bool × List Bool) => match x with | (n, sk, ct) => decrypt n sk ct) (encKeyedInput Turing.MultiTapeTM.encBits) (Turing.MultiTapeTM.encOption encOut)) (h : INDCCA2Of encMsg encOut keyGen encrypt decrypt) :
    INDCCA2InterleavedOf encMsg encOut keyGen encrypt decrypt

    Unrestricted single-challenge 1CCA security implies unrestricted interleaved multi-challenge CCA security ([BS23], Theorem 12.1).

    Bit single-challenge 1CCA security implies bit interleaved multi-challenge CCA security ([BS23], Theorem 12.1).

    Word single-challenge 1CCA security implies word interleaved multi-challenge CCA security ([BS23], Theorem 12.1).