TL;DR
- You'll learn what a zero-knowledge proof actually proves, using two analogies you can explain to a friend.
- You'll also learn the three properties every ZK proof needs (completeness, soundness, zero-knowledge) and the difference between interactive and non-interactive proofs.
If you can read a bit of code, you have basic knowledge of blockchain & cryptography, and you're curious about how "prove without revealing" can possibly work, you're in the right place.
The problem
Here's the situation that ZK solves. I know something: a password, a private key, the answer to a puzzle. I want to convince you I know it. But I don't want to tell you what it is.
That sounds impossible. Usually the only way to prove I know a password is to type it in, and then whoever checks it knows it too.
A zero-knowledge proof gets around this. At the end, you're convinced, and you've learned nothing except the fact that my claim is true.
Intuition #1: the magic cave
This is the classic analogy, from a 1989 paper with the title "How to Explain Zero-Knowledge Protocols to Your Children."
Picture a cave shaped like a ring. The entrance splits into two paths, A and B, which meet at the back at a locked magic door. Only someone who knows the secret word can open it.
Peggy (the prover) claims she knows the word. Victor (the verifier) wants to be convinced, but Peggy refuses to say the word out loud.
So they play a game:
- Victor waits outside. Peggy walks in and picks path A or B at random. Victor can't see which.
- Victor walks to the fork and shouts: "Come out of B!" (he picks A or B at random too).
- If Peggy knows the word, she can always come out the side he asked for. If she's already on that side she just walks back; if not, she opens the door and goes through.
If Peggy is bluffing, she only gets it right when she happened to pick the same side Victor shouts. That's a 50% chance.
One round proves very little. But repeat it 20 times and a bluffer survives with probability (1/2)^20, which is about one in a million. Victor becomes very confident, yet he never heard the word, and he never even saw the door open.
Intuition #2: Where's Waldo
You and I are looking at a giant Where's Waldo page. I claim I found him. You don't believe me, but I don't want to spoil it by pointing.
So I take a huge sheet of cardboard, much bigger than the page, and cut a small Waldo-shaped hole in it. I lay it over the book so that only Waldo shows through the hole.
You see Waldo, so you're convinced. But you have no idea where on the page he is, because the cardboard hides all the context.
That's the heart of ZK: prove the statement ("Waldo is on this page"), hide the witness ("he's at the top left, next to the beach ball").
Vocabulary: the secret thing the prover knows is called the witness. The thing being proven is the statement. You'll see both words in every ZK library.
The three properties
Any zero-knowledge proof system has to give three guarantees. The cave makes them easy to see.
1. Completeness: if the statement is true and the prover is honest, the verifier will be convinced.
Peggy knows the word, so she passes every round.
2. Soundness: if the statement is false, a cheating prover can't convince the verifier (except with tiny probability).
A bluffer fails a round half the time, so 20 rounds makes cheating hopeless.
3. Zero-knowledge: the verifier learns nothing beyond "the statement is true".
Victor only ever sees Peggy walking out of the side he asked for. He could have faked that video himself by hiring an actor and telling them the side in advance, which is exactly why it carries no information about the word.
That last argument is the formal trick behind ZK: if the verifier could have simulated the whole conversation without the secret, then the conversation can't have leaked the secret.
Interactive vs non-interactive
The cave game is interactive: Victor has to be there, shouting random challenges. That's annoying in practice. You don't want to keep a live chat open with every person who wants to check your proof.
Modern ZK systems are mostly non-interactive: the prover produces a single blob of bytes (the proof), and anyone can verify it later, offline, as many times as they like. A blockchain is the perfect "anyone": a smart contract can verify this proof.
How do we get rid of Victor's random challenges? With the Fiat–Shamir heuristic: the prover generates the "random" challenges by hashing everything said so far. A good hash function is unpredictable, so the prover can't cheat by picking convenient challenges. It's as if Victor's coin flips were replaced by a hash function that nobody controls.
Hands-on (no code yet!)
This post is about intuition, so there's no circuit yet. But here's a tiny simulation of the cave that you can paste into Python. It shows why repeating rounds makes bluffing hopeless:
import random
def run_cave(knows_secret: bool, rounds: int) -> bool:
for _ in range(rounds):
peggy_side = random.choice("AB")
victor_asks = random.choice("AB")
if peggy_side != victor_asks and not knows_secret:
return False # stuck on the wrong side of the door
return True
trials = 100_000
for rounds in (1, 5, 10, 20):
wins = sum(run_cave(False, rounds) for _ in range(trials))
print(f"{rounds:>2} rounds: bluffer wins {wins / trials:.5%} of the time")
On my machine the bluffer wins about 50% at 1 round, about 3% at 5, about 0.1% at 10, and basically never at 20.
Gotcha: "zero-knowledge" doesn't mean "the statement is secret"
I tripped over this early on. I assumed a ZK proof hides everything. It doesn't.
The statement is public. If I prove "I know the password for account X", everyone learns that the password for account X exists and that I know it. Only the witness (the password) stays hidden.
This matters a lot later. When we write circuits, we'll explicitly mark which inputs are public and which are private, and a lot of real-world bugs come from accidentally making something public that should have been private (or the reverse).
The other half of my confusion: soundness is probabilistic. A ZK proof doesn't make cheating impossible, it makes it astronomically unlikely, like guessing a 128-bit key. In practice that's the same thing, but it's worth knowing.
Recap
- A ZK proof convinces a verifier that a statement is true without revealing the witness.
- Completeness: honest provers win. Soundness: liars lose. Zero-knowledge: the verifier learns nothing extra.
- Interactive proofs need a live verifier. Fiat–Shamir turns them into a single non-interactive proof that anyone can check.
Next up: where is this actually used? In Post 2: "Where ZK is used in the real world" (coming soon) — we'll look at private payments, rollups, identity, voting and proof of solvency, and why each of them needs ZK.
Further reading
- Zero-knowledge proof (Wikipedia): has the cave story and the history.
- The RareSkills ZK Book: a beginner-friendly path from here to the math.
- ZK MOOC lecture 1: the university-course version of this post.
Series codebase
All the code from posts in this series will be in this GitHub repo: Zero-Knowledge from zero knowledge


Top comments (0)