Cross-chain implementation

in cross •  4 years ago 

Insert picture description here
User AB needs to swap 1BTC and 10ETH.

A uses a password to generate a cipher text. And use ciphertext to lock 1BTC to B.
A sets a retracement transaction, and if B receives it within Y time, it will be returned to A.
B uses ciphertext to lock 10 ETH to A, and broadcasts the transaction.
B also sets a retracement transaction. If A is to receive within X time, it will return to B.
A can only use his own generated ciphertext and B’s secret key to unlock B’s transaction to obtain 10 ETH
After A successfully unlocked 10ETH, B also obtained A's ciphertext. B uses A's password to unlock 1BTC, achieving asset swap.
Core technical points:
Hash Time Lock Protocol (HTLC): The atomicity of transactions is guaranteed through the hash lock and time lock mechanism. In different systems, the ways to implement hash locks and time locks are different, but the principle is the same, that is, transactions are allowed to take effect only after certain hash conditions or time conditions are met.

Hash lock: irreversible hash function, used to unlock AB directly.
Time lock: It is required that the transaction does not take effect within a certain time range or takes effect after a certain point in time. Usually the number of blocks after the higher one or the number of time after it becomes effective is invalid.

image.png

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!