Documentation

CatCryptCore.Examples.CoinToss

Coin Tossing Protocol #

This file formalizes a two-party coin tossing protocol over ZMod p and proves its output uniformity via an additive bijection argument.

Protocol #

Two parties each sample a random element from ZMod p and output their sum. The result is uniformly distributed, because for any fixed a, the map b ↦ a + b is a bijection on ZMod p.

Main definitions #

Main results #

Additive bijection on ZMod p #

noncomputable def CatCryptCore.Examples.CoinToss.addEquiv (p : ℕ) (a : ZMod p) :

Addition by a fixed element is a bijection on ZMod p.

Equations
Instances For

    Protocol Definitions #

    Real coin toss: both parties sample, output the sum.

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

      Ideal coin toss: sample a single uniform element.

      Equations
      Instances For

        Helper Lemmas #

        Sampling uniformly and adding a constant gives the same distribution as sampling uniformly. This is the key step: a + b for uniform b is uniform.

        Main Theorem #

        The inner computation: sampling b and returning a + b equals just sampling.

        The real coin toss protocol is distributionally equivalent to the ideal functionality. Both produce a uniform element of ZMod p.