- What are Zk Snarks ?
- Zero Knowledge Proofs
- Drawback
- Solution → Zk Snarks
- More Blog Posts
- Subscribe to newsletter
What are Zk Snarks ?
First, we need to understand what zero-knowledge proofs are. Then, we will see what zk-SNARKs are.
Zero Knowledge Proofs
A zero knowledge proof is the ability to show that you can do something or you know something without even having to demonstrate or tell the thing you know.
Here is an example:
Let's say there are two people, Alice and Bob. Alice says that she knows a magical spell using which she can go right through the wall. Bob doesn't believe her.
Claim | Alice can pass right throught the wall using the magical spell |
What are her choices?
Choices | Is Zero Knowledge |
Demonstrate how she does it? | No |
Somehow proof to bob that she can do it without actually doing it | Yes |
Alice decided to conduct an experiment where she could go into a cave either via path A or B.
Bob will then stand at the center of the cave and call Alice to come out through a specific path. Alice has to come out only through that path.
Given that Bob doesn't know which paths Alice chose to go in, the probability that both might have chosen the same path is 50%.
Here is some math behind it:
So that means there is a 50% chance she knows the magic spell and a 50% chance she doesn't. Well, that's not so convincing. In other words, she had a 50-50 chance of successfully faking the magic spell.
But what if we repeat this experiment 100 times? Here is the math.
After conducting this experiment 100 times, she has a 0.00000000000000000000000000000788860905221% chance that she will be able to successfully fake that she knows the magic spell every time without actually knowing it.
Which means after this experiment if conducted 100 times, Bob will know that Alice knows the magic spell with 99.99999999999999999999999999999211139094779% certainty.
In fact, we don't even need to do it 100 times to be sure. Conducting that experiment just 7 times will give more than 99% certainty that Alice knows the magic spell.
So to sum up, a zero-knowledge interaction proof will look like this:
Drawback
While that experiment was cool, it is not practical due to two main reasons:
- Interactive: Both verifier and prover need to be present at the time of this ceremony.
- Time-consuming: You have to repeat the experiment at least seven times to get more than 99% certainty of the proof.
Solution → Zk Snarks
Instead, what we verify and prove is that they can both agree on the same sequence of challenges and a hash function. Finally, the prover only needs to send the very last proof, and verifiers can iteratively check and verify that it's correct, making the whole interaction non-interactive and sufficient.