Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

Spontaneous transfers

5 messages, May 8 to 10, 2017. Started by Christian Decker.

Christian Decker (2), Rusty Russell (2), ZmnSCPxj

Permalink First message in the Wayback Machine

Christian Decker permalink original

Hi all,

following the current discussion about invoice based transfers, I've been contacted by some users that would like us to consider other use-cases as well. They'd like not to have to go through the invoice-transfer-release cycle that invoices support, e.g., donations withough prior contact between the recipient and the sender.

The recurring requirements for these transfers are that a) the recipient gets the payment preimage so that she can trigger the clearing of the HTLC, and b) that there is a mechanism that signals to the recipient who the sender is, without out of band communication.

So assuming Alice is the sender and Bob is the recipient I cam up with the following possible solutions:

 - We can stuff that information into the routing info. We have the
   flexibility of adding a new realm in there, and the last hop does
   not contain much useful information currently. So we'd define a new
   "realm" that basically let's the per-hop payload be interpreted as
   the sender information, and we can put R and Alice's ID in there.
 - Another option is that Alice can create a circular route, from
   Alice sending `X+fees` to Bob and then `fees` back to herself,
   i.e., masquerading the payment as an oversized fee that is
   deposited at Bob. This way Alice can trigger the payment herself,
   but we can't communicate the sender's identity to Bob. We may even
   be able to build the game in such a way that the payout of the
   winning amount is the second half of the route, if Alice wins at
   all.

I think the first option is probably the easiest and cleanest, and the second one is more of a novelty, but it'd allow the creation of a gambling service that does not know the identity of its players :-)

Are there other solutions that we can offer with the existing protocol, or are there changes we could add for a v1.1 that would better accomodate these use-cases?

Cheers, Christian

P.S.: I'm seeing quite a few of these ideas being repeated, because we haven't documented these brainstorming ideas anywhere, shall we use the lightning-rfc wiki on Github to catch them, so we can reference them and maybe formulate them as BOLTs later?

Rusty Russell in reply to Christian Decker permalink original

Christian Decker <decker.christian at gmail.com> writes:

Quoted text (7 lines)
> Hi all,
>
> following the current discussion about invoice based transfers, I've
> been contacted by some users that would like us to consider other
> use-cases as well. They'd like not to have to go through the
> invoice-transfer-release cycle that invoices support, e.g., donations
> withough prior contact between the recipient and the sender.

Thanks for bringing this up!

Quoted text (13 lines)
> The recurring requirements for these transfers are that a) the
> recipient gets the payment preimage so that she can trigger the
> clearing of the HTLC, and b) hthat there is a mechanism that signals to
> the recipient who the sender is, without out of band communication.
>
> So assuming Alice is the sender and Bob is the recipient I cam up with
> the following possible solutions:
>
>  - We can stuff that information into the routing info. We have the
>    flexibility of adding a new realm in there, and the last hop does
>    not contain much useful information currently. So we'd define a new
>    "realm" that basically let's the per-hop payload be interpreted as
>    the sender information, and we can put R and Alice's ID in there.

Anti-probing requires the amount and cltv fields. We can use the 16 bytes in the onion to communicate a 128-bit R value, however, which suffices AFAICT.

(If we ever want to support larger amounts we'll need a new onion version but we can probably avoid enlarging it: steal two bytes from `outgoing_cltv_value` and have a new max of 720k bitcoins).

Quoted text (12 lines)
>  - Another option is that Alice can create a circular route, from
>    Alice sending `X+fees` to Bob and then `fees` back to herself,
>    i.e., masquerading the payment as an oversized fee that is
>    deposited at Bob. This way Alice can trigger the payment herself,
>    but we can't communicate the sender's identity to Bob. We may even
>    be able to build the game in such a way that the payout of the
>    winning amount is the second half of the route, if Alice wins at
>    all.
>
> I think the first option is probably the easiest and cleanest, and the
> second one is more of a novelty, but it'd allow the creation of a
> gambling service that does not know the identity of its players :-)

