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

Public key-based routing #4758

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joostjager
Copy link
Contributor

@joostjager joostjager commented Nov 10, 2020

I've proposed lightning/bolts#814 on lightning-rfc. Summary:

In today's Lightning Network, routes are described as a series of short channel ids. Routing nodes use these short channel ids to determine to which of its peers an htlc needs to be forwarded.

A great downside is that a short channel id corresponds directly to a channel point on-chain. A channel point reveals the size of the channel and is thereby an indication of the amount of funds that are kept by the channel parties in their node hot wallets. Large hot wallets are an attractive target to hackers.

This PR proposes a new routing mode based on full public keys instead of short channel ids. When nodes signal option_pubkey_routing, they'll also accept a public key in the tlv onion payload to control the outgoing direction of the htlc.

Would the lnd team be open to accepting a PR implementing this for the 0.13 release?

Rough working code below to show areas of impact. Missing is the feature bit and using that to select the routing mode for hop hints during invoice creation.

@joostjager joostjager requested a review from Roasbeef November 10, 2020 20:19
@Roasbeef Roasbeef added enhancement Improvements to existing features / behaviour routing tlv labels Nov 11, 2020
@Roasbeef
Copy link
Member

Something like this would also be really useful in the HTLC interception API as one would basically be able to generate random identifiers for themselves and/or other clients that may be behind them (similar to the hosted channels idea).

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

Small change, potentially large impact! I think we should also poll some end user wallet like Breez to see if they'd be interested in such a feature. For wallets like them that follow an LSP like model (so most of their users are connected directly to them) this has the potential to greatly improve the privacy of both them and their users. Otherwise it's possible someone could prob invoices to examine the set of short channel IDs listed, even if they're random and/or rotated somewhat.

}
targetPeerKey = targetLink.Peer().PubKey()
} else {
targetPeerKey = *packet.nextHopPubKey
Copy link
Member

Choose a reason for hiding this comment

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

EZ 😎

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The system is ready and waiting for this feature 😎

ChannelID: channel.ShortChanID().ToUint64(),
NodeID: channel.IdentityPub,
// Zeroed out for privacy reasons.
// ChannelID: channel.ShortChanID().ToUint64(),
Copy link
Member

Choose a reason for hiding this comment

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

Assume in final form, we'd also need to actually extend the invoices themselves to signal to the sender that they need to be able to support pubkey routing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that is currently signaled implicitly by one or more zero channel ids in the route hints. It would also be nice to reduce the invoice size (and qr codes) by removing the eight zero bytes completely.

@Roasbeef
Copy link
Member

Also I think one of the reasons we didn't do this in the past was that with the old onion format the overhead would've been 33*20 bytes while in this case with the new TLV onion the overhead only applies to the final hop, who may already have additional data in the payload (AMP, MPP, keysend, etc).

@joostjager
Copy link
Contributor Author

Something like this would also be really useful in the HTLC interception API as one would basically be able to generate random identifiers for themselves and/or other clients that may be behind them (similar to the hosted channels idea).

The proposal in this PR is to leave out the channel id completely. I think what you're suggesting is a workaround for a world without pubkey routing? The downside is that there needs to be some coordination between routing node and final hop as to which obfuscating mapping for the channel ids is being used.

Also I think one of the reasons we didn't do this in the past was that with the old onion format the overhead would've been 33*20 bytes while in this case with the new TLV onion the overhead only applies to the final hop, who may already have additional data in the payload (AMP, MPP, keysend, etc).

I never questioned really why we didn't do it before, but that reason makes sense for sure.

Small correction: the new TLV onion overhead only applies to the second last hop (and possibly preceding ones for multi-hop hints), not the final one.

@joostjager
Copy link
Contributor Author

joostjager commented Nov 24, 2020

Pubkey routing was discussed in yesterday's lightning-dev IRC meeting. One important thing for receivers to be aware of is that senders on an old version are not able to construct hop payloads with the new pubkey field in it. Their invoices are not backwards compatible (at least the hop hint part of it). It would require a new flag on the AddInvoice call to specify whether pubkey-hop hints should be generated or not and perhaps only few users enable the option.

I think that it is better to not zero out the scids in the hop hints, but to populate them with the truncated pubkey of the next hop. Then in the switch forwarding logic implement a three way switch:

  • pubkey available
  • scid matches real channel
  • scid matches truncated pubkey

Routing nodes that signal pubkey routing will also recognize the truncated pubkeys.

That way invoices remain backwards compatible and can be used regardless of the sender version of the node software. Receivers of course still only include new style hop hints for peers that signal support for it.

When a sufficiently large portion of the network has updated, the scid can be removed from the invoice and routing can rely on just the new pubkey tlv field.

@alexbosworth
Copy link
Contributor

Could also be useful if the output index of a batch channel creation ever overflows a uint16 in the future

@lightninglabs-deploy
Copy link

@joostjager, remember to re-request review from reviewers when ready

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements to existing features / behaviour routing tlv
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants