Cryptography / Zero-knowledge proofs

Zero-knowledge proofs

How Peggy convinces Victor that she knows a secret word without ever saying it: a cave, a door, a coin flip, and the three properties every zero-knowledge proof must have.

Intermediate7 steps~7 min
Peggy — the prover: knows the secret word
Victor — the verifier: wants to be convinced
Impostor — claims to know the word, does not
Door — opens only to the secret word
// THE SHORT VERSION

In 30 seconds

A zero-knowledge proof lets a prover convince a verifier that a claim is true without revealing why it is true. The classic picture is a cave with a locked door: Peggy shows she can open it without ever saying the secret word.

A good proof has three properties. An honest prover always passes (completeness), a cheat is almost surely caught (soundness), and the verifier learns nothing else (zero knowledge).

Repeating a random challenge makes the odds of cheating tiny. Modern versions fit in one message and are used in digital identity and blockchains.

Zero-knowledge proofs, step by step

STEPS01 / 07

The cave is an analogy (Quisquater and Guillou, 1990). Real proofs replace the paths and door with mathematics, and the hash shortcut (Fiat–Shamir) relies on the hash behaving like an unpredictable coin.

STEP 01 / 07 A secret to prove
THE MATH
claim: "I know the word" proof must not reveal it
  1. Step 1: A secret to prove. A ring-shaped cave has a door at the back that opens only to a secret word. Peggy, the prover, says she knows the word. Victor, the verifier, wants to be convinced, but Peggy does not want to tell him the word, or anything that would help him learn it.
  2. Step 2: Commit: pick a path. Peggy walks in alone and takes path A or path B at random, as far as the door. Victor stays outside and cannot see which way she went. Her choice is now fixed, before he asks anything. Cryptographers call this first move the commitment.
  3. Step 3: Challenge and response. Victor walks to the fork, flips a coin and calls out the path she must return by: B. Peggy went in by A, so she says the word, the door opens and she walks out of B. Someone who knows the word can answer either call every time. That property is called completeness.
  4. Step 4: A cheat fails half the time. An impostor without the word cannot get through the door. She passes only if she happened to hide in the path Victor then calls, and she cannot know his coin flip in advance. Two of the four cases fail. That a false claim is likely to be caught is called soundness.
  5. Step 5: Repeat to shrink the odds. One lucky round proves little, so they repeat it with a fresh path and a fresh coin flip each time. The chance that a cheat survives every round halves with each one: about one in a thousand after 10 rounds, one in a million after 20. The real Peggy passes them all.
  6. Step 6: Nothing leaks. All Victor ever saw was Peggy coming out of the path he named. He could stage an identical recording with an actor who guesses, cutting out the failed takes. A record that can be faked without the secret cannot contain it, so he learns nothing but the fact. That is zero knowledge.
  7. Step 7: One message, any verifier. The back-and-forth can be removed. Peggy derives the challenge herself as a hash of her commitment, which she cannot steer, and publishes one proof that anyone can check later. Such non-interactive proofs let an ID app show you are over 18 without your birth date, and let blockchains check payments without exposing them.
VALUES SO FAR
claimknows the wordPeggy
commit····secret
call····public
exit····response
cheat····odds
n = 10····odds
n = 20····odds
leaked····result
proof····public

Spotted a mistake on this page?