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:
- hiding — the commitment
creveals nothing about the committed message; - binding — the sender cannot open a single commitment to two different messages.
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:
MaskComm— the one-time-pad / masking commitmentcommit(m; r) = m ⊕ rwithruniform. A uniform mask makes the commitment uniform and independent ofm, so the hiding advantage of every adversary is exactly0(perfect hiding).IdComm— the trivial deterministic commitmentcommit(m; r) = m, which is perfectly binding.
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 #
CommScheme— a commitment scheme (commit,verify, uniform randomness).Hiding_Game/Hiding_Adv— the hiding game and its advantage.CommScheme.PerfectlyBinding— no commitment opens to two distinct messages.MaskComm,IdComm— the masking and identity commitments overBool.
Main results #
maskComm_correct— an honest opening of aMaskCommcommitment verifies.maskComm_perfect_hiding— the masking commitment is perfectly hiding:Hiding_Adv MaskComm m₀ m₁ A = 0for every adversaryA.idComm_perfectly_binding— the identity commitment is perfectly binding.
References #
- [Rosulek, The Joy of Cryptography, Chapter on commitment schemes]
- [Shannon, Communication Theory of Secrecy Systems, 1949]
Commitment Scheme #
A (non-interactive) commitment scheme.
Message,Randomness,Commitmentare the data types.commit r mproduces the commitment to messagemunder randomnessr.verify c m rchecks that(m, r)is a valid opening of the commitmentc.
Randomness is required finite and nonempty so it can be sampled uniformly in
the hiding game.
- Message : Type
Message (committed value) type
- Randomness : Type
Randomness (opening) type
- Commitment : Type
Commitment type
- finRand : Fintype self.Randomness
Randomness is finite (for uniform sampling)
- neRand : Nonempty self.Randomness
Randomness is nonempty (for uniform sampling)
- commit : self.Randomness → self.Message → self.Commitment
Deterministic commitment function
- verify : self.Commitment → self.Message → self.Randomness → Bool
Opening verification: is
(m, r)a valid opening ofc?
Instances For
Correctness: an honestly produced commitment opens back to its message.
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
- C.PerfectlyBinding = ∀ (c : C.Commitment) (m₀ m₁ : C.Message) (r₀ r₁ : C.Randomness), C.verify c m₀ r₀ = true → C.verify c m₁ r₁ = true → m₀ = m₁
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 tom₀(left)Hiding_Game C m₀ m₁ false— commits tom₁(right)
Equations
- CatCrypt.Examples.Commitment.Hiding_Game C m₀ m₁ b = do let r ← CatCrypt.Core.SPComp.sample C.Randomness CatCrypt.Core.SPComp.pure (C.commit r (if b = true then m₀ else m₁))
Instances For
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 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
- CatCrypt.Examples.Commitment.maskGameRaw m₀ m₁ b = (CatCrypt.Deep.RawCode.sample Bool).bind fun (r : Bool) => CatCrypt.Deep.RawCode.ret (r ^^ if b = true then m₀ else m₁)
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
- CatCrypt.Examples.Commitment.maskGameTrue m₀ m₁ = CatCrypt.Deep.NomPackage.ofOracle 1 Unit Bool fun (x : Unit) => CatCrypt.Examples.Commitment.maskGameRaw m₀ m₁ true
Instances For
Ideal hiding game as an oracle-exporting nominal package (commits to m₁).
Equations
- CatCrypt.Examples.Commitment.maskGameFalse m₀ m₁ = CatCrypt.Deep.NomPackage.ofOracle 1 Unit Bool fun (x : Unit) => CatCrypt.Examples.Commitment.maskGameRaw m₀ m₁ false
Instances For
Zero deep-nominal advantage against every adversary package.
Statistical distance zero between the two linked-game families.
Package-level perfect hiding (NomPkgSecure).
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 is correct.
The identity commitment is perfectly binding: since the commitment equals the committed message, any two valid openings expose the same message.