<oembed><type>rich</type><version>1.0</version><title>Anthony Towns [ARCHIVE] wrote</title><author_name>Anthony Towns [ARCHIVE] (npub17r…x9l2h)</author_name><author_url>https://yabu.me/npub17rld56k4365lfphyd8u8kwuejey5xcazdxptserx03wc4jc9g24stx9l2h</author_url><provider_name>njump</provider_name><provider_url>https://yabu.me</provider_url><html>📅 Original date posted:2019-11-07&#xA;📝 Original message:&#xA;On Thu, Nov 07, 2019 at 02:56:51PM +1030, Rusty Russell wrote:&#xA;&gt; &gt; What you wrote to Zmn says &#34;Rusty decrypts the onion, reads the prepay&#xA;&gt; &gt; field: it says 14, LLLL.&#34; but Alice doesn&#39;t know anything other than&#xA;&gt; &gt; ZZZZ so can&#39;t put LLLL in the onion?&#xA;&gt; Alice created the onion.  Alice knows all the preimages, since she&#xA;&gt; created the chain AAAAA....ZZZZZ.&#xA;&#xA;In your reply to Zmn, it was Rusty (Bob) preparing the nonce and creating&#xA;the chain AAAA...ZZZZ -- so I was lost as to what you were proposing...&#xA;&#xA;Here&#39;s what I now think you&#39;re saying, which I think mostly hangs&#xA;together:&#xA;&#xA;Alice sends a HTLC with hash X and value V to Dave via Bob then Carol&#xA;&#xA;Alice generates a nonce AAAA, and calculates H^25(AAAA) = ZZZZ.&#xA;&#xA;Alice creates an onion, and sends the HTLC to Bob, revealing ZZZZ and&#xA;6,TTTT to Bob, along with 2500 msat (25 for the hashing ops between&#xA;AAAA and ZZZZ, and *100 for round numbers). Bob calculates &#34;6&#34; is a&#xA;fair price.&#xA;&#xA;Bob checks H^6(TTTT)=ZZZZ. If not, Bob refunds the 2500 msat, and fails&#xA;the HTLC immediately. Otherwise, Bob passes the onion on to Carol, with&#xA;1900 msat and TTTT; Carol unwraps the onion revealing 15,EEEE. Carol&#xA;calcualtes &#34;15&#34; is a fair price.&#xA;&#xA;Carol checks H^15(EEEE)=TTTT, and fails the route if not, refunding&#xA;1900msat to Bob. Otherwise, Carol passes the onion on to Dave, with 400&#xA;msat and EEEE.  Dave unwraps the onion, revealing 2,CCCC, so can claim&#xA;200 msat as well as the HTLC amount, etc.&#xA;&#xA;After the successful route, Dave passes 2,CCCC and 200msat back to Carol,&#xA;who validates and continues passing things back.&#xA;&#xA;If Carol instead passes, say, 3,CCCC back, then she also has to refund&#xA;300msat to avoid Bob closing the channel, which would be fine, because&#xA;Bob can just pass that back too -- Carol&#39;s the only one losing money in&#xA;that case.&#xA;&#xA;If Carol wants to close the channel anyway and collect the HTLC on&#xA;chain, then Bob&#39;s situation is:&#xA;&#xA;   channel with Alice: +2500 msat&#xA;   channel with Carol: -1900 msat , -fees , -HTLC funds&#xA;&#xA;If Carol isn&#39;t cooperative, Bob only definitely knows TTTT, so to keep&#xA;the channel open with Alice, has to refund 1900msat, so:&#xA;&#xA;   channel with Alice:  +600 msat , +HTLC funds&#xA;   channel with Carol: -1900 msat , -fees , -HTLC funds&#xA;&#xA;(or Bob could keep the 2500 msat at the cost of Alice closing the channel&#xA;too:&#xA;&#xA;   channel with Alice: +2500 msat , -fees , +HTLC funds&#xA;   channel with Carol: -1900 msat , -fees , -HTLC funds&#xA;)&#xA;&#xA;So Bob and either keep the channel open but is out 1300 msat because of&#xA;Carol, or can gain 600 msat at the cost of closing the channel with&#xA;Alice?&#xA;&#xA;As far as the &#34;fair price&#34; goes, the spitballed formula is &#34;16 - X/4&#34;&#xA;where X is number of zero bits in some PoW-y thing. The proposal is&#xA;the thing is SHA256(blockhash|revealedonion) which works, and (I think)&#xA;means each step is individually grindable.&#xA;&#xA;I think an alternative would be to use the prepayment hashes themselves,&#xA;so you generate the nonce AAAA as the value you&#39;ll send to Dave then&#xA;hash it repeatedly to get BBBB..QQQQ, then check if pow(AAAA,BBBB) has&#xA;60 leading zero bits or pow(AAAA,CCCC) has 56 leading zero bits etc.&#xA;If you made pow(a,b) be SHA256(a,b,shared-onion-key) I think it&#39;d&#xA;preserve privacy, but also mean you can&#39;t meaningfully grind unfairly&#xA;cheap routing except for very short paths?&#xA;&#xA;If you don&#39;t grind and just go by luck, the average number of hashes&#xA;per hop is ~15.93 (if I got my maths right), so you should be able to&#xA;estimate path length pretty accurate by dividing claimed prepaid funds by&#xA;15.93*25msat or whatever. If everyone grinds at each level independently,&#xA;I think you&#39;d just subtract maybe 6 hops from that, but the maths would&#xA;mostly stay the same?&#xA;&#xA;Though I think you could obfusticate that pretty well by moving&#xA;some of the value from the HTLC into the prepayment -- you&#39;d risk losing&#xA;that extra value if the payment made it all the way to the recipient but&#xA;they declined the HTLC that way though.&#xA;&#xA;&gt; &gt;&gt; Does Alice lose everything on any routing failure?&#xA;&gt; &gt; That was my thought yeah; it seems weird to pay upfront but expect a&#xA;&gt; &gt; refund on failure -- the HTLC funds are already committed upfront and&#xA;&gt; &gt; refunded on failure.&#xA;&gt; AFAICT you have to overpay, since anything else is very revealing of&#xA;&gt; path length.  Which kind of implies a refund, I think.&#xA;&#xA;I guess you&#39;d want to pay for a path length of about 20 whether the&#xA;path is actually 17, 2, 10 or 5. But a path length of 20 is just paying&#xA;for bandwidth for maybe 200kB of total traffic which at $1/GB is 2% of&#xA;1 cent, which doesn&#39;t seem that worth refunding (except for really tiny&#xA;micropayments, where paying for payment bandwidth might not be feasible&#xA;at all).&#xA;&#xA;If you&#39;re buying a $2 coffee and paying 500ppm in regular fees per hop&#xA;with 5 hops, then each routing attempt increases your fees by 4%, which&#xA;seems pretty easy to ignore to me.&#xA;&#xA;Cheers,&#xA;aj</html></oembed>