Interactive ZK Proofs 🎨
The cave was theatre. Now we do the real thing: a full zero-knowledge proof of an actual mathematical statement, where you sit in the verifier's chair, issue the challenges, and watch a cheater get shredded by probability.
Statements, witnesses, and NP
A proof system talks about statements — claims that are either true or false:
- "This graph can be colored with 3 colors so no edge connects two same-colored nodes." (true/false)
- "I know an x with gˣ ≡ y (mod p)."
- "This Sudoku grid has a solution." / "This transaction balances."
The witness is the secret evidence — the actual coloring, the exponent, the solved grid. NP is precisely the class of statements whose witnesses are short enough to check quickly. The theorem powering this whole field: every NP statement has a zero-knowledge proof (Goldreich–Micali–Wigderson, 1986). Master it for one NP-complete problem — graph 3-coloring — and you've mastered it for all of them.
The graph coloring protocol
Peggy claims graph G is 3-colorable, and she knows a coloring. Victor doubts. Colors are named red, blue, gold — but any relabeling is equally valid, and that's the secret sauce:
- Commit. Peggy randomly permutes her color names (red↔blue↔gold shuffle) and sends Victor one commitment per node — sealed envelopes from Chapter 4. Victor learns nothing: any 3-coloring permutes into any other relabeling with equal probability.
- Challenge. Victor picks a random edge and demands both endpoint envelopes.
- Respond. Peggy opens exactly those two. Victor checks: commitments verify, and the colors differ. Repeat from step 1.
Why it works: an honest Peggy always passes — completeness. A Peggy without a valid coloring must commit to something; whatever she commits to, at least one edge is monochromatic, so a random challenge catches her with probability ≥ 1/|E| per round — soundness. And the revealed pair is always "two random distinct colors" — precisely what Victor could have generated himself — zero knowledge.
🧪 The Verifier's Chair
Your job: challenge edges. Each round, Peggy re-commits with a fresh secret permutation. Flip on cheat mode to face a Peggy who never had a valid coloring — she fills envelopes with random junk and prays you don't probe a bad edge. Catch her.
The simulator: zero knowledge made rigorous
"Victor learns nothing" can't just be vibes — here's the formal trick. Suppose Victor could record the whole conversation: commitments, challenged edges, opened colors. Now imagine a simulator: a program with no Peggy and no coloring at all that picks a random edge, picks two random distinct colors, seals fake envelopes for those two nodes, and prints the same style of transcript. If honest transcripts and simulated ones are indistinguishable, then the transcript contains nothing that required the secret — because the simulator didn't have it.
Don't take my word for it. Play: one transcript below is from a real honest run, the other was forged by the simulator with zero knowledge of any coloring. Spot the real one.
Where this leads
The coloring protocol is beautiful but expensive: ~50 rounds × 20 commitments each, and every round needs Victor awake. Two directions fix this, and they're the next two chapters:
- Σ-protocols (Chapter 6): sleek 3-move proofs (commit → challenge → respond) for algebraic statements like "I know x in y = gˣ", plus the Fiat–Shamir trick that removes the verifier entirely.
- SNARKs (Chapter 7): proofs of arbitrary computations, compressing thousands of rounds into a single 200-byte artifact verifiable in milliseconds.
📌 Week 5 — key takeaways
- The recipe: commit to a randomized encoding of the witness → verifier challenges a random local piece → respond → repeat with fresh randomness.
- Soundness per round ≥ 1/|E| because a bad commitment must contain a monochromatic edge; repetition compounds: (1 − 1/m)ⁿ → 0.
- Zero knowledge = simulatability: you played the simulator and couldn't beat 50/50 at spotting real transcripts — that IS the definition, experienced.
- Binding commitments buy soundness; hiding commitments plus fresh permutations buy zero knowledge — the commit-and-prove pattern behind every modern ZK system.
- Answering two challenges on one commitment exposes the witness (extraction) — "proof of knowledge", not just proof of truth.
- GMW '86: 3-coloring is NP-complete, so every NP statement — Sudoku, transactions, circuits — inherits zero knowledge.
Checkpoint: The Real Thing
- To make the commitments shorter.
- Because the colors would fade otherwise.
- So each round reveals a uniformly random relabeling — no matter how many rounds Victor sees, he can never stitch together the actual coloring.
- To increase the catch probability for cheaters.
- At least 1/m, where m = number of edges.
- Exactly 50%.
- 1/3, because there are three colors.
- Zero — she can always answer convincingly.
- it runs faster than the real protocol.
- it produces indistinguishable transcripts while possessing no witness — so the transcript can't encode any knowledge of the witness.
- it uses encryption on all messages.
- it convinces Victor without Peggy being online.
- It makes the protocol faster.
- It means the protocol is quantum-safe.
- It proves P = NP.
- Any NP statement can be translated into a coloring instance — so a ZK protocol for coloring gives ZK for every efficiently checkable claim.