A zero-knowledge proof convinces someone that a statement is true without revealing why it is true. It sounds paradoxical, but the smallest example needs only the elliptic curve math from the signatures post.
The idea, with no math
Imagine your friend is colorblind. You hold two balls, one red and one green, and they look identical to your friend. You claim they are different colors. How do you prove it without telling them which is which?
Play a game:
- Your friend takes both balls, hides them behind their back, and either swaps them or doesn't.
- They show you the balls and ask: "Did I swap them?"
- You can see the colors, so you always answer correctly.
If the balls were really the same color, you would be guessing and be right half the time. Do ten rounds, and a liar gets all ten right with probability . After enough rounds your friend is convinced the balls differ, but they still can't say which is red.
That is a zero-knowledge proof:
- Your friend is convinced the claim is true: the balls really are different.
- A liar gets caught. Each round, cheating succeeds only by luck, and luck runs out.
- Your friend learns nothing else. They never find out which ball is red, and a recording of the game proves nothing to anyone else, because two people could stage the same rounds with a script they agreed on beforehand.
The shape of every proof in this post is the same as the game:
| In the game | In the real proof |
|---|---|
| Hiding the balls behind your back | Commit to something random |
| Your friend's swap-or-not choice | A random challenge from the verifier |
| Your answer | A response that only works if you know the secret |
| Repeating many rounds | Soundness gets stronger every time |
The rest of the post replaces the balls with a private key, and the guessing game with algebra. The secret is a number , the commitment is a point on a curve, and the answer is a single equation that only someone who knows can satisfy.
What a proof must satisfy
- Completeness: an honest prover with a true statement convinces the verifier.
- Soundness: a prover with a false statement can't convince the verifier, except with negligible probability.
- Zero-knowledge: the verifier learns nothing beyond the fact that the statement is true.
A Schnorr proof of knowledge
The statement: "I know such that ." The prover wants to show this without revealing .
- Commit. The prover picks a random and sends .
- Challenge. The verifier sends a random .
- Response. The prover sends .
- Check. The verifier accepts if:
It is correct because .
Why it is sound
Suppose a prover can answer two different challenges for the same commitment , with responses and . Subtracting:
So anyone who can reliably pass the check must be able to produce . This argument, called special soundness, is how security proofs show that passing means knowing. A prover who doesn't know can prepare an answer for one challenge in advance, but not for a random one.
Why it leaks nothing
The verifier sees a transcript . Anyone can fake one without knowing : pick and at random, then set:
This transcript passes the check, and it is distributed the same way as a real one. Since a simulator with no secret can produce transcripts the verifier can't tell apart from real ones, a real transcript can't contain information about . The randomness of is what hides , and this is why a repeated is fatal, as in the nonce reuse post.
Removing the verifier: Fiat-Shamir
An interactive proof needs the verifier online. Fiat-Shamir replaces the verifier's random challenge with a hash of everything that came before it:
Now the prover computes the whole proof alone, and anyone can check it later. With a message mixed in, this is a Schnorr signature, the same structure as EdDSA. A signature is a proof of knowledge of the private key, bound to a message.
The hash must include the statement () and the commitment (). Leaving out parts of the statement is a known source of real attacks.
From one statement to any program
Proving knowledge of a discrete log is one fixed statement. SNARKs and STARKs prove arbitrary computations, and they follow the same recipe at a larger scale:
- Arithmetize. Turn the program into a set of polynomial constraints over a finite field. "The program ran correctly" becomes "these polynomials satisfy these equations".
- Commit. The prover commits to the polynomials with a polynomial commitment scheme, such as KZG or FRI. A commitment is short and binds the prover to a fixed polynomial.
- Check at a random point. Two different polynomials of degree agree on at most points, so if they agree at a random point out of a huge field, they are almost certainly equal (the Schwartz-Zippel lemma). The verifier checks the constraints at one random point instead of everywhere.
- Make it non-interactive. The random point comes from Fiat-Shamir, as above.
The verifier does a small amount of work whatever the size of the original computation, which is what makes rollups possible: one short proof stands for thousands of transactions.
Zero-knowledge comes from adding random blinding terms to the polynomials, the same role plays in the Schnorr proof.
SNARKs and STARKs
- SNARKs have very small proofs and fast verification. Many need a trusted setup, a one-time ceremony whose secret must be destroyed, and most rely on elliptic curve pairings.
- STARKs need no trusted setup and rely only on hash functions, which is also why they are believed to resist quantum computers. The price is larger proofs.
The takeaway
A zero-knowledge proof is a commitment, a random challenge, and a response that can be verified only if the prover knows the secret. A simulator showing that the transcript could be faked is the argument that nothing leaks. Everything else, including circuits and polynomial commitments, is machinery for applying that pattern to more complex statements.