<oembed><type>rich</type><version>1.0</version><title>Lloyd Fournier [ARCHIVE] wrote</title><author_name>Lloyd Fournier [ARCHIVE] (npub1kh…y05yp)</author_name><author_url>https://yabu.me/npub1khlhcuz0jrjwa0ayznq2q9agg4zvxfvx5x7jljrvwnpfzngrcf0q7y05yp</author_url><provider_name>njump</provider_name><provider_url>https://yabu.me</provider_url><html>📅 Original date posted:2020-12-11&#xA;📝 Original message:&#xA;Hi list,&#xA;&#xA;Currently, if your lightning node has data loss there are two ways of&#xA;recovering your funds once you have established which channels you had with&#xA;which peers:&#xA;&#xA;1. Wait until your peer closes the channel. The downside is that you have&#xA;no control over when this happens.&#xA;2. Connect to your peer and ask them to close it. The downside is that to a&#xA;malicious actor this request reads like &#34;now is a good time to steal my&#xA;money or extort me&#34;.&#xA;&#xA;What if instead we could somehow covertly get a signed cooperative&#xA;settlement transaction for the most recent state without your peer knowing&#xA;that you&#39;ve received it?&#xA;Luckily this mystical and almost incoherent requirement is provided by one&#xA;of the oldest and well developed cryptographic primitives: the so called&#xA;&#34;Oblivious Transfer&#34; (OT).&#xA;&#xA;https://en.wikipedia.org/wiki/Oblivious_transfer&#xA;&#xA;The idea might go something like this: every time you connect to your peer&#xA;they present you with an unsigned cooperative settlement transaction for&#xA;all channels you have with them. You and your peer then do an oblivious&#xA;transfer where they send you their signatures on the transaction or nothing&#xA;(whichever you choose). If you want to carry on with the channel you reveal&#xA;to the sender that you chose nothing. If you are recovering funds you&#xA;choose the signatures and broadcast the transaction.&#xA;&#xA;For this to be useful we have an extra requirement over typical OT which is&#xA;that we can verify the contents of the message we didn&#39;t choose. i.e. even&#xA;if we are not doing a recovery we have to be able to verify that the&#xA;signatures we were offered were valid (wihout actually ever being able to&#xA;use them!). Otherwise a malicious party could just be sending us invalid&#xA;signatures in the OT the whole time. The name for this oblivious signatures.&#xA;&#xA;## Constructing&#xA;&#xA;Oblivious signatures can be created using any verifiable encrypted&#xA;signature scheme where the encryption key is a group element (this includes&#xA;adaptor signatures).&#xA;In [1] they actually use adaptor signatures without calling them that to&#xA;create a Schnorr oblivious signature scheme that is similar to what you&#xA;would do with BIP340 Schnorr in practice.&#xA;I used this in [2] to create scriptless lotteries in Bitcoin.&#xA;&#xA;To start assume that you have three functions (which can be instantiated&#xA;with adaptor signatures):&#xA;&#xA;- `encrypted_sign(x, m, Y) -&gt; e`&#xA;- `encrypted_signature_verify(X, m, Y) -&gt; true/false`&#xA;- `decrypt_signature(e, y) -&gt; s`&#xA;&#xA;Where X is the public signing key Y is the encryption key and (x,y) are&#xA;their corresponding secret keys.&#xA;In our case x can be thought of as a secret key on a funding output.&#xA;&#xA;First, the party receiving the offer decides whether they want to receive&#xA;the settlement tx signature by setting c = 0  or otherwise c = 1 and then&#xA;creates a pedersen commitment Y to c by choosing a random y:&#xA;&#xA;Y = y *G + c * H&#xA;&#xA;and sends the commitment Y to its peer.&#xA;&#xA;The peer then sends `e = encrypted_sign(x, settlement_tx, Y)` back.&#xA;&#xA;If c = 0 (i.e. it is doing a covert recovery) it does `s =&#xA;decrypt_signature(e, y)` and attaches to the settlement transaction and&#xA;broadcasts it.  The channel is now successfully closed assuming the&#xA;encrypted signature was valid.&#xA;&#xA;If c = 1 (i.e. the node is fine and it wants to continue the channel) then&#xA;it checks `encrypted_signature_verify(X, settlement_tx, Y)`. If it passes&#xA;it sends the commitment blinding y back to prove that it doesn&#39;t have the&#xA;signature (i.e. prove c = 1). If verification fails then the node is&#xA;malicious and it fails the channel. Note that it is not possible to decrypt&#xA;the signature if c = 1 since the discrete logarithm of H with respect to G&#xA;is unknown.&#xA;&#xA;## Misc Q&amp;A&#xA;&#xA;- Does this require crazy crypto magic? No with the exception of Pedersen&#xA;commitments it only requires what is being planned to be included in&#xA;lightning anyway i.e. adaptor signatures.&#xA;&#xA;-  Who is receiver and who is sender? In my imagination this works by the&#xA;peer that is opening the connection being the receiver. This seems more&#xA;useful since users who are likely to not have redundant storage and&#xA;generally mess things up and need to recover are often behind NAT or on&#xA;phone networks without a public ip. There are cases where a public node may&#xA;want to recover by having people connect to them but I don&#39;t know what to&#xA;do about that. It looks like you have to choose one or the other.&#xA;&#xA;- Can&#39;t they still steal money? Yes but this is still a strictly better&#xA;than the current situation. The attacker has to guess precisely which&#xA;connection you make is after data loss. This is tricky task especially&#xA;because if they ever guess wrongly you close your channel with them and&#xA;block them. Right now you are the one who tells them you&#39;ve lost data!&#xA;&#xA;- Are these oblivious signatures secure? Yes. Sender security (receiver&#xA;only gets the signature if c = 0) is based on discrete log assumption.&#xA;Hint: if you instantiate the above algorithms with adaptor signatures we&#xA;can extract the discrete log of H from a receiver who knows an opening of Y&#xA;where c = 1 and also successfully decrypts the signature. Receiver security&#xA;is unconditional (Pedersen commitments are unconditionally hiding).&#xA;&#xA;- Does this work for multiple signatures? Yes you can choose to receive N&#xA;signatures to close N channels or nothing.  The signer just sends multiple&#xA;e_1, e_2 produced the same way and the receiver can decrypt them all if c =&#xA;0.&#xA;&#xA;- Does it work for key aggregated signatures i.e. MuSig2? -- Yes&#xA;`encrypted_sign` just becomes a two round protocol to produce `e`.&#xA;&#xA;- What do you do if the channel state has HTLCs in flight? I don&#39;t know --&#xA;I guess you can just put them onto the settlement tx? That way it&#39;s&#xA;possible the payment could still go through. Alternatively you could just&#xA;gift the money to the party offering the recovery settlement.&#xA;&#xA;[1]&#xA;http://www.cs.nccu.edu.tw/~raylin/UndergraduateCourse/ComtenporaryCryptography/Spring2009/TSOINSPET2007.pdf&#xA;[2]&#xA;https://telaviv2019.scalingbitcoin.org/files/scriptless-lotteries-on-bitcoin-from-oblivious-transfer.pdf&#xA;&#xA;Cheers,&#xA;&#xA;LL&#xA;-------------- next part --------------&#xA;An HTML attachment was scrubbed...&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/lightning-dev/attachments/20201211/0179a579/attachment.html&gt;</html></oembed>