The following discussion aims at reflecting on the explanation of zero knowledge proof with detailed example.

The digital age has definitely introduced various advancements that have changed our day-to-day lives as well as business operations. We are more connected than ever with multiple devices in our hands that allow us to carry out financial transactions, share personal information, and purchase products and services. You must have accepted cookies on a specific website to purchase some products or provided your personal information to register an account on an ecommerce platform.

However, users are gradually facing issues related to malicious use of data alongside ensuring higher vulnerability to security breaches. So, where does a zero knowledge proof example fit in the context of modern issues related to information security and privacy? Interestingly, readers can explore two different types of examples to showcase zero knowledge proofs in a promising manner.

Enroll Now: Zero Knowledge Proof Training Course

What Is ZKP?

Before we dive directly into an in-depth understanding of ZKP example, let us reflect on the basics of ZKP. If you are using a smartphone, then you must be using apps that collect and, most probably, resell personal data such as contact information, preferences, and interests. Even in the case of people who don’t use mobile applications, the user’s phone operating system and their network provider collect their data.

Generally, companies could use the information about users in two distinct approaches. They can use the data for optimization of their services to suit the requirements of the target audience. On the other hand, companies can resell the data to other companies. Therefore, the need for a solution to bring the control of data back to people become clearly evident. How is it possible to achieve such a feat? A zero knowledge proof example is suitable in such cases as a solution for certain services that require user data for offering their services.

How It Works

For example, you could not avail of a loan without showcasing your credit score or obtain health insurance without providing health information. Zero knowledge proof can help in such situations to obtain a loan by proving that you have a good credit score without disclosing it.

So, you need to understand that in a ZKP example, you must ensure verification of data without revealing the concerned data. Zero knowledge proofs are revolutionary and innovative instruments in cryptographic hashing that can change the conventional paradigms of information exchange. The most important facets in the working of a zero knowledge proof example refer to the ‘verifier’ and the ‘prover.’

With a transaction that involves ZKPs, prover can aim to prove a certain fact to the verifier without disclosing any other information about the fact to the verifier. The final output makes sure that the prover can establish their capability to compute a certain process without revealing any information about the computational process or input. As a result, the verifier is capable of learning only about the output.

Traits of Zero Knowledge Proof

The next important thing for a beginner to understand a zero knowledge proof example refers to the important criteria that characterize zero knowledge proofs. As a matter of fact, you would barely find any discussion on ZKPs without the mention of their important characteristics. The three significant traits associated with zero knowledge proofs are,

Completeness is the first important characteristic in a zero knowledge proof example. The ZKP must have the capability for convincing the verifier about the fact that the prover knows what they claim to know.

The second significant trait of a ZKP example refers to soundness. The ZKP could not convince the verifier that the information provided by the prover is true in event of false information.

Among all the traits, the zero knowledge trait of ZKP basically signifies the unique highlight of the protocol. The ‘zero-knowledge’ feature implies that the ZKP should not disclose any other information to the verifier. Unfortunately, the process of proving a claim using ZKP does not need hashing even though it’s really important in cryptography. The information itself can be hashed if needed but it’s not necessary to do so.

Hashing is an important part of cryptography. Here’s a guide to hashing in cryptography to help you understand the mechanisms.

Most Popular Zero Knowledge Proof Example

Cryptographic algorithms serve as the foundation of a zero knowledge proof example. The arrival of ZKPs has helped in creation of identity authentication systems without any risks for information theft. However, many people have considerable doubts regarding the functionality of zero knowledge proofs. It is reasonable to wonder about the feasibility of implementing a new cryptographic blockchain protocol before general use.

Therefore, it is important to understand the intricacies in the functioning of ZKP through accurately tailored examples. Since the advent of zero knowledge proofs, there have been many examples to show how ZKPs work. However, the most widely accepted example for zero knowledge proof is the ‘Ali Baba Cave’ example. Let us take a deeper look at the ZKP example of ‘Ali Baba Cave’ to gain a better understanding of ZKPs.

Ali Baba Cave Example

The ‘Ali Baba Cave’ example is the most common zero knowledge proof example that showcases the logic used in the ZKP cryptographic algorithm. In the example, you have to assume two characters, namely Tina and Sam. Both Tina and Sam are on an adventure and end up at a cave. They find two different entrances to two distinct paths, namely A and B. There is another door inside the cave, which helps in connecting both paths.

However, Sam knows the secret code to open the door and is therefore taking over the role of ‘tester.’ On the other hand, Tina wants to purchase the code, and she takes on the role of verifier. Tina wants to verify that Sam actually knows the secret code to open the door and is not lying. So, we can clearly observe the roles of ‘prover/tester’ and ‘verifier’ in the ZKP example.

Now, the parties involved in the ZKP transaction want to achieve their respective goals. For this, Sam must prove to Tina that he knows the code without actually revealing the contents in the code.

How It Works

At this point, it is important to wonder how a ZKP example would work here. First of all, Tina has to wait outside the cave while Sam enters the cave through any one of the paths, A or B. After Sam enters the cave, Tina comes closer to the cave’s opening and calls out to Sam, asking him to come out of the cave through one of the paths.

