November 2026

Zero-Knowledge Proofs

Imagine that you know a secret, and you want to convince someone that you know it. The obvious way is to tell them, but then it's not your secret anymore. It seems impossible to do it any other way: how can anybody be sure that you know something if they never get to see it?

Surprisingly, it can be done. A zero-knowledge proof is a conversation in which one person convinces another that a statement is true, while revealing nothing at all beyond the fact that it's true. In the demonstration below, Peggy claims to know the magic word that opens a door deep inside a cave, and Victor wants to be convinced without ever hearing the word. The buttons under the cave decide if Peggy really knows the word or only pretends to:

This may look like a strange ritual for now. If Peggy really knows the word, she passes every round. If she only bluffs, she passes some rounds by luck, but sooner or later she fails one. Yet at no point does Victor hear the word, and, as we'll see, he doesn't even learn anything that he could use to convince somebody else.

Proofs like this one are not just a curiosity. They let a phone show that its owner is an adult without showing a birth date, they let a payment network check a transaction without seeing who paid whom, and they let a single short message prove that millions of computations were done correctly. In this article we'll build up to how they work, one small step at a time. We'll start with the most obvious way to prove that you know something, and see why it fails.

Some demonstrations in this article are animated. You can pause or resume all of them at once, or use the button in the corner of each one.

Proof by Showing

When you log in to a website, you prove that you are you by typing a password. In other words, you prove that you know a secret by showing it. In the demonstration below, Peggy proves to Victor that she knows the password. You can drag the slider to move through time:

This works as a proof, since Victor can now check the word against his records. But the proof has a nasty side effect: at the end, Victor knows the password as well as Peggy does. He could log in as Peggy, or tell the password to someone else. A website that is broken into leaks every password that its users ever typed, because each user gave their secret away to prove that they knew it.

What we want is a proof that convinces Victor of the fact that Peggy knows the secret, without giving him the secret itself. For pictures, there's a simple physical trick that does exactly that. The demonstration below shows a large picture full of small shapes. Somewhere among them there is one golden star, and Peggy has found it. The slider pulls a large sheet of cardboard over the picture:

The sheet is many times larger than the picture and has a single small hole in it. Peggy places it so that the hole sits exactly over the star. Victor can look through the hole and see that the star really is there, so he knows that Peggy found it. But he can't see where in the picture the hole is, since the edges of the sheet are far beyond the edges of the picture. He's convinced, yet he's no closer to finding the star himself.

This trick shows that "proving without showing" isn't a contradiction. But it works only for pictures and needs a large piece of cardboard. Computers send each other numbers, not cardboard, and most secrets aren't stars hidden in a picture. We need a method that works for any secret, and to find one we'll have to go into a cave.

The Cave

This story was told by the cryptographer Jean-Jacques Quisquater and his colleagues in a 1989 paper with the charming title "How to Explain Zero-Knowledge Protocols to Your Children". The cave is shaped like a ring, with a single entrance. Deep inside, at the far side of the ring, the path is blocked by a door that opens only when someone says the magic word. The slider moves Peggy along the path, and the buttons decide if she knows the word:

I'm drawing the cave from above. When Peggy knows the word, she can walk all the way around the ring, and the door opens and closes behind her. When she doesn't know it, she can get as far as the door from either side, but no farther.

Notice that from the entrance, the two halves of the ring look the same. Someone who stands at the fork, where the entrance meets the ring, can't see the door, and can't see which half of the ring a person went into. This is all that the proof will need.

Here's how it works. Victor waits outside while Peggy goes into the cave and picks one of the two halves. Then Victor walks up to the fork and calls out which side he wants Peggy to come out of: left or right. The buttons set Peggy's choice and Victor's call, and the slider moves through time:

If Victor calls the side that Peggy went into, she simply walks back. If he calls the other side, she says the word, goes through the door, and comes out of the side he asked for. Either way, Victor sees her come out where he wanted.

Now let's see what happens when Peggy doesn't know the word, but tries to fool Victor anyway. She goes into one side and hopes for the best:

If Victor happens to call her side, she walks out, and her bluff works. If he calls the other side, she's stuck at the door, and Victor knows that she lied. Since Peggy has to pick a side before she hears the call, and Victor picks the call at random, she guesses right only half of the time.

