A zero-knowledge proof lets someone check a statement while the secret information stays with the person proving it. For example, you could convince someone that you know the password to a door without saying the password. The usual abbreviation is ZK.
Contents
Ali Baba’s cave makes the mechanism visible: the verifier chooses a test that someone without the secret can pass only by luck. Independent repetitions reduce that chance of cheating while keeping the secret hidden.
Two passages and one secret door
Imagine a cave with a single entrance. Inside, the path forks: passage A goes left and passage B goes right around a rock. They reach opposite sides of a magic door. A password opens the door, allowing someone to cross from A to B or back again. There is no other way between the passages.
Alice knows the password and wants to convince Bob. She is the prover; Bob is the verifier. Her statement is “I can open this door.” The password is the secret that enables her to pass the test.
Bob waits outside and cannot see which passage Alice takes. Once she has disappeared beyond the fork, he approaches it and asks her to come out through A or B. From there, he can see the exits of both passages, but not the door or what Alice does beside it.
Knowing the password, Alice can satisfy either request. If she is already in the requested passage, she walks back. If she is in the other one, she opens the door, crosses over and returns through the passage Bob named.
One round: choose first, receive the test second
- Alice enters. She chooses A or B while Bob cannot see her route.
- Bob makes a random request. After Alice has chosen, he asks for A or B with equal probability. He must not reveal the request in advance.
- Alice responds by acting. She comes out through the named passage. Bob checks whether the exit matches his request.
- The next round starts afresh. Alice makes another hidden choice, and Bob makes a new, independent random request.
The order does the work. If Bob says “come out through A” before Alice enters, someone without the password can simply walk into A, turn around and return. The test works when the initial choice is already fixed and the coming request is still unknown.
Why the chance of cheating is 2−n
Now someone without the password enters instead of Alice. They can only return through their own passage: the closed door blocks the crossing. Whether they chose A or B, Bob’s random request matches that choice with probability 1/2.
To pass all n independent rounds, the impostor must get lucky every time. Multiply the probabilities: (1/2)n = 2−n.
| Consecutive rounds | Chance of passing all without the password |
|---|---|
| 1 | 1/2 = 50% |
| 10 | 1/1 024 ≈ 0.0977% |
| 20 | 1/1 048 576 ≈ 0.0000954% |
The figure 1/1 048 576 describes an impostor’s attempt to pass a fixed run of 20 tests. Bob counts every round, including failures. Allowing failed attempts to disappear and presenting only successful ones would create a different test.
The calculation uses fresh, independent requests with equal chances of A and B. A predictable sequence or a hint about the next request would let the impostor enter the matching passage in advance.
The three properties of a zero-knowledge proof
Completeness: someone with the secret passes
If Alice knows the password and both participants follow the rules, she can always use the requested exit. A proof should accept an honest participant’s correct answer. This property is called completeness.
Soundness: cheating rarely convinces the verifier
An impostor may guess correctly, but independent repetitions reduce the chance of passing the whole test. This illustrates soundness: a false statement should not pass verification except with a bounded, small probability. In the cave, that probability is visible directly: 2−n.
Zero knowledge: the test does not disclose the secret
Bob hears his requests and sees Alice emerge. He does not hear the password or watch the door open. But zero knowledge means more than keeping the password unspoken: his observations should give him no additional knowledge about the secret beyond the statement being established.
A recording helps explain this. Its requests could be agreed in advance: enter A, receive request A, leave through A; repeat with B. That needs no password. Choose the sides randomly and the record of requests and successful exits will look like a record of honest tests.
The mathematical definition uses a related idea called simulation: the verifier’s observations can be reproduced without receiving the secret. Each particular protocol has to establish this property for its model of the verifier. Our cave example has considered an honest Bob who follows the agreed procedure.
Why a video does not replace the verifier
What matters to Bob is that he personally chose unpredictable requests after Alice entered. A viewer of a finished video does not know that: the requests could have been agreed beforehand and unsuccessful takes removed. Bob, convinced through his own interaction, and someone sent a recording have different evidence.
Saving the conversation therefore does not by itself create a non-interactive zero-knowledge proof, or NIZK. In a non-interactive protocol, the verifier receives a proof and checks it without a separate exchange of requests with the prover. That requires a specific cryptographic construction; recording successful answers is not enough.
The next step is the Fiat–Shamir transformation and a non-interactive proof: a worked Schnorr example shows how the verifier can check a proof later, without sending a fresh request.
From the cave to a cryptographic proof
Software checks mathematical relationships in place of journeys through a cave. The verifier knows the public statement, while secret information enables the prover to construct an accepted proof. For example, a proof can establish that a specified condition is satisfied while keeping the underlying data hidden.
One practical example is shielded payments in Zcash. Their zk-SNARK proofs let the conditions of a transaction be checked while its private data stays with the participants.
When reading about ZK, distinguish three questions: what is being proved, which information stays hidden and who can verify the result. The cave explains the sequence of a test and the three properties; the ZK platform map shows how proof systems relate to networks, privacy and computation markets.
Crypto analyst and blockchain developer. In the industry since 2018. Creator of Telochain blockchain, GameFi project Telomeme, and Yieldo platform. Author of Telegram channel @tonsdot.
How we collect and check data — Yieldo's methodology.
How we publish, date and correct material — editorial policy.