Proof and Reasoning

Zero-Knowledge Proofs, Convincing Someone Without Revealing Why

Learn how you can prove you know a secret without disclosing it, through a cave story, a graph coloring protocol and a small number example.

Key takeaways

  • A zero-knowledge protocol must convince an honest verifier of true claims and almost never of false ones, while leaking nothing else.
  • The verifier asks random questions that a prover without the secret cannot all answer, so repetition drives cheating odds toward zero.
  • Zero knowledge is argued by showing that the verifier could have produced a convincing-looking transcript alone.
  • The idea underlies some identification schemes, signatures and privacy-preserving verification systems.
  • Real systems need expert design, since small implementation mistakes can leak the secret.

A zero-knowledge proof is an exchange in which one party, the prover, convinces another, the verifier, that a statement is true while giving away nothing beyond its truth. You can show that you know a password, a solution or a secret key without handing it over, and without giving the verifier anything that would help them convince someone else.

It sounds impossible, because an ordinary proof works by showing the reasons. The trick is to add interaction and randomness.

A cave with a locked door

A well-known teaching story, popularized in a paper by Jean-Jacques Quisquater and coauthors, uses a ring-shaped cave. The entrance splits into a left passage and a right passage, which meet at the far end at a door that opens only with a secret word. Peggy claims to know the word. Victor wants evidence.

Victor waits outside while Peggy walks down a passage of her choice. Then he comes to the fork and shouts which side he wants her to come out of. If she knows the word, she can always comply, going through the door if necessary.

If she does not know it, she can comply only when Victor happens to name the side she entered, a chance of 1/2. After 20 rounds with independent random calls, a bluffer succeeds with probability 1/2²⁰, less than one in a million. Victor never hears the word.

Two balls and a color-blind friend

Here is another version with no cave. You have two balls that are identical except that one is red and one is green. Your friend cannot distinguish those colors and doubts that they differ at all.

Your friend holds one in each hand, puts them behind their back, and either swaps them or not, deciding by a coin flip. When they show the balls again, you say whether a swap happened. If the balls really differ in color, you are always right. If they were identical, you could only guess. Ten correct answers in a row would happen by guessing about once in a thousand tries.

Your friend becomes convinced that the balls differ, yet never learns which one is red. Every answer you gave was something they already knew, since they did the swapping.

Three properties

Shafi Goldwasser, Silvio Micali and Charles Rackoff introduced the formal idea in the mid-1980s. Their definition, in plain terms, asks for three things.

What a zero-knowledge protocol must satisfy
Protocol Prover and verifier exchange messages Zero knowledge The verifier learns nothing beyond truth Completeness A true claim and honest prover are accepted Soundness A false claim passes only with small chance Protocol Prover and verifier exchange messages Completeness A true claim and honest prover are accepted Soundness A false claim passes only with small chance Zero knowledge The verifier learns nothing beyond truth

Soundness is probabilistic: a cheater can get lucky. As with other randomized verification, repetition makes the luck required absurdly large.

Order matters in these exchanges. Peggy must choose her passage before she hears Victor's call, and Victor must choose without knowing which way she went. If she could predict the calls, she could bluff forever. If he could not trust that she had already committed, her correct answers would show nothing. Almost every zero-knowledge protocol has this rhythm of commitment, random challenge and response.

Proving that a map can be three-colored

Take a network of points joined by lines. Suppose the prover knows how to color the points with three colors so that every line joins two different colors. Finding such a coloring can be extremely hard for large networks. Here is a protocol due to Oded Goldreich, Micali and Avi Wigderson.

  1. The prover randomly shuffles the names of the three colors.
  2. She commits to the color of every point, as if sealing each in its own locked box.
  3. The verifier chooses one line at random.
  4. The prover opens only the two boxes at its ends.
  5. The verifier checks that the two colors differ.

If the coloring is correct, the check always passes. If the prover has no valid coloring, then at least one line has matching ends, and with E lines the verifier hits it with probability at least 1/E each round.

For a hypothetical network with 100 lines, a cheater survives 1,000 rounds with probability at most (0.99)¹⁰⁰⁰, about 0.00004. With 5,000 rounds the bound is around 10⁻²².

The verifier learns nothing useful, since each round shows just two different colors, randomly renamed. Because three-coloring is an NP-complete problem, this implies that, assuming secure commitments exist, every statement in the class NP has a zero-knowledge proof.

