Atomic swap: what it is and how it works

()

What are atomic swaps and why are they needed. Advantages and disadvantages of technology

Recently, the cryptocurrency community has been actively discussing a new revolutionary function – atomic swaps. Their introduction can radically change the usual mechanism of trade and exchange in the market, as it is intended to provide users with full control over their assets during exchange and trade, as well as to oust all cryptocurrency exchanges and exchangers from the market, with the exception of those who work with fiat currencies.

Atomic swap (atomic swap) – a new technology that allows you to perform decentralized P2P trade between different types of digital assets. In other words, this is an option that would allow you to make cryptocurrency purchase and sale transactions directly from one user to another.

The main advantage of this technology is that transactions between users can take place in a decentralized way, but at the same time, participants will remain protected from fraudulent activities even in the absence of intermediary participation of cryptocurrency exchanges or other trading platforms.

The security of atomic swaps is ensured by a smart contract, so none of the parties can simply run away with money. In atomic informatics, the whole and indivisible operation is called part. Consequently, an atomic transaction can be completed in its entirety or in no way. That is, either both users receive their coins, or the transaction will not be completed.

The ability to make trade transactions opens up enormous prospects for the development of the cryptocurrency market, and also allows you to remove several vulnerabilities:

  • The possibility of hacking. Centralized exchanges are always at risk of hacker attacks and hacks. One of the saddest facts is the Coincheck hack, where $ 550 million worth of NEM was stolen. This state of affairs significantly undermines confidence in the cryptocurrency market.
  • Eliminates the risks associated with the human factor. Exchange management is not always able to skillfully cope with their responsibilities. So, once the hacking of Mt.Gox, when bitcoins worth $ 500 million were stolen, occurred precisely because of the fault of the leadership.
  • Expands exchange reserves. Exchanges can not always respond in a timely manner to increased demand and provide the necessary exchange reserve.
  • Makes trading fully decentralized. Centralized exchanges are officially registered and are subject to the laws and whims of the government of the particular country that issued the license.

Atomic swaps can be performed either directly between individual blockchains with different coins that support this technology, or through special channels outside the block chain, which are an offshoot of the main chain. Therefore, atomic swaps are often also called cross-chain atomic swaps.

Various organizations that implement this technology may charge a commission for an atomic swap, but it will still be safer and more profitable than trading operations on centralized exchanges.

How it works

The principle of operation of an atomic swap is most easily explained by the example of an operation. Let’s say there are A and B who need to conduct a transaction to exchange bitcoin for some altcoin. A has bitcoin, B has the altcoin that he wants for A, which he wants to exchange for bitcoin. In the traditional sense, A would have to replenish his exchange account in bitcoin and place a sell order, and B would have to deposit funds on the exchange and find a suitable order for him or just place his own, in addition, each of the participants would have to pay the exchange commission .

With atomic swaps A and B can be exchanged directly. Their interactions will be protected by an HTLC encrypted temporary contract. In fact, this is a two-way communication channel between participants, which allows for safe cooperation in the blockchain or outside it. The interaction in it occurs according to the following algorithm:

  1. The blockchain status segment is blocked by a smart contract, multi-signature, or any other technique that can be agreed with a group of participants;
  2. Participants in the transaction sign transactions with each other, but do not transfer them individually to the network for verification to miners;
  3. When all participants have signed transactions, they are added to the main blockchain chain.

Temporary state contracts can be closed at a certain point agreed upon by the participants and inscribed in the contract. For example, participants can agree that the contract will exist for 2 hours, and after this period will be closed, or automatic closure will occur after transactions for a certain amount.

In the above example, A will be the initiator of the transaction. And it creates a temporary contract that will act as a deposit box and store funds until the completion or cancellation of an atomic swap. To open such cell A, you will need to generate a secret number and create its hash. A hash plays the role of a lock from a deposit cell, therefore A should never share a secret number with B, since knowing the number B will be able to find out the hash, open the cell and pick up its contents.

