Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

Onion-Routing for Messages

4 messages, Dec 8 to 9, 2015. Started by Mats Jerratsch.

Mats Jerratsch (2), Bryan Bishop, Rusty Russell

Permalink First message in the Wayback Machine

Mats Jerratsch permalink original

I've been thinking a lot about the Onion Routing we designed a couple of weeks ago and how we would use it in practice.

So I am in full privacy mode currently and I would prefer to design a system in which sender and receiver of a payment by default do not learn any additional information about each other. This means that payments will - by default - get routed over a rendezvous point(RP) and encrypted using a onion scheme.

So if A wants to make a payment to E, E will choose a RP C and create an onion object which will allow C to route the payment further towards E. A will not know which node is receiving the payment, A only knows that it should route the payments towards C. So A uses the object E sent him and wraps the onion layers for the routing towards C around it. When C receives it, it does not know that A sent it, nor that it should be relayed to E finally. It will just follow the instructions E put in the onion object.

In practice E can use a (reasonably sized) QR code to transmit this blob of data to A.

However, we have to decide whether we want this whole onion-routing to be one-time and one-directional or not.

The design where we stopped few weeks ago did fill up the onion objects with zeros, so unless the nodes store some data to relate to that message later, it is not possible for the receiver to send a message back to the sender. (or to have any additional communications at all for that matter)

This means we would need to transmit the payment hash together with the blob in the QR code. Furthermore, if the payment goes missing, we need some additional communications channel to address routing of the refund payment. (NFC would qualify for that if we are using a mobile wallet) It also means that payment requests are one-time only, as they include the payment hash. (even though we could try to do some fancy things if we settle for EC keys for payments)

On the other hand, it would be possible to have a message system integrated. When parsing the onion object, each node could encrypt and append the pubkey of the node it received the object from together with the ephemeral key used initially. When the receiver wants to send a message back, he encrypts it using some designated ephemeral key included by the sender and uses the onion object to send it back. The nodes on the route can unwrap the onion object again to route it back to the original sender.

This means that a payment request is just a way of contacting the receiver to obtain information about making a payment. It can be stored and reused whenever you want to make a payment. You can also send the necessary signatures for the pay-to-contract scheme as include other data necessary if we want to implement something like Proof-of-Payment. In general, it would allow for very general purposes.

Which - on the other hand - is also problematic. It is difficult to provide a reasonable DoS protection against nodes just spamming the network with unnessesary messages. We could assign super tiny payments to the process of sending a message to counter spam, but it might be difficult to implement.

Additionally it serves a security risk, as someone obtaining the onion object can 'hunt down' the sender by targeting the nodes consisting the route one by one. Currently this is only possible for tracking down the receiver. For one to succeed in such a task, it is necessary to extract the private key used for encryption for ALL nodes in the rout e.

- -- Mats Jerratsch Backend Engineer, Blockchain e: mats.jerratsch at blockchain.com PGP: https://pgp.mit.edu/pks/lookup?op=get&search=0x7F3EC6CA

Bryan Bishop in reply to Mats Jerratsch permalink original

On Tue, Dec 8, 2015 at 11:13 AM, Mats Jerratsch wrote:

Quoted text (2 lines)
> However, we have to decide whether we want this whole onion-routing to
> be one-time and one-directional or not.

I have sort of lost track of preferences regarding what is to be sent through onion routing versus what's not...

Originally I had assumed that some out-of-band messaging would be taking place (like an equivalent to a BIP70-style payment protocol). Rather than a single QR code, I was expecting an interactive wallet-to-wallet protocol while both sides are busy communicating with the onion routing network for the actual payment route negotiation stuff. When they ultimately find that no sufficiently cheap route exists, then the wallets would opt to create a new payment channel in some circumstances.

Once a path is found, the recipient would then communicate over the wallet-to-wallet channel to pass over the fully-constructed onion routing information. Sending that data back over the onion routing network may not be necessary. Unfortunately this increases the complexity of the payment side (wallet-to-wallet), but meanwhile makes for less message passing in onion land, which could make the problem easier to think about?

- Bryan http://heybryan.org/ • ••• ••• ••••

Mats Jerratsch in reply to Bryan Bishop permalink original
Quoted text (2 lines)
> I have sort of lost track of preferences regarding what is to be
> sent through onion routing versus what's not...

