English
Conditional payment of Wisdom Chain document knowledge base
This article comes from the official Twitter of Wisdom Chain
URL:
https://twitter.com/Wisdom_Chain/status/1298458216725176328?s=20
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.
簡體中文
本文來自Wisdom Chain官方Twitter
URL:
https://twitter.com/Wisdom_Chain/status/1298458216725176328?s=20
假如我們現在要做一筆交易,我想把自己的資料賣給你,怎樣交易才是最安全的?
顯然這里會有兩個問題:
因為我賣的是資料,肯定不能直接給你,否則你得到資料后直接跑了怎么辦?
但我肯定也不能先拿你的錢,因為可能我給你的資料是不符合你要求的,或者我拿了錢之后也跑了。
要解決上面這個問題,我們就需要一個完美精準的「一手交錢、一手交貨」方案,零知識證明和區塊鏈這時就可以派上用場了。
今天我們盡可能用普通人能聽懂的語言,完整講解了這樣一個有趣的解決方案:Wisdom Chain的條件支付。
這個概念意味著什么呢?簡單點講,就是在沒有_信任第三方_的場合下達成_完美公平地「_一手交錢一手交貨」的方案。
想象一個交易場景,如果交易雙方在沒有信任第三方在場的情況下,誰也不愿意先出手付款 / 交貨給對方,否則對方會跑路。一手交錢一手交貨就意味著:付款 / 交貨動作必須具備原子性(大白話:要么交換完成,要么不交換,不給任何一方賴賬的空間)。
所謂完美公平是指任何一方都沒辦法占更多的小便宜。不過這個概念是一個古老的話題,早在 80 年代起就有很多學者在研究如何做到完美公平交易。但是長期以來,大家一致認為一個受信任的第三方是必不可少的。后來等到位元幣誕生,大家發現利用區塊鏈的特性就可以做到。
那么什么Widom Chain中的條件支付是如何實作的呢?
據官方透露在Widom Chain中的條件支付主要是由“哈希時間鎖定”、“哈希高度鎖定”與其他因素構成,這里暫只討論哈希時間鎖定與哈希高度鎖定。
什么是哈希時間鎖定
哈希鎖定,全稱哈希時間鎖定合約(HashTimeLockContract),是閃電網路中提出的一種新的技術實作形式。
哈希鎖定模式是指用戶在規定的時間段對于哈希值的原值進行猜測來支付的一種機制。簡單講,就是在智能合約的基礎上,雙方先鎖定資產,如果都在有限的時間內輸入正確哈希值的原值,即可完成交易。
在這樣的機制下可以實作小額支付的快速確認,也就是說實作閃電網路快速確認的目標。接下來筆者將通過哈希鎖定的應用場景之資產兌換為例來為大家科普哈希鎖定是怎么實作的。
怎么實作哈希時間鎖定?為了方便理解哈希時間鎖定到底是如何鎖定的,這里給大家類比了兩個鎖,一個是哈希鎖,一個是時間鎖。
1、哈希鎖
通過哈希值上鎖,上鎖之后只有用產生這個哈希值的原本值進行開鎖,假設數123,哈希之后的值為a03a,通過a03a上鎖,不考慮哈希碰撞的情況下,只能由123解鎖。
2、時間鎖
時間鎖要求在規定時間內輸入哈希鎖的密碼。如果時間鎖的時間是1個小時,那么就要求用戶需要在1個小時內輸入哈希鎖的密碼,如果在1個小時后輸入哈希鎖的密碼,時間鎖仍然不會開啟。
也就是說同時打開這兩個鎖的條件是,在規定的時間內輸入哈希值原本的值,上面的例子就是在1個小時內,輸入“123”,兩把鎖才會都處于開啟狀態。
現在A將利用哈希時間鎖定的機制把自己的WDC在B那里兌換以太幣,具體的操作步驟如下:
A先生成亂數S,再把亂數的哈希值H(S)通過網路給B,假設亂數是123,哈希值是a03a。
同時,A進行時間上鎖和哈希上鎖,假設時間鎖的時間為1小時,哈希鎖上鎖的哈希值是a03a。上完鎖后,待轉換的WDC就被鎖定在鏈1上。
B收到A給的哈希值“a03a”后,B根據這個哈希值在以太坊上部署智能合約,并往合約中存同等價值的以太幣。B的智能合約要求A在規定時間內提供密碼“123”才可以取走智能合約中的以太幣。
這個程序相當于,B自己也上了兩把鎖,其中哈希鎖和A的那把哈希鎖一樣,需要用同樣的密碼才可以打開,時間鎖假如為半個小時。
A使用B的這個智能合約,并在半個小時內輸入自己的密碼“123”,就能打開B在鏈B上的哈希鎖,就能取走B智能合約里的以太幣(相當于B的以太幣,因為智能合約是B創建的,合約里的以太幣也是B轉進去的)。
因為A在呼叫了B的智能合約時輸入了密碼,因此B也就知道了密碼是“123”,他只要在一個小時內通過這個密碼打開鏈A上的哈希鎖,A的WDC就會轉給B。
通過上面的程序,可以看到,A可以通過哈希時間鎖定這種方式,實作了WDC到以太幣的兌換。
通過上面的說明我們了解了哈希時間鎖定,下面的哈希高度鎖定就會很簡單的明白,原理與哈希時間鎖定大致相同。所以我們簡單的描述下哈希高度鎖定。
哈希高度鎖定
A和B可以達成協議,協議將鎖定A的10WDC,在時刻T到來之前(T以未來的某個區塊鏈高度表述),如果B能夠向A出示一個適當的R,使得R的哈希值等于事先約定的值H,B就能獲得這10WDC;如果直到時刻T過去了,B仍然未能提供一個正確的R,這WDC將自動解凍并歸還A。這個程序產生亂數和驗證亂數的程序。
當明白了哈希時間鎖定與哈希高度鎖定后,你就明白了WisdomChain的條件支付的技術原理。
關注Wisdom Chain動態
Twitter:@Wisdom_Chain
微博:WisdomChain
知乎:智慧鏈技術社區
Facebook:WisdomChain
Telegram:@WisdomPublicChain
相關資源
WIsdom Chain公鏈檔案知識庫:
https://docs.wisdchain.com/#/
Wisdom Chain官網:
https://wisdchain.io/
Wisdom Chain技術論壇:
http://tech.wisdchain.io/
Wisdom Chain開源代碼庫:
https://github.com/WisedomChainGroup
Wisdom Chain區塊瀏覽器:
https://scan.wisdchain.com
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/7288.html
標籤:區塊鏈技術
上一篇:公鏈轉賬錯誤的方法