Having created such a cell, A owns the key and the lock from it and transfers the address to the contract B. The second side reviews the conditions and if everything suits, it must create a similar cell and enter its deposit there. To do this, A passes B the hash of its cell. It should be noted that none of the participants at this stage can withdraw funds from the cell, because for this A needs a signature from B, and vice versa.

After B creates a similar deposit box, A will have the opportunity to sign cell B and thereby redeem assets. After participant A signs his side of the contract, B will receive the secret number created by A, that is, the key to the cell lock and will be able to pick up the coins invested there by participant A at creation.

Under such a system, both parties agree among themselves on the exchange rate and conditions, all their actions are cryptographically protected, therefore they do not need the participation of a security intermediary. The HTLC agreement is structured in such a way that none of the participants at a certain stage could deceive the other side and both parties are dependent on each other.

In the event that one of the participants interrupts the transaction, the funds invested in the cells will be returned after a certain period specified in the contract.

Cryptocurrencies with support for atomic swap technology

Atomic swap technology is currently under development and only some cryptocurrencies have successfully completed testing of such swaps. The first successful implementation of an atomic swap took place on September 20, 2017 between Decred and Litecoin. Further, similar transactions were made with Bitcoin, Viacoin and Vertcoin.

It should be noted that for the successful completion of the transaction, participants need to establish the blockchain of both cryptocurrencies participating in the exchange. From a technical point of view, this is not very convenient for ordinary users. In order to make atomic swaps possible for a wide range of users, the Komodo project launched the development of a decentralized trading platform BarterDEX, which will allow direct transactions with cryptocurrency without having to download the blockchain.

Testing conducted by developers using the Electrum service yielded positive results and during the transaction it was possible to successfully conduct an atomic swap without installing a blockchain.

Komodo developers managed to link the Ethereum and Bitcoin blockchain among themselves, as well as implement support for ERC-20 tokens, so their decentralized exchange can now carry out direct exchanges with almost 95% of all currencies.

An equally significant project working on the implementation of atomic swaps is Blocknet, which creates Internet blockchains, as well as Altcoin, which develops a decentralized exchange and cryptocurrency wallet, in which the option of atomic swaps will be implemented.

Advantages and disadvantages of atomic swaps

Benefits:

  • Atomic swaps increase the security of transactions, since they exclude the influence of centralized exchanges;
  • Allow you to make transactions without paying a commission to intermediaries;
  • Are completely safe for both parties;
  • Make cryptocurrency transactions completely decentralized;
  • Expand exchange reserves. Disadvantages:
  • The technology is under development;
  • To complete the operation, it is necessary to install cryptocurrency blockchains participating in the exchange or to attract a special service.

Future prospects

The source code for atomic swap technology is publicly available, so any developer with the desire and skills can improve the technology and apply it to any projects.

On the basis of atomic swaps, it is possible to create completely decentralized exchanges that are not controlled by the government or even the owners, which will significantly protect cryptocurrency users during trading operations.

Against the background of regular hacks and hacker attacks on cryptocurrency trading platforms, the introduction of this technology can turn the trading industry around. Many users are looking forward to the successful completion of testing, after which only decentralized exchanges with support for atomic swaps and those who work with fiat can remain on the market. While the relevance of the rest will be in question.

Conclusions

Atomic swaps are a revolutionary technology that can make cryptocurrencies and trading operations with them truly decentralized and safe. They do not require the participation of an intermediary in the transaction, and therefore they allow you to carry out trading operations outside of centralized exchanges that are prone to attacks and are in one way or another subject to government laws.

In addition, atomic transactions will allow you to remove the commission for completing the transaction or significantly minimize it, and also allow users to remain as anonymous as possible within the framework of a particular cryptocurrency network.

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.

Leave a Reply

Your email address will not be published. Required fields are marked *