Half is not very convincing. A single round can easily go well by chance, just like a single coin toss. But Victor doesn't have to stop at one round. He can ask Peggy to do it again, and again, each time with a new random call. Someone who knows the word passes every round. A bluffer has to guess right every time, and each new round halves her chances.

The demonstration below starts with 1,024 bluffers, each one a dot. The slider sets how many rounds they have to go through, and each round removes everyone who guessed wrong:

As you can see, about half of the bluffers survive one round, about a quarter survive two, and after ten rounds about one in a thousand is left. After 20 rounds, a bluffer gets through only about once in a million attempts, and after 40, once in a million million. Victor can't be completely sure that Peggy knows the word, but he can make the chance that she bluffed as small as he likes, just by asking for more rounds.

This is the shape of every zero-knowledge proof. There's a prover, Peggy, who wants to show that a statement is true, and a verifier, Victor, who checks. They exchange messages back and forth, and the verifier's messages contain random challenges that the prover can't predict. Two properties make it a proof. When the statement is true, an honest prover always convinces the verifier; this is called completeness. When it's false, a cheating prover convinces the verifier only with a tiny probability; this is called soundness.

Many conversations have those two properties. The password check has them too. What makes the cave special is the third property, the one in the name.

Nothing Learned

It feels clear that Victor doesn't learn the magic word in the cave. He never hears it, and all he sees is Peggy coming out of the side he called. But "it feels clear" is not good enough for cryptographers, and the idea they came up with to make it precise is one of the most beautiful parts of this story.

Suppose Victor records the whole session with a camera at the fork, so that he can later show his friends that Peggy knows the word. Each round of his film shows the side he called, and Peggy coming out of it. Now imagine a faker who doesn't know the word, but wants to make a film that looks just the same. The buttons switch between Peggy's real film, all the takes the faker recorded, and the faker's final cut:

The faker records many takes. In each one, the actor playing Peggy goes into a random side, and the actor playing Victor calls a random side. About half of the takes fail, and the faker simply cuts them out. In the final cut, every round shows a call and Peggy coming out of the right side, and nobody can tell it apart from the real film.

This tells us something important about Victor's film: it can't contain the magic word, or anything else that depends on it, because the faker made a film that looks exactly the same without knowing the word. Whatever Victor takes away from the session, he could have produced on his own. This is what it means for a proof to be zero-knowledge: everything that the verifier sees could have been made without the secret. A program that makes such a fake record is called a simulator, and showing that a simulator exists is how cryptographers prove that a protocol leaks nothing.

This leads to a curious conclusion. Victor's film convinces nobody but Victor. He was there, he chose each call at random, and he knows that Peggy couldn't have known the calls in advance. His friends weren't there, and for all they know, the film was cut from failed takes. The proof convinces the person who takes part in it, and nobody else. We'll see later that this is sometimes a feature and sometimes a problem.

Notice also that the faker could only cut out the failed takes because the faker chose the order of events. In the real cave, the order is what matters: Peggy must commit to a side before Victor's call, and Victor's call must be truly random. Remove either one and the proof falls apart. We'll meet this pattern of commit, challenge, and response again and again.

The cave is a lovely story, but it's still a story about a physical door. To use the same idea for real secrets, we have to replace each part of it with something that can be sent as a message. The first part to replace is the most physical one: Peggy committing to a side, out of Victor's sight.

Sealed Boxes

In the cave, the rock walls hide Peggy's choice from Victor, and they also stop her from changing her mind after she hears his call. She can't step from one side of the ring to the other without the door. To do the same with messages, we need a way to fix a value now but reveal it only later. The everyday version is a locked box. In the demonstration below, Peggy writes her choice on a card, locks it in a box, and gives the box to Victor. The slider moves through time:

While Victor holds the locked box, he can't see what's inside, so the box is hiding. Peggy can't change the card anymore, because the box is no longer in her hands, so it's also binding. Only when Peggy sends the key does Victor learn what she chose, and he can be sure that it's what she chose at the start.

Cryptographers call this a commitment. A digital commitment doesn't use a box, of course. A common recipe is to mix the value with a long random number and feed both into a hash function, which we'll look at more closely later. The scrambled result is the locked box: it reveals nothing about the value, and it's practically impossible to find a different value that gives the same result. To open the commitment, Peggy reveals the value and the random number, and Victor repeats the calculation.

