Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cancellable payments to the multi-hop-locks construction #19

Merged

Conversation

t-bast
Copy link
Contributor

@t-bast t-bast commented Dec 9, 2019

Adding a section detailing cancellable/stuckless payments.
It seems secure, but it's worth having more eyes on the proposal to find potential attacks/abuse.
Please try to break it, I may have missed something :)

Fixes #12

Copy link
Collaborator

@jonasnick jonasnick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice and simple explanation. Approach ACK.

However, she still only sends `y0+y1+y2` to Dave.

At the end of the update phase, Dave cannot create the adaptor signature because he is missing `z2`.
Dave can request `z2` from Alice (and present `y0+y1+y2` to prove that he received the HTLC).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like you're introducing z2 instead of deferring to send y0+y1+y2 as in the original writeup because that allows Dave to prove that he has y0+y1+y2. How does that help though? If Dave is malicious he can just not claim the payment even if he proves knowledge of y0+y1+y2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Dave is malicious he can just not claim the payment

That's true, but in this case we cannot solve anything. If the recipient doesn't want to claim the payment, there's no way you'll be able to get it through. The recipient does have an incentive to claim the payment though, because it's money he's receiving (and he signaled the intent to receive that money by creating an invoice).

I think that it is indeed interesting to consider the case of a malicious recipient for some attack scenario, but in this proposal to add cancellation this is an orthogonal problem.

Forcing Dave to present y0+y1+y2 is a way to prevent spam and reduce attack surface. It forces that step to be only possible at the right moment in the protocol.
It's also a way to distinguish which payment Dave is trying to settle.
If you're trying two routes (first one with y0+y1+y2 and second one with y0'+y1'+y2') you want to only release the sender secret for one of those. We could arguably use another id, but that would waste space in the onion...

I'm not making a very strong case for this as there may be room for improvement there, but I feel it's still a small safety measure.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forcing Dave to present y0+y1+y2 is a way to prevent spam and reduce attack surface.

My point was that spam or sending messages out of order is not really an issue if Dave can already do something worse, namely not claiming the payment. You have a fair point about attack surface, but I don't see it. The recipient can only send an ACK back if he received the onion, which proves the same to the receiver as showing y0+y1+y2 to the sender.

Distinguishing payments seems to be a clear advantage of your method. Perhaps it would also be possible to fix the original proposal in this regard by sending (y0+y1+y2)*G as part of the the ACK to distinguish the payment (the recipient can read off (y0+y1+y2)*G from the HTLC with the left hop).

In any case we don't need to write a spec here :). I think it would be very helpful to add a sentence mentioning how the original proposal differs and why.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good points! Some more comments to enrich the discussion:

The recipient can only send an ACK back if he received the onion

That depends on how you plan on making the sender/recipient interaction :)
We don't know yet in Lightning how that will be done, it may be via an onion or something else.
I could easily see that interaction be done outside of the Lightning protocol:

  • Alice is on a merchant website and wants to pay with Lightning
  • The merchant website displays a QR code containing the invoice
  • Alice scans it, which tries sending multiple payment attempts with different sender-side secrets
  • Once the merchant receives a valid payment, the web page refreshes to offer a new QR code that contains instructions on where to send the sender-side secret (via an API call for example)
  • Alice's wallet can scan this QR code, verify y0+y1+y2 and post the corresponding secret to the given URL

In that case the merchant is able to show that new QR code before he received the payment onion: so you need a way of verifying that he did receive something from Alice.

I think the goal here is to propose the most general way of doing such cancellable payments. Implementations can then add more restrictions or tweaks depending on how the sender and the recipient are able to interact.

Perhaps it would also be possible to fix the original proposal in this regard by sending (y0+y1+y2)*G as part of the the ACK to distinguish the payment (the recipient can read off (y0+y1+y2)*G from the HTLC with the left hop).

Great idea, I really like that. That means that y0+y1+y2 effectively becomes the sender-side secret (no need for a z2). I'll update the proposal to do that.

I think it would be very helpful to add a sentence mentioning how the original proposal differs and why.

I'll re-read the original proposal and do that. Cancellable payments had been floating around with this kind of construction for a while before this was posted on the mailing list: this is why there are many slightly different constructions depending on who you ask :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out that Hiroki's proposal does what you suggest, I should have re-read it :D

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could easily see that interaction be done outside of the Lightning protocol:

My imagination didn't go that far but it's not implausible.

I think the goal here is to propose the most general way of doing such cancellable payments.

Agreed. I just wanted to know why this differed from what I called the "original" proposal. I didn't know that this was folklore.

@t-bast t-bast force-pushed the cancellable-multi-hop-locks branch from efd4e14 to 12b0a53 Compare December 11, 2019 08:18
@t-bast t-bast force-pushed the cancellable-multi-hop-locks branch from 12b0a53 to 1cf5d4d Compare December 11, 2019 14:40
@jonasnick jonasnick merged commit bb59f45 into BlockstreamResearch:master Dec 11, 2019
@@ -124,6 +124,42 @@ An adversary may not choose the latest update to reply to but instead selects a
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.
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.

Cancellable payments

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The payments can't really be cancelled (you can't cancel an HTLC one it's extended, you either need cooperation or for the time-lock to expire), so IMO a better phrase is: two-phase payments. This solves the issues of the client saying the payment didn't arrive, to get the sender to pay again, which allows them to double settle.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. The paragraph does explain that though.

@t-bast t-bast deleted the cancellable-multi-hop-locks branch December 12, 2019 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend multi-hop-locks with sender-controlled tweak?
3 participants