Documentation

CatCryptCore.Prob.XorBij

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 #

Main results #

References #

General XOR Equivalence #

def CatCrypt.Prob.XorBij.xorEquiv {α : Type} (op : ααα) (hInvol : ∀ (a b : α), op (op a b) b = a) (x : α) :
α α

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
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
      @[simp]

      Product XOR Bijection #

      XOR bijection on Bool × Bool (component-wise).

      Used in PRPCCA for ciphertext-space bijections.

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

        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.

        Zero Advantage Corollaries #

        If real game is sample key >> apply bijection and ideal game is sample, then every adversary has zero advantage.

        XOR Algebraic Helpers #

        theorem CatCrypt.Prob.XorBij.xor_self_inverse (a b : Bool) :
        (a ^^ b ^^ b) = a

        XOR is self-inverse: xor (xor a b) b = a

        @[simp]

        XOR with false is identity

        @[simp]

        XOR with true is negation