XOR Bijection Library #
This file provides reusable XOR bijection infrastructure for cryptographic proofs.
Overview #
Many CatCrypt proofs rely on the fact that XOR with a fixed value is a bijection. This file centralizes the definition and key theorems, eliminating duplication across 20+ example files.
Main definitions #
xorEquiv- General XOR bijection for any type with an involutive XOR operationboolXorBij- XOR bijection onBool(the most commonly used specialization)
Main results #
rHoare_sample_xor- Sampling a key and applying XOR has the same distribution as sampling directly (coupling lemma)advantage_zero_of_xor- Zero advantage corollary for XOR-based games
References #
- [Shannon, Communication Theory of Secrecy Systems, 1949]
General XOR Equivalence #
XOR with a fixed value is an equivalence for any involutive binary operation.
Given an operation op satisfying op (op a b) b = a for all a b,
xorEquiv op h x is the equivalence a ↦ op a x with inverse r ↦ op r x.
Equations
- CatCrypt.Prob.XorBij.xorEquiv op hInvol x = { toFun := fun (k : α) => op k x, invFun := fun (r : α) => op r x, left_inv := ⋯, right_inv := ⋯ }
Instances For
Bool XOR Bijection #
XOR with a fixed Bool is a bijection.
This is the fundamental property used in OTP, PRF, MAC, PRG, and many other cryptographic proofs; it is shared here rather than duplicated per file.
Equations
Instances For
Product XOR Bijection #
Coupling Lemma #
The key theorem: sampling a key uniformly and applying XOR with a fixed message is indistinguishable from sampling uniformly.
This eliminates the ~15-line coupling proof pattern repeated across ~10 files.
Core coupling: for any bijection family, sampling a key and applying the
bijection is coupled with uniform sampling via eqPost.
This is the general pattern:
- Real:
k ← sample α; pure (f k) - Ideal:
sample α - Coupled via bijection
f : α ≃ α
Coupling for Bool XOR: sampling a key and XORing with a message has the same distribution as sampling directly.
Real game: k ← sample Bool; pure (xor k m)
Ideal game: sample Bool
This is the single most commonly needed coupling in CatCrypt examples.
Coupling for product Bool XOR.
Zero Advantage Corollaries #
If real game is sample key >> apply bijection and ideal game is sample,
then every adversary has zero advantage.
Zero advantage for Bool XOR games.