Documentation

CslibFrontier.Crypto.Game.Hop

Game hops as a calc chain #

A game-hopping proof moves from one game to the next, and each hop changes the success probability by at most its loss. Here the hops are steps of x ≈[ε] y on success probabilities, so a hop sequence is a calc block that names each game and each loss:

calc Pr[G₀] = Pr[G₁] := by rw [h₀₁]                       -- equal distributions
  _ ≈[ε₁] Pr[G₂] := Game.approxEq_of_advantage_le h₁₂     -- an advantage bound
  _ ≈[ε₂] Pr[G₃] := h₂₃                                   -- `|Pr[G₂] - Pr[G₃]| ≤ ε₂`

Game.advantage_le_of_approxEq then closes an ℝ≥0 advantage bound with the chain, and Game.approxEq_iff_advantage_le reads a real advantage bound as a hop and back.

The same lemmas apply to experiments, which are programs e : ProbComp Bool: Pr[e] is Pr[ProbComp.eval e] and the advantage between experiments is the advantage between their distributions, so Game.approxEq_of_advantage_le takes an experiment advantage bound and gives Pr[e₀] ≈[ε] Pr[e₁].

Use calc when the hop sequence is the argument a reader should follow; the game_trans tactic remains the tool for chains whose hops are proved in place.

Main results #

theorem Cslib.Crypto.Game.approxEq_iff_advantage_le {G₀ G₁ : Game} {ε : ℝ} :
Probability.ApproxEq ε (G₀ true).toReal (G₁ true).toReal ↔ ↑(G₀.advantage G₁) ≤ ε

A hop of error ε between two games is a bound of ε on their advantage.

theorem Cslib.Crypto.Game.approxEq_of_advantage_le {G₀ G₁ : Game} {ε : NNReal} (h : G₀.advantage G₁ ≤ ε) :

An advantage bound is a hop.

theorem Cslib.Crypto.Game.approxEq_advantage (G₀ G₁ : Game) :
Probability.ApproxEq (↑(G₀.advantage G₁)) (G₀ true).toReal (G₁ true).toReal

A hop costs at most the advantage between its games.

theorem Cslib.Crypto.Game.advantage_le_of_approxEq {G₀ G₁ : Game} {δ : ℝ} {ε : NNReal} (h : Probability.ApproxEq δ (G₀ true).toReal (G₁ true).toReal) (hδ : δ ≤ ↑ε := by exact_mod_cast le_rfl) :
G₀.advantage G₁ ≤ ε

A chain of hops whose total error is at most ε bounds the advantage between its ends by ε. The bound hδ defaults to a cast check, which proves it when ε is the chain's sum of errors.