<oembed><type>rich</type><version>1.0</version><author_name>npub1e46n428mcyfwznl7nlsf6d3s7rhlwm9x3cmkuqzt3emmdpadmkaqqjxmcu</author_name><author_url>https://nostr.ae/npub1e46n428mcyfwznl7nlsf6d3s7rhlwm9x3cmkuqzt3emmdpadmkaqqjxmcu</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2020-04-22&#xA;📝 Original message:&#xA;On 4/22/20 7:27 PM, Olaoluwa Osuntokun wrote:&#xA;&gt; &#xA;&gt;&gt; Indeed, that is what I’m suggesting&#xA;&gt; &#xA;&gt; Gotcha, if this is indeed what you&#39;re suggesting (all HTLC spends are now&#xA;&gt; 2-of-2 multi-sig), then I think the modifications to the state machine I&#xA;&gt; sketched out in an earlier email are required. An exact construction which&#xA;&gt; achieves the requirements of &#34;you can&#39;t broadcast until you have a secret&#xA;&gt; which I can obtain from the htlc sig for your commitment transaction, and my&#xA;&gt; secret is revealed with another swap&#34;, appears to be an open problem, atm.&#xA;&#xA;Hmm, indeed, it does seem to require a change to the state machine, but I don&#39;t think a very interesting one. Because B&#xA;providing A an HTLC signature spending a commitment transaction B will broadcast does not allow A to actually broadcast&#xA;said HTLC transaction, B can be rather liberal with it. Indeed, however, it would require that B provide such a&#xA;signature before A can send the commitment_signed that exists today.&#xA;&#xA;&gt; Even if they&#39;re restricted in this fashion (must be a 1-in-1 out,&#xA;&gt; sighashall, fees are pre agreed upon), they can still spend that with a CPFP&#xA;&gt; (while still unconfirmed in the mempool) and create another heavy tree,&#xA;&gt; which puts us right back at the same bidding war scenario?&#xA;&#xA;Right, you&#39;d have to use anchor outputs just like we do on the commitment transaction :).&#xA;&#xA;&gt;&gt; There are a bunch of ways of doing pinning - just opting into RBF isn’t&#xA;&gt;&gt; even close to enough.&#xA;&gt; &#xA;&gt; Mhmm, there&#39;re other ways of doing pinning. But with anchors as is defined&#xA;&gt; in that spec PR, they&#39;re forced to spend with an RBF-replaceable&#xA;&gt; transaction, which means the party wishing to time things out can enter into&#xA;&gt; a bidding war. If the party trying to impeded things participates in this&#xA;&gt; progressive absolute fee increase, it&#39;s likely that the war terminates&#xA;&gt; with _one_ of them getting into the block, which seems to resolve&#xA;&gt; everything?&#xA;&#xA;No? Even if we assume there are no tricks that you can play with, eg, the package limits duri eviction, which I&#39;d be&#xA;surprised about, the &#34;absolute fee/feerate&#34; thing still screws you. The attacker here gets to hold something at the&#xA;bottom of the mempool and the poor honest party is going to have to pay an absurd (likely more than the HTLC value) fee&#xA;just to get it unstuck, whereas the attacker never would have had to pay said fee.&#xA;&#xA;&gt; -- Laolung&#xA;&gt; &#xA;&gt; &#xA;&gt; On Wed, Apr 22, 2020 at 4:20 PM Matt Corallo &lt;lf-lists at mattcorallo.com &lt;mailto:lf-lists at mattcorallo.com&gt;&gt; wrote:&#xA;&gt; &#xA;&gt; &#xA;&gt; &#xA;&gt;&gt;     On Apr 22, 2020, at 16:13, Olaoluwa Osuntokun &lt;laolu32 at gmail.com &lt;mailto:laolu32 at gmail.com&gt;&gt; wrote:&#xA;&gt;&gt;&#xA;&gt;&gt;     &gt; Hmm, maybe the proposal wasn&#39;t clear. The idea isn&#39;t to add signatures to&#xA;&gt;&gt;     &gt; braodcasted transactions, but instead to CPFP a maybe-broadcasted&#xA;&gt;&gt;     &gt; transaction by sending a transaction which spends it and seeing if it is&#xA;&gt;&gt;     &gt; accepted&#xA;&gt;&gt;&#xA;&gt;&gt;     Sorry I still don&#39;t follow. By &#34;we clearly need to go the other direction -&#xA;&gt;&gt;     all HTLC output spends need to be pre-signed.&#34;, you don&#39;t mean that the HTLC&#xA;&gt;&gt;     spends of the non-broadcaster also need to be an off-chain 2-of-2 multi-sig&#xA;&gt;&gt;     covenant? If the other party isn&#39;t restricted w.r.t _how_ they can spend the&#xA;&gt;&gt;     output (non-rbf&#39;d, ect), then I don&#39;t see how that addresses anything.&#xA;&gt; &#xA;&gt;     Indeed, that is what I’m suggesting. Anchor output and all. One thing we could think about is only turning it on&#xA;&gt;     over a certain threshold, and having a separate “only-kinda-enforceable-on-chain-HTLC-in-flight” limit.&#xA;&gt; &#xA;&gt;&gt;     Also see my mail elsewhere in the thread that the other party is actually&#xA;&gt;&gt;     forced to spend their HTLC output using an RBF-replaceable transaction. With&#xA;&gt;&gt;     that, I think we&#39;re all good here? In the end both sides have the ability to&#xA;&gt;&gt;     raise the fee rate of their spending transactions with the highest winning.&#xA;&gt;&gt;     As long as one of them confirms within the CLTV-delta, then everyone is&#xA;&gt;&gt;     made whole.&#xA;&gt; &#xA;&gt;     It does seem like my cached recollection of RBF opt-in was incorrect but please re-read the intro email. There are a&#xA;&gt;     bunch of ways of doing pinning - just opting into RBF isn’t even close to enough.&#xA;&gt; &#xA;&gt;&gt;     [1]: https://github.com/bitcoin/bitcoin/pull/18191&#xA;&gt;&gt;&#xA;&gt;&gt;&#xA;&gt;&gt;     On Wed, Apr 22, 2020 at 9:50 AM Matt Corallo &lt;lf-lists at mattcorallo.com &lt;mailto:lf-lists at mattcorallo.com&gt;&gt; wrote:&#xA;&gt;&gt;&#xA;&gt;&gt;         A few replies inline.&#xA;&gt;&gt;&#xA;&gt;&gt;         On 4/22/20 12:13 AM, Olaoluwa Osuntokun wrote:&#xA;&gt;&gt;         &gt; Hi Matt,&#xA;&gt;&gt;         &gt;&#xA;&gt;&gt;         &gt;&#xA;&gt;&gt;         &gt;&gt; While this is somewhat unintuitive, there are any number of good anti-DoS&#xA;&gt;&gt;         &gt;&gt; reasons for this, eg:&#xA;&gt;&gt;         &gt;&#xA;&gt;&gt;         &gt; None of these really strikes me as &#34;good&#34; reasons for this limitation, which&#xA;&gt;&gt;         &gt; is at the root of this issue, and will also plague any more complex Bitcoin&#xA;&gt;&gt;         &gt; contracts which rely on nested trees of transaction to confirm (CTV, Duplex,&#xA;&gt;&gt;         &gt; channel factories, etc). Regarding the various (seemingly arbitrary) package&#xA;&gt;&gt;         &gt; limits it&#39;s likely the case that any issues w.r.t computational complexity&#xA;&gt;&gt;         &gt; that may arise when trying to calculate evictions can be ameliorated with&#xA;&gt;&gt;         &gt; better choice of internal data structures.&#xA;&gt;&gt;         &gt;&#xA;&gt;&gt;         &gt; In the end, the simplest heuristic (accept the higher fee rate package) side&#xA;&gt;&gt;         &gt; steps all these issues and is also the most economically rationale from a&#xA;&gt;&gt;         &gt; miner&#39;s perspective. Why would one prefer a higher absolute fee package&#xA;&gt;&gt;         &gt; (which could be very large) over another package with a higher total _fee&#xA;&gt;&gt;         &gt; rate_?&#xA;&gt;&gt;&#xA;&gt;&gt;         This seems like a somewhat unnecessary drive-by insult of a project you don&#39;t contribute to, but feel free to&#xA;&gt;&gt;         start with&#xA;&gt;&gt;         a concrete suggestion here :).&#xA;&gt;&gt;&#xA;&gt;&gt;         &gt;&gt; You&#39;ll note that B would be just fine if they had a way to safely monitor the&#xA;&gt;&gt;         &gt;&gt; global mempool, and while this seems like a prudent mitigation for&#xA;&gt;&gt;         &gt;&gt; lightning implementations to deploy today, it is itself a quagmire of&#xA;&gt;&gt;         &gt;&gt; complexity&#xA;&gt;&gt;         &gt;&#xA;&gt;&gt;         &gt; Is it really all that complex? Assuming we&#39;re talking about just watching&#xA;&gt;&gt;         &gt; for a certain script template (the HTLC scipt) in the mempool to be able to&#xA;&gt;&gt;         &gt; pull a pre-image as soon as possible. Early versions of lnd used the mempool&#xA;&gt;&gt;         &gt; for commitment broadcast detection (which turned out to be a bad idea so we&#xA;&gt;&gt;         &gt; removed it), but at a glance I don&#39;t see why watching the mempool is so&#xA;&gt;&gt;         &gt; complex.&#xA;&gt;&gt;&#xA;&gt;&gt;         Because watching your own mempool is not guaranteed to work, and during upgrade cycles that include changes to the&#xA;&gt;&gt;         policy rules an attacker could exploit your upgraded/non-upgraded status to perform the same attack.&#xA;&gt;&gt;&#xA;&gt;&gt;         &gt;&gt; Further, this is a really obnoxious assumption to hoist onto lightning&#xA;&gt;&gt;         &gt;&gt; nodes - having an active full node with an in-sync mempool is a lot more&#xA;&gt;&gt;         &gt;&gt; CPU, bandwidth, and complexity than most lightning users were expecting to&#xA;&gt;&gt;         &gt;&gt; face.&#xA;&gt;&gt;         &gt;&#xA;&gt;&gt;         &gt; This would only be a requirement for Lightning nodes that seek to be a part&#xA;&gt;&gt;         &gt; of the public routing network with a desire to _forward_ HTLCs. This isn&#39;t&#xA;&gt;&gt;         &gt; doesn&#39;t affect laptops or mobile phones which likely mostly have private&#xA;&gt;&gt;         &gt; channels and don&#39;t participate in HTLC forwarding. I think it&#39;s pretty&#xA;&gt;&gt;         &gt; reasonable to expect a &#34;proper&#34; routing node on the network to be backed by&#xA;&gt;&gt;         &gt; a full-node. The bandwidth concern is valid, but we&#39;d need concrete numbers&#xA;&gt;&gt;         &gt; that compare the bandwidth over head of mempool awareness (assuming the&#xA;&gt;&gt;         &gt; latest and greatest mempool syncing) compared with the overhead of the&#xA;&gt;&gt;         &gt; channel update gossip and gossip queries over head which LN nodes face today&#xA;&gt;&gt;         &gt; as is to see how much worse off they really would be.&#xA;&gt;&gt;&#xA;&gt;&gt;         If mempool-watching were practical, maybe, though there are a number of folks who are talking about designing&#xA;&gt;&gt;         partially-offline local lightning hubs which would be rendered impractical.&#xA;&gt;&gt;&#xA;&gt;&gt;         &gt; As detailed a bit below, if nodes watch the mempool, then this class of&#xA;&gt;&gt;         &gt; attack assuming the anchor output format as described in the open&#xA;&gt;&gt;         &gt; lightning-rfc PR is mitigated. At a glance, watching the mempool seems like&#xA;&gt;&gt;         &gt; a far less involved process compared to modifying the state machine as its&#xA;&gt;&gt;         &gt; defined today. By watching the mempool and implementing the changes in&#xA;&gt;&gt;         &gt; #lightning-rfc/688, then this issue can be mitigated _today_. lnd 0.10&#xA;&gt;&gt;         &gt; doesn&#39;t yet watch the mempool (but does include anchors [1]), but unless I&#39;m&#xA;&gt;&gt;         &gt; missing something it should be pretty straight forward to add which mor or less&#xA;&gt;&gt;         &gt; resolves this issue all together.&#xA;&gt;&gt;         &gt;&#xA;&gt;&gt;         &gt;&gt; not fixing this issue seems to render the whole exercise somewhat useless&#xA;&gt;&gt;         &gt;&#xA;&gt;&gt;         &gt; Depends on if one considers watching the mempool a fix. But even with that a&#xA;&gt;&gt;         &gt; base version of anchors still resolves a number of issues including:&#xA;&gt;&gt;         &gt; eliminating the commitment fee guessing game, allowing users to pay less on&#xA;&gt;&gt;         &gt; force close, being able to coalesce 2nd level HTLC transactions with the&#xA;&gt;&gt;         &gt; same CLTV expiry, and actually being able to reliably enforce multi-hop HTLC&#xA;&gt;&gt;         &gt; resolution.&#xA;&gt;&gt;         &gt;&#xA;&gt;&gt;         &gt;&gt; Instead of making the HTLC output spending more free-form with&#xA;&gt;&gt;         &gt;&gt; SIGHASH_ANYONECAN_PAY|SIGHASH_SINGLE, we clearly need to go the other&#xA;&gt;&gt;         &gt;&gt; direction - all HTLC output spends need to be pre-signed.&#xA;&gt;&gt;         &gt;&#xA;&gt;&gt;         &gt; I&#39;m not sure this is actually immediately workable (need to think about it&#xA;&gt;&gt;         &gt; more). To see why, remember that the commit_sig message includes HTLC&#xA;&gt;&gt;         &gt; signatures for the _remote_ party&#39;s commitment transaction, so they can&#xA;&gt;&gt;         &gt; spend the HTLCs if they broadcast their version of the commitment (force&#xA;&gt;&gt;         &gt; close). If we don&#39;t somehow also _gain_ signatures (our new HTLC signatures)&#xA;&gt;&gt;         &gt; allowing us to spend HTLCs on _their_ version of the commitment, then if&#xA;&gt;&gt;         &gt; they broadcast that commitment (without revoking), then we&#39;re unable to&#xA;&gt;&gt;         &gt; redeem any of those HTLCs at all, possibly losing money.&#xA;&gt;&gt;&#xA;&gt;&gt;         Hmm, maybe the proposal wasn&#39;t clear. The idea isn&#39;t to add signatures to braodcasted transactions, but&#xA;&gt;&gt;         instead to CPFP&#xA;&gt;&gt;         a maybe-broadcasted transaction by sending a transaction which spends it and seeing if it is accepted. You&#xA;&gt;&gt;         only need to&#xA;&gt;&gt;         know the transaction&#39;s exact format (ie txid, which we do, since we sent a signature for it long ago) to do&#xA;&gt;&gt;         this, you&#xA;&gt;&gt;         don&#39;t have to actually *have* the fully-signed transaction (and you don&#39;t).&#xA;&gt;&gt;&#xA;&gt;&gt;         &gt; In an attempt to counteract this, we might say ok, the revoke message also&#xA;&gt;&gt;         &gt; now includes HTLC signatures for their new commitment allowing us to spend&#xA;&gt;&gt;         &gt; our HTLCs. This resolves things in a weaker security model, but doesn&#39;t&#xA;&gt;&gt;         &gt; address the issue generally, as after they receive the commit_sig, they can&#xA;&gt;&gt;         &gt; broadcast immediately, again leaving us without a way to redeem our HTLCs.&#xA;&gt;&gt;         &gt;&#xA;&gt;&gt;         &gt; I&#39;d need to think about it more, but it seems that following this path would&#xA;&gt;&gt;         &gt; require an overhaul in the channel state machine to make presenting a new&#xA;&gt;&gt;         &gt; commitment actually take at least _two phases_ (at least a full round trip).&#xA;&gt;&gt;         &gt; The first phase would tender the commitment, but render them unable to&#xA;&gt;&gt;         &gt; broadcast it. The second phase would then &lt;insert something something&#xA;&gt;&gt;         &gt; scriptless scripts here&gt; enter a new sub-protocol which upon conclusion,&#xA;&gt;&gt;         &gt; gives the commitment proposer valid HTLC signatures, and gives the responder&#xA;&gt;&gt;         &gt; what they need to be able to broadcast their commitment and claim their&#xA;&gt;&gt;         &gt; HTCLs in an atomic manner.&#xA;&gt;&gt;         &gt;&#xA;&gt;&gt;         &gt; -- Laolu&#xA;&gt;&gt;         &gt;&#xA;&gt;&gt;         &gt; [1]: https://github.com/lightningnetwork/lnd/pull/3821&#xA;&gt;&gt;</html></oembed>