Hash locking of cross chain technology solutions
Understanding 2021-06-04 10:25:33
Abstract : How to achieve hash locking ?

This is the second stage of the vernacular blockchain 1357 It's original

author | Yu Xing

Produce | Vernacular blockchain

Tweets before vernacular 《 Dr. Xiao Feng is full of praise Cosmos And Boca's two major cross chain technology projects 》 Cross chain technology is mentioned in , One of the implementation modes of cross chain technology is hash locking , Today, Dabai will explain in detail what hash locking is .

01 Hash lock and lightning network

Hash lock , Full name hash time lock contract (Hash TimeLock Contract), It's a new technology form in lightning network .

Hash lock mode is a mechanism that users guess the original value of hash value in a specified period of time to pay . In short , On the basis of smart contracts , Both sides lock in assets first , If you input the original value of the correct hash value in a limited time , To complete the transaction .

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, Dabai will take the asset exchange of hash locking application scenario as an example to show you how hash locking is realized .

02 How to achieve hash time locking ?

In order to understand how hash time locking works , Here's an analogy between two locks , One is Hashimoto , One is the time lock .

 Hash lock of cross chain technology solution

1、 Hashimoto

Lock... By hash , After locking, only the original value of the generated hash value is used to unlock , Suppose the number 123, The value after hash is a03a, adopt a03a locked , Regardless of hash collisions , Only by 123 Unlock .

2、 Time lock

The time lock requires that the password of the hash lock be entered within the specified time . If the time of the time lock is 1 Hours , Then the user needs to be in 1 Enter the password of the hash lock within two hours , If in 1 Enter the password of the hash lock in an hour , The time lock still won't open .

That is to say, the condition for opening the two locks at the same time is , Enter the original value of the hash value within the specified time , The above example is in 1 Within hours , Input “ 123 ”, Both locks will be open .

Now Dabai will use the hashing time locking mechanism to exchange its bitcoin with Xiaohei for Ethernet , The specific operation steps are as follows :

(1) First generate random numbers S, And then the hash value of the random number H(S) Through the network to Xiaohei , Suppose the random number is 123 , Hash value is a03a .

meanwhile , Dabai has time lock and hash lock , Suppose the time of the time lock is 1 Hours , The hash value of the lock is a03a. After locking , The bitcoin to be converted is locked in the chain A On .

 Hash lock of cross chain technology solution

(2) Xiaohei receives the hash value from Dabai “ a03a ” after , Xiaohei deploys the smart contract on Ethereum according to the hash value , And deposit the same value in the contract . Xiaohei's smart contract requires Dabai to provide the password within the specified time “ 123 ” Then you can take the Ethernet money from the smart contract .

This process is equivalent to , Xiao Hei also put on two locks , The hash lock is the same as Dabai's , You need the same password to open , If the time lock is half an hour .

(3) Dabai uses Xiaohei's smart contract , And enter your password in half an hour “ 123 ”, Can open the little black in the chain B The Hashi lock on the wall , You can take the Ethernet money from the Xiaohei smart contract ( It's equivalent to a little black ether coin , Because the smart contract was created by Xiaohei , The ether coin in the contract is also transferred by Xiaohei ).

(4) Because Dabai entered the password when calling Xiaohei's smart contract , So Xiao Hei knows that the password is “123”, He just needs to open the chain with this code in an hour A The Hashi lock on the wall , Big white's bitcoin will be transferred to little black .

Through the above process , You can see , Dabai can lock this way through hash time , Realized the exchange of bitcoin to Ethernet currency . Of course, this often requires Dabai to pay a little bit more bitcoin to Xiaohei as a handling fee , After all, there is no free labor force .

03 Advantages and disadvantages of hash locking

After listening to Dabai's explanation, some of my friends will be confused ? Isn't it OK to have a hash lock ? After all, Dabai must enter the password of the hash lock to take away Xiaohei's ether coin , Xiaohei can only input the chain when Dabai is finished B The chain can only be opened after the hash lock password on A The Hashi lock on the wall . It seems that hash lock can handle things , Why add a time lock ?

In the hash time locking mechanism , If the time exceeds the time limit , Tokens locked in the system will be withdrawn . therefore , In addition, the time lock effectively promotes the big white to untie the chain within the time specified by the small black B The Hashi lock on the wall , Xiaohei will also untie the chain within the time period prescribed by Dabai because of his own interests A The Hashi lock on the wall . In the whole process, there is no need to understand each other between chains , And then speed up the trade . And if the deal fails , Hash locking does not charge extra fees . However, the application of hash locking is limited , It supports fewer functions . You want the current trading platform to promote hash locking , Towards decentralization DEX Do you ? Why? ? Welcome to share your opinion in the message area .


『 Statement : This article is the author's independent opinion , It does not represent the position of vernacular blockchain , This content is only for the majority of encryption enthusiasts to learn and exchange science , It does not constitute an investment opinion or suggestion , Please look at it rationally , Set up the right idea , Improve risk awareness . The copyright and final interpretation right of the article belong to the vernacular blockchain .』

author : Vernacular blockchain ; From the content open platform of the chain “ Get the number ”, The views expressed herein are those of the author only , It doesn't represent the official position of the chain

all “ Get the number ” article , The originality and authenticity of the content are guaranteed by the contributors , If the manuscript is due to plagiarism 、 The legal consequences caused by fraud, etc , The contributor is responsible for

Get platform to publish articles , If there is any infringement 、 Violations and other improper speech contents , Readers are invited to supervise , Once confirmed , The platform will be offline immediately . If there is a problem with the content of the article , Please send it to email :linggeqi@chaindd.com

Please bring the original link to reprint ,thank
Similar articles