Commitments give us the first half of the cave as messages. With them, we can build a zero-knowledge proof for a much more interesting secret than a magic word.

Coloring Maps

Here's a puzzle. The demonstration below shows a network of dots connected by lines. The goal is to paint every dot with one of three paints, red, yellow, or blue, so that no line connects two dots of the same paint. You can click a dot to change its paint:

One line, marked with a cross, connects two dots of the same paint, and you can probably fix it with a single click. A painting with no crosses is called a valid 3-coloring. The name comes from coloring maps, where countries that share a border must get different colors; each dot is a country, and each line is a border.

For a small network like this one, you can find a valid coloring with some patience. For a network with thousands of dots, nobody knows a method that is much faster than trying an enormous number of possibilities. And yet, if someone hands you a finished coloring, checking it is easy: you just look at every line. Let's suppose that Peggy has found a coloring for a huge network, and she wants to convince Victor of that without showing it to him.

The first idea she needs is that the names of the paints don't matter. If she swaps the paints around, so that every red dot becomes yellow and every yellow dot becomes red, the coloring is still valid. The slider goes through all six ways of swapping three paints, and the column on the right shows which paint becomes which:

Every swap gives a different-looking coloring, but the pattern underneath is the same, and none of them has a cross. This matters because it means that the color of any single dot means nothing on its own. A dot is red in one swap and blue in another.

Now we can describe one round of the proof. Peggy picks one of the six swaps at random, paints a fresh copy of the network, and seals the paint of every dot in its own locked box. Victor sees only the network of boxes. Then he picks one line at random, the challenge, and Peggy opens just the two boxes at its ends. In the demonstration below you can click any line to challenge it, and the slider starts a new round with a new swap:

If Peggy's coloring is valid, the two opened boxes always show two different paints, so she passes every round. And what does Victor learn? Only that two connected dots have two different paints, which he knew would happen anyway. Because Peggy swaps the paints in every round, the pair that he sees is a random pair of different paints. If you go to the next round and check the same line again, you'll likely see a different pair. Victor could have produced pairs like these himself, by picking two different paints at random. Just like the faker's film, his record of the session could have been made without the coloring.

Now suppose that Peggy is cheating. She has no valid coloring, so at least one line in her painting connects two dots of the same paint. She can't move that line after the boxes are sealed, so if Victor happens to pick it, he catches her. The network has 19 lines, so in each round a cheater survives with a chance of at most 18 in 19. That's much less sharp than the cave's one in two, so Victor needs more rounds. The demonstration below starts with 1,024 cheaters again:

After 10 rounds most cheaters are still around, but after 100 rounds only a handful remain. Each round still multiplies a cheater's chances by the same number, so they shrink exponentially; it just takes longer. For a network with a million lines, Victor would need tens of millions of rounds for good confidence, which is slow but entirely possible for computers.

This protocol was found in 1986 by Oded Goldreich, Silvio Micali, and Avi Wigderson, and it's far more important than it may seem. Coloring networks belongs to a large family of problems, known as NP-complete problems, with a remarkable property: any puzzle whose solution is easy to check, from Sudoku to "this number has a factor I know" to "this transaction is valid", can be translated into a network that is 3-colorable exactly when the puzzle has a solution. The translation is mechanical, and a solution to the puzzle gives a coloring of the network. In principle, then, the map-coloring proof can prove knowledge of the solution to any such puzzle, in zero knowledge.

In practice, translating a puzzle into a network creates gigantic networks, and the proof needs millions of rounds. For one very common kind of secret, there's a much more elegant proof. To understand it, we need a short detour through clocks.

Clock Arithmetic

If it's 9 o'clock now, what time will it be 5 hours from now? Not 14 o'clock, but 2 o'clock, because a clock wraps around after 12. The slider below sets how many hours we add to 9 o'clock:

As you can see, adding 3 hours brings us to 12, and adding 12 hours brings us right back to 9. This kind of arithmetic, where numbers wrap around after a fixed value, is called modular arithmetic, and it's the playground of most of modern cryptography. You can add, subtract, and multiply on a clock just like with ordinary numbers; you just wrap around whenever you pass the top.

