If we want to make a transaction now, I want to sell my data to you. what is the safest way of transaction?
Obviously, there are two problems:
Because what I sell is the data, certainly cannot give you directly, otherwise how can I do if you get the data and then directly run away?
But I certainly can't take your money first, because the data I gave you may not meet your requirements, or I took the money and ran away.
To solve the above problem, we need a perfect and accurate "one hand pay, one hand delivery" solution. Zero knowledge proof and blockchain can be used at this time.
Today we try to explain this interesting solution in the language that ordinary people can understand: the conditional payment of Wisdom Chain.
What does this concept mean?
To put it simply, it is to reach a perfect and fair "one hand pay, one hand delivery" scheme without trusting a third party.
Imagine a transaction scenario in which neither party is willing to make payment / delivery to the other party without the presence of a trusted third party, otherwise the other party will run away. One hand payment and one hand delivery means that the payment / delivery action must be atomic.
The so-called perfect fairness means that neither side can take more advantage. However, this concept is an old topic. As early as the 1980s, many scholars have been studying how to achieve a perfect fair trade. But for a long time, it has been agreed that a trusted third party is essential. Later, when Bitcoin was born, we found that it could be done by using the characteristics of blockchain.
How is conditional payment realized in Wisdom Chain?
According to official disclosure, conditional payment in Wisdom Chain is mainly composed of "hash time locking", "hash height locking" and other factors. Here, only hash time locking and hash height locking are discussed.
What is hash time locking?
Hash lock, full name of hash time lock contract, is a new technology implementation form proposed in lightning network.
Hash lock mode is a mechanism that users guess the original value of hash value to pay in a specified period of time. In short, on the basis of the smart contract, both parties lock the assets first. If both parties input the original value of the correct hash value in a limited time, the transaction can be completed.
In this mechanism, we can realize the rapid confirmation of micro payment, that is to say, to achieve the goal of rapid confirmation of lightning network. Next, the author will take the asset exchange of the application scenario of hash locking as an example to explain how hash locking is realized.
How to implement hash time locking? In order to facilitate the understanding of how hash time locking is locked, here we compare two locks, one is hash lock and the other is time lock.
1. Hash lock
Through hash value locking, after locking, only the original value of the hash value is used to unlock. Assuming that the number is 123, the value after hash is a03a. Through a03a locking, without considering hash collision, it can only be unlocked by 123.
2. Time lock
The time lock requires the password for the hash lock to be entered within a specified time. If the time of the time lock is 1 hour, the user is required to enter the password of the hash lock within 1 hour. If the password of the hash lock is input after 1 hour, the time lock will not be opened.
In other words, the condition for opening the two locks at the same time is to input the original value of the hash value within the specified time. In the above example, if "123" is input within one hour, both locks will be in the open state.
Now A will use hash time locking mechanism to exchange its WDC in B for Ethernet currency. The specific steps are as follows:
A first generates random number S, and then give hash value H (S) of random number to B through the network, assuming that the random number is 123, and the hash value is a03a.
At the same time, A locks time and locks Hash, assuming that the time lock time is 1 hour, and the Hash value of Hash lock is a03a. After locking, the WDC to be converted is locked on chain 1.
After B receives the hash value "a03a" given by A, B deploys the smart contract on the Ethernet site based on this hash value and stores the same value of ETH in the contract. B's smart contract requires A to provide the password "123" within the specified time to take away the ETH in the smart contract.
This process is equivalent to that B itself has two locks. The hash lock is the same as the hash lock of A. it needs the same password to open it. If the time lock is half an hour.
A uses the smart contract of B, and enters its own password "123" within half an hour, then it can open B's hash lock on chain B, and take away the ETH in B smart contract (equivalent to B's ETH, because the smart contract is created by B, and the ETH in the contract is also transferred by B).
Because A entered the password when calling the smart contract of B, so B also knew that the password was "123". As long as he opened the hash lock on the chain A in one hour, the WDC of A would be transferred to B.
Through the above process, we can see that A can realize the exchange from WDC to ETH through hash time locking.
Through the above description, we understand the hash time locking, and the following hash height locking will be very simple to understand, and the principle is roughly the same as hash time locking. So let's briefly describe hash height locking.
Hash height lock
A and B can reach an agreement to lock A's 10WDC. Before the arrival of time T (T is expressed in terms of a block chain height in the future), if B can show a suitable R to A so that the hash value of R is equal to the predetermined value H®, B can obtain the 10WDC; if B still fails to provide A correct R until time T has passed, the WDC will automatically unfreeze and return it to A. This process produces random numbers and verifies them.
When you understand hash time lock and hash height lock, you understand the technical principle of conditional payment for WisdomChain.