Lightning network used in blockchain and its application

tranngocthinh1611 27 views 34 slides May 19, 2024
Slide 1
Slide 1 of 34
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34

About This Presentation

Lightning network


Slide Content

Lightning network Proposed by Joseph Pool & Thaddeus Dryja July 2022

Multisig

Timelock

Hash values and Secrets

Bidirectional Payment Channels

Open channel To open the channel, Alice and Bob each send 5 bitcoins to a 2-of-2 multisig address . Bitcoins can only be spent from this address if both Alice and Bob sign. Additionally, Alice and Bob both create a secret (a string of numbers), and exchange the hash.

Commitment transaction Alice sends 4 bitcoins to herself, and 6 bitcoins to a 2 nd -multisig address . Bob can unlock the 2 nd -multisig addr , but only after 1000 extra blocks mined.  Or , it can be opened by Alice on her own, but only if she  also  includes the secret for which Bob has just now given her the hash.  Similarly, Bob sends 6 bitcoins to himself, and 4 bitcoins to the 2 nd -multisig addr . Alice can unlock this address if she waits an additional 1000 blocks, or Bob can unlock it with Alice using her secret.

After all this exchanging of “half-valid” commitment transactions and hashes of secrets, They both sign and broadcast the opening transaction , to make sure it's recorded on the blockchain. The channel is now officially open.

Alice and Bob could sign and broadcast the half-valid commitment transaction they got from the other. If Alice does, Bob gets six bitcoins immediately. If Bob does, Alice gets four bitcoins immediately. But whomever signs and broadcasts the transaction will have to wait 1000 blocks to unlock the subsequent multisig-address, and claim the remaining bitcoins. However, and this is the key trick of a payment channel: neither sign and broadcast their half of the transaction at all .

Updating the Channel Bob wants to send Alice 1 bitcoin back (now, 5 btc for each) Similar process.. They both sign their new half valid commitment transaction, and give it to each other + exchange new secret’s hash. Alice and Bob hand each other their  first  secrets, as used in the  first  set-up.

Broadcast old commitment tx Bob cannot safely sign and broadcast the older commitment transaction any more, because Alice now knows Bob's first secret. If Bob were to sign and broadcast that commitment transaction, he would immediately send 4 bitcoins to Alice... and he would have to wait 1000 blocks to claim his own six bitcoins. That's a problem, because now that Alice knows his secret, she could use this time to beat Bob to the punch, and claim the other six bitcoins as well!

Cooperatively closing out a channel

Alice send BTC to Carol through Bob

From: Carol Bob 10BTC To: Bob 4BTC Required to unlock: To: Carol Bob 5BTC Require to unlock: or To: Carol Bob 1BTC or or Bob Sign Bob Sign Carol Sign Bob Sign Carol Sign 1st Carol Sign Bob Sign Bob Sign 1st From: Carol Bob 10BTC To: Carol 5BTC Required to unlock: To: Carol Bob 4BTC Require to unlock: or To: Carol Bob 1BTC or or Carol Sign Carol Sign Bob Sign Carol Sign Bob Sign 1st Carol Sign Bob Sign Carol Sign 1st

Settling the Status Carol send Bod (or broadcast) the secret to receive btc, Bod forwards this secret to Alice. I.e. Bod could claim his btc any time. 🡪 to terminate an HTLC off-chain requires both parties to agree on the state of the channel.

Notice about HTLC timeout If Bob gets the value from Carol only after Alice already reclaimed her coin back, Bob is stuck in the middle after all. Therefore, The time-out in Bob and Carol’s HTLC must therefore expire before the time-out in Alice and Bob’s HTLC expires.

Limitation of Lightning Network Inbound and Outbound Capacity Inbound cap: the amount of money you can receive (= remote cap) Outbound cap: the amount of money you can send

Limitation of Lightning Network

Limitation High liveness requirements Nodes are required to be online in order to send and receive payments The network is congestion 🡪 not be able to get money back fast Opening and Closing Channel Fee + Routing Fee

Lightning network CLI lncli openchannel lncli addinvoice lncli sendpayment

DEX with LN

AMM Oracle trader DEX Token A commitment Token B commitment DEX Trader X Bid A/B Request rate A/B Trader Y Ask B/A AMM MODEL TRADITIONAL MODEL

pBTC : PRV 10 : 20 trader DEX 1 pBTC channel 0 0 PRV channel 2 Rate BTC:PRV = 1:2 OPEN pBTC : PRV 10.5 : 19 trader DEX 0.5 pBTC 0.5 1 PRV 1 TRADE 0.5 BTC Trader send pBTC half commitment DEX send PRV half commitment Trader send PRV half commitment DEX send pBTC half commitment AMM: UNISWAP MODEL

pBTC : PRV 10 : 15 Trader A DEX BID 0.5 pBTC for 1PRV Rate pBTC:PRV = 1:1.5 BID Trader A DEX 1 pBTC 0 0 PRV 2 MATCHING WITH OTHER TRADER COMBINE TRADITIONAL TRADING MODEL & AMM MODEL Trader B ASK Trader B 2 pBTC 0 0 PRV 7 Trader A DEX 0.5 pBTC 0.5 1 PRV 1 Trader B 1.5 pBTC +0.5 +1 PRV 6

Thank you
Tags