Lightning Network – HTTP of blockchain networks

The Lightning Network (LN) is an innovative solution that can solve Bitcoin's scalability problems. Since its launch in January, the LN has been growing steadily. Not only can it greatly reduce transactions' confirmation times, but it can also render Bitcoin suitable once again for micropayments. Moreover, the LN can facilitate exchange of value across two different blockchains without having to rely on any centralized entities.
For those of you who have no knowledge of networking, the HyperText Transfer Protocol (HTTP) is the building block of the internet. It is the set of rules that govern how packets (i.e., data) are transferred between two users. The data can be text, video, picture, or any other item that a user chooses to send across the internet. The HTTP protocol works over the TCP/IP set of protocols, which is the founding protocol of the internet. To understand this easily, imagine that TCP is a truck on a highway, and HTTP is the load that is being carried by this truck.

The Lightning Network (LN) is one of the latest innovations in the blockchain technology sector that aims to fulfill a promise initially made by Bitcoin – a network that can complete transactions instantly with low fees.

The Lightning Network was first proposed in 2015 by Joseph Poon and Thaddeus Dryja, two Bitcoin-obsessed computer scientists. They wrote a paper explaining the scalability issue of Bitcoin, and proposed a solution in the form of an off-chain instant payment system, which they named the Lightning Network.

Bitcoin’s scalability problem


Elizabeth Stark, a colleague of Poon and Thaddeus who edited their paper, explains the Bitcoin scalability issue as follows:
Imagine if you have to send an email, you not only have to download every email you’d ever sent but any email that anybody had ever sent.”

This is how the blockchain works. In order for it to function properly, you need to have a global consensus across the network. This means that every transaction and every change in the blockchain has to be verified and transmitted over the entire network for validation. Such a validation process is mandatory, otherwise, there is a risk that the digital currency might be simply copied and added onto the blockchain fraudulently.

This is called the ‘double spend’ problem and to understand it, consider how fiat currency (physical currency) works. It is next to impossible to copy fiat currencies because there are so many safeguards against this. Merchants can simply detect a fake currency note via just examining it with the naked eye. The ‘double spend’ problem is a similar problem when digital currencies are considered. Validation by the entire network is necessary to prevent digital tokens from being counterfeited.

However, this causes a problem, as there are thousands of users trying to validate their transactions in a single moment. The blockchain can only hold a limited number of transactions at any instant and, as transactions pile up, the validation process gets slower and slower.

The Lightning Network – the magical solution


The Lightning Network is the holy grail of the blockchain's scalability problem. A blockchain’s inability to scale is not a problem that is specific to Bitcoin. Any blockchain-based altcoin can be integrated into the Lightning Network to allow for seamless transactions between digital currencies.

Consider the Lightning Network as a layer-two application that can utilize the underlying blockchain, and its data, for operations. The blockchain can be used as a base layer for building a decentralized Internet, and the Lightning Network, along with Blockstack and other similar applications, can be built upon this base layer. These applications can then utilize the underlying blockchain to anchor their transactions and data.

What this means is that the Lightning Network’s relationship to the blockchain is similar to how a number of application protocols such as HTTP, FTP, and others, have been built upon the TCP/IP layers. The Lightning Network is built upon the underlying blockchain to provide it with support and greater functionality.

Any number of applications can be built upon the blockchain to perform any specific set of tasks. The Lightning Network enables instant high-volume transactions. Tumblebit is a Bitcoin compatible service which offers payment channels on top of the blockchain. State Channels, which are two-way discussion channels, facilitate off-chain contracts. Similarly, an infinite number of other applications can be built to support the underlying blockchain.

The benefit of creating a second layer (layer-two), which is anchored onto the blockchain, is that it minimizes the amount of data saved onto the underlying public ledger (the base layer). This decreases the load on blockchains and promotes operations, such as off-chain transactions, to occur while keeping the whole process decentralized.

[caption id="attachment_3933" align="aligncenter" width="819"] Source: Elizabeth Stark, Blockstack Summit 2017[/caption]

How it works


The Lightning Network works similarly to smart contracts. It basically uses the same principles to promote instant execution of transactions with minimal fees. To illustrate this with an example, let’s consider two users: Alice and Bob. They want to carry out transactions, so they engage in a multi-signature transaction on the blockchain.

