Zero Knowledge Proof – A Layman Explanation
Currently, the transactions in blockchain like Bitcoin or Ethereum are public. Neither companies nor individuals are particularly keen on flashing their information onto a public database that can be read by anyone (like co-workers, or business competitors) without any restrictions.
Let’s consider yourself at a coffee shop and paying for your purchase using a Bitcoin wallet. Since these payment transactions are public, the coffee show owner or staff can check back your wallet balance and know how many bitcoins you have. As a result, Zero-knowledge proof has created a lot of excitement in the crypto space due to their potential to increase privacy and security in blockchain applications.
So, what is Zero-knowledge proof (ZKP):
Zero-knowledge proof or Zero-knowledge protocol is a method by which one party (the prover) can prove to another party (the verifier) that something is true, without revealing any detailed information or sharing the content. In other simple words, Zero-Knowledge proof allows you to prove that you know some secret to somebody without actually revealing the secret. Let’s illustrate it with the help of the following examples.
1| Two balls and the color-blind friend example:
Imagine your friend is color-blind and you have two balls: one red and one green, but otherwise identical.
You show these balls to your friend and mention the difference. To your friend, they seem completely identical and he is skeptical that they are actually distinguishable.
You want to prove to him they are in fact differently-colored, but nothing else, thus you do not reveal which one is red and which is the green.
You give the two balls to your friend and he puts them behind his back. Next, he takes one of the balls and brings it out from behind his back, and displays it. This ball is then placed behind his back again and then he chooses in another round to reveal just one of the two balls. He will ask you, “Did I switch the ball?”. By looking at their colors, you can, of course, say with certainty whether or not he switched them.
The above proof is zero-knowledge because your friend never learns which ball is green and which is red; indeed, he gains no knowledge about how to distinguish the balls.
2| Candy bars example:
Bob and Alice got some chocolate bars for Halloween.
Suppose Bob and Alice got some chocolate bars for Halloween. They would like to know if they received the same amount of candy. Since they don’t want to share, they wish to disclose without sharing their number of chocolates.
Let’s assume they can have either exact 10, 20, 30 or 40 chocolate bars in their trick-or-treat bags.
To compare the number of chocolate bars they got without sharing the actual number, Bob gets 4 lockable boxes. Puts a label in each that says 10, 20, 30 or 40 (chocolate bars).
Then Bob throws away all the keys except for the key to the box that corresponds to the number of chocolate bars he’s got. Let’s say he has 20 chocolate bars.
Alice takes 4 small pieces of paper and writes “+” on one of them and “-” on all the others. Then she slips the “+” piece through a slot into the box with the number that corresponds to the number of candies she’s got.
Let’s say she has 30 candy bars and slips the pieces of paper with “-” into the rest of the boxes and also leaves. Bob returns and opens the one box he still has the key to and sees if it contains “+” or “-”. If it is a “+”, Alice has the same number of chocolate bars in her bag. If the slip of paper says “-”, it means that they have a different amount of candy.
We know that Bob’s bag contains 20 and Alice’s  has 30 chocolate bars. By opening the box and finding the paper with “-”, Bob learns that Alice has different amount of candy. But he has no way of finding out whether Alice has more or fewer chocolate bars.
Alice also returns and sees that Bob has a piece of paper with a “-” on it. Therefore Alice knows Bob has a different amount of candy.
As explained above, through zero-knowledge proof one can prove possession of certain information without revealing the information to the verifier. Remember in the above example, both Alice and Bob only