Damn, I thought of doing exactly this trick to implement LightningDice service just yesterday! As usual, you're one step ahead :)

You also want to be able to prove to a third party if the server cheats, so the server revealing the payment preimage should be enough to show that you lost. I can't think of a way of doing that with preimages.

But ignoring that, we can pack a full payment hash into a pair of per_hop, so the LightningDice(TM) service run a pair of neighboring nodes:

1. LD provides a payment hash as usual.
2. You pick a payment preimage for your winnings.
3. Construct route through the two LD nodes and back to you, except
   1. the payment hash is encoded into the two padding fields for the LD nodes.
   2. the onion switches to commit to your own payment hash for the return

Then if you lose (using your payment hash XOR preimage), LD takes the money and you can see you lost by receiving the preimage. If you win, it simply continues forwarding the onion with the new payment hash and (increased) amount.

The cool thing about this is that you can pay someone probabalistically via the LD server (as long as you trust them not to collude on payment hashes).

Quoted text (11 lines)
> Are there other solutions that we can offer with the existing
> protocol, or are there changes we coiruld add for a v1.1 that would
> better accomodate these use-cases?
>
> Cheers,
> Christian
>
> P.S.: I'm seeing quite a few of these ideas being repeated, because we
> haven't documented these brainstorming ideas anywhere, shall we use
> the lightning-rfc wiki on Github to catch them, so we can reference
> them and maybe formulate them as BOLTs later?

Yes, I think we all have mental lists. This seems like something work having a wiki on github for?

Cheers, Rusty.

ZmnSCPxj in reply to Christian Decker permalink original

Good morning Christian,

Quoted text (12 lines)
>- Another option is that Alice can create a circular route, from
>Alice sending `X+fees` to Bob and then `fees` back to herself,
>i.e., masquerading the payment as an oversized fee that is
>deposited at Bob. This way Alice can trigger the payment herself,
>but we can't communicate the sender's identity to Bob. We may even
>be able to build the game in such a way that the payout of the
>winning amount is the second half of the route, if Alice wins at
>all.
>
>I think the first option is probably the easiest and cleanest, and the
>second one is more of a novelty, but it'd allow the creation of a
>gambling service that does not know the identity of its players :-)

I think this is a clever way of doing anonymous donations to controversial charities. Not even the receiver can leak information on who the donators are.

Regards, ZmnSCPxj

Christian Decker in reply to Rusty Russell permalink original

On Tue, May 09, 2017 at 10:52:42AM +0930, Rusty Russell wrote:

Quoted text (7 lines)
> Anti-probing requires the amount and cltv fields.  We can use the 16
> bytes in the onion to communicate a 128-bit R value, however, which
> suffices AFAICT.
>
> (If we ever want to support larger amounts we'll need a new onion
> version but we can probably avoid enlarging it: steal two bytes from
> `outgoing_cltv_value` and have a new max of 720k bitcoins).

Right, we can't use those fields, and 16 bytes is not sufficient to identify the sender. But we could probably use it for a prefix lookup in our routing table and then derive the payment preimage from that. If this is the last hop the `channel_id` is also empty, and we can use that as well. By defining a new realm we can also reorder the fields to have 24 contiguous bytes.

Quoted text (25 lines)
> Damn, I thought of doing exactly this trick to implement LightningDice
> service just yesterday!  As usual, you're one step ahead :)
>
> You also want to be able to prove to a third party if the server cheats,
> so the server revealing the payment preimage should be enough to show
> that you lost.  I can't think of a way of doing that with preimages.
>
> But ignoring that, we can pack a full payment hash into a pair of
> per_hop, so the LightningDice(TM) service run a pair of neighboring
> nodes:
>
> 1. LD provides a payment hash as usual.
> 2. You pick a payment preimage for your winnings.
> 3. Construct route through the two LD nodes and back to you, except
>    1. the payment hash is encoded into the two padding fields for the LD nodes.
>    2. the onion switches to commit to your own payment hash for the return
>
> Then if you lose (using your payment hash XOR preimage), LD takes the
> money and you can see you lost by receiving the preimage.  If you win,
> it simply continues forwarding the onion with the new payment hash and
> (increased) amount.
>
> The cool thing about this is that you can pay someone probabalistically
> via the LD server (as long as you trust them not to collude on payment
> hashes).

