Finance:Atomic swap

From HandWiki
Revision as of 18:20, 27 August 2021 by imported>JTerm (add)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

An atomic swap allows for the exchange of one cryptocurrency for another cryptocurrency without the need for a trusted third party.

Overview

In traditional cryptocurrencies a trusted third party such as an cryptocurrency exchange or decentralized exchange (DEX) is necessary to perform a swap of cryptocurrencies in order to prevent one party from sending a currency without receiving a currency in return. An atomic swap is an all-or-nothing way to trade cryptocurrencies without those risks. An atomic swap system can use a hash time-locked smart contract so that a party must deliver the currency to be swapped within a specified time, or else the transaction will be cancelled. This preserves atomicity in that either the swap will take place, or no currency will be swapped.[1][2]

Atomic swap process

Atomic swap or atomic cross-chain trading (ACCT) is a mechanism, where two (or more) parties own coins in separate cryptocurrencies, and want to exchange them without having to trust a third party. The term “atomic” here means indivisible, and refers to the fact that sending cryptocurrency on one chain and sending other cryptocurrency on the other chain cannot be performed independent of each other. If these transactions could be performed independent of each other, then while one party could fulfill their side of the bargain and send some cryptocurrency on one chain, the other party would have the option of going back on their end of the bargain and simply not following through with the protocol, ending up with both cryptocurrencies.

A decentral exchange where two parties, A and B, want to exchange cryptocurrencies can be based on the following process:

  1. A generates some random data (called the secret) x.
  2. A generates T x1 (the payment) containing an output with the chain-trade smart contract in it. It allows coin release either by signing with the two keys (Ak and Bk) or with (secret x, Bk). This transaction is not broadcast. The chain release script contains hashes, not the actual secrets themselves.
  3. A generates T x2 (the contract), which spends T x1 and has an output going back to Ak. It has a lock time in the future and the input has a sequence number of zero, so it can be replaced. A signs T x2 and sends it to B, who also signs it and sends it back.
  4. A broadcasts T x1 and T x2. B can now see the coins but cannot spend them because it does not have an output going to them, and the tx is not finalized anyway.
  5. B performs the same scheme in reverse on the alternative chain. The lock time for B should be much larger than the lock time for A. Both sides of the trade are now pending but incomplete.
  6. Since A knows the secret, A can claim his coins immediately. However, A, in the process of claiming his coin,reveals the secret x to B, who then uses it to finish the other side of the trade with (x, Bk).

Atomic swaps have the disadvantage that both chains need to implement the atomic swap (of course in addition to being capable to provide smart contracts) in order for this to work.[3][4]

History

The idea of atomic swaps was first described in 2013 by Bitcointalk user Tier Nolan.[5]

ZCash releases their tool atomic swap tool, ZBXCAT, in experimental stage Oct 2017.[6][7]

Usage

In September 2017, Decred began to support atomic swaps between Decred, Bitcoin and Litecoin .[5]

Using multi-hop locks, atomic swaps can be realized without hashing.[8]

A Lightning Network is a second, optional layer that removes the mining fee and creates an instantaneous transaction.[9][10][6] Lightning Network was released March 2018 by Lightning Labs.[11]

See also

References

  1. van der Hoeff, Mitchel (9 May 2018). "Atomic Swaps Simply Explained: How to Swap Cryptocurrencies without a Middleman". https://hackernoon.com/atomic-swaps-simply-explained-how-to-swap-cryptocurrencies-without-a-middleman-6cd29680c32e. Retrieved 29 September 2018. 
  2. van Aaron, Wirdum (11 Jan 2017). "Atomic Swaps: How the Lightning Network Extends to Altcoins". https://bitcoinmagazine.com/articles/atomic-swaps-how-the-lightning-network-extends-to-altcoins-1484157052/. Retrieved 29 September 2018. 
  3. PoC Consortium - a CryptoGuru SIG (27 Dec 2017). "The Burst Dymaxion". The Burst Dymaxion: p. 5. https://www.burst-coin.org/wp-content/uploads/2017/07/The-Burst-Dymaxion-1.00.pdf. 
  4. PoC Consortium - a CryptoGuru SIG (27 Dec 2017). "The Burst Dymaxion". https://www.burst-coin.org/wp-content/uploads/2017/07/The-Burst-Dymaxion-1.00.pdf.  This article incorporates text from this source, which is in the public domain.
  5. 5.0 5.1 "Decred Adds Atomic Swap Support for Exchange-Free Cryptocurrency Trading" (in en-us). NASDAQ.com. 2017-09-20. http://www.nasdaq.com/article/decred-adds-atomic-swap-support-for-exchange-free-cryptocurrency-trading-cm848329. 
  6. 6.0 6.1 O'Leary, Rachel Rose (11 Jan 2018). "Atomic Action: Will 2018 Be the Year of the Cross-Blockchain Swap?". https://www.coindesk.com/atomic-action-will-2018-year-cross-blockchain-swap/. Retrieved 29 September 2018. 
  7. "zcash-hackworks/zbxcat". ZCash. 19 Oct 2017. https://github.com/zcash-hackworks/zbxcat. Retrieved 29 September 2018. 
  8. Malavolta, Giulio; Moreno-Sanchez, Pedro; Schneidewind, Clara; Kate, Aniket; Maffei, Matteo. "Multi-Hop Locks for Secure, Privacy-Preserving and Interoperable Payment-Channel Networks". https://eprint.iacr.org/2018/472.pdf. Retrieved 29 September 2018. 
  9. "Decentralized Exchanges, Off-Chain Atomic Swaps, And A Brief Look Into The Future". 20 Apr 2018. https://cointelegraph.com/news/decentralized-exchanges-off-chain-atomic-swaps-and-a-brief-look-into-the-future. Retrieved 29 September 2018. 
  10. Castor, Amy (27 May 2017). "Cross Blockchain Trades? Lightning Gives New Life to Atomic Swaps". https://www.coindesk.com/cross-blockchain-trades-lightning-gives-new-life-atomic-swaps/. Retrieved 29 September 2018. 
  11. Torpey, Kyle (11 Mar 2018). "Bitcoin's Highly-Anticipated Lightning Network Goes Live As Startup Raises $2.5 Million". https://www.forbes.com/sites/ktorpey/2018/03/15/bitcoins-highly-anticipated-lightning-network-goes-live-as-startup-raises-2-5-million/#60fe82bd7eb0. Retrieved 29 September 2018.