Analysis of Cross-chain Atomic Interchange Protocol

Foreword

Each blockchain has its own data assets and data information. Since the creation of Bitcoin, TPS has always been a bottleneck in the blockchain industry, and it is difficult to break through. Various solutions have emerged for this industry to improve consensus, block expansion, and improve data structures. The side chain technology such as plasma enhances the performance of the blockchain from the lateral expansion of the blockchain. That is, the main chain is responsible for handling basic transactions, and the side chain is responsible for handling specific transactions. For example, Bitcoin can generate a pizza chain, a fruit chain, and a drink chain. When people need to use bitcoin to purchase pizza, fruit, and drinks, they can convert bitcoin to Digital assets on the side chain, purchased in the side chain. In this way, each chain can be used to handle different transactions, divide and conquer different transactions, improve the processing capacity of the chain as a whole, and increase the storage capacity of the chain.

Atomic interchange

Atomic exchange of assets across the chain, that is, in different blockchain systems. In other words, the asset transfer swap is successful or fails. Can't appear, Alice transferred the asset successfully on A, but did not receive the corresponding amount of assets on the B chain. The following is an example of the transfer of assets between Alice and Bob in Bitcoin and Ethereum to illustrate the principle of atomic interchange in cross-chain transactions.

Atomic interchange steps :

1) Alice has 1BTC and wants to exchange Bob's 20ETH. Alice and Bob have one account on each of the two chains.

2) First, Alice randomly generates a key K, initiates transaction 1, and transfers 1BTC to the Bob bitcoin account. The transaction can only be completed when Bob's signature and key K are obtained.

3) Before the transaction 1 is initiated, Alice will broadcast a retracement transaction (transaction 2), which indicates that if the transaction 1 is not completed within 48 hours, the asset will be returned to Alice; the retracement transaction will be shared by Alice and Bob. Effective after signing. At the same time, Alice will only initiate transaction 1 if transaction 2 is successful.

4) Bob receives Alice's transaction 2 and adds a signature to transaction 2 if he agrees to cross-chain transfers. At this time, transaction 2 takes effect, and Alice broadcasts transaction 1 to the entire network.

5) Bob initiates transaction 3 on Ethereum, pays 20 ETH to Alice to get the key K, and Alice can get 20 ETH after entering the key K and signature in the transaction. In order to secure Bob's assets in Transaction 3, a retracement transaction (transaction 4) will also be sent before transaction 3.

6) After Alice receives the transaction 4, it will attach its own signature. After the retracement transaction 4 takes effect, Bob will broadcast the transaction 3 on the whole network.

7) Alice obtains her own signature and key K in transaction 3 for obtaining 20 ETH; at this time transaction 3 succeeds, Alice obtains 20 ETH, and Bob obtains key K.

8) In Bitcoin, Bob enters his signature and key K to obtain 1BTC. Atomic interchange summary

Atomic swaps did not transfer Bitcoin assets to Ethereum, but only exchanged ownership of both chain assets. The total assets of the two chains have not changed, so the atomic swap agreement cannot achieve inter-chain asset transfers. Atomic interchange can be used not only in blockchains, but also in centralized systems, as long as the system provides retracement, time lock, and key lock.

Design analysis

In the transfer transaction 1, the key K and the Bob signature are required to be satisfied at the same time:

1. The key K guarantees the security of the sponsor's funds, that is, the recipient K cannot directly obtain the assets without the key K.

2. The recipient's signature guarantees the security of the recipient's assets, that is, without the recipient's private key, even if someone else obtains the key K, the asset cannot be obtained.

The completion of transaction 1 requires confirmation from both the initiator and the receiver.

The role of the retracement transaction:

1. Agreeing on the transfer of assets (48 hours unsuccessful, then cancel transaction 1 and withdraw funds to Alice)

2. Avoid an asset launching multiple cross-chain transactions (similar to “double flower”, locking cross-chain trading assets within 48 hours, the asset cannot be used for other transactions)

Quesstion :

How to guarantee the correctness of the key K in the transaction 3 in the atomic exchange, that is, the correct transaction of the key K is successful, and the wrong transaction fails?

Reference materials:

[Fire Coin Blockchain Industry Special Report] Cross-chain articles (on) https://www.jianshu.com/p/f2d2e83473fc

Author: Cao Haitao