<oembed><type>rich</type><version>1.0</version><title>Rusty Russell [ARCHIVE] wrote</title><author_name>Rusty Russell [ARCHIVE] (npub1zw…hkhpx)</author_name><author_url>https://yabu.me/npub1zw7cc8z78v6s3grujfvcv3ckpvg6kr0w7nz9yzvwyglyg0qu5sjsqhkhpx</author_url><provider_name>njump</provider_name><provider_url>https://yabu.me</provider_url><html>📅 Original date posted:2019-11-05&#xA;📝 Original message:&#xA;ZmnSCPxj &lt;ZmnSCPxj at protonmail.com&gt; writes:&#xA;&gt; Good morning Rusty,&#xA;&#xA;Hi ZmnSCPxj!&#xA;&#xA;&gt; Is this intended to be enforceable onchain if a channel is dropped onchain while a message is being routed?&#xA;&gt; By a vague sense of the description, it seems to me, it would require a complicated SCRIPT (or multiple tiny 50-msatoshi UTXOs) to enforce onchain.&#xA;&#xA;No, it&#39;s done as a simple subtraction from direct to-local and to-remote&#xA;payments.  Enforcement is by peer closing the channel, which you&#xA;wouldn&#39;t do over a few msat.&#xA;&#xA;&gt; Also, it is not exactly clear to me, the mechanism you are proposing in detail.&#xA;&gt; Can you give a motivating example, for example in a route from&#xA;&gt; ZmnSCPxj, through Rusty, to my imaginary friend YAIjbOJa (who is not&#xA;&gt; in fact me)?&#xA;&#xA;Sure: for simplicity I&#39;m sending a 0-value HTLC.&#xA;&#xA;ZmnSCPxj has balance 10000msat in channel with Rusty, who has 1000msat&#xA;in the channel with YAIjbOJa.&#xA;&#xA;Rusty prepares a nonce, AAAAA and hashes it 25 times = ZZZZZ.&#xA;&#xA;ZmnSCPxj prepares the onion, but adds extra fields (see below).  He then&#xA;sends the HTLC to Rusty, but also sends ZZZZZ, and 25x50 msat (ie. those&#xA;fields are in the update_add_htlc msg).  His balance with Rusty is now&#xA;8750msat (ie. 25x50 to Rusty).&#xA;&#xA;Rusty decrypts the onion, reads the prepay field: it says 14, LLLLL.&#xA;Rusty checks: the hash of the onion &amp; block (or something) does indeed&#xA;have the top 8 bits clear, so the cost is in fact 16 - 8/2 == 14.  He&#xA;then hashes LLLLL 14 times, and yes, it&#39;s ZZZZZ as ZmnSCPxj said it&#xA;should be.&#xA;&#xA;So Rusty takes the 14x50 as prepayment, and forwards the HTLC as&#xA;normal to YAIjbOJa, along with LLLLL and 11x50msat.  His balance with&#xA;YAIjbOJa is now 450msat.&#xA;&#xA;YAIjbOJa decrypts the onion.  And it says 10,BBBBB.  YAIjbOJa checks&#xA;that hashing BBBBB 10 times does indeed give LLLLL.  Now it takes the&#xA;11x50 msat, and fulfils the HTLC.  It replies to Rusty with 10,BBBBB&#xA;in the update_fulfill_htlc message, returning the (implicit) 1x50msat;&#xA;Rusty&#39;s balance with YAIjbOJa is now 500msat.&#xA;&#xA;Rusty checks that BBBBB hashed 10 times gives LLLLL.  Now it returns&#xA;24,BBBBB to ZmnSCPxj with the update_fulfill_htlc, demonstrating to&#xA;ZmnSCPxj that he&#39;s entitled to it, and (implicity) returning 1x50msat to&#xA;ZmnSCPxj, so their balance is now 8800msat.&#xA;&#xA;Now let&#39;s look at attacks:&#xA;&#xA;1. Rusty steals the funds and doesn&#39;t return them.  ZmnSCPxj closes&#xA;   channel, having lost 26x50msat.&#xA;&#xA;2, YAIjbOJa steals the funds and doesn&#39;t return them.  Rusty closes&#xA;   the channel, having lost 11x50msat.&#xA;&#xA;3. ZmnSCPxj doesn&#39;t put correct preimages in, or too few, or other&#xA;   malformation.  If it&#39;s Rusty&#39;s onion, he won&#39;t forward it and will&#xA;   give an error.  If it&#39;s YAIjbOJa who rejects it, Rusty returns all&#xA;   but the 14x50msat he has preimages for.&#xA;&#xA;Obviously Rusty needs some upper limit on how much he&#39;ll pay out, to&#xA;avoid infinite exposure (say limit the total exposure to 10,000 sats).&#xA;&#xA;A reasonable limit for each HTLC would be 20 hops x 16 x 50msat ==&#xA;16sat.  Even with no other limits, with 486 HTLCs in flight each way,&#xA;that&#39;s only 15456 satoshis.  You&#39;ll probably lament the channel closure&#xA;more.&#xA;&#xA;Hope that helps!&#xA;Rusty.&#xA;&#xA;&gt;&gt; Hi all,&#xA;&gt;&gt;&#xA;&gt;&gt; It&#39;s been widely known that we&#39;re going to have to have up-front&#xA;&gt;&gt; payments for msgs eventually, to avoid Type 2 spam (I think of Type 1&#xA;&gt;&gt; link-local, Type 2 though multiple nodes, and Type 3 liquidity-using&#xA;&gt;&gt; spam).&#xA;&gt;&gt;&#xA;&gt;&gt; Since both Offers and Joost&#39;s WhatSat are looking at sending&#xA;&gt;&gt; messages, it&#39;s time to float actual proposals. I&#39;ve been trying to come&#xA;&gt;&gt; up with something for several years now, so thought I&#39;d present the best&#xA;&gt;&gt; I&#39;ve got in the hope that others can improve on it.&#xA;&gt;&gt;&#xA;&gt;&gt; 1.  New feature bit, extended messages, etc.&#xA;&gt;&gt; 2.  Adding an HTLC causes a push of a number of msat on&#xA;&gt;&gt;     commitment_signed (new field), and a hash.&#xA;&gt;&gt;&#xA;&gt;&gt; 3.  Failing/succeeding an HTLC returns some of those msat, and a count&#xA;&gt;&gt;     and preimage (new fields).&#xA;&gt;&gt;&#xA;&gt;&gt;     How many msat can you take for forwarding? That depends on you&#xA;&gt;&gt;     presenting a series of preimages (which chain into a final hash given in&#xA;&gt;&gt;     the HTLC add), which you get by decoding the onion. You get to keep 50&#xA;&gt;&gt;     msat[1] per preimage you present[2].&#xA;&gt;&gt;&#xA;&gt;&gt;     So, how many preimages does the user have to give to have you forward&#xA;&gt;&gt;     the payment? That depends. The base rate is 16 preimages, but subtract&#xA;&gt;&gt;     one for each leading 4 zero bits of the SHA256(blockhash | hmac) of the&#xA;&gt;&gt;     onion. The blockhash is the hash of the block specified in the onion:&#xA;&gt;&gt;     reject if it&#39;s not in the last 3 blocks[3].&#xA;&gt;&gt;&#xA;&gt;&gt;     This simply adds some payment noise, while allowing a hashcash style&#xA;&gt;&gt;     tradeoff of sats for work.&#xA;&gt;&gt;&#xA;&gt;&gt;     The final node gets some variable number of preimages, which adds noise.&#xA;&gt;&gt;     It should take all and subtract from the minimum required invoice amount&#xA;&gt;&gt;     on success, or take some random number on failure.&#xA;&gt;&gt;&#xA;&gt;&gt;     This leaks some forward information, and makes an explicit tradeoff for&#xA;&gt;&gt;     the sender between amount spent and privacy, but it&#39;s the best I&#39;ve been&#xA;&gt;&gt;     able to come up with.&#xA;&gt;&gt;&#xA;&gt;&gt;     Thoughts?&#xA;&gt;&gt;     Rusty.&#xA;&gt;&gt;&#xA;&gt;&gt;     [1] If we assume $1 per GB, $10k per BTC and 64k messages, we get about&#xA;&gt;&gt;     655msat per message. Flat pricing for simplicity; we&#39;re trying to&#xA;&gt;&gt;     prevent spam, not create a spam market.&#xA;&gt;&gt;     [2] Actually, a number and a single preimage; you can check this is&#xA;&gt;&gt;     indeed the n&#39;th preimage.&#xA;&gt;&gt;     [3] This reduces incentive to grind the damn things in advance, though&#xA;&gt;&gt;     maybe that&#39;s dumb? We can also use a shorter hash (siphash?), or&#xA;&gt;&gt;     even truncated SHA256 (128 bits).&#xA;&gt;&gt;&#xA;&gt;&gt;&#xA;&gt;&gt; Lightning-dev mailing list&#xA;&gt;&gt; Lightning-dev at lists.linuxfoundation.org&#xA;&gt;&gt; https://lists.linuxfoundation.org/mailman/listinfo/lightning-dev</html></oembed>