fedimint icon indicating copy to clipboard operation
fedimint copied to clipboard

Do not give full invoice to LN Gateway when sending lightning payments

Open elsirion opened this issue 1 year ago • 6 comments

Instead only give payment hash, destination and amount to LN Gateway.

Stretch goal: implement some custom (optional?) routing based on LDK that uses some probing server @moneyball described in the chat. The goal would be to outperform cln's native pay plugin. (this might become a separate issue once the main part is solved)

elsirion avatar Jul 16 '22 14:07 elsirion

Is this just to minimize the data being passed around? If there's routing hints necessary to make the payment (if the end destination is private and/or using an LSP like muun or breez), then you wouldn't be able to pay them.

Also with route blinding around the corner, that may be necessary too. Either route blinding with bolt11 or with bolt12 (which should also be smaller if the goal is minimizing data).

TonyGiorgio avatar Aug 05 '22 21:08 TonyGiorgio

Is this just to minimize the data being passed around?

The goal would be for the gateway to learn as little as possible about how federation users are spending their money.

Route blinding sounds interesting. With any of these approaches our client would need to get smarter. Right now the client is extremely simple. For sending it (1) escrows tokens in federation payable to anyone who find preimage and (2) tells gateway about it. This is what the escrow contract actually looks like. Notice the entire invoice is included. For it to do route blinding the client would need to learn to route which it can't do currently ...

justinmoon avatar Aug 06 '22 14:08 justinmoon

This project is relevant to this: https://github.com/lightningdevkit/rust-lightning/tree/main/lightning-rapid-gossip-sync

It would allow for performant client-side pathfinding. My understanding is that LDK should be modular enough to allow for just the pieces you want to include on the client (invoice management, pathfinding, key management(?)) while keeping other components on the LSP/server if so desired.

Remind me again of the design...are private keys for the LN channels stored on the LSP or the Fedimint user client device? ie is the LN aspect to this custodial or non-custodial?

moneyball avatar Aug 06 '22 16:08 moneyball

lightning-rapid-gossip-sync

Thanks, we'll watch that. It seems like work is happening in this branch. Benchmarks look nice.

Are private keys for the LN channels stored on the LSP or the Fedimint user client device?

The LSP currently does everything lightning-related, including hold all lightning private. But the LSP must trust the federation to redeem the blinded tokens it issues for real bitcoin, and the federation and federation users don't need to trust the LSP.

justinmoon avatar Aug 08 '22 12:08 justinmoon

One step in this direction would be to just remove the description from the invoice https://github.com/fedimint/fedimint/blob/5ee44fbe10f15c882a3751323c625d860137e68e/modules/minimint-ln/src/contracts/outgoing.rs#L21

justinmoon avatar Aug 18 '22 17:08 justinmoon

Good idea, though the gateway might not be able to verify the signature of the complete invoice if that's part of it? Maybe that's fine, since the gateway trusts that the federation is not giving them bad invoices to pay. Though I'm unsure of how lightning nodes react when they see an invoice that does not have all of the information and cannot verify signature.

TonyGiorgio avatar Aug 18 '22 18:08 TonyGiorgio

@elsirion the other day we were talking and you mentioned that core lightning has APIs that we might be able to leverage which require less than the full invoice? Something like "pay along path" or something?

justinmoon avatar Jun 07 '23 14:06 justinmoon

@elsirion the other day we were talking and you mentioned that core lightning has APIs that we might be able to leverage which require less than the full invoice? Something like "pay along path" or something?

SendPay is probably what you want: https://lightning.readthedocs.io/lightning-sendpay.7.html

You can call getroute first if you want, or if you have all the info already you just construct the array of hops.

TonyGiorgio avatar Jun 07 '23 15:06 TonyGiorgio

Partially fixed, currently only LND supports private payments.

elsirion avatar Dec 07 '23 18:12 elsirion

Can you elaborate on what you mean by private payments and what LND provides that other LN implementations do not?

moneyball avatar Dec 07 '23 18:12 moneyball

tl;dr: this comment is only relevant in the Fedimint context.

LND has an API call SendPaymentV2 that allows only supplying the amount, payment hash, destination and payment secret to make a payment, so we implemented support for paying invoices without revealing the description to the gateway there first.

The only other LN implementation that Fedimint currently fully supports is CLN, which afaik does not have such an API call. One can still build this feature by using getroute and sendpay, but that's far more complicated and the recent push was more about getting interfaces in and validating our general strategy. Eventually we'll implement private payments for CLN.

elsirion avatar Dec 07 '23 20:12 elsirion