The sealed boxes are called commitments. In a real system they are made with cryptography and need two properties. They must be hiding, so that the verifier cannot peek at a color before it is opened. They must be binding, so that the prover cannot change a color after seeing which line was chosen. Without the first, knowledge leaks. Without the second, cheating is trivial.

The shuffling of colors is just as important. Without it, the verifier could open different lines over many rounds and gradually assemble the whole coloring. With fresh random names and fresh boxes each time, what is seen in one round cannot be matched with what is seen in another.

What does learning nothing mean

The definition is clever. Imagine someone who does not know the secret but wants to fabricate a recording of a successful session. In the cave, they could film many attempts and keep only those where the called side happened to match the entry side. The edited film looks exactly like a real one.

If a transcript can be produced without the secret, with the same statistical appearance, then the transcript carries no information about the secret. The forger is called a simulator. The same argument explains why Victor cannot use his recording to convince a friend: the friend has no way to know it was not edited.

What convinces Victor is something the film cannot capture: he chose his calls live, after Peggy had committed.

A small numerical example

A scheme due to Claus Schnorr proves knowledge of a secret exponent. It uses modular arithmetic. The numbers below are tiny for illustration and would give no security at all.

public: p = 23, g = 2, and g has order q = 11    (2¹¹ = 2048 = 1 mod 23)
secret: x = 7
public: y = g^x = 2⁷ = 128 = 13 mod 23

1. prover picks r = 3 and sends t = 2³ = 8
2. verifier sends a random challenge c = 5
3. prover sends s = r + c·x = 38 = 5 mod 11
4. verifier checks g^s = t · y^c mod 23
      left:  2⁵ = 32 = 9
      right: 8 · 13⁵ = 8 · 4 = 32 = 9      accepted

The check works because g^s = g^(r + cx) = g^r · (g^x)^c. The random r masks x in the value of s.

If the prover ever reused the same r with two different challenges, the verifier could subtract the two equations and solve for x. Strictly, this basic form is zero knowledge against a verifier who chooses challenges honestly at random. The security rests on the difficulty of the discrete logarithm for very large, carefully chosen numbers.

The simulator for this scheme runs the steps out of order. Pick the challenge and answer first, say c = 2 and s = 4. Then compute a first message that makes the check come out right, t = g^s divided by y^c. Here y² = 169 = 8 mod 23, and the inverse of 8 is 3, because 8 × 3 = 24 = 1. So t = 16 × 3 = 48 = 2 mod 23. The record (t, c, s) = (2, 2, 4) passes verification, and nobody needed to know x to write it.

Now the warning about reuse. With r = 3 again and challenge 2, the honest answer is s = 3 + 14 = 17 = 6 mod 11. Together with the earlier pair (c = 5, s = 5), the difference of answers divided by the difference of challenges is (5 − 6)/(5 − 2) = −1/3. Since the inverse of 3 mod 11 is 4, this equals −4 = 7 mod 11, which is the secret.

That calculation has a positive side. It shows that anyone able to answer two different challenges after the same first message effectively knows x, which is the argument for soundness.

Removing the conversation

Back and forth is inconvenient. A technique associated with Amos Fiat and Adi Shamir replaces the verifier's random challenge with the output of a hash function applied to the prover's first message and the statement. The prover cannot easily steer the hash, so the whole proof becomes a single message that anyone can check. The Schnorr scheme turned this way gives a digital signature.

Later constructions produce very short proofs that large computations were carried out correctly. They appear in some cryptocurrencies and are studied for identity systems, for instance proving that you are over a certain age without showing your birth date. The field moves quickly, so check current sources for particular systems.

Never build your own version for real data. Use reviewed libraries and seek expert advice.

How this differs from a mathematical proof

A proof in a journal is a fixed text that anyone can read, check and pass on. A zero-knowledge proof is a live process whose conviction is personal and probabilistic, and it is designed to explain nothing.

In principle, a mathematician who possessed a proof of an open problem could encode it as a large coloring puzzle and persuade you that the proof exists without showing a line. The conversion would be enormous, and it requires the proof to be written in a formal, checkable form. Mathematics as practiced wants the opposite, since the reasons are usually more valuable than the verdict, as discussed in why theorems get reproved.

Written for 4Mathematics with AI writing tools and not reviewed line by line by a person. Check anything you rely on against a textbook or primary source. Report an error.

Keep reading

All 41 articles in Proof and Reasoning →

Latest news on this topic