Bitcoin is still young but we can learn much from its history. In January 2015 for example, Bitstamp was hacked and relieved of 19,000 bitcoins worth $5 million at the time. Roughly a year later Bitfinex, one of the world’s largest bitcoin exchanges announced that hackers had managed to compromise the platform and get away with 120,000 bitcoins.
Topping all of this of course, is the now infamous Mt. Gox fiasco. Mt. Gox was once the foremost bitcoin exchange, and in 2013 handled around 70% of all bitcoin transactions worldwide. In April 2014 the platform abruptly suspended all services and closed down the website. It subsequently came to light that approximately 850,000 bitcoins had been stolen, an amount valued at more than $450 million at the time (when 1 BTC was roughly $530).
Bitcoin’s past is littered with the failures of prominent exchanges, but until now there has never been a real alternative. Atomic Swaps might be about to change that.
What is an Atomic Swap?
Atomic Swaps (also known as Atomic Cross-Chain Trading) were first described in the BitcoinTalk forum by Tier Nolan in May 2013. They are cross-chain trades that can be done without the need for a third party. If you wanted to sell Litecoin in exchange for Bitcoin for example, you would typically need to register with an exchange platform like Coinbase or Kraken. Using an Atomic Swap however, you could exchange your cryptocurrency with another person directly.
Here are the key features of a cross-chain Atomic Swap:
- It’s Atomic, meaning it either happens or it doesn’t.
- It involves two blockchains, like Bitcoin and Litecoin.
- Atomic Swaps are trustless, meaning it is impossible to act fraudulently.
- Atomic Swaps do not require a third party and are typically decentralized.
The key innovation behind Atomic Swaps is Hashed TimeLock Contracts (HTLC). These are contracts which require the recipient of a transaction to generate a cryptographic proof of payment which is shared with the sender before a predefined amount of time has passed.
In combination with multi-signature addresses, this provides a powerful, trustless way to trade cryptocurrencies in a decentralized manner.
How does an Atomic Swap work?
For an Atomic Swap to take place, two parties need to agree on a trade between cryptocurrencies. Both parties submit their Hashed TimeLock Contracts to the appropriate blockchain. As an example, let’s say party A might send their contract to the Bitcoin blockchain, while party B sends their contract to the Litecoin blockchain.
Both parties audit the contracts to ensure the amounts are correct. If everything is as agreed upon, the transaction is initiated by one of the parties. Crucially, when party A redeems the payment on the Litecoin blockchain, the key that was used for the contract on the Bitcoin blockchain is revealed to party B. That way, both parties are guaranteed access to their payment.
If one of the payments is not redeemed in time, both payments are revoked and returned to the owner. This way, neither party ever loses ownership and fraud is impossible.
What is required for an Atomic Swap to work?
Atomic Swaps are not yet possible across all cryptocurrencies, as several prerequisites need to be met. Both blockchains must have:
- A shared hash function – Atomic Swaps use a shared secret to redeem the transaction. In order for the shared secret to work, it must be based on the same hash function.
- Signature checks – These ensure that only the participating parties can access the funds
- Branched transaction scripts – these provide the functionality of redeeming or revoking a transaction depending on a condition
- CheckLockTimeVerify or CheckSequenceVerify in transaction scripts – these prevent funds in multi-signature wallets from being spent until a certain signature pattern is entered or an allotted time has passed.
As it happens, most Altcoins share Bitcoin’s simple script language and fulfill these requirements. However, the tools which enable Atomic Swaps are not readily available for all Altcoins. To the best of my knowledge the five cryptocurrencies which have successfully completed an Atomic Swap are: Bitcoin, Litecoin, Ethereum, Decred and VertCoin.
Off-chain Atomic Swaps
Up until now, this article has been describing on-chain Atomic Swaps, which operate basically like cross-chain variations of normal cryptocurrency transactions. This has several drawbacks, however.
First of all, the on-chain method requires four transactions and subsequently incurs four transaction fees. Naturally, participants need to wait for the blocks to be mined before initiating the next transaction, drawing out the process and making it time-consuming. These factors make Atomic Swaps uneconomical for all but larger sums.
Additionally, getting started with Atomic Swaps in any currency is still a struggle. Both parties need to head over to the Decred Github repo and operate the tool from the command line. In this respect, there is still a long way to go for on-chain Atomic Swaps to take hold of the mainstream.
The Lightning Network may offer a better alternative. This is a separate off-chain protocol which sits on top of the Bitcoin blockchain as a second layer. First conceptualized by Joseph Poon and Thaddeus Dryja, the Lightning Network offers a potential solution to Bitcoin’s scalability issues, by creating an off-chain payment channel between two participants.
With regards to Atomic Swaps, the Lightning Network is able to circumvent the waiting time and transaction fees which would apply if done on the blockchain. Indeed, on the 16th of November 2017, Lightning Labs hit a milestone by successfully conducting the first off-chain Atomic Swap.
Today we're excited to announce the first ever Lightning cross-chain swap from Bitcoin to Litecoin!⚡️⛓️?
Check out the code and demo here: https://t.co/92CMslUrV4 https://t.co/hnaAUWktuN
— Lightning Labs⚡️ (@lightning) November 16, 2017
How can atomic swaps help scale crypto?
It’s clear from the above that on-chain Atomic Swaps, as first conducted between Litecoin and Decred on September 20th 2017, do not offer a scaling solution. The fees are too high, the waiting time is too long, and the process is too manual to be a scalable solution.
Off-chain Atomic Swaps on the Lightning Network however, are a very exciting prospect. Transactions on this secondary layer are instant. This promises the capability to handle millions or even billions of transactions per day. The days of waiting 30 minutes for a transaction confirmation may soon be behind us.
Additionally, the Lightning Network promises almost negligible transaction fees. The fees charged go to the nodes rather than miners. Because the Network does not require mining there are far fewer costs involved, and transaction fees are consequently much smaller.
What’s the timeline for Atomic Swaps?
Both on-chain and off-chain Atomic Swaps have been successfully completed in 2017. It seems clear at this point, that off-chain swaps offer far more potential to solve Bitcoin’s scaling problems than the on-chain solution. The speed at which this innovation will be available to the public will depend on the progress made by the Lightning Network.
Fiat is to gold as lightning network is to Bitcoin.
Fiat was effectively a layer 2 solution to scaling gold. It was backed and settled to gold until that backing was removed. Unlike fiat though, LN's settlement to Bitcoin is cryptographically secured and cannot be removed!
— Charlie Lee [LTC] (@SatoshiLite) December 10, 2017
Promisingly, the Blockchain Ltd. team managed to release Thunder, the first practical implementation of the Lightning Network in May 2016, which is still in the testing phase. In further good news, Lightning Network developers released the first Desktop App which is open to the public, and is designed to encourage testing, and experimentation (Download it here).
Then, in March 2018 Lightning Labs announced the first beta release on the Lightning mainnet. This release implemented deeper cross-implementation compatibility, better fault-tolerance logic and a number of important bug fixes. Significantly, this release opens the door for developers to start working on Lightning applications (Lapps). This is a crucial step in establishing a strong ecosystem around Lightning.
Add to that a $2.5 million funding round, and it’s not hard to see why the Lightning network has been growing so rapidly in recent weeks. A network to network comparison between the Lightning Network and Bitcoin Cash, shows that the former now has more active nodes (1,362) than the latter (1,287). Considering that the number of active nodes in mid-January stood at a poultry 29, this rapid expansion is even more impressive.
Looking beyond Lightning, blockchain developers have conducted a successful Atomic Swap between two ERC20 tokens. This is exciting news because most Altcoins are ERC20 tokens, which are currently difficult to trade between one another. Only a few exchanges list a significant number of ERC20 tokens, and these can often only be bought and sold for BTC or ETH.
That being said, users will have to wait a little while longer for a chance to use the Lightning Network on the mainnet. The Network has had trouble attracting developers and the teams working on ironing out the kinks, are correspondingly small.
Leave a Reply