Research/Bitcoin Dev Archive / lightning-dev list
Payment presentation strawmen.
8 messages, Sep 6 to 27, 2016. Started by Rusty Russell.
Ryan Grant (3), Rusty Russell (2), CJP (2), Christian Decker
Hi all,
Joseph mentioned the critical issue of how a payee tells a payer how to pay. Here's my ordered wishlist:
1) Can be presented with a standard QR code (ie. 1-way comms) 2) Minimal state required on the client. 3) Minimal network queries required by client (ie. minimize privacy leaks). 4) Minimal state required on the server.
Here's a range of possibilities:
A) Simply present amount and public node address, rely on routing protocol for client to get there. - 4+33 bytes, tiny. eg. http://ozlabs.org/~rusty/images/QR-04.gif [1] - Client has to know entire network, or queries for route/fee information which leaks far too much.
B) Present one or more chains of channels from landmarks, with fee info. Channels are represented as blocknum & txnum pairs. - Adds 4 + 4 + 2 bytes per hop. eg http://ozlabs.org/~rusty/images/QR-11.gif - Client needs to know channel tx -> node ID mapping for all nodes. - Client must either know routes to landmarks (ie. globally agreed), or query for them.
C) As above, but include IDs for each hop in chain. - Additional 33 bytes per hop. eg http://ozlabs.org/~rusty/images/QR-21.gif - Client must either know routes to landmarks, or query for them.
C is more scalable, OTOH B will work for the first million or so nodes...
Cheers, Rusty. [1] Assuming an average route length of 5, 3 landmarks, and 20 bytes overhead.
Payments unexpectedly fragmented into multiple LN channels are trickier than transactions spending multiple UTXOs. If Alice pays Bob using multiple channels to fund one payment, then Bob's accounting procedures might need time-based heuristics to join separate LN transactions.
Wherever payments might fragment, some reassembly protocol support, like BIP 70's merchant_data field, should be available. Every wallet should be assisting with this accounting.
Since it's a low-level protocol, a varint should suffice. Since we didn't need to bring in X.509 yet, call it payment_id. Lack of a payment_id could, if tolerated at all, be considered a "don't fragment" request.
On Sat, Sep 10, 2016 at 06:16:07AM -0500, Ryan Grant wrote:
Quoted text (10 lines)
> Payments unexpectedly fragmented into multiple LN channels are > trickier than transactions spending multiple UTXOs. If Alice pays Bob > using multiple channels to fund one payment, then Bob's accounting > procedures might need time-based heuristics to join separate LN > transactions. > > Wherever payments might fragment, some reassembly protocol support, > like BIP 70's merchant_data field, should be available. Every wallet > should be assisting with this accounting. >
At least for the implementation using the r-hash to condition the release of funds there is nothing special about splitting a payment. As long as the recipient knows the total amount it should be receiving it can delay the release of the secret until it is guaranteed all funds. Collating the partial payments is done with the r-hash. I'm pretty sure that the private key release would also work the same way.
A timeout might be sensible though just to be able to safely retry should a partial payment get stuck.
In theory Lightning would also support arbitrary splitting and merging along the paths of the payment. Not sure if this is still possible (or desirable) when adding Onion Routing to the mix though :-)
Cheers, Christian
On Sat, Sep 10, 2016 at 4:36 PM, Christian Decker <decker.christian at gmail.com> wrote:
Quoted text (7 lines)
> At least for the implementation using the r-hash to condition the > release of funds there is nothing special about splitting a > payment. As long as the recipient knows the total amount it should be > receiving it can delay the release of the secret until it is > guaranteed all funds. Collating the partial payments is done with the > r-hash. I'm pretty sure that the private key release would also work > the same way.
I understand how to collect partial payments on one channel this way, but my reading was that the same r-hash cannot be used safely across multiple channels. Once one channel completes, exposure of the r-hash to a colluding intermediary in the other channel could allow pulling funds before sending them onward.
Oops, I see my mistake. Hold onto the r-hash longer.
Hi,
I just woke up with a new thought:
With source routing and explicit fee payment, you can actually atomically pay multiple parties, by letting all but one of the recipients be intermediate parties in the route, and just paying them a very high transaction fee. With "atomically" I mean it is impossible that payment to one of the recipients succeeds and payment to another fails.
Payment amount can be obfuscated by letting yourself (the sender) be the final recipient, so none of the intermediate nodes sees the actual amount being transferred.
It isn't rocket science (or advanced cryptography), but I hadn't realized this before.
- CJP
CJP <cjp at ultimatestunts.nl> writes:
Quoted text (17 lines)
> Hi, > > I just woke up with a new thought: > > With source routing and explicit fee payment, you can actually > atomically pay multiple parties, by letting all but one of the > recipients be intermediate parties in the route, and just paying them a > very high transaction fee. With "atomically" I mean it is impossible > that payment to one of the recipients succeeds and payment to another > fails. > > Payment amount can be obfuscated by letting yourself (the sender) be the > final recipient, so none of the intermediate nodes sees the actual > amount being transferred. > > It isn't rocket science (or advanced cryptography), but I hadn't > realized this before.
Tricky :) And adds some interesting game theory:
Imagine the simple case where I pay C $4 in fees, via B:
$5 $5 $1 $1
A ---> B ---> C ---> B ---> A
4days 3days 2days 1day
B can simply use the H-preimage it gets from A to fulfill the HTLC A offered, gaining $4 and ignoring C. If C somehow gets the preimage out-of-band, it can claim the $5 from B and then B can get its $1 from C.
The risk (for B) is that C will wait until the C->B HTLC has expired, *then* use the B->C HTLC to collect $5, leaving B out-of-pocket.
Now, there's nothing special about this: the game happens for normal fees too, especially since we don't know if two apparently-distinct nodes are actually identical. It's just more tempting when the fees are high.
Fun!
Thanks, Rusty.
You mentioned two examples of out-of-band distribution of the pre-image: from B (role 2) to B (role 1), and as a scenario assumption of C receiving the pre-image out-of-band. I think there is no risk in this.
I think out-of-band distribution of the pre-image is not only harmless: it is even desirable. If one of the intermediate nodes blocks the regular distribution, the other ones can commit the transaction on their channels as soon as they receive the pre-image (in- or out-of-band). The node on the payee-side of the blocking node can enforce being paid by the HTLC mechanism, and the node on the payer-side doesn't mind not having to pay (but can still pay voluntarily). The only nodes potentially losing funds are the ones that don't follow the regular protocol.
If you don't have out-of-band distribution of the pre-image, one blocking node can potentially keep all HTLCs on his payer-side locked for quite some time (until their time-outs). Eventually they end up being rolled back, with the blocking node again being the only one losing funds (which is good).
The advantage of having your HTLCs resolved quickly, so those funds can flow in the opposite direction quickly, might be a sufficient incentive for non-regular distribution of the pre-image. In Amiko Pay, payer->payee distribution is added next to payee->payer distribution, but it's a voluntary thing, and people might decide to remove it from their version of Amiko Pay, without any real harm being done.
CJP
Rusty Russell schreef op di 27-09-2016 om 11:33 [+0930]:
Quoted text (23 lines)
> Imagine the simple case where I pay C $4 in fees, via B: > > $5 $5 $1 $1 > A ---> B ---> C ---> B ---> A > 4days 3days 2days 1day > > B can simply use the H-preimage it gets from A to fulfill the HTLC A > offered, gaining $4 and ignoring C. If C somehow gets the preimage > out-of-band, it can claim the $5 from B and then B can get its $1 from > C. > > The risk (for B) is that C will wait until the C->B HTLC has expired, > *then* use the B->C HTLC to collect $5, leaving B out-of-pocket. > > Now, there's nothing special about this: the game happens for normal > fees too, especially since we don't know if two apparently-distinct > nodes are actually identical. It's just more tempting when the fees are > high. > > Fun! > > Thanks, > Rusty.