Mathematicians usually number the clock from 0, so a 12-hour clock has the numbers 0 to 11. Let's use a larger clock with 47 numbers, from 0 to 46, start at 1, and keep doubling. The slider sets how many times we double:

At first, nothing surprising happens: 1, 2, 4, 8, 16, 32. But the next doubling gives 64, which is past the top of the clock, so we wrap around to 64 − 47 = 17. From then on, the path jumps all over the clock with no obvious pattern. After 23 doublings it comes back to 1, and the loop starts again. It visits only 23 of the 46 numbers, which happens because 47 − 1 = 2 × 23; I'll simply ignore the numbers that the loop never visits.

Doubling a number some given number of times is easy, even on a gigantic clock, since there are shortcuts that need only a few hundred steps. But going backwards is a different story. If I tell you that some number of doublings gave 21, how many doublings was it? On our small clock you can find out by following the path. On a clock with a number of positions that has 78 digits, which is a typical size in practice, nobody knows a way that is fundamentally faster than trying, and trying would take longer than the age of the universe. This problem is called the discrete logarithm, and its difficulty is what the next proof stands on.

There's a neat way to picture the loop. Let's take the 23 numbers that it visits and arrange them around a ring in the order in which the doublings visit them. The slider moves the numbers from the clock to the ring:

On the ring, every doubling moves exactly one stop forward. This makes doubling look trivial, but remember the catch: for a real clock, the order of the stops is something nobody can work out. Anybody can start at 1 and walk forward a given number of stops, but nobody can look at a number and say where on the ring it sits.

The ring has one more useful property. Multiplying two numbers on the clock adds their positions on the ring. For example, 8 sits at stop 3 and 32 sits at stop 5, and 8 × 32 = 256, which wraps around to 21, at stop 8. Multiplying is just walking.

A Secret Number

We now have everything we need for a real cryptographic secret. Peggy picks a random stop number, x, and keeps it secret. Then she walks x stops from 1 and publishes the number where she lands, y. The slider sets the secret:

On our small ring, anybody could find x by walking around until they meet y. On a ring with 2256 stops, nobody can. In cryptography, x is called a private key and y a public key. Peggy can tell the whole world y, and only she knows the step count that leads to it. Now, she wants to prove to Victor that she knows x, without revealing anything about it.

The protocol she uses was published by Claus-Peter Schnorr in 1989, and it has the same three moves as the cave. First, Peggy picks a random number of stops, r, which cryptographers call a nonce, and sends Victor the number where it lands, t. This is her commitment. Second, Victor picks a random challenge c. Third, Peggy answers with s, a number of stops: the r stops of the nonce, plus c times x stops. The two sliders set the nonce and the challenge:

Notice that the response arc always ends at the same stop as the nonce followed by c copies of the secret. Victor can't see the arcs, but he can check this without them. He walks s stops from 1, which anybody can do, and he multiplies t by y as many times as the challenge says. Since multiplying is walking, both calculations land on the same number exactly when s = r + c × x. On the clock, that check reads:

2s = t · yc

I've kept the challenges small so the drawing stays readable. In a real protocol they are huge random numbers, and the arcs would wrap around the ring countless times.

Why does Peggy need the nonce at all? Take it away, and the response is just c copies of x. Victor knows c, so he can divide and get the secret. The nonce is a random head start that hides the secret, just like Peggy's random swap of paints in the map-coloring proof. Because r is random and Peggy never reveals it, the response s is also a random number, and on its own it says nothing about x.

We can make that precise with the same argument as the faker's film. A forger who doesn't know the secret can make conversations that pass Victor's check, if the forger is allowed to choose the challenge. He picks c and s first, at random, and then works out the t that makes the check come out right. That needs only a division on the clock, not the secret. The demonstration below shows six real conversations next to six forged ones, and the slider makes new batches:

Both columns pass the check, and both are made of numbers that are spread at random over the ring. Nobody can tell which column came from someone who knows the secret. So whatever Victor sees in a real conversation, he could have made himself, and he learns nothing about x. The forger succeeds only because he picked the challenge before the commitment. In the real protocol, Peggy must send t before she sees c, and that order is what convinces Victor.

Why can't a cheating Peggy pull off the same trick? Suppose she could answer two different challenges for one commitment. In the demonstration below, Peggy sends one t, and the two sliders set two different challenges:

The two responses differ by exactly c1 − c2 copies of the secret, because the nonce is the same in both. Anyone who has both answers can divide and get x. On the clock, division has its own rules, and the result can look surprising when the arcs wrap around, but it always works when the number of stops is a prime, like our 23. This means that anyone who can answer more than one challenge for a commitment must know the secret, and a cheater who doesn't know it can answer at most one challenge out of an enormous number of possible ones. That's soundness.

The same fact is a trap for honest provers. If Peggy ever uses the same nonce twice, the two conversations reveal her secret to anyone who looks. This isn't a hypothetical mistake. In 2010, a group of hackers called fail0verflow showed that Sony had signed software for the PlayStation 3 using a fixed number where a fresh random nonce was needed, which let them compute Sony's private signing key with exactly this kind of division.

Schnorr's protocol is short, fast, and leaks nothing. But it's still a conversation: Victor has to be there, at the right moment, to pick a random challenge. That's fine for logging into a computer, but useless for a proof that has to convince people who aren't there when it's made.

No Conversation

Victor's only job in Schnorr's protocol is to pick a challenge that Peggy can't predict. If something else could produce such a challenge, Victor wouldn't need to be there at all. The tool that does it is a hash function, which takes any message and turns it into a fixed-size jumble of bits. In the demonstration below, the message at the top goes through a widely used hash function called SHA-256, and the grid shows its 256 output bits, dark for 1 and light for 0. The slider changes the amount in the message:

Notice that changing a single digit, for example from 10 to 11, scrambles the whole grid. The same message always gives the same grid, but nobody knows how to predict the grid of a message without computing it, or how to find a message that gives some chosen grid, other than by trying one message after another. For practical purposes, a good hash function behaves like a die that anybody can roll, that always gives the same result for the same message, and whose result nobody can steer.

This suggests a trick, published by Amos Fiat and Adi Shamir in 1986. Instead of asking Victor for a challenge, Peggy computes it herself, by hashing her commitment together with the message she wants to send. Everything else stays the same. The buttons pick a message, and the slider sets the nonce:

Peggy can't choose the challenge to suit herself, because it comes out of the hash, and the hash depends on the commitment that she has to fix first. If she changes t, the challenge changes unpredictably. The order of commit, then challenge, is now enforced by the hash function instead of by Victor's timing.

The result is a single block of numbers, t and s, that anyone can check at any time: recompute the challenge from the hash, then do Victor's check. This is called a non-interactive proof. Because the message goes into the hash, the proof is tied to it. If someone changes the message, the challenge changes, and the old response no longer passes. What we've built is a digital signature: a proof that whoever wrote this message knows the secret behind the public key, which can't be moved to another message. Schnorr signatures, and close relatives of them like Ed25519, are used in everyday tools such as SSH, and since 2021 they have been part of Bitcoin.

Remember that Victor's film convinced nobody but Victor. A non-interactive proof is the opposite: it convinces everybody who checks it. That's exactly what a signature needs, but it does give up something. In a live conversation, Peggy can later deny that she ever proved anything, since Victor could have faked the record. With a signature, she can't.

There's one more catch. Since Peggy computes the challenge on her own, a cheater can try again as often as she likes, in private, without anyone noticing failures. She prepares an answer for one particular challenge, then keeps trying new commitments until the hash happens to produce that challenge. In the demonstration below, every square is one attempt, and the slider sets how many bits long the challenge is:

With a 1-bit challenge, the cave's left or right, the cheater gets lucky almost immediately. Each extra bit doubles the expected number of attempts: with 10 bits, she needs about a thousand. This is why the cave protocol, made non-interactive by simply hashing its rounds, would need far more rounds than a live conversation. A live cheater gets one chance to fool Victor, but an offline cheater gets as many chances as her computers can afford. Forty bits of challenge mean about a trillion attempts, which a determined attacker can afford. Real systems use challenges of 128 bits or more, which no amount of computing can beat by trial.

Proving Computations

Schnorr's protocol proves one specific thing: "I know the number of steps that leads to this public number". The map-coloring proof can prove anything, but it's painfully slow. Since the early 2010s, cryptographers have found ways to get the best of both: short, fast proofs of any computation. The full machinery is beyond this article, but its central ideas are within reach.