Agree, it hasn't been on list for quite some time, the last time we discussed it, we only included the route in there.

http://lists.linuxfoundation.org/pipermail/lightning-dev/2015-October/00 0247.html

Back then only the pubkey of the next hop has been part of the onion object, with no additional message to the final receiver. For having the added privacy of changing R value we would probably add a random number in there as well.

Quoted text (8 lines)
> Originally I had assumed that some out-of-band messaging would be
> taking place (like an equivalent to a BIP70-style payment
> protocol). Rather than a single QR code, I was expecting an
> interactive wallet-to-wallet protocol while both sides are busy
> communicating with the onion routing network for the actual payment
> route negotiation stuff. When they ultimately find that no
> sufficiently cheap route exists, then the wallets would opt to
> create a new payment channel in some circumstances.

Interesting. I think the important term here is 'out-of-band', as I would implement above using the actual lightning network. But I also fail to see how to implement a secure and private communications. I guess one way would be to have wallets open up a hidden service on TOR and take payment requests on a service listening there. But it would not exactly reduce complexity nor would provide sufficient defense against DoS attacks. Everything simplifies a bit when we assume these communications using non-private way as simple HTTPS-requests-responses, but I think we are sacrificing too much privacy on the way.

Quoted text (7 lines)
> Once a path is found, the recipient would then communicate over
> the wallet-to-wallet channel to pass over the fully-constructed
> onion routing information. Sending that data back over the onion
> routing network may not be necessary. Unfortunately this increases
> the complexity of the payment side (wallet-to-wallet), but
> meanwhile makes for less message passing in onion land, which could
> make the problem easier to think about?

Do you mind defining wallet-to-wallet channel a bit more? Which techniques could/should they use without leaking information?

Yes, we would increase the total load for the nodes if they should handle these additional messages. But I think we can go with a simplified message-delivery-system where each hop costs like 1 satoshi. I call it simplified, because we are not using the a HTLC, but just rebalancing the unencumbered outputs of the commit transaction.

As the sender of a message you can go to the first node and give him 30 satoshis for opening the onion object and passing the message to the next node as instructed in the onion object. It would pay the next node 29 satoshis, and so on. These would not be enforcable on the blockchain, so a dishonest node could just keep the 29 satoshis and not deliver anything at all. However, if you receive a message to relay it, it is a strong indication that there is a payment to follow up to that message. The general incentive is to relay these messages, as fees of payment are likely higher. Given that we can have sub-satoshi payments too, we might want to tune the cost-per-hop to make it substantially less than any fees you could get of the payment.

If it remains a problem (and some people could just join the network and not relay anything just for the sake of it), we might either find a way to proof this behavior or even use HTLCs for these, even though that would probably be not practical and bloat commit transactions waay too much.

- -- Mats Jerratsch Backend Engineer, Blockchain e: mats.jerratsch at blockchain.com PGP: https://pgp.mit.edu/pks/lookup?op=get&search=0x7F3EC6CA

Rusty Russell in reply to Mats Jerratsch permalink original

Mats Jerratsch via Lightning-dev <lightning-dev at lists.linuxfoundation.org> writes:

Quoted text (8 lines)
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA512
>
>> I have sort of lost track of preferences regarding what is to be
>> sent through onion routing versus what's not...
>
> Agree, it hasn't been on list for quite some time, the last time we
> discussed it, we only included the route in there.

Yes, plus some padding for future stuff.

        There are two ideas here.  One is the passing of messages over
the lightning network.  The other is a rendezvous node for payments.
Fortunately, the two can be extricated.  The vendor negotiates with a
node to forward a payment, then tells the buyer to route to that node.
Buyer doesn't need to know it's not the final recipient; there's no
protocol change.

Provision of messaging is an interesting idea, but as you point out there are problems with payments. If we use lightning for this, then the recipient will just claim the route failed and not pay for the message. If we don't use lightning, we have to trust the nodes instead. If we don't charge, we worry about spam.

More generally, reinventing a p2p messaging network seems outside scope. The good news is that there's nothing stopping us doing so in a future revision (is there?).

Cheers, Rusty. PS. Congratulations on the job!!