Hybrid Argument for XOR Encryption #
This file carries out the hybrid argument for two and three instances of one-bit
XOR encryption, after ProofFrog's Hybrid protocol. The games are shallow SPComp
computations.
Overview #
Hybrid Arguments: A standard technique for proving security reductions. If a single instance of a primitive is secure, then n instances are secure with advantage at most n times the single-instance advantage.
Core Idea: We construct a sequence of hybrid games:
Game₀= real game (all n instances use the real primitive)Gameᵢ= first i instances are ideal, remaining (n-i) are realGameₙ= ideal game (all instances are ideal)
Each adjacent pair of hybrids differs in exactly one position, enabling a reduction to single-instance security.
Main Results #
single_oracle_zero_advantage- one XOR encryption has advantage0against a uniform ciphertexttwoReal/twoHybrid/twoIdealandthreeHybrid- the hybrid ladders for two and three instancestwo_instance_advantage_bound,three_instance_triangle- the real-to-ideal advantage is at most the sum of the adjacent-step advantageshybrid_step_zero_advantage- every adjacent step of the three-instance ladder has advantage0
ProofFrog Comparison #
ProofFrog's Hybrid protocol (for PubEnc):
- Automatically generates hybrid sequence
- Uses Z3 for equivalence checking
This file:
- Explicit hybrid games as
SPCompcomputations (selectOracle,threeHybrid) - Advantage bounds via the triangle inequality
- Step couplings via pRHL
References #
- ProofFrog: https://github.com/ProofFrog/ProofFrog
- [Bellare-Rogaway, Code-Based Game-Playing Proofs]
- [Rosulek, The Joy of Cryptography, Chapter 5]
Type Definitions #
Message/key/ciphertext type (simplified to Bool)
Equations
Instances For
Single-Instance Oracles #
The hybrid argument is based on two oracles:
- Real oracle: uses the actual cryptographic primitive
- Ideal oracle: returns random/ideal output
Real oracle: XOR encryption (CPA$ secure)
Equations
Instances For
Ideal oracle: random ciphertext
Equations
Instances For
Single-Instance Security #
The key property: XOR encryption is perfectly secure (zero advantage)
XOR encryption produces indistinguishable outputs for any two messages.
The proof uses bijection coupling: for uniform k, xor k m is uniformly distributed, so realOracle m and idealOracle m produce the same distribution.
XOR encryption has zero distinguishing advantage
Hybrid Game Structure #
For n oracle calls, we define:
- Hybrid i: first i calls use ideal oracle, rest use real oracle
- Hybrid 0 = all real (real game)
- Hybrid n = all ideal (ideal game)
Select oracle based on position relative to hybrid index
Equations
Instances For
Two-Instance Hybrid Games #
For concrete demonstration, we define hybrid games for two encryption instances.
Real game: both encryptions use real oracle
Equations
- CatCrypt.Examples.DeepHybrid.twoReal m₀ m₁ = do let c₀ ← CatCrypt.Examples.DeepHybrid.realOracle m₀ let c₁ ← CatCrypt.Examples.DeepHybrid.realOracle m₁ CatCrypt.Core.SPComp.pure (c₀, c₁)
Instances For
Hybrid 1: first encryption ideal, second real
Equations
- CatCrypt.Examples.DeepHybrid.twoHybrid m₀ m₁ = do let c₀ ← CatCrypt.Examples.DeepHybrid.idealOracle m₀ let c₁ ← CatCrypt.Examples.DeepHybrid.realOracle m₁ CatCrypt.Core.SPComp.pure (c₀, c₁)
Instances For
Ideal game: both encryptions use ideal oracle
Equations
- CatCrypt.Examples.DeepHybrid.twoIdeal m₀ m₁ = do let c₀ ← CatCrypt.Examples.DeepHybrid.idealOracle m₀ let c₁ ← CatCrypt.Examples.DeepHybrid.idealOracle m₁ CatCrypt.Core.SPComp.pure (c₀, c₁)
Instances For
Hybrid Step Couplings #
Coupling between twoReal and twoHybrid (differ in position 0)
The key insight: both games use the same second oracle call (realOracle m₁), so the second components will match. The first components differ but we don't need them to match for this postcondition.
Coupling between twoHybrid and twoIdeal (differ in position 1)
The key insight: both games use the same first oracle call (idealOracle m₀), so the first components will match.
Triangle Inequality for Advantage #
The total advantage is bounded by the sum of step advantages.
Advantage bound: Real to Ideal via Hybrid
N-Instance Generalization #
For the general case with n instances, we use a simpler fixed-size structure.
Three-instance output type
Equations
Instances For
Hybrid games for 3 instances
Equations
- One or more equations did not get rendered due to their size.
Instances For
Hybrid 0 = all real
Hybrid 3 = all ideal
Triangle bound for 3-instance case
Perfect Security for XOR Encryption #
For XOR encryption, each single step has zero advantage, so the total advantage is also zero.
Key lemma: realOracle and idealOracle produce identical distributions.
Since XOR with a uniform random key produces a uniform distribution, both oracles sample from the same distribution. This means all hybrid games are actually identical!
All threeHybrid games simplify to the same computation.
Since realOracle = idealOracle for XOR encryption, all branches of the hybrid game produce the same result.
Key observation: Each step in a hybrid ladder for XOR has zero advantage.
This is because realOracle and idealOracle produce identical distributions (both sample uniformly). Therefore consecutive hybrids are actually the same game, giving advantage = 0.
Summary #
This file demonstrates the generic hybrid argument pattern:
Structure #
Single-Instance Security: Prove real and ideal oracles are indistinguishable
single_oracle_coupling: XOR encryption couples perfectly with randomsingle_oracle_zero_advantage: Zero distinguishing advantage
Hybrid Ladder: Define intermediate games
selectOracle i pos: Uses ideal for pos < i, real for pos >= itwoHybrid,threeHybrid: Concrete hybrid game instances
Step Bounds: Each adjacent step bounded by single-instance advantage
step_0_1_coupling: First step preserves second componentstep_1_2_coupling: Second step preserves first component
Triangle Inequality: Total advantage bounded by sum of steps
two_instance_advantage_bound: Concrete 2-instance boundthree_instance_triangle: Concrete 3-instance bound
ProofFrog Comparison #
| ProofFrog | This file |
|---|---|
| Auto hybrid generation | Explicit selectOracle |
| Z3 for equivalence | rHoare + coupling |
| ~50 lines | ~350 lines |
| Fast iteration | Machine-checked |
Key Insight #
For XOR encryption (or any perfectly secure primitive):
- Single-instance advantage = 0
- n × 0 = 0
- Therefore n-fold security is also perfect
For computationally secure primitives, the bound would be:
- Adv(Real, Ideal) ≤ n × Adv(SingleReal, SingleIdeal)
This is the standard "n-factor security loss" of hybrid arguments.
Proved results #
single_oracle_coupling: bijection coupling of one XOR encryption with a uniform ciphertextsingle_oracle_zero_advantage: advantage0, from the couplingstep_0_1_coupling,step_1_2_coupling: the two-instance step couplingstwo_instance_advantage_bound: triangle inequality over the two-instance ladderthree_instance_triangle: triangle inequality over the three-instance ladderhybrid_step_zero_advantage: every three-instance step has advantage0