Introduction To The Lightning Network
Trust is the foundation of modern financial infrastructure. Traditionally, we rely on centralized financial institutions like banks to facilitate the movement of funds from one account to another. These institutions act as intermediaries and provide a sense of security to the parties involved in a transaction. In fact, these financial institutions try to include the word “trust” in their brand names as a psychological cue to get their customers to trust them. Think “Trust bank”, or “Fidelity Bank”. However, trust has given financial institutions a lot of power as they can control and manipulate the financial system at will.
With Bitcoin, we can eliminate the need for middlemen and facilitate transactions between two or more people from anywhere in the world. Bitcoin is ‘trustless’ because it facilitates and verifies transactions using cryptography, a distributed blockchain ledger, and mathematical challenges known as proof-of-work.
Lightning Network Basics
The Lightning Network is a decentralized, trustless, and secure payment protocol that operates on top of Bitcoin. Lightning is built on Bitcoin’s multi-signature addresses that require more than one signature to spend the funds stored in them. This type of address provides an added layer of security and reduces the risk of funds being stolen or lost, as the funds can only be spent if all parties involved agree.
The Lightning network aims to solve the scalability problems that are inherent in Bitcoin, as well as provide a secure, fast, and cheap payment system for all participants. For a bit of context, Visa – the world’s largest payments processor can process over 47,000 transactions per second while Bitcoin on its own can only process about 7 transactions per second (on-chain). This is because Bitcoin’s proof-of-work consensus mechanism requires multiple confirmations from the network participants before a transaction can be added to the blockchain.
The Lightning Network significantly scales Bitcoin as thousands of Bitcoin payments can be performed per second through Lightning channels.
Lightning Channels
A lightning channel is simply a payment channel that allows two participants to transact with each other without the need for each transaction to be recorded on the bitcoin blockchain. This provides a faster and cheaper alternative to on-chain transactions. With a lightning channel, thousands of payments between two participants can be reduced to only 2 transactions on the blockchain: the first one is used to open the channel, and the second one closes the channel and adds the transaction on-chain.
To create a lightning channel, either of the participants deposits an agreed amount of bitcoin into a multi-signature address. This funds the channel and sets the maximum amount that can be transferred between the participants. Once the channel is established, the participants can send payments to each other as many times as they like, updating the balances within the channel. The transactions are signed by both participants and stored off-chain, and only the final, agreed-upon balances are broadcast to the blockchain when the channel is closed.
By establishing multiple payment channels with different participants, a user can transact with anyone in the Lightning Network without the need for direct channels between them. Payments can be routed from one channel to another until they reach their final destination, allowing for fast and efficient transactions with low fees. The use of payment channels in the Lightning Network enables trustless, off-chain transactions and provides a solution to the scalability issues faced by the Bitcoin blockchain.
Trustlessness in Lightning
The Lightning Network achieves trustlessness through a combination of technical and game-theoretic mechanisms. One of the key technical mechanisms of the Lightning Network that makes it trustless is the use of smart contracts.
Smart contracts are self-executing agreements that are encoded in bitcoin script. These contracts automatically enforce the terms of the agreement between parties, without the need for intermediaries. This means that the terms of a transaction are transparent, and all participants are held accountable for their actions. The smart contracts used in Lightning are called HTLCs (Hashed Time Lock Contracts).
In an HTLC, the receiver of a payment provides a cryptographic hash of the secret that will allow them to claim the payment. The sender can then try to guess the secret and claim the payment, but if they fail, the payment will automatically be returned to the sender after a predetermined amount of time. HTLCs allow the Lightning Network to function without the need for trust between parties, as the funds are automatically returned if the conditions are not met, making it a secure and efficient method for making micropayments.
The Lightning Network also leverages game theory to prevent participants from cheating. The network operates as a non-cooperative game, where each participant acts in their self-interest. The network’s design discourages cheating by making it more profitable for participants to play fair than to cheat. A great illustration of game theory in lightning is found in the story of a family lunch with a parent and two children sharing potato chips.
In this example, the siblings are taught to play a game called “split and choose,” where one sibling splits the bowl of chips into two servings, and the other sibling gets to choose which serving they want. This game ensures fairness by making it in the best interest of both siblings, especially the one splitting the bowl, to play fair. For instance, if the sibling who splits the potatoes creates a portion that is bigger than the other, the other sibling who chooses can pick the bigger portion, hence punishing the splitting sibling for their unfairness. The Lightning Network works in the exact same way – there is a constant dynamic between the two participants in a lightning channel that ensures that if one party tries to cheat, the other party has the power to punish them for cheating.
Let’s explain this better with an example of a lightning payment between Alice and Bob. Alice wishes to send some sats to Bob, so she opens a channel between herself and Bob with a funding transaction which is recorded on the blockchain.
Now, Alice and Bob can send multiple payments to each other via the channel. For each payment, Alice’s and Bob’s balance in the lightning wallet changes, and these changes are facilitated by committed transactions that update the channel balance and give the other channel partner the ability to get their funds back whenever they want.
As lightning payments are in essence multi-signature transactions, the commitment transactions for each party usually contain the signature of the other party (Bob’s commitment transaction contains Alice’s signature and vice versa). The commitment transaction also contains a timelock delay and a revocation secret to one of the payments. The timelock prevents the owner of the output from spending it immediately once the commitment transaction is included in a block (remember the splitter in the story above?) while the revocation secret enables both parties to claim a payment immediately without the timelock.
The two-channel partners hold half of the revocation secret so that neither one knows the whole secret. If they share their half, then the other channel partner has the full secret and can use it to exercise the revocation condition. When signing a new commitment transaction, each channel partner revokes the previous commitment by giving the other party their own half of the revocation secret.
When they create a new commitment, they exchange the necessary “penalty” information that makes the previous commitment transaction uneconomical to broadcast. This means that each new commitment effectively makes the previous one unusable. While it’s still technically possible to broadcast old commitments, the penalty mechanism makes it illogical to do so as it causes financial loss.
For instance, if Alice attempts to be malicious by making a payment to Bob and then tries to broadcast the previous commitment transaction where she holds all the funds. As explained earlier, Alice would experience a timelock delay in claiming her funds, while Bob – who now has Alice’s half of the revocation secret- can punish Alice by using a “penalty transaction“. A penalty transaction spends from the same channel but with an earlier version of the channel’s state, effectively penalizing Alice for breaking the channel’s agreement and granting Bob access to all the funds.
For the Lightning Network, the Bitcoin blockchain acts as a court system. And like all courts, Bitcoin keeps track of each channel’s initial and final balances as evidence and approves penalties when either party tries to cheat. Basically, the Bitcoin blockchain remains the single source of truth for Lightning payments and as Bitcoin is trustless, its trustless attributes are also passed down to Lightning which is built on top of it.
Final thoughts
In conclusion, the Lightning Network represents a major shift in the way financial transactions are conducted. By eliminating the need for trust between parties, the Lightning Network provides a decentralized, trustless solution that allows participants to transact directly with each other. This opens up new possibilities for conducting transactions in a secure, efficient, and transparent manner, without the need for intermediaries or centralized authorities. The technical aspects of the Lightning Network, such as smart contracts, payment channels, and commitment transactions, make it a robust solution for achieving trustlessness in a very trust-dependent world.
Thank You For Reading
If you found this article helpful, please consider sharing it, supporting one of these affiliates, or making a value for value donation so that we can continue to publish more Bitcoin-only content.