The Lightning Network (Part 3)

 

The Lightning Network Between 3 people, Atomic Swaps, and The Full Picture

In Part 2, we looked at how the Lightning Network (LN) would work between 2 people. In this final article, we will explore how the LN works between 3 people, how Atomic Swaps work, and the full picture of the Lightning Network.

The Lightning Network with 3 People

In a different scenario from Part 2, let’s say Alice wants to hire Carol as a Graphic Designer. Alice offers Carol 1 LTC for 2 jobs. Instead of going through the hassle of creating a multisig address for the both of them, Alice notices that they have a common friend named Bob. Alice has a multisig address with Bob already and she notices that Carol does too. Both of these multisigs are 2 of 2. Alice then decides to Pay Carol through Bob.

 
1_VfkZJvdtPt1IrN8HyFk2_g.png
 

Now in order to do pull this off, we’ve got to do something called “hashing.” Hashing simply means to cryptographically scramble a set of alphanumeric characters (R) into a different set of numbers called a “hash.” The cool thing about hashes are that you can reproduce the hash if you have the original data set (R). However, you can’t reproduce (R) from the hash. This unique characteristic allows the hash to act as a “lock” for Alice’s 1 LTC that can only be released if you have the key (R).

Step 1

Carol creates a random set of alphanumeric #’s (R) through her LTC wallet and then hashes it. She sends this hash to Alice. The hash will serve 2 purposes in this scenario: 1) a receipt 2) and a lock

1. A Receipt

The Lightning Network transactions occur “off chain” meaning they’re not recorded on the blockchain. Because of this, Carol has no idea that Alice is the one sending the LTC. However if Carol sees the hash, she’ll know it’s from Alice. In this way, the hash acts like a receipt.

2. A Lock

When Alice sends the 1 LTC, she will create the condition that the LTC can only be cashed out if (R) can be reproduced. Therefore, the LTC is locked up until Carol provides the key=>(R). This is called a “Pay to Contract” transaction. Lastly, Alice also pays that initial opening payment channel fee.

Step 2

 
1_qld19Z3mVS2IuH232eWY5A.png
 

After Alice receives the hash, Alice sends 1 LTC with the hash to her multisig wallet with Bob. Alice then pays a small opening fee to open a payment channel through a Hash Time Locked Contract. Bob does the same by sending 1 LTC with the hash to his multisig with Carol. He also pays a small fee to open the channel.

Step 3

 
1_4jMpst0OoV6zErZzj18mWQ.png
 

Carol finishes a project so Alice offers a payment of 0.5 LTC to Bob with the hash. She sets the condition that it can only be cashed out if (R) is reproduced. Bob can’t take or steal Alice’s LTC because he doesn’t have (R). So he sends 0.5 LTC to Carol to obtain it.

Step 4

Carol sees that hash and confirms that it’s from Alice. Instead of producing (R), Carol goes to finish her second project. Alice then sends 1 LTC for the 2 projects with the hash to Bob. Bob does the same to Carol. This time Carol claims her LTC by showing Bob (R). Bob then claims his own LTC by showing (R) to Alice. The opening and closing payment channel fees are now fully settled and the transaction is recorded on the blockchain. Voila! Believe it or not, that’s it!

What About Atomic Swaps?

Atomic Swaps allow users to trade between two cryptocurrencies without going through an exchange.

This is how it works between 2 people:

  1. LTC is sent from Alice -> Carol

  2. At the same time, BTC is sent from Carol -> Alice

  3. To do this, you will need to have multisigs for both LTC and BTC.

This is how it works between 3 people:

  1. First, LTC is sent from Alice -> Bob -> Carol.

  2. At the same time, BTC is sent from Carol -> Bob -> Alice.

  3. To do this, you will need to have multisigs for both LTC and BTC.

The Full Picture of the Lightning Network

Consider Bob a hub that not just 2 people, but 5 or 10 people are connected to. Bob can also connect to another hub that’s also networked with another 10 people. This is the full vision of the Lightning Network: Peer-to-Peer, zero payment transactions, Atomic Swaps of different currencies, and hundreds if not thousands of multisig addresses connected through multiple hubs.

 
9a8af-1v887ydzkphteec-uvnwrha.png
 

Final Comments:

  1. It is noteworthy to mention that Bob will most likely have to be a “whale” or an exchange to provide all the LTC and BTC for the atomic swaps.

  2. The LN is also a bit more complex than I’ve described because it can include other factors such as adding a decreasing nLockTime to each proposed payment offer. This means that every offer Alice makes will expire faster than the one before it. This negates the previous offers. There will also be punishing contracts in case a party attempts to steal coins.

  3. One exciting new LN development that Elizabeth Stark briefly mentioned at the Blockstack Summit 2017 is the possibility of Layer 3 capabilities. For example, Layer 1 is the blockchain, Layer 2 is the LN, Layer 3 would be contracting abilities for apps to be built on top of which would tap into Layer 2 then Layer 1.

  4. If this was a bit overwhelming have no fear! The Lightning Team is developing a User Interface (UI) that will take care of all of this for you. For example, Jack Mallers recently announced ZAP: A Lightning Network Wallet. This is a wallet that allows LN transactions between 2 people. He will release the source code within the week. Take a look. It is simple, stunning, and very user friendly.

  5. Finally, if you’d like to get involved with Lightning Network Development, check out this website to learn more about how to get involved here: https://github.com/lightningnetwork/lnd/

Alright, you’ve made it! Congratulations and thanks for joining me on this three part journey of understanding the Lightning Network! You can read about how the LN might scale here.


Remember to share with your friends and donate below! Until next time, onwards and upwards. 😁


Discussion Questions:

  1. What are some concerns you may have about the LN network?

  2. What two segwit enabled coins would you atomic swap first?

  3. What technology in cryptocurrency do you want to know more about next?

Sources:

https://lightning.network/

https://www.youtube.com/watch?v=8zVzw912wPo

https://streams.lykke.com/Project/ProjectDetails/b134b15b54e745559f26c217bef5a2f8

Donation Addresses:

LTC: LgGHRsbYHs93gKttBMehLzth3xDAU3tCSZ

BTC: 36Nc4cJxcwp5Xn6wfo1W9UuC5SRQKXHmYy (Segwit address. Legacy and Segwit chains accepted)