If Sam knows the secret code to open the door in this zero knowledge proof example, then he would open the door and return through a path requested by Tina. When Sam does not know the secret code, he might have to return back to the same path he selected to go inside. On the other hand, if Sam exits the cave through the other side, then Tina can be sure that Sam knows the code.

Furthermore, Tina may assume that Sam might have passed the test with his luck. As a matter of fact, it is clearly evident that the transaction has a 50% possibility of both parties selecting the same path. On the contrary, if the same transaction is executed multiple times, then the possibilities of Sam exiting through the same path as chosen by Alice, without having the secret code, reduce considerably.

Subsequently, the possibilities of Sam exiting the cave through Alice’s chosen path reduce to almost zero if he doesn’t know the code. Therefore, this ZKP example shows that Sam could demonstrate the truth of his statement to Tina by exiting the cave through the path selected by her multiple times.

Proving All Traits of ZKP in the Example

The example provides a clear impression of the working of zero knowledge proofs with an impression of their essential traits. First of all, it is important to note the feature of completeness in the highlighted zero knowledge proof example. The example clearly shows that Sam could demonstrate the truth of his statement, i.e., ‘he knows the code’ to Tina.

If Sam exits the cave through the path chosen by Tina multiple times in the example, then he can prove the truth of his statement. The second trait of soundness is evident in the fact that Sam could not convince Tina that he knows the code if he actually doesn’t know it. If Sam does not know the code, then he would be less likely to exit the cave through Tina’s selected path.

Furthermore, the probability of Sam exiting the cave through Tina’s selected path reduces almost to zero if he doesn’t know the code. Therefore, the ZKP example also provides a clear indication of soundness of the transaction, thereby satisfying an important ZKP criterion. Subsequently, the final trait of zero knowledge proof, i.e., zero knowledge, is also evident in the ‘Ali Baba Cave’ example.

Zero knowledge traits are visible in the example involving Sam and Tina as Tina cannot learn anything about the code. Tina stays out of the cave, thereby making it impossible for her to learn about the code. Therefore, Sam could prove to Tina that he knows the code to the door without revealing it to her.

Also Read: Enterprise Blockchain Examples That You Should Know

Simpler ZKP Example for Beginners

The classic cave zero knowledge proof example definitely offers a comprehensive impression of the technology’s functionality. In addition, beginners can also use the example for learning more about the features of blockchain. However, many people face confusion in understanding the classic cave example for zero knowledge proofs. So, let us tone down the technicality and reflect on an example that could explain ZKP, even to 5-year old’s! Let us assume Sam and Tina again as the main characters, although they are kids in the following example.

Both Tina and Sam have received candy bars for Halloween and are quite overjoyed for it. Now, both of them want to know if each of them got the same amount of chocolate bars. However, Tina and Sam don’t want to say how many chocolates each of them has. After all, the kids don’t want to share their hard-earned Halloween candy with others. Now, let us make the most important assumption for this zero knowledge proof example.

Tina and Sam could have exactly 10, 20, 30, or 40 candy bars in their Halloween trick-or-treat bags. Sam brings four boxes with locks and the labels of 10, 20, 30, and 40 on each box. After locking up all the boxes, Sam throws the keys of all boxes. Sam doesn’t throw the key of the box indicating the number of candy bars he has received. For the case of this example, let us suppose that Sam has 20 candy bars. Now, Sam leaves the scene, and Tina arrives.

The Full Process Of ZKP

Tina will take four different pieces of paper. She will then put a negative sign (-) on three of them and a positive sign (+) on one. Now, Tina puts the paper with a positive sign in the box indicating the number of candy bars she has received. In the case of this example, let us suppose that Tina has 30 chocolate bars. Tina also puts the other pieces of paper with negative sign into other boxes and then leaves the room.

In the next step of this ZKP example, Sam arrives in the room and opens the box with his key. Sam opens the box to see whether he has got a paper with a positive sign or one with a negative sign. Since Sam opens the box corresponding to the number of candy bars he has, he can check whether Tina has the same amount of chocolates. If Sam finds a paper with a positive sign, then he knows that Tina also has the same number of chocolates.

What if Sam finds a paper with negative sign? Now, he can only know that he doesn’t have the same number of candies as Tina. When Tina returns to the room, she sees a paper with a negative sign on it. So, she can verify that both of them don’t have the same number of candies. However, none of them can know whether the other person has more or fewer chocolate bars.

Enterprise courses can offer you better context to ZKP. Enroll in our blockchain courses and take your blockchain career to the next level.

Final Words

With the help of the above-mentioned examples, you can clearly establish a fundamental understanding of zero knowledge proofs. The benefits of blockchain technology are escalating considerably across various industries. Therefore, a zero knowledge proof example can provide the ideal foundation for a comprehensive understanding of their implementation.

Most important of all, ZKP example provides clear insights into the design of ZKP protocols. If you want to learn about zero knowledge proofs, then you can enroll in the ZKP masterclass. The platform offers comprehensively designed learning resources to develop all-round expertise in ZKP fundamentals. Make the most of this opportunity and start learning about ZKP right now on 101 Blockchains!