header-langage
简体中文
繁體中文
English
Scan to Download the APP
Partnered With:

Take asset exchange as an example to explain the way of hashing locking

Read this article in 4 Minutes
Popular hash locking: how to achieve hash time locking and the advantages and disadvantages of hash locking
The original title: "popular science | cross chain technology scheme of hash lock"
Source: Vernacular blockchain


  01  Hash locking and lightning networks


Hash locking, Hash TimeLock Contract, isLightning networkA new form of technical implementation is proposed.


Hash lock mode is a mechanism whereby users pay by guessing the original value of a hash value within a specified period of time.To put it simply, on the basis of a smart contract, both parties first lock the asset, and if they input the original value of the correct hash value within a limited time, the transaction can be completed.


In this mechanism, the fast confirmation of micro-payment can be realized, that is to say, the goal of fast confirmation of lightning network can be realized. Next through the hash locking application scenario of asset exchange as an example to explain how hash locking is implemented.


  02  How to implement hashing time locking?


In order to understand how the hash time lock works, here is the analogy of two locks, one is a hash lock, one is a time lock.




1. Hash lock


throughHash valueLock, the lock can only be unlocked with the original hash value, let's say 123, the hash value is A03A, lock by A03A, regardless of the hash collision, can only be unlocked by 123.


2. Time lock


Time locking requires the password of the hash lock to be entered within a specified time. If 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 entered after 1 hour, the time lock will still not be opened.


In other words, the condition for both locks to be opened is that the original hash value is entered within the specified timeWithin one hour, enter "123" and both locks will be open.


现在大白将利用哈希时间锁定的机制把自己的比特币在小黑那里兑换以太币,具体的操作步骤如下:


(1) Mr. Baymax becomes a random number S, and then gives the hash value H(S) of the random number to Xiaohei through the network. It is assumed that the random number is 123 and the hash value is A03A. At the same time, Baymax performs time lock and hash lock. Assume that the time lock is 1 hour, and the hash value of the hash lock is A03A. Once locked, the bitcoins to be converted are locked on chain A.




(2) After receiving the hash value "A03A" given by Baymax, Hei will deploy the smart contract on Ethereum according to the hash value and deposit the same value of Ethereum into the contract. The smart contract requires Baymax to provide the password "123" within a specified period of time in order to withdraw the Ethereum from the smart contract. This process is equivalent to, xiaohei himself also on two locks, the hash lock and baymax that hash lock, need to use the same password can be opened, if the time lock for half an hour.




(3) to light use black this smart contracts, and enter your password in less than half an hour "123", will be able to open the small black hash lock on the chain B, can remove black smart the etheric currency in the contract (the equivalent of the etheric COINS, the little black because smart contract is black, the Ethernet in the contract currency is also little black turn in).




(4) Since Baymax entered the password when he called The smart contract of Hei, Hei knew that the password was "123". As long as he opened the hash lock on chain A with this password within one hour, Baymax's bitcoin would be transferred to Hei.




From the above process, it can be seen that Baymax can realize the exchange from Bitcoin to Ether by hashing time lock. Of course, this often requires Baymax to pay a little more bitcoin to Xiahei as a handling fee, after all, there is no free labor.


  03 Advantages and disadvantages of hashing locking


Listen to the above explanation some partners will be confused? Can't you just have a hash lock? After all, Baymax had to enter the hash lock password to take away black's ether, and black couldn't unlock the hash lock on chain A until baymax had entered the hash lock password on chain B. Why add a time lock when it looks like a hash lock?


In the hashing time locking mechanism, if the time exceeds the specified time,Tokens locked in the system will be recalled. Therefore, in addition to the time lock, Baymax can effectively unlock the hash lock on chain B within the time specified by Hei, and Hei will also unlock the hash lock on chain A within the time specified by Baymax for his own interests.


Chains don't have to know each other throughout the process,That, in turn, accelerated the pace of trading. And if the transaction fails, there is no extra handling charge for hash locking.


However, hash locking has limited application scenarios and supports fewer features.Do you want today's trading platforms to aggressively promote Hash locking and move toward decentralized DEX? Why is that? Feel free to share your thoughts in the comments section.


The original link


Welcome to join the official BlockBeats community:

Telegram Subscription Group: https://t.me/theblockbeats

Telegram Discussion Group: https://t.me/BlockBeats_App

Official Twitter Account: https://twitter.com/BlockBeatsAsia

举报 Correction/Report
Choose Library
Add Library
Cancel
Finish
Add Library
Visible to myself only
Public
Save
Correction/Report
Submit