zk-SNARKS: How can knowing some numbers prove the truth about anything in real-life?

Noha Abuaesh
5 min readAug 27, 2020

In the simplest way I can think of, this article will explain the need for, and the concept behind zk-SNARKS.

1. What problems can zk-SNARKS help solve?

zk-SNARKS help us prove that we are telling the truth about something without having to reveal that specific thing. Here is a scenario:

Imagine that I am the best buddy of a famous celebrity. And I keep bragging about it everywhere. But, unfortunately, a lot of people don’t believe me and think I am just making this up to get some attention. This really hurts me, because I know that I am telling the truth, so I try to prove it to them by saying: “Hey, I have their personal phone number!”. But they still don’t believe me. They say: “Unless you give us that number and we try calling this celebrity and make sure they pick it up, you don’t have a good enough proof for us to believe you.” Now, I am in a very bad situation, because if I give them the number, I am going to lose my friend’s trust for giving away their personal phone number to random strangers. But, if I don’t give them the number, they will never believe that I am telling the truth. I need to prove to them that I know the celebrity’s phone number, without actually letting them know the number itself.

A blindfolded cat.

This is exactly why zk-SNARKS are here, remember: to help us prove that we are telling the truth about something without having to reveal that specific thing.

“You must trust and believe in people or life becomes impossible.”

— Anton Chekhov

2. How can zk-SNARKS solve this problem?

To solve this problem, I can call my celebrity friend in-front of those people(without letting them see the screen to keep the phone number hidden from them),and put the call on loud speaker to let them listen to me actually talk to my friend. But this solution will still bug my celebrity friend. I can’t just keep calling my celebrity friend whenever I want to prove to somebody that I know her, especially that I want to prove it to the whole world, since I am a very big bragging mouth. Plus, it’s also not a good idea to use your friends like this without their knowledge.

So, I decided to talk to my celebrity friend about it. I went to her and said: “Hey, I am so proud to be your friend, and I want everybody to know that we are best friends forever. But they don’t believe me. Is it OK with you if I keep calling you to prove it to others?” My friend of course refused. This made me so sad. But my friend is a kind person. She said: “I will really hate if you keep calling me at random times with random strangers listening to our call. And of course I do not want you to give my number to anyone. But, I will help you prove to others that you have my phone number. Let’s talk to my technical advisor who can find smart solutions for every problem.

Her technical advisor suggested adding a special section on her official web-page to securely verify her phone number, such that if anyone enters the correct phone number for the celebrity in that secured field, it will display a message confirming that they indeed entered the correct number.

This is how the technical advisor proposed to verify if anyone knows the celebrity’s phone number.
Thanks to this feature on my friend’s page, I can now prove to anyone that I know her phone number without having to reveal it to others.

Finally, I can now prove to the whole world that I know the celebrity’s personal phone number without actually revealing it to anyone, and without having to get back to my friend every time I do it! In a way, zk-SNARKS does the same thing that this little script does: verifies the truth without having to reveal it. But of course, there are some different details to it.

3. Exactly, how does zk-SNARKS work?

Well, of course zk-SNARKS are not web-based scripts. One very important feature of zk-SNARKS is that they are very secure and it is very hard (i.e. impossible)to hack them. So, if my celebrity friend wants to ensure that her phone number stays totally private, and that none of her proud bragging friends have to type it in an online form with others watching as they type, she will have to do more than just add the feature to her official website. Again, we speak to her technical advisor who suggests using zk-SNARKS.

First, we had to find a way to encode the phone number to a form that no one can figure out the original number by just looking at it. This form is called a “proof”. It is like an undeniable certificate that represents the original piece of information(my friend’s phone number). So, we wrote a program that takes in a phone number, and generates its proof. Now I can keep this proof with me and take it out whenever I want to brag about knowing my friend’s number. Next, we needed to write some code to construct a verifier: a “program” — actually a smart contract- that takes a proof as input, process it, and then tells us whether or not the proof is accepted; i.e. this proof was constructed based on the correct phone number or not.

Now, my friend is not afraid of her private phone number being exposed to hackers online or typed infront of others, because now I only need to give my proof(which is an complicated encoded version of the phone number). Here is how her web-page looks like now:

By that, our analogy is over. I hope you were able to understand why we need zk-SNARKS, and how they can enable us take a couple of steps further in building trustless applications.

--

--