<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-12-17&#xA;📝 Original message:&#xA;On Sun, Dec 15, 2019 at 03:43:07PM +0000, ZmnSCPxj via Lightning-dev wrote:&#xA;&gt; For now, I am assuming the continued use of the existing Poon-Dryja update mechanism.&#xA;&gt; Decker-Russell-Osuntokun requires `SIGHASH_NOINPUT`/`SIGHASH_ANYPREVOUT`, and its details seem less settled for now than taproot details.&#xA;&#xA;Supporting PTLCs instead of HTLCs is a global upgrade in that you need&#xA;all nodes along your payment path to support it; moving from Poon-Dryja&#xA;to Decker-Russell-Osuntokun is only relevant to individual peers. So I&#xA;think it makes sense to do PTLCs first if the required features aren&#39;t&#xA;both enabled at the same time.&#xA;&#xA;&gt; Poon-Dryja with Schnorr&#xA;&gt; -----------------------&#xA;&#xA;I think MuSig between the two pairs is always superior to a NUMS point&#xA;for the taproot internal key; you definitely want to calculate a point&#xA;rather than use a constant, or you&#39;re giving away that it&#39;s lightning,&#xA;and if you&#39;re calculating you might as well calculate something that can&#xA;be used for a cooperative key path spend if you ever want to.&#xA;&#xA;&gt; A potential issue with MuSig is the increased number of communication rounds needed to generate signatures.&#xA;&#xA;I think you can reduce this via an alternative script path. In&#xA;particular, if you want a script that the other guy can spend if they&#xA;reveal the discrete log of point X, with musig you do:&#xA;&#xA;   P = H(H(A,B),1)*A + H(H(A,B),2)*B&#xA;   [exchange H(RA),H(RB),RA,RB]&#xA;&#xA;   [send X]&#xA;&#xA;   sb = rb + H(RA+RB+X,P,m)*H(H(A,B),2)*b&#xA;&#xA;   [wait for sb]&#xA;&#xA;   sa = ra + H(RA+RB+X,P,m)*H(H(A,B),1)*a&#xA;&#xA;   [store RA+RB+X, sa+sb, supply sa, watch for sig]&#xA;&#xA;   sig = (RA+RB+X, sa+sb+x)&#xA;&#xA;So the 1.5 round trips are &#34;I want to do a PTLC for X&#34;, &#34;okay here&#39;s&#xA;sb&#34;, &#34;great, here&#39;s sa&#34;.&#xA;&#xA;But with taproot you can have a script path as well, so you could have a&#xA;script:&#xA;&#xA;   A CHECKSIGVERIFY B CHECKSIG&#xA;&#xA;and supply a partial signature:&#xA;&#xA;   R+X,s,X where s = r + H(R+X,A,m)*a&#xA;&#xA;to allow them to satisfy &#34;A CHECKSIGVERIFY&#34; if they know the discrete&#xA;log of X, and of course they can sign with B at any time. This is only&#xA;half a round trip, and can be done at the same time as sending the &#34;I&#xA;want to do a PTLC for X&#34; message to setup the (ultimately cheaper) MuSig&#xA;spend. It&#39;s an extra signature on the sender&#39;s side and an extra verification &#xA;on the receiver&#39;s side, but I think it works out fine.&#xA;&#xA;&gt; Pointlocked Timelocked Contracts&#xA;&gt; --------------------------------&#xA;&gt; First, I will discuss how to create a certain kind of PTLCs, which I call &#34;purely scriptless&#34; PTLCs.&#xA;&gt; In particular, I would like to point out that we *actually* use in current Poon-Dryja Lightning Network channels is *revocable* HTLCs, thus we need to have *revocable* PTLCs to replace them.&#xA;&gt; * First, we must have a sender A, who is buying a secret scalar, and knows the point equivalent to that scalar.&#xA;&gt; * Second, we have a receiver B, who knows this secret scalar (or can somehow learn this secret scalar).&#xA;&gt; * A and B agree on the specifications of the PTLC: the point, the future absolute timelock, the value.&#xA;&gt; * A creates (but *does not* sign or broadcast) a transaction that pays to a MuSig of A and B and shares the txid and output number with the relevant MuSig output.&#xA;&gt; * A and B create a backout transaction.&#xA;&gt;   * This backout has an `nLockTime` equal to the agreed absolute timelock.&#xA;&gt;   * It spends the above MuSig output (this input must enable `nLockTime`, e.g. by setting `nSequence` to `0xFFFFFFFE`).&#xA;&gt;   * It creates an output that is solely controlled by A.&#xA;&gt; * A and B perform a MuSig ritual to sign the backout transaction.&#xA;&gt; * A now signs and broadcast the first transaction, the one that has an output that represents the PTLC.&#xA;&gt; * A and B wait for the above transaction to confirm deeply.&#xA;&gt;   This completes the setup phase for the PTLC.&#xA;&gt; * After this point, if the agreed-upon locktime is reached, A broadcasts the backout transaction and aborts the ritual.&#xA;&gt; * A and B create a claim transaction.&#xA;&gt;   * This has an `nLockTime` of 0, or a present or past blockheight, or disabled `nLockTime`.&#xA;&gt;   * This spends the above MuSig output.&#xA;&gt;   * This creates an output that is solely controlled by B.&#xA;&gt; * A and B generate an adaptor signature for the claim transaction, which reveals the agreed scalar.&#xA;&gt;   * This is almost entirely a MuSig ritual, except at `s` exchange, B provides `t + r + h(R | MuSig(A,B) | m) * MuSigTweak(A, B, B) * b` first, then demands `r + h(R | MuSig(A,B) | m) * MuSigTweak(A, B, A) * a` from A, then reveals `r + h(R | MuSig(A,B) | m) * MuSigTweak(A, B, B) * b` (or the completed signature, by publishing onchain), revealing the secret scalar `t` to A.&#xA;&gt; * A is able to learn the secret scalar from the above adaptor signature followed by the full signature, completing the ritual.&#xA;&#xA;(I think it makes more sense to provide &#34;r + H(R+T, P, m)*b&#34; instead of&#xA;&#34;r+t + H(R,P,m)*b&#34; -- you might not know &#34;t&#34; at the point you need to&#xA;start the signature exchange)&#xA;&#xA;I think the setup can be similar to BOLT-3:&#xA;&#xA;  Funding TX output:  MuSig(A,B)&#xA;&#xA;  Commitment Tx Held by A:&#xA;    - locktime: obscured commitment number&#xA;    - input: funding tx&#xA;    - outputs:&#xA;        balance A&#xA;&#x9;balance B&#xA;&#x9;PTLC paying to A&#xA;&#x9;PTLC paying to B&#xA;        [etc]&#xA;&#xA;balance B can pay directly to B&#xA;&#xA;balance A pays to MuSig(Rn,B) -- where Rn is the revocation key for the&#xA;nth commitment, and A holds a presigned tx by B with relative locktime&#xA;set, paying the funds to A.&#xA;&#xA;PTLCs also pay to MuSig(Rn,B) -- &#xA;&#xA;for the one paying to A, A holds a tx&#xA;partially presigned by B that needs the point&#39;s discrete log added to x&#xA;with relative timelock; for the one paying to B, A holds a presigned tx&#xA;by B that has absolute locktime set and pays to MuSig(Rn,B) for which&#xA;A has another presigned tx by B that has relative locktime set.&#xA;&#xA;HTLC&#39;s also pay to MuSig(Rn,B) but they&#39;re tweaked by a script -- if&#xA;they&#39;re paying to B, A just holds the same timelocked presigned tx&#39;s as&#xA;for PTLCs; if they&#39;re paying to A, A will use a &#34;HASH160 X EQUALVERIFY&#xA;A CHECKSIGVERIFY delay CSV&#34; script path instead.&#xA;&#xA;B has a similar commitment Tx; and A holds pre-signed tx&#39;s for the&#xA;PTLC&#39;s there, except without the relative timelock txs.&#xA;&#xA;This adds up to B needing to provide A with signatures for:&#xA;&#xA;  the funding tx&#xA;  A&#39;s balance&#xA;  each PTLC/HTLC paying/refunding to A from A&#39;s commitment and the sub tx for each of those&#xA;  each PTLC/HTLC paying/refunding to B from B&#39;s commitment&#xA;&#xA;and each of those signatures need to be updated every commitment update.&#xA;&#xA;Note that you need to receive all the partial signatures to spend the&#xA;commitment tx before you provide your partial signature over the funding&#xA;tx to authorise the commitment tx. So yet more rounds of communication.&#xA;&#xA;I think this approach would let you upgrade existing channels to support&#xA;PTLCs without closing/reopening, though.&#xA;&#xA;&#xA;&#xA;I think you could do something eltoo-ish to simplify watchtowers:&#xA;&#xA;    Funding TX output: MuSig(A,B)&#xA;&#xA;    Commitment Tx Held by A:&#xA;      - locktime: obscured commitment number&#xA;      - inputs: funding tx&#xA;      - outputs: MuSig(Rn,B)&#xA;&#xA;    Settlement Tx Held by A:&#xA;      - nsequence: to_self_delay&#xA;      - input: commitment tx held by A&#xA;      - outputs:&#xA;         balance A&#xA;&#x9; balance B&#xA;&#x9; PTLC paying to A&#xA;&#x9; PTLC paying to B&#xA;&#xA;    Secondary Settlement Tx Held by B:&#xA;      - no abs/relative locktime&#xA;      - input: commitment tx held by A&#xA;      - outputs:&#xA;         balance A&#xA;&#x9; balance B&#xA;&#x9; PTLC paying to A&#xA;&#x9; PTLC paying to B&#xA;&#xA;in which case once the commitment is revoked, B only needs to do a single&#xA;signature of MuSig(Rn,B) to claim all the funds if A publishes the&#xA;old commitment, without having to worry about any HTLC/PTLC info? The&#xA;settlement tx can be a bit simplified I think too. Maybe the edge case&#xA;when the absolute locktime is close to the relative locktime makes this&#xA;painful, though I think it would make eltoo painful then too? Not sure&#xA;if I&#39;m missing something here. &#xA;&#xA;(Note that this gives symmetric delays: if A unilaterally closes the&#xA;channel by publishing the commitment tx, and B wants their funds, B can&#xA;either immediately claim all the funds via the revocation secret if A&#xA;was cheating, or has to publish the settlement tx first, at which point&#xA;A can get all A&#39;s funds immediately as well)&#xA;&#xA;&gt; Revocable Outputs and PTLCs&#xA;&gt; ---------------------------&#xA;&gt; * No wallet uses relative-timelock for ordinary spends, unlike abolute-locktime where Bitcoin Core always uses absolute-locktime `nLockTime` for ordinary spends.&#xA;&#xA;I think the fact lightning relative timelocks will be &#34;round&#34; numbers,&#xA;and the timelocked tx will be published as soon as possible will make&#xA;it relatively easy to distinguish them from other spends anyway. Doing&#xA;it scriptlessly is cheaper on chain though.&#xA;&#xA;Anyway, my picks are:&#xA;&#xA; - [x] Poon-Dryja PTLCs prior to eltoo&#xA; - [x] scriptless revocation via MuSig(Rn,B) internal keys&#xA; - [x] support HTLCs via taproot&#xA; - [x] (optionally) allow use of script paths to minimise round trip&#xA;       delay&#xA;&#xA;Cheers,&#xA;aj</html></oembed>