A multi-signature transaction permits the users to open an address or a channel that they can use for carrying out transactions. These channels require the signature from the private keys of all of the users involved in the channel for a transaction to be accepted.

Alice and Bob want to carry out a transaction that is worth $20 in total. As such, Bob commits $15 and Alice commits $5 to enter into a $20 payment channel. The blockchain will only see the initial transaction that Bob and Alice carried out to enter the channel. While this channel exists, Bob and Alice can exchange coins as many times as they want to, without having to incur extra fees.

[caption id="attachment_3934" align="aligncenter" width="1366"] Source: Elizabeth Stark, Blockstack Summit 2017[/caption]

Now, the question arises: What is stopping one of the users from simply stealing all of the funds of the other person? There is a cryptographic proof that can be used to reverse all the states (transactions) changed via the payment channel. Let’s say that Alice tries to steal all of Bob’s coins. If this happens, then Bob can simply go back to the blockchain and use the cryptographic proof to get not only his coins back, but also Alice’s as a penalty.

Moreover, let’s say that Bob loses internet coverage for some time, but Alice wants her funds freed from the contract. Payment channels are actually time-locked contracts. This means that even if Bob loses connectivity, Alice can easily get her funds out after the timeout period expires. Therefore, the Lightning Network protects users from counterparty fraud and users can transact with each other without having to trust each other.

Blockchain is the court


The core tenant of the Lightning Network is that it protects users from counterparty risk. What actually happens is that the underlying blockchain, on which the Lightning Network is based, acts as a judge.

Moreover, the Lightning Network is based on smart contracts, which are built on the underlying blockchain. The only addition is the timeout feature, which enables users to safely take their funds out after its expiry.

Therefore, let’s say that Bob and Alice enter into a payment channel, now they can perform as many transactions as they like. However, if any one of them tries to execute fraudulent transactions, then the other user can go back to the blockchain and demand their payment back from the other party, with whom they have been contracted.

In this scenario, the blockchain is the judge and similar to how contracts work in real life - you can enter into a contract with other parties without having to go to court. The Lightning Network works in a similar manner.

Elizabeth Stark while speaking at the Blockstack summit of 2017, explains:
So fundamentally, the way the lightning works is it uses the blockchain as an arbiter. The blockchain is a court and actually kind of like the way you have contracts in real life and not every contract goes to courtIn this way you could transact thousands or maybe millions of times and then you could settle to the underlying blockchain, and if somebody tries to cheat you, or if they just disappear, then you know that the blockchain is there to secure your transaction.

She perfectly sums up the principle behind Lightning Network in a one liner as:
Blockchain is a global, decentralized judge that cannot be bribed

The Lightning Network also promotes carrying out transactions between different blockchains, which means that users owning different cryptocurrencies can easily carry out transactions and exchange their tokens through the Lightning Network. This process is called cross-chain atomic swaps.

Cross-chain atomic swaps sound like something out of a chemistry book, but don’t worry, there’s no chemistry in cryptocurrency, only computer science. Using the process of cross-chain atomic swaps, the Lightning Network can handle even transactions between two different cryptocurrencies. Currently, the lightning network supports only cross-chain atomic swaps between Bitcoin's and Litecoin's blockchains.

This will allow users to carry out transactions with each other even if one has bitcoin and the other has litecoin. This process involves an intermediate node between the two users that has the liquidity in both currencies that are being dealt with. The beauty of this whole process is that it is entirely decentralized.

This is just the start


The Lightning Network is not the first of layer-two applications built on top of the blockchain and surely, it won’t be the last. However, the introduction of the Lightning Network and its quick acceptance, with over 1,268 nodes on the network currently, shows that the cryptocurrency community is tired of waiting for long periods of time that can reach days to validate their transactions. They need quick platforms, such as the Lightning Network.

In the future, we can look forward to layer-three applications that communicate with layer-two applications, which can share data with the underlying blockchain. For all of those aware of the basic network, this will be similar to how the TCP/IP protocols generalized the 7 OSI layers of networking. The third layer may allow for more complex applications that will enable the blockchain to handle complicated tasks that were previously impossible for execution on a public ledger.