Skip to content

Commit 5c6513d

Browse files
committed
A few multi-hop-locks clarification
* Fixed a few typos * Fixed a small error in the update phase of the flow diagram * Harmonized terms payer/payee * Added a few clarifications (from the LN's point of view) * Some markdown linting
1 parent 495096d commit 5c6513d

File tree

3 files changed

+58
-49
lines changed

3 files changed

+58
-49
lines changed

md/images/multi-hop-locks.png

-2.85 KB
Loading

md/images/multi-hop-locks.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ participant Dave
77

88
== Setup ==
99

10-
Dave->Alice : z*G
10+
Dave->Alice : z*G
1111
note left
1212
z can be a proof of payment
1313
end note
1414
Alice->Alice : draw y0, y1, y2 at random
1515
note left
1616
Alice sets up tuple (L,y,R) for every hop
1717
end note
18-
Alice->Alice: z*G, y0, (z+y0)*G
19-
Alice->Bob : (z+y0)*G, y1, (z+y0+y1)*G
20-
Alice->Carol: (z+y0+y1)*G, y2, (z+y0+y1+y2)*G
21-
Alice->Dave : (z+y0+y1+y2)*G, y0+y1+y2
18+
Alice->Alice : z*G, y0, (z+y0)*G
19+
Alice->Bob : (z+y0)*G, y1, (z+y0+y1)*G
20+
Alice->Carol : (z+y0+y1)*G, y2, (z+y0+y1+y2)*G
21+
Alice->Dave : (z+y0+y1+y2)*G, y0+y1+y2
2222

2323
== Update ==
2424

@@ -34,8 +34,9 @@ Carol->Dave : psig(C,txD,(z+y0+y1+y2)*G)
3434

3535
== Settlement ==
3636

37-
Dave->Dave : create adaptor_sig(D,txD,(z+y0+y1+y2)*G),\nMuSig combine with psig(C,txD,(z+y0+y1+y2)*G),\nbroadcast txD with combined sig
37+
Dave->Dave : create adaptor_sig(D,txD,(z+y0+y1+y2)*G),\nMuSig combine with psig(C,txD,(z+y0+y1+y2)*G),\nbroadcast txD with combined sig
3838
Carol->Carol : compute z+y0+y1 = adaptor_sig(D,txD,(z+y0+y1+y2)*G) - psig(D,txD,(z+y0+y1+y2)*G) - y2\nto create adaptor_sig(C,txC,(z+y0+y1)*G),\nMuSig combine with psig(B,txC,(z+y0+y1)*G),\nbroadcast txC with combined sig
39-
Bob->Bob : compute y0 = adaptor_sig(C,txC,(z+y0+y1)*G) - psig(C,txC,(z+y0+y1)*G) - y1\nto create adaptor_sig(B,txB,(z+y0)*G),\nMuSig combine with psig(A,txB,(z+y0)*G),\nbroadcast txB with combined sig
39+
Bob->Bob : compute z+y0 = adaptor_sig(C,txC,(z+y0+y1)*G) - psig(C,txC,(z+y0+y1)*G) - y1\nto create adaptor_sig(B,txB,(z+y0)*G),\nMuSig combine with psig(A,txB,(z+y0)*G),\nbroadcast txB with combined sig
40+
Alice->Alice : compute z = adaptor_sig(B,txB,(z+y0)*G) - psig(B,txB,(z+y0)*G) - y0
4041

4142
@enduml

md/multi-hop-locks.md

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -26,97 +26,105 @@ Protocol
2626

2727
![multi-hop-locks](images/multi-hop-locks.png)
2828

29-
In the setup phase the payee chooses `z` at random and sends the payer `z*G`.
30-
The payer will set up the multi-hop locks such that a successful payment reveals `z` to her and only her.
29+
In the setup phase the recipient chooses `z` at random and sends the sender `z*G`.
30+
The sender will set up the multi-hop locks such that a successful payment reveals `z` to her and only her.
3131
Knowledge of `z` can be a proof of payment which is similar in concept to payment preimages in the Lightning v1.0 (see section below for details).
3232

33-
We picture the payment starting from the payer on the left side through intermediate hops to the payee on the right side.
34-
The setup phase continues with the payer setting up a tuple `(Li,yi,Ri)` consisting of the *left lock* `Li` and *right lock* `Ri` for every hop `i` in the following way:
35-
Every `yi` is a scalar uniformly chosen at random.
36-
The payers own left lock `L0` is set to `z*G` which was previously received from the payer.
37-
Now for every lock `Ri` for hop `0<=i<n` and `Lj` for hop `j=i+1` the payer sets `Ri <- Li + yi*G` and `Lj <- Ri` (see the diagram).
33+
We picture the payment starting from the sender on the left side through intermediate hops to the recipient on the right side.
34+
The setup phase continues with the sender setting up a tuple `(Li,yi,Ri)` consisting of the *left lock* `Li` and *right lock* `Ri` for every hop `i` in the following way:
35+
36+
- Every `yi` is a scalar uniformly chosen at random.
37+
- The sender's own left lock `L0` is set to `z*G` which was previously received from the recipient.
38+
- For every lock `Ri` for hop `0<=i<n` and `Lj` for hop `j=i+1` the sender sets `Ri <- Li + yi*G` and `Lj <- Ri` (see the diagram).
39+
40+
Note that in Lightning, the sender would not directly send `(Li,yi,Ri)` to the intermediate nodes: it will instead use the payment onion to carry those values without disclosing his identity to intermediate nodes.
3841

3942
In the update phase adjacent hops add a multisig output to their off-chain transactions similar to how they would add an HTLC output in the Lightning v1.0.
4043
Despite significant differences between v1.0 HTLCs and the outputs used to forward payments in scripless scripts multi-hop locks we continue to call the outputs HTLCs because they have the same purpose and work similarly on the surface.
4144
Just like v1.0 HTLCs, scriptless script HTLCs have a time out condition such that the left hop can reclaim her coins if the payment fails.
42-
But otherwise scriptless script HTLCs are plain 2-of-2 MuSig outputs and the hashlock is only implicitly added to the output only when a partial signature is received (see below).
45+
But otherwise scriptless script HTLCs are plain 2-of-2 MuSig outputs and the hashlock is only implicitly added to the output when a partial signature is received (see below).
4346
For demonstration purposes we assume [eltoo](https://blockstream.com/eltoo.pdf)-style channels which means that both parties have symmetric state and there's no need for revocation.
4447

4548
If the payment does not time out, the coins in the scriptless script HTLC output shared by two adjacent hops will be spent by the right hop.
46-
Therefore, the left hop `i` creates a transaction `txj` that spends the HTLC and sends to coins to an output that the right hop `j` controls.
49+
Therefore, the left hop `i` creates a transaction `txj` that spends the HTLC and sends the coins to an output that the right hop `j` controls.
4750
Because the left hop is now aware of the message (i.e. the transaction digest of `txj`) it is going to sign, its public signature nonce can be sent to the right hop.
48-
Nonce commitments have been exchanged earlier whenever convenient for both nodes such that the nonce commitment roundtrips are not on the critical path of the payment.
51+
Nonce commitments may have been exchanged earlier whenever convenient for both nodes such that the nonce commitment roundtrips are not on the critical path of the payment.
4952

50-
Upon receiving notice of the new HTLC and the left hops public nonce, the right hop `j` creates transaction `txj` as well, combines both nonces and partially signs `txj` as `psig(j,txj,Lj)`.
53+
Upon receiving notice of the new HTLC and the left hop's public nonce, the right hop `j` creates transaction `txj` as well, combines both nonces and partially signs `txj` as `psig(j,txj,Lj)`.
5154
This is similar to a regular partial signature except that its left lock `Lj` is added to the combined signature nonce.
5255
The left hop verifies the partial signature and sends its own partial signature for `txj` to the right hop in the following two cases:
5356

54-
- the left hop is the payer
55-
- the left hop `i` received a signature `psig(i-1, txi, T-yi*G)` from the preceding hop `i-1` for the left hops transaction `txi`. In combination with the partial signature just received from the right hop, it is guaranteed that as soon as the right hop spends the coins, the left hop can open its left lock and spend the coins with `txi` as we will see below.
57+
- the left hop is the sender
58+
- the left hop `i` received a signature `psig(i-1,txi,T-yi*G)` from the preceding hop `i-1` for the left hop's transaction `txi`. In combination with the partial signature just received from the right hop, it is guaranteed that as soon as the right hop spends the coins, the left hop can open its left lock and spend the coins with `txi` as we will see below.
5659

5760
Therefore the update phase starts with the leftmost pair and continues to the right.
5861
After receiving the partial signature from the left, the right hop can complete it as soon as it learns the secret of its left lock.
59-
In order to reduce the overall number of communication rounds the setup phase and update phase can be merged together.
62+
In order to reduce the overall number of communication rounds the setup phase and update phase can be merged together (e.g. using the payment onion in Lightning).
6063

61-
The settlement phase begins when the payee receives the partial signature from its left hop.
62-
Because the multi-hop locks were set up by the payer such that the payee knows the secret of her left lock, she can use it as the adaptor secret and create an adaptor signature.
63-
The adaptor signature is combined with the left hop's partial signature resulting in a final signature for the right hop's (the payee's) transaction.
64-
At this point the right hop can broadcast the transaction to settle on-chain.
64+
The settlement phase begins when the recipient receives the partial signature from its left hop.
65+
Because the multi-hop locks were set up by the sender such that the recipient knows the secret of her left lock, she can use it as the adaptor secret and create an adaptor signature.
66+
The adaptor signature is combined with the left hop's partial signature resulting in a final signature for the right hop's (the recipient's) transaction.
67+
At this point the right hop can broadcast the transaction to settle on-chain (in case the left hop disappears or tries to cheat).
6568

66-
In this case the left hop notices the combined signature and learns its right lock secret by subtracting the right hop's previously received partial signature and its own partial signature.
67-
```
69+
In this case the left hop notices the combined signature and learns its right lock secret by subtracting the right hop's previously received partial signature and its own partial signature:
70+
71+
```text
6872
sig(tx,T) - psig(i,tx,Ri) - psig(j,tx,Lj) = adaptor_sig(j,tx,Lj) - psig(j,tx,Lj) = yj
6973
```
70-
Alternatively, the right hop can send its secret `yj` directly to the left hop and request to update commitment (Lightning v1.0) or settlement (eltoo) transaction such that the HTLC is removed, the left hop's output amount is decreased by the payment amount and the right hop's output amount is increased by that amount.
71-
If the left hop would not follow up with an update, the right hop can still broadcast the transaction until the HTLC times out.
7274

73-
Either way, once the payee claims the payment, the left hop learns the right lock secret, computes its left lock secret by subtracting `yi`, computes an adaptor signature, and so on until the payer learns the proof of payment `z` which completes the payment.
75+
Alternatively, the right hop can send its secret `yj` directly to the left hop and request to update commitment (Lightning v1.0) or settlement (eltoo) transaction such that the HTLC is removed, the left hop's output amount is decreased by the payment amount and the right hop's output amount is increased by that amount.
76+
If the left hop would not follow up with an update, the right hop can still broadcast the transaction before the HTLC times out.
7477

78+
Either way, once the recipient claims the payment, the left hop learns the right lock secret, computes its left lock secret by subtracting `yi`, computes an adaptor signature, and so on until the sender learns the proof of payment `z` which completes the payment.
7579

7680
Proof of Payment (PoP)
7781
---
78-
The main difference to Lightning v1.0 is that the proof of payment (`z`) is only obtained by the payer and not by every hop along the route.
79-
Therefore, the proof of payment can be used to authenticate the payer to the payee.
82+
83+
The main difference to Lightning v1.0 is that the proof of payment (`z`) is only obtained by the sender and not by every hop along the route.
84+
Therefore, the proof of payment can be used to authenticate the sender to the recipient.
8085
It is not necessary to reveal the PoP itself but instead a signature of `z*G` can be provided.
8186
Due to payment decorrelation intermediate hops can not associate a payment with the PoP.
8287

83-
Obviously, not only the payer is able prove knowledge of `z`.
84-
Everyone the payee or payer choose to share `z` with can do so too which makes it unclear who actually paid.
85-
Therefore a signed statement (invoice) from payee should be sent to payer that includes `z*G` and the payers public key.
86-
Then the PoP is both a signature with the PoP and the payers secret key which can only be provided by the payer (or everyone the payer chooses to collaborate with).
88+
Obviously, not only the sender is able prove knowledge of `z`.
89+
Everyone the recipient or sender choose to share `z` with can do so too which makes it unclear who actually paid.
90+
Therefore a signed statement (invoice) from recipient should be sent to sender that includes `z*G` and the sender's public key.
91+
Then the PoP is both a signature with the PoP and the sender's secret key which can only be provided by the sender (or everyone the sender chooses to collaborate with).
8792

88-
Ideally a single static invoice would be payable by multiple parties allowing spontaneous payments without requiring extra communication with the payee.
93+
Ideally a single static invoice would be payable by multiple parties allowing spontaneous payments without requiring extra communication with the recipient.
8994
But this is not compatible with PoPs because the PoP must be created from fresh randomness for every payment.
90-
However, recurring payments from a single payer [can be done using hash chains](https://lists.linuxfoundation.org/pipermail/lightning-dev/2018-November/001496.html).
91-
95+
However, recurring payments from a single sender [can be done using hash chains](https://lists.linuxfoundation.org/pipermail/lightning-dev/2018-November/001496.html).
9296

9397
Atomic Multipath Payments (AMP)
9498
---
95-
With scriptless script multi-hop locks it is possible to do AMP in a similarly to [*base AMP*](https://lists.linuxfoundation.org/pipermail/lightning-dev/2018-November/001577.html) while allowing payment decorrelation between the paths.
96-
The payer sets up multiple routes to the payee using uncorrelated locks such that any partial payment claimed by the payee reveals the proof of payment (`z`) to the payer.
97-
Because the payee doesn't want to give up the PoP for just a partial payment, she waits until all routes to her are fully established and claims the all partial payments at once.
9899

99-
It's also possible to set up multiple paths such that the receiver's payment preimage is only revealed once all paths are established, similar to [*base AMP*](https://lists.linuxfoundation.org/pipermail/lightning-dev/2018-February/000993.html) (also known as *low AMP*).
100+
With scriptless script multi-hop locks it is possible to do AMP in a way similar to [*base AMP*](https://lists.linuxfoundation.org/pipermail/lightning-dev/2018-November/001577.html) while allowing payment decorrelation between the paths.
101+
The sender sets up multiple routes to the recipient using uncorrelated locks such that any partial payment claimed by the recipient reveals the proof of payment (`z`) to the sender.
102+
Because the recipient doesn't want to give up the PoP for just a partial payment, she waits until all routes to her are fully established and claims all the partial payments at once.
103+
104+
It's also possible to set up multiple paths such that the recipient's secret (`z`) is only revealed once all paths are established, similar to [*base AMP*](https://lists.linuxfoundation.org/pipermail/lightning-dev/2018-February/000993.html) (also known as *low AMP*).
100105
The difference is that in the multi-hop-locks world we can keep the proof of payment.
101106
This is referred to as [*high AMP*](https://lists.linuxfoundation.org/pipermail/lightning-dev/2018-November/001494.html).
102107

103108
In high AMP the sender first draws a random number `q` and determines random `q1, ... qn` where `n` is the number of paths such that `q = q1 + ... qn`.
104-
The sender adds `q*G` to the receiver's payment point on every path, who is therefore unable to claim any payment because the receiver is not aware of `q`.
105-
However, when setting up each path `i` the sender sent `qi` along to the receiver.
106-
As soon as all paths are established, the receiver can compute `q` and claim the payments.
109+
The sender adds `q*G` to the recipient's payment point on every path, who is therefore unable to claim any payment because the recipient is not aware of `q`.
110+
However, when setting up each path `i` the sender sends `qi` along to the recipient.
111+
As soon as all paths are established, the recipient can compute `q` and claim the payments.
107112

108113
Batched updates
109114
---
110-
In the description of the multi-hop lock flow above we assumed that adding an HTLC output is immediately followed by a signatures from the right hop.
115+
116+
In the description of the multi-hop locks flow above we assumed that adding an HTLC output is immediately followed by a signature from the right hop.
111117
However, [BOLT #2](https://github.com/lightningnetwork/lightning-rfc/blob/206084c9399abcfacdc95800acc27ebc5ca40b0c/02-peer-protocol.md#normal-operation) specifies that multiple updates (from both sides) can occur before a signature is exchanged.
112118
MuSig-based multi-hop locks can handle this similarly:
113-
Each update is accompanied by a public nonce to create a signature of the transaction including the update.
114-
Either left or right hop can conclude the batching phase by replying to the latest update with their public nonce and a partial signature.
119+
120+
- Each update is accompanied by a public nonce to create a signature of the transaction including the update.
121+
- Either left or right hop can conclude the batching phase by replying to the latest update with their public nonce and a partial signature.
115122

116123
An adversary may not choose the latest update to reply to but instead selects a different `(public nonce, transaction)`-pair from the victim's updates.
117124
This is not vulnerable to an attack similar to the [late message Wagner's attack](https://medium.com/blockstream/insecure-shortcuts-in-musig-2ad0d38a97da) because the adversary should not be able to trick the victim into signing a transaction with a different nonce.
118125
Instead, the victim's nonce is tied to a specific transaction which prevents the attacker from choosing a message for signing after seeing the victim's nonce.
119126

127+
Resources
120128
---
121129

122130
* [MuSig](https://eprint.iacr.org/2018/068.pdf)

0 commit comments

Comments
 (0)