Cryptographic Advantage #
This file defines the advantage of an adversary in distinguishing games.
Probability that a computation returns true, starting from an initial heap. This sums over all final heaps.
Equations
- CatCrypt.Crypto.prTrue G h₀ = ∑' (h : CatCrypt.Core.Heap), (G h₀) (some (true, h))
Instances For
Advantage: distinguishing probability between two games,
measured as the absolute difference of the probabilities of returning true.
Scope: the initial heap is fixed to Heap.empty. This is the empty-heap
distinguishing probability, not the supremum over all initial heaps; the
stronger all-heap notion is SDist.sdist. The two are reconciled by the
bridge lemmas sdist_isPure_le / sdist_oracleGame_le (SDist.lean), which
bound this empty-heap advantage by the all-heap statistical distance. Use
Advantage for empty-heap game hops; reach for sdist when the adversary
may choose the starting state.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Advantage with explicit adversary
Equations
- CatCrypt.Crypto.AdvantageA G₀ G₁ A = CatCrypt.Crypto.Advantage (G₀.bind A) (G₁.bind A)
Instances For
Key Lemmas #
Triangle inequality for advantage |Pr[G₀] - Pr[G₂]| ≤ |Pr[G₀] - Pr[G₁]| + |Pr[G₁] - Pr[G₂]|
Perfect indistinguishability from pRHL equality. If G₀ and G₁ produce equal outputs when started from equal heaps, no adversary can distinguish them.
Zero advantage from invariant-preserving judgment with state separation.
If G₀ and G₁ preserve an invariant I and produce equal values, they are indistinguishable for any adversary that respects I.
Key Hypothesis: hA_respects states that when two heaps are I-related,
the adversary produces the same distribution. This captures the essence of
state separation: the adversary cannot observe differences in protocol-internal
state that is encapsulated by I.
In CatCrypt/Rocq, this is enforced structurally via package validity:
- A's locations
LAare disjoint from protocol locationsL - I only constrains locations in L
- Therefore A cannot observe I-related differences (A only sees
LA)
For the basic case where I = eqPre (heap equality), use advantage_zero_of_rHoare.
Symmetry and Reflexivity #
Advantage is symmetric: swapping games doesn't change the advantage.
Self-advantage is zero: no adversary can distinguish a game from itself.
Utility Lemmas for Advantage Bounds #
prTrue is at most 1 (probability bound).
Advantage of sampling uniform Bool vs pure constant is at most 1/2.
General Sampling Lemmas #
prTrue of sampling then applying F decomposes as weighted sum over the sampled type.
Advantage with uniform prefix sampling.
If two games differ only in their continuation after sampling, and the continuation advantage is bounded for all sampled values, then the overall advantage is bounded.
For finite types (like Word = Bool), this follows from the fact that sampling is a convex combination, and advantage respects convexity.
IsPure Prefix Factoring #
Factoring out an IsPure prefix from advantage bounds.
If pfx is heap-independent and for every prefix value x, the advantage
between f x and g x is bounded by ε, then the overall advantage
is also bounded by ε.
This is the key lemma for mechanizing HKDF hybrid steps where the
differing game depends on the prefix output (e.g., th_2 from keygens).