Ah I see, I had a bit of trouble seeing how we could create a route that commits to the 2 possible outcomes, since the HMAC commits to the `amt_to_forward`, so there'd be no way of forwarding either wins or losses. You're saying that the route simply stops at LD if we lose.

The XORing is quite interesting though I can't really see how it'd work yet. LD would commit to a secret by sending you the hash, you construct a route using that hash and your own pick (payment hash for the second half) on the first half and then send the winnings back to me using my own pick? How are you combining the LD hash and your own hash to make it provably fair and giving LD the ability to pull the payment in say 50% of the cases?

Cheers, Christian

Rusty Russell in reply to Christian Decker permalink original

Christian Decker <decker.christian at gmail.com> writes:

Quoted text (15 lines)
> On Tue, May 09, 2017 at 10:52:42AM +0930, Rusty Russell wrote:
>> Anti-probing requires the amount and cltv fields.  We can use the 16
>> bytes in the onion to communicate a 128-bit R value, however, which
>> suffices AFAICT.
>>
>> (If we ever want to support larger amounts we'll need a new onion
>> version but we can probably avoid enlarging it: steal two bytes from
>> `outgoing_cltv_value` and have a new max of 720k bitcoins).
>
> Right, we can't use those fields, and 16 bytes is not sufficient to
> identify the sender. But we could probably use it for a prefix lookup
> in our routing table and then derive the payment preimage from
> that. If this is the last hop the `channel_id` is also empty, and we
> can use that as well. By defining a new realm we can also reorder the
> fields to have 24 contiguous bytes.

Hmm, good point. I was wrong about stealing 2 bytes from outgoing_cltv_value, BTW: it needs to be a block height :(

Quoted text (19 lines)
>> 1. LD provides a payment hash as usual.
>> 2. You pick a payment preimage for your winnings.
>> 3. Construct route through the two LD nodes and back to you, except
>>    1. the payment hash is encoded into the two padding fields for the LD nodes.
>>    2. the onion switches to commit to your own payment hash for the return
>>
>> Then if you lose (using your payment hash XOR preimage), LD takes the
>> money and you can see you lost by receiving the preimage.  If you win,
>> it simply continues forwarding the onion with the new payment hash and
>> (increased) amount.
>>
>> The cool thing about this is that you can pay someone probabalistically
>> via the LD server (as long as you trust them not to collude on payment
>> hashes).
>
> Ah I see, I had a bit of trouble seeing how we could create a route
> that commits to the 2 possible outcomes, since the HMAC commits to the
> `amt_to_forward`, so there'd be no way of forwarding either wins or
> losses. You're saying that the route simply stops at LD if we lose.

Yes. LD knows the preimage, so can take the funds (if it wins). The rest of the onion commits to the *new* rhash and amount, so if it loses LD launches a new HTLC using the rest of the onion.

Quoted text (7 lines)
> The XORing is quite interesting though I can't really see how it'd
> work yet. LD would commit to a secret by sending you the hash, you
> construct a route using that hash and your own pick (payment hash for
> the second half) on the first half and then send the winnings back to
> me using my own pick? How are you combining the LD hash and your own
> hash to make it provably fair and giving LD the ability to pull the
> payment in say 50% of the cases?

Well, you can tell if it cheats, since it provides the preimage, you know you should have won. You can't prove it to a third party, however.

XOR rules might look like:

        bottom 7 bits = 0000000 -> LD wins (house edge)
        otherwise bottom bit = 1 : LD wins
        otherwise bottom bit = 0 : player wins

Cheers, Rusty.