Documentation

CatCryptCore.Examples.Commitment

Commitment Schemes: Perfect Hiding and Perfect Binding #

A commitment scheme lets a sender commit to a message m — publishing a commitment c that hides m — and later open it by revealing m together with the randomness r. Following Rosulek, The Joy of Cryptography (Chapter on commitment schemes), the two security goals are:

This file defines a minimal CommScheme structure, the hiding game (phrased over the core AdvantageA), and the perfect-binding predicate, then instantiates two schemes over Bool:

The two examples witness the information-theoretic tension Rosulek highlights: a commitment scheme cannot be simultaneously perfectly hiding and perfectly binding. MaskComm is the OTP argument on the hiding side; IdComm shows the binding predicate is inhabited.

Main definitions #

Main results #

References #

Commitment Scheme #

A (non-interactive) commitment scheme.

Randomness is required finite and nonempty so it can be sampled uniformly in the hiding game.

Instances For

    Correctness: an honestly produced commitment opens back to its message.

    Equations
    Instances For

      Perfect binding: no commitment can be opened to two distinct messages. That is, if (m₀, r₀) and (m₁, r₁) both verify against the same commitment c, then m₀ = m₁.

      Equations
      Instances For

        Hiding Game #

        The hiding game for a commitment scheme.

        The challenger samples fresh randomness r and returns the commitment to m₀ (when b = true) or m₁ (when b = false). The adversary is given the commitment and tries to guess b.

        • Hiding_Game C m₀ m₁ true — commits to m₀ (left)
        • Hiding_Game C m₀ m₁ false — commits to m₁ (right)
        Equations
        Instances For
          noncomputable def CatCrypt.Examples.Commitment.Hiding_Adv (C : CommScheme) (m₀ m₁ : C.Message) (A : C.CommitmentCore.SPComp Bool) :

          Hiding advantage: the probability with which an adversary distinguishes a commitment to m₀ from a commitment to m₁.

          Equations
          Instances For

            Masking Commitment: Perfect Hiding #

            commit(m; r) = m ⊕ r, the one-time-pad commitment.

            The masking commitment over Bool: commit r m = r ⊕ m, opened by revealing (m, r). This is the one-time-pad commitment.

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

              The masking commitment is correct: an honest opening verifies.

              Coupling: the two hiding games for the masking commitment are equidistributed.

              For a uniform mask r, both r ⊕ m₀ and r ⊕ m₁ are uniformly distributed (XOR-by-a-fixed-bit is a bijection of the mask). The bijection boolXorBij (m₀ ⊕ m₁) re-labels the mask on the right so the two commitments coincide, coupling the games under eqPost.

              The masking commitment is perfectly hiding: every adversary has hiding advantage exactly 0.

              Reflection into the Package / UC Stack #

              The shallow maskComm_perfect_hiding bounds a single distinguisher applied to the two hiding-game bodies. This section lifts it to a composable statement about deep nominal packages linked with an arbitrary adversary package, following the stack shallow game → rawCode% → NomPackage.ofOracle → DeepNomAdvantage → sdist → UC via the shared CatCryptCore.Deep.ReflectUCHelpers combinators. The masking commitment commit r m = r ⊕ m is heap-independent, so the shallow coupling maskComm_hiding_coupling upgrades to a full SPComp equality of the two reflected bodies (spcomp_eq_of_isPure_coupling), and the whole stack follows with no purity bridge on the adversary.

              The reflected masking-commitment hiding-game body for bit b: sample a uniform mask r and return the one-time-pad commitment r ⊕ (if b then m₀ else m₁).

              Equations
              Instances For

                The reflected body evaluates back to the shallow hiding game.

                The hiding game is heap-independent (a uniform mask then a pure commitment).

                The two reflected bodies (commit to m₀ vs. m₁) have equal evaluations: the heap-independent coupling maskComm_hiding_coupling upgrades to SPComp equality.

                Real hiding game as an oracle-exporting nominal package (commits to m₀).

                Equations
                Instances For

                  Ideal hiding game as an oracle-exporting nominal package (commits to m₁).

                  Equations
                  Instances For

                    Zero deep-nominal advantage against every adversary package.

                    Statistical distance zero between the two linked-game families.

                    Package-level perfect hiding (NomPkgSecure).

                    theorem CatCrypt.Examples.Commitment.mask_uc (m₀ m₁ : Bool) :
                    Crypto.UCEmulates 0 { hon := Deep.NomPackage, out := Bool, leak := Empty, sim_if := Empty, view := Bool } (fun (A : { hon := Deep.NomPackage, out := Bool, leak := Empty, sim_if := Empty, view := Bool }.hon) => Core.SPComp.map Sum.inl (Crypto.runPkg (A.pkg.link (maskGameTrue m₀ m₁).pkg))) fun (A : { hon := Deep.NomPackage, out := Bool, leak := Empty, sim_if := Empty, view := Bool }.hon) => Core.SPComp.map Sum.inl (Crypto.runPkg (A.pkg.link (maskGameFalse m₀ m₁).pkg))

                    Perfect UC emulation of the linked-game families over the trivial-leak interface (out = Bool, leak = Empty) with the identity simulator (composition plumbing).

                    Reflection mirrors the shallow game. Against the forwarding adversary, the deep-nominal advantage equals the shallow hiding advantage under the identity distinguisher — which is 0 by maskComm_perfect_hiding.

                    Identity Commitment: Perfect Binding #

                    commit(m; r) = m — a deterministic commitment that ignores its randomness. It provides no hiding, but it is perfectly binding: the commitment is the message, so it can only be opened to that one message. This witnesses the hiding/binding tension: no scheme achieves both perfectly.

                    The identity commitment over Bool: commit r m = m, opened by revealing m (the randomness is irrelevant).

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

                      The identity commitment is correct.

                      The identity commitment is perfectly binding: since the commitment equals the committed message, any two valid openings expose the same message.