The first idea is that any computation can be broken down into a network of tiny steps, each one an addition or a multiplication. A classic example asks for a number x such that x³ + x + 5 equals 35. The demonstration below shows this calculation as a circuit of four steps, and the slider sets x:

Each circle takes the numbers on its incoming wires and produces one on its outgoing wire. Only x = 3 gives the public result. To check the calculation, you need to check every circle: that its output really is the sum or the product of its inputs. A real computation, like checking a transaction or a password, becomes a circuit with millions of such circles. Peggy wants to convince Victor that she knows numbers for all the wires that make every circle correct, without revealing them, and without Victor checking millions of circles.

The second idea is to pack all those numbers into a single polynomial: a curve made of powers of x, like the one in the circuit. A clever encoding turns "every circle is correct" into "this polynomial equals that one". And polynomials have a remarkable property. Two different polynomials can only agree at a few places; at most as many as their highest power. In the demonstration below, the brown curve is the correct polynomial, and the pink curve is a forged one that a cheater might send. The slider moves a test point:

The two curves cross at four points, which I've circled. At a crossing, the forgery passes the test. Everywhere else, like at this point, it fails. If Victor picks the test point at random, the forgery almost always fails. In real systems the curves live on a clock with about 2255 positions, and even with millions of crossings the chance of hitting one is less than one in 1060. A single check at a random point tells Victor whether two enormous polynomials are the same, which means whether millions of circles are all correct.

From here, the rest is assembled from parts we've already seen. Peggy commits to her polynomials before she knows the test point, using commitments built so that she can later open the value at any single point. The test point is the challenge, and it comes from a hash, as in Fiat and Shamir's trick. Peggy also adds random padding to her polynomials, just like the nonce in Schnorr's protocol, so that the opened values reveal nothing about the wires.

The result is called a zk-SNARK, short for zero-knowledge succinct non-interactive argument of knowledge. The word "succinct" is the astonishing part: for a popular construction from 2016 by Jens Groth, a proof takes under 200 bytes, less than this paragraph, and checking it takes milliseconds no matter how large the computation was. The cryptocurrency Zcash, launched in 2016, uses such proofs to show that a payment is valid without revealing the sender, the receiver, or the amount. Today, similar systems compress thousands of transactions into a single proof, and digital identity wallets are starting to use zero-knowledge proofs to show facts like "over 18" without revealing anything else on the ID.

Further Reading

The cave comes from "How to Explain Zero-Knowledge Protocols to Your Children" by Jean-Jacques Quisquater and colleagues. It's a short, playful paper that tells the story of Ali Baba's cave and is worth reading for its charm alone.

Matthew Green's blog post "Zero Knowledge Proofs: An illustrated primer" walks through the map-coloring proof and simulators in more depth, in a friendly voice, with some history of how these ideas came about.

For the step from circuits to polynomials, Vitalik Buterin's "Quadratic Arithmetic Programs: from Zero to Hero" works through the same x³ + x + 5 = 35 example in full detail. It needs some comfort with algebra.

Finally, Justin Thaler's free book "Proofs, Arguments, and Zero-Knowledge" is a complete and rigorous course on modern proof systems, for readers who want to understand how today's zk-SNARKs actually work.

Final Words

When Shafi Goldwasser, Silvio Micali, and Charles Rackoff first described zero-knowledge proofs in 1985, the idea was so strange that their paper was rejected several times before it was accepted. A proof, to a mathematician, was something written down and checked line by line. The idea that a conversation full of coin tosses could count as a proof, and that it could convince without explaining, seemed almost like a contradiction. Goldwasser and Micali later received the Turing Award, the highest honor in computer science, in part for this work.

What I find most striking is how little each piece needs. A rock wall, a locked box, a swap of paints, a random head start. None of them is clever on its own. The cleverness is in the order: commit, then challenge, then answer, and in the realization that "could have been faked" is exactly the property that makes a record harmless.

There's also something quietly philosophical here. A zero-knowledge proof separates two things that we usually treat as one: being convinced and being told. For most of history, the only way to convince someone of a fact was to show them the evidence, and showing meant giving it away. It turns out that, with a bit of randomness and a lot of care, you can hand someone certainty while keeping everything else to yourself.