freedomlayer / offset

Offset payment engine
https://www.offsetcredit.org
Other
163 stars 20 forks source link

RequestSendFundsOp should only contain next nodes on route #208

Closed realcr closed 5 years ago

realcr commented 5 years ago

Summary

Currently RequestSendFundsOp always contains the full route from the buyer to the seller. To (somewhat) protect the buyer's privacy, we propose to remove the nodes from the beginning of the route. Those nodes are not required for the correct operation of the protocol, and they expose the identity of the buyer.

Example: Consider the following network layout:

B -- C -- D -- E

Currently, a RequestSendFundsOp message from B to E contains the route: B -- C -- D -- E. We denote the contents of the route in the RequestSendFundsOp message received by the following nodes:

In other words: when the message is forwarded from B to C, it still contains the full B -- C -- D -- E. Next, when C forwards the message to D, it still contains the full route: B -- C -- D -- E. Finally, when the message arrives at D, is still contains the full route: B -- C -- D -- E. This reveals to E the public key of the buyer: B, hence violating the privacy of B.

Instead, we propose that when a node receives a RequestSendFundsOp message, the message will contain as a route only the next nodes, and not include the node itself and the previous nodes. Continuing the example,

Privacy implications

This modification should provide some sort of privacy for the buyer (But not for the seller). Note that this will not provide "perfect" privacy for the buyer, for the following reasons:

That said, the proposed modification is a "quick win" for increasing the buyer privacy without too much work.

In the future, if this becomes important enough, we might be able to consider techniques like onion routing, where every node is given only the identity of the next node to forward a RequestSendFundsOp, in encrypted form.

Instructions

The proposed modification does not require changing the structure of RequestSendFundsOp or any serialization code.

The major changes required are:

  1. offst-proto signature buffers
  2. offst-funder logic (The part that deals with incoming and outgoing Request messages).

Part (1) Currently the ResponseSendFundsOp contains the following capnp description:

struct ResponseSendFundsOp {
        requestId @0: Uid;
        destHashedLock @1: HashedLock;
        randNonce @2: RandNonce;
        signature @3: Signature;
        # Signature{key=destinationKey}(
        #   sha512/256("FUNDS_RESPONSE") ||
        #   sha512/256(requestId || sha512/256(route) || randNonce) ||
        #   srcHashedLock || 
        #   destHashedLock || 
        #   destPayment ||
        #   totalDestPayment ||
        #   invoiceId
        # )
        # ...
}

Consider the signature description above (in comment). The signature currently contains sha512/256(route). This part needs to be removed, as with the proposed modification nodes later on the route will not be able to calculate this value. Therefore the route should not be included at all inside the signature. The new signature should be:

   # Signature{key=destinationKey}(
        #   sha512/256("FUNDS_RESPONSE") ||
        #   sha512/256(requestId || randNonce) ||
        #   srcHashedLock || 
        #   destHashedLock || 
        #   destPayment ||
        #   totalDestPayment ||
        #   invoiceId
        # )
        # ...

This new signature form should be updated in all the comments that contain signature description:

The code that computes this signature could be found in funder/signature_buff.rs in offst-proto. Make sure to modify all the places that calculate the signature. I think that the code in signature_buff.rs contains some kind of code duplication for the computation of the signature. If you can refactor this part while you are there it could be an extra win.

After this part is finished, cargo test should work correctly. At this point the full route is still forwarded in the tests, but the signature does not include the full route any more.

Part (2) offst-funder logic

I think that the files that require modification are:

Stuff that should be changed:

Other notes

realcr commented 5 years ago

@pzmarzly : Do you want to work on this one?

pzmarzly commented 5 years ago

Ok