Commitment Schemes

The Cheating Problem

Alice and Bob want to play “guess the coin flip” over the phone:

  1. Alice flips a coin
  2. Bob guesses heads or tails
  3. Alice reveals the result

The problem: Alice can cheat. After hearing Bob’s guess, she can simply lie about what she flipped.

We need a way for Alice to lock in her answer before Bob guesses, without revealing it yet.


The Sealed Envelope

Think of a commitment like a sealed envelope:

  1. Alice writes her answer on paper
  2. She seals it in an envelope
  3. She hands the sealed envelope to Bob
  4. Bob makes his guess
  5. Alice opens the envelope to reveal the answer

Why this works:

  • Bob can’t peek inside the sealed envelope
  • Alice can’t swap the contents after handing it over

The envelope is both opaque and tamper-evident.


Two Phases

Every commitment scheme has two phases:

PhaseWhat happens
CommitLock in a value without revealing it
RevealOpen the commitment, prove what was inside

The commit phase produces a commitment (the sealed envelope). The reveal phase opens it.


Two Properties

A secure commitment scheme guarantees two things:

Hiding: The commitment reveals nothing about the value.

Before the reveal phase, the receiver learns zero information about what’s inside.

Binding: The committer cannot change the value after committing.

Once committed, the sender is bound to that value. No take-backs.

Both properties are essential. Without hiding, the receiver peeks. Without binding, the sender cheats.


Building Commitments from Hashes

The simplest construction uses a hash function.

To commit to message mm:

  1. Pick a random value rr (called a nonce)
  2. Compute c=H(mr)c = H(m \| r)
  3. Send cc to the receiver

The symbol \| denotes concatenation.

To reveal:

  1. Send mm and rr to the receiver
  2. Receiver computes H(mr)H(m \| r)
  3. If it matches cc, the commitment is valid

The commitment cc is just a hash. Short, fixed-size, reveals nothing.


Why It’s Hiding

Hash functions are one-way. Given c=H(mr)c = H(m \| r), you can’t work backwards to find mm.

But there’s a subtlety. What if mm is just “heads” or “tails”?

Without the random rr, the receiver could just compute H("heads")H(\text{"heads"}) and H("tails")H(\text{"tails"}), compare to cc, and know the answer immediately.

The nonce rr prevents this. Even if there are only two possible messages, each commitment looks completely random.

The randomness makes commitments to the same message look different every time.


Why It’s Binding

To cheat, Alice would need to find mm' and rr' such that:

H(mr)=H(mr)H(m \| r) = H(m' \| r')

where mmm \neq m'.

This is a hash collision. For secure hash functions, finding collisions is computationally infeasible.

Binding relies on collision resistance. If you can’t find collisions, you can’t change your commitment.


The Full Protocol

Setup: Alice and Bob agree on a hash function HH.

Commit phase:

  1. Alice has secret value mm
  2. Alice generates random nonce rr
  3. Alice computes c=H(mr)c = H(m \| r)
  4. Alice sends cc to Bob

Reveal phase:

  1. Alice sends (m,r)(m, r) to Bob
  2. Bob computes H(mr)H(m \| r)
  3. Bob checks: does it equal cc?
  4. If yes, accept mm as the committed value

Applications

Commitments appear throughout cryptography:

ApplicationHow commitments help
Sealed-bid auctionsAll bidders commit first, then reveal simultaneously
Zero-knowledge proofsProver commits to values before verifier’s challenge
Electronic votingCommit to votes, reveal only after polls close

Anywhere you need “I’ll tell you later, but I’m locking in my answer now”, that’s a commitment scheme.


Key Insight

Commitments separate when you decide from when you reveal.

This simple primitive enables fair protocols between parties who don’t trust each other. Alice can’t cheat because she’s bound. Bob can’t cheat because he can’t peek.

A commitment is a cryptographic promise. The math ensures you keep it.