Documentation

CatCryptCore.Examples.Cryptobox.HYBRID

AE Hybrid Argument for Cryptobox #

Hybrid games for the AE switching step in the Cryptobox security proof. The AE step transitions session-by-session from real encryption (with random shared keys) to ideal encryption (random ciphertext + log-based decryption).

Overview #

The aeStepAdvantage from GameHopping.lean captures the distance:

  Advantage(PKAE_nikeSwitch, PKAE_cc(true))

We decompose this via a hybrid argument over sessions. The hybrid game aeHybrid S is parameterized by a set S : Finset SID of "switched" sessions:

Boundary conditions #

Per-step structure #

Each step switches a single session sid from real to ideal:

  Advantage(aeHybrid(S), aeHybrid(S ∪ {sid})) ≤ saeAdvantage E (R_sae sid A)

Main results #

References #

Hybrid Encryption Oracle #

The encryption oracle for the hybrid game. Parameterized by a set of switched sessions S : Finset SID. For honest-honest sessions in S, we use ideal encryption (sample random ciphertext + log). For honest-honest sessions NOT in S, we use real encryption with a random cached key. For corrupt sessions, we always use real encryption with the actual NIKE shared key.

Hybrid encryption oracle parameterized by switched session set.

  • Honest-honest sessions in switched: ideal (sample random ciphertext, log it)
  • Honest-honest sessions not in switched: real (random cached key + E.enc)
  • Corrupt sessions: real (N.sharedkey + E.enc)
Equations
  • One or more equations did not get rendered due to their size.
