Research/Bitcoin Dev Archive / lightning-dev list
On Path Privacy
4 messages, Dec 26, 2019, to Jan 20, 2020. Started by ZmnSCPxj.
ZmnSCPxj (3), Antoine Poinsot
Privacy Loss Models ===================
Shortest Path Heuristic -----------------------
First, let us presuppose a network connected as below:
B --- C
/ \
/ \
A D
\ /
\ /
F --- E
Now, let us suppose that some evil surveillor insinuates itself into the network:
B --- C
/ \ / \
/ \ / \
A --- S --- D
\ / \ /
\ / \ /
F --- E
The strategy of the surveillor is thus the below:
* It makes itself more central to the network by creating large numbers of channels, especially to distant nodes. * It lowers its channel fees relative to the other nodes, making its channels attractive to pathfinders that consider channel fees. * It uses the "shortest path heuristic". That is: * Suppose in the given example, S receives a forward via the B-S channel, to the S-D channel. * Then it knows the payer is B and the payee is D.
More precisely, the "shortest path heuristic" simply means performing the below precomputation:
* Take the entire routemap.
* Create a mapping of the tuple of an incoming channel and an outgoing channel (of the surveillor node), to a set of pairs of payers and payees.
* For each possible payer in all nodes:
* For each each possible payee in all nodes:
* Take the shortest path from payer to payee.
* If the surveillor node is in that path, determine the incoming channel and outgoing channel, then add the payer and payee to the corresponding entry in the mapping.
Then, whenever the surveillor node has to perform a forward, it only needs to look up the incoming channel and outgoing channel in the mapping. This results in a set of possible payer/payee pairs.
This analysis becomes more powerful when the surveillor has acquired forwarding logs from multiple nodes on the network. If a payment is determined to have passed through multiple nodes, whose forwarding logs the surveillor has acquired, then the surveillor can simply perform the above precomputation for each node, then take the intersection of the sets in each mapping entry.
Much of the privacy loss is effectively due to forwarding nodes being able to create "reverse" routing tables. That is, instead of a routing table that inputs a source and destination and outputs a (set of) likely direction(s) to send packets to, a reverse routing table inputs a direction from sent and to sent and outputs a (set of) likely source(s)/destination(s).
Unremovable Forwarding Data ---------------------------
As we know, switching Lightning from HTLCs to PTLCs (i.e. from payment hash + preimage to payment point + scalar) enables many new features, including the so-called "path decorrelation". The theory is that by changing the payment point at each hop, multiple coordinating surveillor nodes will be unable to determine if the same payment passed through them.
However, this is not sufficient, as the data below cannot be removed or hidden:
* The sidereal time at which `update_add_htlc` messages are sent * This can be used to determine if two forwards are possibly on the same payment path. * Worse, the sidereal time between the outgoing `update_add_htlc` and the `update_fail_htlc` / `update_fulfill_htlc` response can be measured to help characterize the distance, in nodes, to the payee. * We cannot change or mask this time, unless we are willing to add random, potentially-large latencies to forwards, which we do not want to do since the entire point of Lightning Network is fast payments. * The value being transmitted cannot be hidden from the forwarding node. * While we know how to send homomorphically encrypted values that can be summed up, the forwarding node has to know the value of its own channels, and would know how much a forward changes its own channel values in order to determine if it has enough capacity on a channel to actually offer the outgoing HTLC. * The timelock of the payment cannot be hidden from the forwarding node. * The forwarding node is liable for the timelock of any HTLCs it offers, and it has to know about the exact timelock in order to force a channel onchain when any HTLCs pending on it have a timelock that is expiring very soon.
The above data helps two cooperating surveilling nodes to determine if two forwards on their nodes belong to the same logical payment, even if path decorrelation masks the payment point along the entire path:
* The two nodes can determine: * How long a shortest-path payment takes to reach from one to the other. * How much fees the shortest path between them costs. * How much CLTV-delta the shortest path between them costs.
By deriving the above data, two nodes can have a very good guess of which forwards passing through them are likely to belong to the same payment, which helps them triangulate better the payer and payee, especially given the shortest path heuristic. Thus, even *with* path decorrelation, two cooperating surveilling nodes can still correlate forwards across them (they just will not be able to execute a wormhole attack).
Now, of note is that the the timelock is particularly leaky in terms of privacy. The timelock gives an upper bound on the distance of the forwarding node to the ultimate payee. In combination with another privacy loss, this can allow a forwarding node to precisely identify the ultimate payee of a payment.
Both value and timelock can be randomized somewhat by use of "shadow routes", as implemented in C-Lightning. However, the current C-Lightning implementation only inserts shadow routes at the end of the route; it should also insert shadow routes at random points in the route, and mildly overpay fees along the way (not just give extra value+cltv-delta to the last node), to reduce the ability of multiple cooperating surveillors to determine if their forwards are the same payment.
REDACTED SECTION ----------------
REDACTED TEXT.
Non-Solutions to Privacy Loss =============================
Unpublished Channels Delenda Est --------------------------------
Unpublished channels are becoming popular for some reason, and even section 4.1 of [this paper](https://arxiv.org/pdf/1909.02717) gives it as a solution for improving privacy without sacrificing utility.
Unfortunately for that paper, this is wrong, and unpublished channels must be destroyed.
Unpublished channels do not improve privacy, but instead move the privacy risks from shared to concentrated on specific nodes, which become targets for surveillors. Further, because it moves risk to fewer high-value targets (a symptom of centralization), it violates [Risk Sharing Principle](https://github.com/libbitcoin/libbitcoin-system/wiki/Risk-Sharing-Principle).
As I noted [here](https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2019/unpublished-channels-and-a-proposal-for-local-channel-publication#m-e4330806), the Axiom of Terminus means that I can have the heuristic:
* If I receive a forwarding request: * If the incoming channel is unpublished, the node on the other end is the payer. * If the outgoing channel is unpublished, the node on the other end is the payee.
This gives very precise information about who the payer and payee is, and is not fixable by e.g. shadow routing or [REDACTED TEXT].
Now, of course the above heuristic is only doable by primarily-forwarding nodes with a mix of unpublished and published channels, and only to nodes that use the unpublished channels. Otherwise, independent third parties cannot even know about nodes that *only* use unpublished channels, so that should be good, right?
Unfortunately:
* Payers have pretty good privacy otherwise: the (unremovable) timelock is a hint to the distance to the payee, not payer, and the payer could always claim that it received the payment via other published channels.
* Thus, ***the fact that with unpublished channels some nodes can now identify the payer precisely is a major privacy loss for payers***.
* Those nodes with a mix of unpublished channels and published channels become major targets for surveillance.
* They may be tempted by the dark side to defray their operating costs by actively selling the payment information they have acquired.
* Their backups and persistent storage can be hacked and copies of forwarding logs acquired, even if they are strongly committed to privacy for their clients.
* Competitors who *do* sell their payment information can outcompete them, undercutting their fees (which also has the effect that payments are more likely to be routed to them due to the lower fees, increasing their ability to surveill further).
* The existence of unpublished channels is still attested on the blockchain, and onchain analysis can give hints on which unpublished users ended up making channels with specific published nodes.
* Lightning is practically the only use of 2-of-2 P2WSH, since most HODL usages will be either 1-of-1 or 2-of-3 ("never take two chronometers to sea: take one or three").
* Since current Bitcoin requires revealing a 2-of-2 script in P2WSH, even mutual closes of unpublished channels are visible publicly on the blockchain anyway, and subsequent use of that money can be traceable to specific servers.
* Taproot fixes this.
* CoinJoin fixes this.
If all channels were published, then this spreads out the information that forwarding nodes can keep. Surveillors capable of stealing forwarding logs of nodes will need to gather the forwarding nodes of large numbers of nodes. This is risk sharing: privacy-leaking information is spread out and no single node is a particularly juicy target for acquisition of control.
Note that nodes can publish themselves without publishing their IP addresses; thus they can at least hide their locations at the IP layer while revealing their locations at the Lightning layer. Nodes can also use Tor, at the cost of increased latency with the rest of the network, which behooves us to design our protocol to minimize bandwidth and turnaroud.
Refusal to Log --------------
Now, a forwarding node operator may not necessarily be an evil surveillor, and may even have a desire to be (seen as) good. Such a node operator might, as protection against hacks, and protection against evil surveillors who might hack their node and snoop their data, refuse to maintain a log of forwards.
Let us presuppose that there exists some magic spell, that ensures that a node operator is in fact performing (or not performing) some promised act (or disavowed act). I will now show that, even if such a spell could exist, a node operator cannot promise to not keep a log of forwards, at least with the current HTLCs being sent via Poon-Dryja channels.
First:
* Poon-Dryja requires transaction revocation.
* Transaction revocation requires that nodes be able to recognize old state and revoke them.
* Revoking a transaction means spending it using a special revocation branch of a special modified script.
* Special scripts in Bitcoin must be encoded in P2SH/P2WSH.
* To spend a P2SH/P2WSH, we need to show the whole encoded script, even those branches that are not taken.
* Thus, to spend a revocable HTLC output, a node has to store the hash and timelock, even if it is taking the revocation path.
* While HTLCs currently used have yet another transaction (HTLC-timeout or HTLC-success) to actually claim the funds, both the HTLC and the claim transactions have to be revocable, else an attacker might publish an old state that has all channel funds in HTLCs.
If the victim is unable to publish the HTLC script in order to spend (and revoke) the plain HTLC output without an HTLC-timeout or HTLC-success transaction being published, then the attacker can simply refuse to publish the HTLC-timeout/HTLC-success and the victim still loses access to the funds (though the attacker will still not be able to claim it, the attacker might just want to make the victim lose funds).
Thus, every node must be able to publish the HTLC script in order to revoke it (even without the attacker publishing HTLC-success/HTCL-timeout), which means it has to keep every old state hash and timelock.
Then, secondly:
* The hashes used in forwarding have to be the same in both the incoming HTLC and the outgoing HTLC.
Thus:
* Nodes have to keep all hashes and timelocks for all HTLCs of all older channel states of all channels, otherwise they are insecure. * Third parties acquiring the above data from nodes can correlate forwards by checking for HTLCs that exist in two channels. * Indeed, because HTLC scripts are different based on whether it is the local or the remote side that offered them, third parties can determine as well which HTLC is incoming and which it outgoing. * Further, the stored timelock gives an upper bound on the time an HTLC was created, giving hints on timing of a payment as well. * Therefore all current secure nodes are required to store data that is enough to derive a log of forwards.
Of course, this is not so dire. In the (close?) future, improvements to base layer will allow nodes to elide enough information from its stored data, so that a log of forwards can no longer be derived:
* Schnorr means we can use pointlocked timelocked contracts with payment decorrelation, thus allowing breaking of the link between incoming and outgoing PTLCs even in the data stored by nodes. * Once an outgoing PTLC has been claimed and we have determined the incoming PTLC, we can delete the delta between the two contracts from persistent storage, thus preventing from linking incoming from outgoing PTLCs. * Taproot means we can put the revocation branch of revocable HTLCs in a separate tapleaf. * Thus, nodes can store only the Merkle path to the revocation script, and thus no longer store the hash and timelock for all HTLCs on all older states. * `SIGHASH_NOINPUT` means we can implement Decker-Russell-Osuntokun. * Thus, honest nodes no longer need to store data from previous states of the channel.
Against the above, however, I must remind:
* We still need to create a magic spell that allows third parties to actually believe, without tr\*st, the promises of node operators that they will not store a plain log of forwards of their node, and that they will not modify the available open-source software to do so and run their locally-modified versions.
* Even if the above magic spell were created, at ***some*** point in the past the node knew an incoming HTLC/PTLC and its link to an outgoing HTLC/PTLC.
* Lower layers beneath the node software may betray the above magic spell nevertheless:
* "Deleted" data might be implemented by a database layer by simply marking some record as unused, and then reuse of that record might take a long time, meaning that old data may still exist in "deleted" records.
* The filesystem layer might implement recovery logs or other techniques where "overwritten" data is kept, as a simple function of reliability, and that data may remain validly readable outside the filesystem (i.e. deleted data might not be overwritten).
* The spinning rust / floating gate lower layers may, even with data overwritten, retain transient inductive / capacitive charge that can be read by specialized equipment, or may not overwrite data from sectors / blocks marked bad and then remapped elsewhere.
* In short, we cannot "refuse to log": we have to write the link between an outgoing HTLC/PTLC to an incoming HTLC/PTLC somewhere persistent *first* (in case our node gets randomly shut down while a forward is not yet claimed), wait for the outgoing HTLC/PTLC to be claimed, and *then* delete it later.
And "delete" is not necessarily an operation that is possible in the presence of attackers that want to retain your data.
Possible Solutions ==================
Avoiding Shortest Path ----------------------
The shortest path heuristic is key in analyzing payments on the Lightning network. Thus, breaking this heuristic is important.
* One way is to `permuteroute` the shortest-path. * For reference, `permuteroute` is described here: https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2019/improving-lightning-network-pathfinding-latency-by-path-splicing-and-other-real#m-fc0157b9 * Briefly: It is an algorithm where you input an existing route, plus a "breakage" (a channel or node that is failing) on that route. The algorithm then makes a short-range pathfinding to heal the break, or fails if it takes too long for it to find a way to heal the break. * Start with a shortest path via normal shortest-path pathfinding algorithms, then randomly select one intermediate node on that path and treat it as a "breakage" with `permuteroute`. * If that succeeds, try it a few more times until it fails or you are satisfied with the additional path length, then just use the latest randomized path. * Add random tweaks to your channel traversal costs. * This is done currently by the C-Lightning route randomization feature, but note that it is currently set to up to a +/-5% tweak. * [This paper](https://arxiv.org/pdf/1909.06890) evaluates the C-Lightning route randomization as well. It suggest adding random tweaks to the costs of entire routes instead, though it may not be easy for normal pathfinding algorithms to implement this. * Rusty Russell Random Route Ralgorithm. * Alluded to in [SLP134](https://stephanlivera.com/episode/134/). * In a private email, Rusty recounted the random routing routine; roughly reworded: * Start with a Dijkstra starting from the payer node and completing over the entire routemap. * Store the distance from each node to the payer. * This step can be precomputed, rather than performed each time we need a path. * Then the algorithm proper: * Start at the destination. payee node. * Toss a biased coin (bias controlled by how much you want to overpay fees): * If it is heads, pick a channel at random and extend the route to it. * If it is tails, find which channel goes to the node with lowest-distance-to-payer and extend the route to it. * Keep doing the above until we reach the payer node. * Then apply shadow routing afterwards. * Note that the above algorithm is roughly similar to the Greedy Best First Search with precomputed distance heuristic (a.k.a. `getroutequick`, which I presented in LNConf 2019). * The only difference is that there is a random coin toss between selecting a random channel and going towards the source node, where `getroutequick` just goes towards the source node. * We can approximate the Rusty Russell Random Routing Ralgorithm by applying a random tweak to the distance heuristic in a Greedy Best First Search! * The algorithm as described has a chance of creating small loops, which should be avoided. * Small loops that curl (i.e. pass multiple times) through a surveillor node are equivalent to a payment passing through multiple surveillor-controlled nodes, and can be identified even post-payment-decorrelation as being the same payment. * Thus you end up paying for routing through the loop, but do not gain much privacy from that extra payment because now you are giving more accurate data to a specific node (where the payment curled through). * A proper Greedy Best First Search avoids loops due to marking nodes as they are visited, so I think basing the algorithm around Greedy Best First Search plus random tweak on the heuristic is better. * Usage discounting. * When a base pathfinder returns a path, increment a "usedness" counter on each node on that path. * On future pathfinding calls, consider those nodes to have higher than normal cost, according to their usedness. * Of note is that pathfinding algorithms do NOT actually need a single numeric cost. * Instead, they need a mathematical group and group operation, with an additional "comparison" operation to determine which of two group elements is smaller. * Integer costs are a group with a comparison operation. * Instead of integer cost, we can have a pair of `(usedness, fee)`. * Add each tuple element separately, e.g. `(usedness_a, fee_a) + (usedness_b, fee_b) = (usedness_a + usedness_b, fee_a + fee_b)`. * To compare, e.g. `(usedness_a, fee_a) < (usedness_b, fee_b)`, we first compare by `usedness`, then if they are equal, compare `fee`. * This gives good diversity over multiple calls of the pathfinder, which is useful for: * Multipath, since we want each candidate path to have different nodes as much as possible, without completely discounting those nodes in case of bottlenecks in the network. * Ensures your payment data is distributed to multiple nodes rather than reusing the same nodes again and again, improving Risk Sharing since your data is spread out over more nodes. * The `usedness` needs to persist across node restarts.
Direct Path Exemption ---------------------
As mentioned above, avoiding the shortest path breaks the shortest path heuristic, adding uncertainty to analyses and thus improving privacy.
However, we should note an important exception to avoiding the shortest path:
* If the shortest path is a single hop, directly from the payer to the payee without intervening nodes, then we should prefer that path rather than avoid it.
The reason why we have this exception is that ***not telling any other nodes gives us the best privacy***. This is achievable only by having direct channels with a payee, thus it ***does not scale***, since it would not be practical to have direct channels between every payer and payee. However, if we find that the payment is to a direct peer, taking this exception should be a massive, low-hanging privacy win.
This brings up the following observation:
* In order to avoid the shortest path, we may need to add more nodes to the path we use. * By adding more nodes to the path we use, we increase the number of nodes that know our payment, increasing our chances of informing some surveillor.
Extended Shadow Routing -----------------------
Another apropos observation is that having more nodes on a path reduces the reliability of payments along the path. Every node on that path is a possible failure point in forwarding.
Worse, paths that are longer in terms of hops are more likely to have the below failure mode:
* A forwarding node is able to accept and irrevocably forward an HTLC. * Before the outgoing HTLC can be claimed offchain, the forwarding node shuts down. * The payment is now "stuck" until the incoming HTLC of the node reaches timeout.
Basically, if a forwarding node fails between the time it forwards the HTLC and the time the next node is able to claim it, payments get stuck for durations that can be counted in entire blocks. As path length increases, this failure mode becomes more likely:
* There are more possible nodes to fail. * The time between when a node is able to forward and the next node is able to claim becomes longer, making it more likely that an individual node fails during this time.
Of course, taking the shortest path in terms of node hops is precisely what reverse routing tables can break. This is the core of the observation that privacy and usability are apparently at odds with one another.
Reverse routing tables cannot precisely identify the payer and payee. However, the timelock, as well as the time it takes for an HTLC to be forwarded and then claimed, can give hints as to the distance between the forwarding node and the payee. We cannot do anything about the sidereal time at which events occur, but we *can* do something about timelocks, i.e. shadow routing as already implemented in C-Lightning.
A secondary concern is that, after path decorrelation is implemented, the *delta* in value, timelock, and sidereal time between two cooperating surveilling nodes can be used to determine if two forwards on those nodes belong to the same overall payment. Shadow routing does not help this, since it only adds timelock and value tweaks to the *end* of the path, and any *delta* between two surveilling nodes remains the same.
Avoiding the shortest path has a chance that the sub-path between the two surveilling nodes is not the delta of the shortest path between them, which helps remove payment correlation in a post-decorrelation world. However, it does have the drawback that increasing the actual path length tends to increase the number of nodes along the path, reducing reliability.
By inserting shadow routes in the middle of the path instead of just the payee end, we can gain some of the above advantage of removing payment correlation in a post-decorrelation world, without having to incur the reduced reliability of actually increasing the number of hops along a path. This is only useful in a post-decorrelation world, as use of HTLCs means that two cooperating surveilling nodes can determine if two forwards between them belong to the same overall payment.
Inserting such shadow routes basically amounts to overpaying fees and giving more timelock slack to forwarding nodes.
Multipath Value Obfuscation ---------------------------
An observation we can have is that, the difference between a fixed known value and a random value will be indistinguishable from a random value. The same observation underlies adaptor signatures and payment decorrelation.
Thus, one way to obfuscate the unremovable data of the payment value is to always start with payments split into two subpayments.
* Take a random value from 1 to the total payment minus 1 and use it on one subpayment. * Take the difference between the total payment amount and the above random value and use it as the other subpayment.
Both numbers will look like random values, and only together can they be used to identify the actual value.
The value obfuscation only works to obfuscate the final payee value. Without "avoiding shortest path" or "extended shadow route", the value of the payment can still be used by two cooperating surveilling nodes to identify if two forwards belong to the same (sub)payment, even in a post-decorrelation world.
With HTLCs, two cooperating surveilling nodes that happen to be on separate subpayments can still identify the total payment and thereby have a guess on what is being bought.
Good morning list,
Quoted text (2 lines)
> Unpublished Channels Delenda Est > -----------------------------------
Further thoughts on this topic.
In blockchain layer, decentralization is not a value in and of itself. Instead, it is an instrumental goal, with the terminal values actually being Censorship Resistance and Monetary Policy Preservation. (i.e. the point of decentralizing is to prevent transactions from being labelled "illegal" and disallowed, and to prevent breaching of the pre-determined 21M limit)
Thus, we should consider as well that on the Lightning layer, decentralization is not a value in and of itself. Again, we should consider what terminal value is actually being supported if we target decentralization in the Lightning layer.
I would like to refer to the original Peter Todd hub-and-spoke model, where in a single server (hub) is used by multiple clients (spokes) to send offchain payments to one another. Obviously this has no privacy from the single server, as the single server now knows exactly who pays and is paid for all transactions (though xref. Chaumian techniques such as TumbleBit).
By allowing multiple hubs, we get a little more privacy, as a cross-hub payment requires that multiple hubs cooperate to identify the ultimate sender and ultimate receiver of the payment. Still, with unpublished channels connecting "hubs" to "spokes", this allows such cooperation to be done and to properly identify every sender and receiver of every payment that goes through the cooperating parties.
To further increase privacy we truly need to destroy the separation of "hub" and "spoke". To me, this is a form of decentralization, where there is no "server" and "client", but all nodes are equal peers.
Obviously not all nodes can be purely equal, as some nodes will have more liquidity available to them as an inherent part of the inequality of the universe. The point is not to eliminate all inequality, but to reduce it to the minimum feasible, in order to promote certain properties, in this case, the valued Privacy Preservation. Thus:
* We should encourage people to at least increase the number of channels they have to the network. Multipath helps with this. * We should discourage people from using completely unpublished channels, as this creates a (arguably not necessary) split between "hub" and "spoke".
Admittedly the goal may be too difficult in any case.
Regards, ZmnSCPxj
Hi ZmnSCPxj,
Just a nit to add for reference to this great writeup.
Quoted text (4 lines)
> - Add random tweaks to your channel traversal costs. > - This is done currently by the C-Lightning route randomization feature, but note that it is currently set to up to a +/-5% tweak. > - [This paper](https://arxiv.org/pdf/1909.06890) evaluates the C-Lightning route randomization as well. > It suggest adding random tweaks to the costs of entire routes instead, though it may not be easy for normal pathfinding algorithms to implement this.
Since the authors made this analysis, the total fuzzing has been replaced by a tweak of both the base and proportional fees, added along the CTLV during the shadow route random walk. https://github.com/ElementsProject/lightning/blob/8c387932c0095ffbe7314a73004337f5cc15ece0/plugins/pay.c#L827
Regards, Darosior
Good morning list,
Few people have responded to this topic, but when has that ever stopped me from spamming the mailinglist?
Analysis of Path Extension for Privacy ======================================
As mentioned before, increasing the path length deliberately, by any means, intuitively makes it seem that privacy is improved. I will now show how this is not a panacea and that its cost in terms of increased fees, increased risk of stuckness, and increased worst-case stuckness might not justify its benefits, which are weaker (at least on the current network) than they might seem at first glance.
Let us first start with an example network:
A -- B -- S1-- C -- D -- G -- H
| / / \ | / |
| / / \ | / |
I -- J E -- S2-- F
Let us suppose that `A` wishes to make a payment to `F`. Further, let us assume for simplicity that all nodes charge the same amount for forwarding, and that they all charge 0.01 units base and 0 proportional.
Finally, let us also assume that `S1` and `S2` are two nodes run by a single surveillor, and that all the other nodes are otherwise not interested in destroying Lightning privacy. Now, obviously `A` and `F` do not know that `S1` and `S2` are run run by a surveillor, thus cannot identify S1 and S2 as belonging to a single actor that wants to snoop their payment.
Now let us suppose that A takes the shortest path `A -> B -> S1 -> C -> E -> S2 -> F`. Would it be improved to artifically increase the path length?
We can observe that, with the current network, due to the same hash being used in the entire route, `S1` and `S2` can easily notice when they are on the same route.
Thus, suppose we increased the path length by taking this route instead: `A -> B -> S1 -> I -> J -> C -> D -> G -> E -> S2 -> F`. Then our surveillor gets exactly the same information as in the case `A -> B -> S1 -> C -> E -> S2 -> F`.
* An incoming payment went into S1 via B, so the payer must be A or B (taking the shortest-path heuristic pre-S1). * An outgoing payment went out of S2 via F, so the payer must be F (taking the shortest-path heuristic post-S2).
Thus, in many cases, it is immaterial if we actually inserted greater length onto the path. We can generally expect that surveillors can easily just buy a bunch of BTC and insert many nodes into the network to act as surveillance nodes, especially since forwarding pays fees and thus the requirement to lock funds in channels is not in fact an opportunity cost. Once a path passes through more than one surveillor nodes, any increase in length between the two endmost cooperating surveillor nodes does not improve privacy. Thus `A` would end up paying the costs of increased path length (higher fees, higher risk of stuckness, highest worst-case stuckness) *without* any benefit to its privacy.
Indeed, we might point out that if `A` took the path `A -> B -> S1 -> C -> D -> G -> H -> F`, then it would have avoided `S2` and the single surveillor would have a much larger set of possible destinations to analyze. But if it instead took the longer path `A -> B -> S1 -> I -> J -> C -> D -> G -> E -> S2 -> F`, then `S2` would have helped the surveillor pin down the destination that either A or B is paying to.
Which brings the next point: longer path also means increased chances of going through *two* surveillance nodes, and thus having the payment endpoints (ultimate sender, ultimate receiver) be identified by surveillor nodes. The increased path length also means less reliable forwarding (more nodes can fail), meaning it is now more likely that `A` will have to find another route. This increases the chances that `S1` and `S2` will be on *some* route. And because the same hash will *also* be used on the alternate routing attempts, then if on one attempt we went `A -> B -> S1 -> C -> D -> G -> H -> F` and on the next attempt we went `A -> I -> J -> C -> E -> S2 -> F`, then both `S1` and `S2` can still triangulate the ultimate payer and ultimate payee as with getting the shortest path in the first place!
The intuition that "sub-optimal paths means better privacy" is countered by the intuition that "the more people you tell, the less private it is". At least on the current network, the fact that we can identify a single payment (across multiple nodes within an attempt, and across multiple attempts trying to forward the same payment) means increased path length does not buy a lot of privacy, and the significant losses in useability might not be commensurate to the mild increase in privacy it *theoretically* could get.
Fortunately, the PTLC-based path decorrelation fixes most of these, and with that, at least it is hard for `S1` and `S2` to identify if forwards going through them are the same payment, at least from the payment hash.
Digression: `permuteroute` Privacy ----------------------------------
Previously, [I discussed the `permuteroute` algorithm](https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2019/improving-lightning-network-pathfinding-latency-by-path-splicing-and-other-real#m-fc0157b9), which is basically the Path Splicing technique applied to Lightning payments. TLDR: When a payment fails at a particular node or channel along a route, we copy the path prefix before the break, the path postfix after the break, and make a route around the break, getting better time behavior since it is likely that the area around the break has alternate routes that are still relatively short (Dijkstra algorithm in particular has a massive increase in runtime for every additional node on the shortest path, so if the shortest path is very short, the runtime for the Dijkstra run to bridge the break would be much faster than if we redid it from the source to the destination).
An advantage of `permuteroute` is also the fact that *you do not tell more people about your payment*. The prefix of path is reused rather than looking for a completely new path, and the nodes along that prefix *already* knows about the payment and its hash and its amount and its CLTV-delta, from the previous failing payment attempt. Telling them approximately the same details *again* in the next payment attempt is not an *additional* privacy leak at least. (in general a `permuteroute` will either increase or give the same path length as the previous attempted path, so the first attempt will give, via the unremovable data CLTV-delta and amount, the shortest distance from a surveillor node to the destination, and subsequent `permuteroute` attempts will tend to give a *longer* distance to the destination, which does not help the surveillor to *narrow down* the destination, thus does not increase privacy leaks to the nodes on the reused prefix.)
Thus, I expect that `permuteroute` will give, not only a good improvement in practical pathfinding speed, it would also give a mild practical improvement in privacy compared to using high-randomization pathfinding techniques like the Rusty Russell Random Route Ralgorithm for *every* payment attempt.
Privacy Non-Improvement Due To Practical Limits -----------------------------------------------
There is a practical limit to the number of nodes you can stuff onto an artificially lengthened path. Unfortunately, it means as well that privacy improvement at the destination end translates to privacy reduction at the source end.
For instance, it is likely that wallets would want to bound the outgoing CLTV-delta at the ultimate sender. If this CLTV-delta were, for instance, to be a year away from the current blockheight, then at the worst-case, in case of a stuck payment, the funds used in a stuck payment would be locked for a year in an HTLC. Thus, obviously wallets will be designed to impose some maximum CLTV-delta at the ultimate sender. For example, C-Lightning limits this, by default, to 576 blocks.
Knowing this limit, if an arbitrary forwarding node were, for instance, to note that the incoming HTLC had a CLTV that was 548 blocks in the future, then it can guess that the ultimate sender is a node within 28 CTLV-delta blocks away from it. Of course, such a large CLTV means that the outgoing HTLC probably has a similarly large CLTV relative to now, meaning that the destination is harder to find. But in effect, any improvement in making the destination harder to find comes with a decay in the privacy of the source.
As well, the amount can give a lesser degree of this, if the forwarding node can guess some standard amount is the final payment at the destination; C-Lightning imposes a default `maxfeepercent` limit of 0.5%.
This works with only analyzing CLTV-delta (and maybe amount, but that is much less reliable), from a single forwarding node, thus path decorrelation does *not* help with this (path decorrelation helps when multiple, but not all, forwarding nodes are controlled by a single surveillor). CLTV-delta and amount are unremoveable data and thus this analysis is always possible, so any improvement we can use to improve destination privacy is likely to come at the cost of the source privacy.
This may still be a good tradeoff: the onion protocol used makes identifying the source very difficult, whereas the destination is tightly constrained by the CLTV-delta that must be provided to every forwarding node, so sacrificing a little source privacy to get a little destination privacy may still be worth it, but it should as well be noted that payment information is much more valuable if information about *both* the payer *and* the payee is available.
Random Walk Loops -----------------
Increasing the path length using a naive form of Rusty Russell Random Route Ralgorithm may lead to loops being formed in the proposed path, e.g. `A - > B -> S1 -> C -> E -> G -> D -> E -> S2 -> F`. For the node `E`, which appears twice in that route, this is not much different from the case that it is running two separate nodes `S1` and `S2`: a node it controls appears more than once on the same route, thus leading to the ability to eliminate intermediate hops from consideration. That is, the "detour" through `G` and `D` becomes immaterial to the analysis that `E` can perform on the route. The end result is that we pay more for including `G` and `D`, but they do not increase our privacy against the node that happens to be the pivot on a loop.
Thus, we should use path length increasing algorithms that specifically avoid loops being formed. Of course, this can now be used as a basis for a heuristic by which a forwarding node can eliminate some nodes from its analysis by simply assuming that loops do not occur.
With path decorrelation, identifying loops becomes difficult and they will have much lower privacy loss.
Analysis of Multipath and JIT Routing for Privacy =================================================
Multipath gives an improvement to useability, allowing payments to be distributed across multiple paths rather than requiring that the entire payment be successfully routable as a single large payment.
I would point out as well that Just-In-Time Rebalancing, more commonly known as JIT Routing, gives you most of what multipath gives, but with much simpler software design. (Nothing prevents Just-In-Time rebalancing from being done by the ultimate payer, so as long as the payer has *some* channel that can hold the entire payment, it would be perfectly fine to initially have the ultimate payer with its funds distributed across multiple channels, which is another thing that people have been thinking would require multipath to solve: Just-in-time rebalance works with this as well.)
I will now demonstrate that JIT Routing gives better privacy than multipath, at least with the current network.
With multipath, every part of the payment has the same hash. Thus, suppose `A` splits a single payment into two parts, each taking paths `A -> B -> S1 -> C -> D -> G -> H -> F` and `A -> I -> J -> C -> E -> S2 -> F`. Again, this gives `S1` and `S2` the same tight information, that it is likely the ultimate sender is either `A` or `B` and the ultimate destination is `F`. `S1` and `S2` need only compare their CLTV-deltas (data that cannot be removed from the payment) to determine which one is likely to be nearer the source and which is likely to be nearer the destination, and thereby get better triangulation of both the ultimate sender and ultimate receiver.
In fact, it is worse than that. Multiple cooperating surveillors that find themselves on different parts of the same payment can use the unremovable CLTV-delta information to create a Venn diagram of the possible destinations, then consider that the destination is the intersection of those nodes that are within the outgoing CLTV-delta of each of them. (Similar information as well can be extracted from multiple attempts of a single payment.)
On the other hand, an important property of JIT Routing is that a rebalance attempt triggered by a payment has a different hash from the payment. Thus, the other nodes that would be involved in the JIT Routing are never given the important detail of the hash of the actual payment, thus preventing them from easily being correlated. Because there is only a single path for the "real" payment, we follow the principle "telling more people makes it less private": only the nodes specified by the ultimate payer in the payment onion are told of the *actual* payment details, all the other "supporting" nodes that facilitate the payment by allowing rebalances are not told about the payment details, they only get told about rebalances, which are much less interesting (it is literally just shuffling your own money around). In particular, they are *not* told the CLTV-delta of the "main" payment path, which is the largest single-node privacy leak in Lightning (for multi-node surveillors, the hash is an even bigger privacy leak).
Of course, path decorrelation helps reduce the issues that multipath has. CLTV-deltas are still an issue under multipath though, and the fact that rebalances triggered by a payment do not leak the actual CLTV-deltas of the original payment is still an important advantage that JIT Routing has over even decorrelated multipath.
Analysis of Path Decerrelation for Privacy ==========================================
As noted above, path decorrelation mitigates privacy issues with both artificially-lengthened paths, and multipath.
Of note is that these only close privacy leaks regarding hashes. CLTV-delta in particular is still not fixed by path decorrelation.
However, path decorrelation does enable some important possible techniques.
Extended Shadow Routing -----------------------
As noted before, artificially increasing the path length makes it harder for forwarding nodes to use the shortest-path heuristic to determine te ultimate payer and ultimate payee of a payment attempt. Increasing the path length tends to increase the number of hop nodes that are traversed, increasing costs, risk of stuck payments, and lock time of stuck payments.
We can observe in particular that when considering stuckness, every additional hop node affects our useability twice:
* Every additional hop node is another hop node that could fail between forwarding and claiming. * Every additional hop node demands additional CLTV-delta for that hop, increasing the total amount of time we will offer on the first outgoing HTLC.
Thus, very long routes tend to greatly reduce useability.
A way to mitigate this would be to use "extended shadow routing", where instead of *actually* taking a longer path, we *pretend* to take a longer path and overpay some forwarding nodes with more fees and CLTV-delta than they demand.
For example, as noted above, the shortest path from `A` to `F` is `A -> B -> S1 -> C -> E -> S2 -> F`. Or more precisely, if `A` has to pay 1.0 unit to `F`, and all hop nodes have a 0.01 base fee and 0 proportional fee, the route is: `A ->1.05-> B ->1.04-> S1 ->1.03-> C ->1.02-> E ->1.01-> S2 ->1.00-> F`. (I have elided the CLTV-delta requirements, but I am sure you can imagine the CLTV-delta requirements from this; indeed, CLTV-delta is a much better way to break privacy than the amount, so consider the example as a proxy for CLTV-delta being used to analyze the path.)
With path decorrelation, `S1` and `S2` can no longer rely on a single hash along the entire route. Even so, they could still determine the shortest path between them, and thereby know the expected difference in amount and CLTV-delta from the outgoing of `S1` to the incoming of `S2`.
Quoted text (1 line)
>From this, they can determine with high probability that forwards of similar value and sidereal timing are actually belonging to the same single payment.
Now suppose instead `A` took the sub-optimal path `A ->1.07-> B ->1.06-> S1 ->1.05-> C ->1.04-> D ->1.03-> G ->1.02-> E ->1.01-> S2 ->1.00-> F`. Now `S1` and `S2` can no longer use the shortest path between them to determine that this is a single payment --- the outgoing of `S1` minus the incoming of `S2` is no longer the cost of the direct path between them, so they cannot assign high probability that the two forwards they see are hops of the same payment. But for `A`, this comes at the cost of higher fees, higher CLTV-delta, and higher risk of payment attempt failure --- now any failures at `D` and `G` will affect the payment experience.
To mitigate this, instead `A` can take this sub-optimal path that has fewer nodes but overpays the fees and CLTV-delta of `C`: `A ->1.07-> B ->1.06-> S1 ->1.05-> C ->1.02-> E ->1.01-> S2 ->1.00-> F`. This is extended shadow routing, where not only do we overpay at the destination, we also randomly overpay intermediate hops. We still use the shortest path in terms of hops, but the random overpaying we do at intermediate hops makes it harder for other intermediate hops to determine if the forwards belong to the same payment or not.
(Again, just to be clear: we also adjust the CLTV-delta correspondingly to overpay the CLTV-delta demanded by `C`.)
Standardized Multipart Splitting Amounts ----------------------------------------
Of course, if the only payment going around with an amount of 1.0 units is the payment between `A` and `F`, and all the other payments do not, it is still possible, even with path decorrelation, for `S1` and `S2` to correlate the forwards by looking at the payment amounts.
Fortunately, if we are able to fix the triangulation issues with multipath by implementing path decorrelation, we can subsequently use multipath to fix the amount-correlation issue. (Nothing to be done about the CLTV-delta, though...) This is done by specifying a set of standardized payment amounts, and forcing our algorithms to split with those amounts always, possibly overpaying the destination a little just to hide all the payment amounts of a multipath to standardized payment amounts.
For example, suppose we define standardized payment amounts 16, 8, 4, 2, 1, 0.5, 0.25, 0.125, 0.0625. If we want to pay 1.3 units, we could split our payment into 1, 0.25, and 0.0625, leading to a total of 1.3125 units, for a 0.96% overpayment.
The advantage of this is that it strengthens increasing the path length (whether for real, or by "extended shadow routing" which just artificially increases the path length by overpaying intermediate hops). As noted before, if the only payment going around with 1.0 units is that between `A` and `F`, then `S1` and `S2` can increase the probability they assign that the two forwards they see belong to the same payment, even if we increased the path length between them so they can no longer use the shortest-path heuristic. But if we use standardized payment amounts, and 1.0 is one of the standard amounts, then `S1` and `S2` cannot be certain that the two forwards they individually see are the same payment --- they could be two unrelated standard-amount payments instead. This reduces amount-based correlation.
In particular, with path decorrelation, multiple attempts of a part are now also harder to correlate --- it could be that those are unrelated attempts from a different payment.
Of course, this topic is likely to lead to a lot of debate. For instance, powers of two might not be the best (maybe a Fibonacci sequence would be better to minimize overpayment, in much the same way they reduce unused space in `malloc` implementations), multipart receivers might not want to receive a multipart payment composed of payments below the dust threshold (because if they have to drop onchain, they may end up getting multiple incoming parts worth zilch each), more standard payment amounts just split the anonymity set (and what number of standard payment amounts is optimal?) and so on. Since the benefit of standardized multipart splitting amounts lies in there *being* a standard, I suggest we instead just vote on *whether or not* to define such a standardized set of amounts, and if we do decide to go with this, just hold a lottery on who exactly will define the standardized amounts. (instead replacing the long debates on what standardized payment amounts to use with long debates on how to do a trustless online-only lottery)
No matter what set of standardized amounts we define, it seems to me that there will be payments so small that splitting them up would be unnecessarily uneconomical, or the payment amount might be smaller than the smallest standardized amount. We might accept the loss of privacy in those if we consider them to be small and not of much interest.
Amount Decorrelation By Self-Payment ------------------------------------
We already know that we can perform donations by using a self-payment, hiding the donation in the fee of the node we wish to pay.
With PTLCs, which are a requirement of path decorrelation anyway, we can increase the security of such circular payments (they can no longer be stolen by wormhole attacks), and also have a proof-of-payment arrive from the payee (by using the sum of the payee secret plus a secret known by the payer at the payee hop). This also implements a form of stuckless payments.
If we use two standardized sets of payments with a small difference between them, it becomes possible as well to pay smaller amounts by paying using the *difference* between two standard payment amounts. As well, the return path ends up misleading successful analysis, as it *inverts* the direction of who is the *actual* payer and who is the *actual* payee. This could be used to mislead analysis by using a standard amount in the forward section of the path and then use a non-standard amount in the return path, allowing payment of tiny amounts that are impractical given the standard set, but misleading the *actual* amount and who is the *actual* payer and *actual* payee.
As a concrete example, suppose `A` wants to pay `I` a tiny 0.1 units, and does not care that the fees it ends up paying may be a significant fraction of that micropayment. It could do: `A ->8.01-> B ->8.0-> I ->7.9-> S1 ->7.89-> B ->7.88-> A`. `A` ends up paying 8.01 - 7.88 = 0.13, so it paid 0.1 to `I` and 0.03 in fees. `S1` might end up being able to analyze the non-standard amount of `7.9-> S1 ->7.89` and determine that `I` pays `A` about 7.88 units, when in fact the actual payment is `A` paying `I` 0.1 units.
Against this technique, we should also remind of the principle "telling more people makes it less private", however. As well, this increases the number of hop nodes that could fail the payment, meaning more payment attempts (and thus more people getting told of the payment). More analysis on the use of circular payments when paying may be in order.
In any case, this would require explicit support in the BOLT spec as well, as we would need invoices to be payable with a direct payment, and with an indirect circular payment as well.
Regards, ZmnSCPxj