How ZKP technology works.

Romualds Bahvalovs
6 min readFeb 26, 2023

--

Hi everyone! Today we are going to talk about zero-knowledge proof technology. This topic is very popular now, so I decided to tell you about it in this article. If you prefer video format, you can watch my video on this topic at the link: https://youtu.be/Oyj-tr0Z1lQ.

What is a Zero-knowledge proof?

Zero-knowledge proof is a cryptographic protocol in which one party (the verifier) proves to the other party (the verifier) that something is true without revealing how it is true. This technology is used in projects like Zcash and Aleo.

By the way, if you haven’t seen my video course about Aleo, I’ll provide the link at the end of the article.

This technology was first proposed by scientists at the Massachusetts Institute of Technology in 1985. The article was called «The knowledge complexity of interactive proof-systems». So it is not a new development, but it has only become realizable in our time.

How does this technology work?

Imagine that you are in a room with a person who is blindfolded. There are two balls on the table in front of you, one white and one black. You need to prove to the second person (the verifier) that the balls are really different colors, without revealing which ones. To do this, you must ask him to hide both balls under the table.

After that, ask to take out only one so that you can see it. Next, the ball is hidden again and the next time the verifier may again show either white or black. However, you will be able to prove the claim, since you know exactly whether he changed them under the table.

Nevertheless, the verifier will not be completely sure of the truth of the fact, because luck or deception could have taken place. This problem is solved by repeating the experiment a number of times. With every round the chance to be right by chance will halve: after five repetitions the probability of being wrong is 1 in 32, after 10 rounds it is 1 in 1024, and after 20 rounds — about 1 in 1 000 000. With repeats it is possible to achieve the desired level of proof reliability, but it is impossible to achieve absolute certainty.

What is zero-knowledge proof used for?

One obvious application of zero-knowledge proof in cryptocurrencies is to check if a user has funds for a transaction, without revealing to network participants who the user is and how much money they have in their account.

Corporations collect a lot of information about each of us: personal data, habits, and desires. Using this data, they sell advertising and hold our attention more effectively. There is only one way out of this situation: delete accounts. There is no other way to keep your data private. But what if you want to take out a loan, for example? You are forced to give the bank accurate information about your income. Using ZKP technology, you could give the bank information that your income is more than a certain amount.

One condition is important. This range must be significant, otherwise it will not make sense. Such methods could help the financial world use blockchain technology. But at the moment it is difficult because of the lack of legislative ability to do so.

What types of zero-knowledge proofs are there?

There are two types of proofs: interactive and non-interactive. In the ball example, the interactive type of proof was used. Because the verifier himself interrogates the proving person in real time. This method has one major disadvantage, which is limited transferability. We proved to one person that the balls are different colors, but if we want to prove it to another person, we have to do it all over again.

The other form is non-interactive proof. Using this option, we can provide proof that everyone can check for themselves.

As you know, all transactions are visible on the bitcoin network.

In this way, you can find out how many coins each user has and where he spends them. At the very least, this is insecure. There are projects that use zero-knowledge non-interactive proofs to protect your transactions.

For example, this is implemented in the project Aleo. No one will see how many coins and to whom you transferred.

For blockchain, we must use non-interactive proofs because proofs must be verified by every node in the network. That is how blockchains reach consensus. It would be too time consuming to prove our transactions to every node in the network.
In addition to its many advantages, the technology has some disadvantages. First, the technology cannot 100% guarantee the correctness of the proof. We can only reduce the probability of error by increasing the number of checks. In this way, we can infinitely reduce the probability that someone will fake the proof. Second, the algorithm requires a large number of calculations, which creates additional complexity. For example, previously it was impossible to run the algorithm on weak devices. Now the developers have made significant progress in solving this problem.
Implementation of ZKP technology in crypto projects.
I will tell you about it on the example of my favorite project — Aleo. Aleo allows you to create private applications using ZKP technology. You can go to Aleo.org and see all the details of how the project works.

I said earlier that ZKP requires a lot of computation to work with. The developers have optimized this process, which allows to use this technology quite comfortably. The big advantage is that Aleo team created Leo programming language and IDE called Aleo Studio, which make the process of creating a private application as easy as possible.

Until now, users have had to choose one of two things: privacy or programmability. For example, Zcash provides users with full privacy but limited programmability. Ethereum provides powerful programmability, but limited privacy.

Aleo uses zero-knowledge cryptography to achieve both privacy and programmability. Like Zcash, this system gives us strong privacy guarantees because transactions only contain proof, not the input that generates it. And like Ethereum, ZEXE can support smart contracts that allow users to interact or transfer value in a pre-defined way.

How to transfer token using ZKP technology?

To do this, we can use a decentralized exchange — DEX. DEX is a decentralized application that allows users to buy or sell tokens on the chain without having to search for a specific buyer or seller.

Let’s say you want to exchange token A for token B on an Aleo-based DEX. First you will need to prove to DEX that you have enough token A to make the transaction. But since this information can be shown with a zero-knowledge proof, this does not mean revealing your wallet balance or trading history. Instead, you can refer to the proof on the previous transaction chain to show that you have enough balance to make a trade.

When you make a DEX transaction in Aleo, you calculate updated off-chain account balances based on the exchange rate. This transaction is completed by submitting a zero-knowledge proof to the Aleo network as a transaction, indicating that the action occurred. The proof itself contains no information about what the action was, what exchange it was executed on, or who was involved.

Link to my video course about Aleo: https://youtube.com/playlist?list=PLsvDEBW3znFKjDFilUiE10lQi7zacQrer

--

--

No responses yet