Instances For

    Hybrid Decryption Oracle #

    The decryption oracle for the hybrid game, following the same switching logic as encryption.

    Hybrid decryption oracle parameterized by switched session set.

    • Honest-honest sessions in switched: ideal (log-based decryption)
    • Honest-honest sessions not in switched: real (random cached key + E.dec)
    • Corrupt sessions: real (N.sharedkey + E.dec)
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      Hybrid Game #

      The hybrid game composes the collision-checking PKEY oracles with the hybrid encryption/decryption oracles.

      AE hybrid game parameterized by switched session set S.

      Uses collision-checking GEN (matching PKAE_cc) and routes encryption/decryption through the hybrid oracles. The set S controls which honest-honest sessions use ideal encryption:

      • S = {}: all honest sessions use real encryption (= PKAE_nikeSwitch)
      • S = Finset.univ: all honest sessions use ideal encryption (= PKAE_cc true)
      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        Boundary Theorems #

        The hybrid game at the two extremes matches the existing game definitions.

        Empty boundary: when no session is switched, the hybrid game equals PKAE_nikeSwitch — all honest-honest sessions use real encryption with random cached keys.

        Proof strategy: When switched = {}, the condition sid ∈ switched is always false, so the hybrid oracles always take the "real" branch. The real branch of the hybrid enc/dec oracles uses getOrSampleKey + E.enc/E.dec, which matches PKAE_nikeSwitch.

        Universe boundary: when all sessions are switched, the hybrid game equals PKAE_cc true — all honest-honest sessions use ideal encryption.

        Proof strategy: When switched = Finset.univ, the condition sid ∈ switched is always true for any sid, so the hybrid oracles always take the "ideal" branch for honest-honest sessions. The ideal branch matches pkaeEncOracle/ pkaeDecOracle with b = true.

        The only subtlety is that PKAE_cc true uses pkaeEncOracle which checks b && hon_s && hon_r while the hybrid oracle checks hon_s && hon_r then sid ∈ switched. When switched = univ and both are honest, both branches produce the same ideal behavior. When either party is corrupt, both fall through to the real encryption with N.sharedkey.

        Per-Step Advantage #

        The advantage of switching a single session from real to ideal encryption.

        Per-step advantage: the distinguishing distance when adding session sid to the switched set.

        This captures the cost of switching one session from real to ideal encryption. The reduction to single-instance SAE (saeAdvantage) requires showing that the per-session difference can be simulated by a single SAE adversary.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          When sid ∈ S, inserting sid again does nothing, so the step advantage is 0.

          Proof strategy: insert sid S = S when sid ∈ S, so the two hybrid games are definitionally equal.

          SAE Reduction Adversary #

          The reduction adversary that converts a single-session SAE attacker into a PKAE hybrid distinguisher. When the SAE game provides real encryption, we get aeHybrid S; when it provides ideal encryption, we get aeHybrid (insert sid S).

          SAE reduction adversary for the hybrid step.

          Given SAE oracles for a single session, constructs PKAE oracles where:

          • Session sid: routes through SAE oracles (real or ideal depending on SAE game)
          • Other sessions in switched: ideal encryption (random ciphertext + log)
          • Other sessions not in switched: real encryption (random cached key)
          • Corrupt sessions: real encryption (N.sharedkey)

          When plugged into SAE(false), this gives aeHybrid S. When plugged into SAE(true), this gives aeHybrid (insert sid S).

          This captures the core of the hybrid argument: the per-step advantage is bounded by the SAE advantage of this reduction adversary.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            Hybrid Step Bound #

            The per-step advantage is bounded by the SAE advantage of the reduction.

            theorem CatCrypt.Examples.Cryptobox.aeHybrid_step_bound [CT : CryptoTypes] [LinearOrder CryptoTypes.PK] (N : NIKEScheme) (E : NBSES) (I : KeyInjection) (S : Finset SID) (sid : SID) (_hns : sid ∉ S) (A : PKAEOracles → Core.SPComp Bool) (h_real : aeHybrid N E I S A = SAE E false (R_SAE_hybrid N E I S sid A)) (h_ideal : aeHybrid N E I (insert sid S) A = SAE E true (R_SAE_hybrid N E I S sid A)) :
            aeHybridStepAdvantage N E I S sid A ≤ saeAdvantage E (R_SAE_hybrid N E I S sid A)

            Per-step reduction: the hybrid step advantage for session sid is bounded by the SAE advantage of the reduction adversary R_SAE_hybrid.

            The two oracle alignment hypotheses capture the core of the reduction:

            • h_real: when SAE provides real encryption, the composed game equals the hybrid game without sid switched
            • h_ideal: when SAE provides ideal encryption, the composed game equals the hybrid game with sid switched

            Proving these alignments requires showing that routing the target session through SAE oracles produces identical distributions to the hybrid oracles. The main subtlety is aligning the SAE log (indexed by nonce) with the PKAE log (indexed by (SID, Nonce)) for the target session.

            Triangle Inequality over Hybrid Chain #

            Decomposing the AE step advantage into a sum of per-step advantages.

            theorem CatCrypt.Examples.Cryptobox.aeHybrid_union_triangle [CT : CryptoTypes] [LinearOrder CryptoTypes.PK] (N : NIKEScheme) (E : NBSES) (I : KeyInjection) (A : PKAEOracles → Core.SPComp Bool) (S : Finset SID) (sids : List SID) (hnodup : sids.Nodup) (hdisjoint : ∀ sid ∈ sids, sid ∉ S) :
            Crypto.Advantage (aeHybrid N E I S A) (aeHybrid N E I (S ∪ sids.toFinset) A) ≤ (List.map (fun (sid : SID) => aeHybridStepAdvantage N E I (S ∪ (List.takeWhile (fun (x : SID) => decide (x ≠ sid)) sids).toFinset) sid A) sids).sum

            Auxiliary: advantage of switching from S to S ∪ T is bounded by the sum of advantages of inserting each element of T one at a time.

            This follows from the triangle inequality applied iteratively: Advantage(aeHybrid S, aeHybrid (S ∪ T)) ≤ Σ_{sid ∈ T} Advantage(aeHybrid S_i, aeHybrid S_{i+1}) where S_0 = S and S_{i+1} = insert t_i S_i.

            theorem CatCrypt.Examples.Cryptobox.aeStep_triangle [CT : CryptoTypes] [LinearOrder CryptoTypes.PK] (N : NIKEScheme) (E : NBSES) (I : KeyInjection) (A : PKAEOracles → Core.SPComp Bool) (sids : List SID) (hnodup : sids.Nodup) (hcomplete : sids.toFinset = Finset.univ) :
            aeStepAdvantage N E I A ≤ (List.map (fun (sid : SID) => aeHybridStepAdvantage N E I (List.takeWhile (fun (x : SID) => decide (x ≠ sid)) sids).toFinset sid A) sids).sum

            AE step triangle inequality: the AE step advantage (from PKAE_nikeSwitch to PKAE_cc true) is bounded by the sum of per-step hybrid advantages over all sessions.

            Combined with aeHybrid_step_bound, this gives: aeStepAdvantage ≤ Σ_{sid} saeAdvantage E (R_SAE_hybrid ... sid A)

            Proof strategy:

            1. Rewrite PKAE_nikeSwitch = aeHybrid ∅ via aeHybrid_empty
            2. Rewrite PKAE_cc true = aeHybrid Finset.univ via aeHybrid_univ
            3. Apply aeHybrid_union_triangle with S = ∅ and sids = all sessions
            4. Simplify ∅ ∪ sids.toFinset = Finset.univ

            Combined Bound #

            Putting together the triangle inequality and per-step SAE reduction.

            theorem CatCrypt.Examples.Cryptobox.aeStep_bounded_by_sae [CT : CryptoTypes] [LinearOrder CryptoTypes.PK] (N : NIKEScheme) (E : NBSES) (I : KeyInjection) (A : PKAEOracles → Core.SPComp Bool) (sids : List SID) (hnodup : sids.Nodup) (hcomplete : sids.toFinset = Finset.univ) (sae_eps : SID → ENNReal) (h_oracle_align : ∀ (S : Finset SID), ∀ sid ∉ S, aeHybrid N E I S A = SAE E false (R_SAE_hybrid N E I S sid A) ∧ aeHybrid N E I (insert sid S) A = SAE E true (R_SAE_hybrid N E I S sid A)) (hsteps : ∀ sid ∈ sids, saeAdvantage E (R_SAE_hybrid N E I (List.takeWhile (fun (x : SID) => decide (x ≠ sid)) sids).toFinset sid A) ≤ sae_eps sid) :
            aeStepAdvantage N E I A ≤ (List.map sae_eps sids).sum

            AE hybrid bound: the AE step advantage is bounded by the sum of SAE advantages of the per-session reduction adversaries.

            This is the main result of the hybrid argument:

              aeStepAdvantage N E I A ≤ Σ_{sid} saeAdvantage E (R_SAE_hybrid ... sid A)
            

            Combined with cryptobox_security_full from GameHopping.lean, this gives the complete Cryptobox security bound.

            Finset-Based Bound (Alternative Formulation) #

            An alternative formulation using Finset.sum instead of List.map ... .sum, which is sometimes more convenient for downstream use.

            theorem CatCrypt.Examples.Cryptobox.aeStep_bounded_by_sae_finset [CT : CryptoTypes] [LinearOrder CryptoTypes.PK] (N : NIKEScheme) (E : NBSES) (I : KeyInjection) (A : PKAEOracles → Core.SPComp Bool) (sae_eps : SID → ENNReal) (hsteps : ∀ (S : Finset SID), ∀ sid ∉ S, aeHybridStepAdvantage N E I S sid A ≤ sae_eps sid) :

            AE hybrid bound (Finset version): the AE step advantage is bounded by the sum of per-session SAE advantages over all sessions.

            This takes the per-step bounds as hypotheses, matching the structure of ae_hybrid_bound from Cryptobox.lean.