<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <updated></updated>
  <generator>https://nostr.ae</generator>

  <title>Nostr notes by </title>
  <author>
    <name></name>
  </author>
  <link rel="self" type="application/atom+xml" href="https://nostr.ae/npub1lpkmxpl2zhk0w30vtdz7s64ml9644k785eggmjsjgs7wman3szzqac74n4.rss" />
  <link href="https://nostr.ae/npub1lpkmxpl2zhk0w30vtdz7s64ml9644k785eggmjsjgs7wman3szzqac74n4" />
  <id>https://nostr.ae/npub1lpkmxpl2zhk0w30vtdz7s64ml9644k785eggmjsjgs7wman3szzqac74n4</id>
  <icon></icon>
  <logo></logo>




  <entry>
    <id>https://nostr.ae/nevent1qqs8gg30nglxww5c0c5st48gp28l67m9p3qluy5u0urqglzhsvyw8jgzyruxmvc8ag27ea69a3d5t6r2h0uh2kkmc7n9prw2zfzrem0kwxqggyl8y3v</id>
    
      <title type="html">📅 Original date posted:2023-08-09 🗒️ Summary of this ...</title>
    
    <link rel="alternate" href="https://nostr.ae/nevent1qqs8gg30nglxww5c0c5st48gp28l67m9p3qluy5u0urqglzhsvyw8jgzyruxmvc8ag27ea69a3d5t6r2h0uh2kkmc7n9prw2zfzrem0kwxqggyl8y3v" />
    <content type="html">
      In reply to &lt;a href=&#39;/nevent1qqsd5n8hf87hmrjugc6hm8prx3a3kultch2yuert9cjewr5ec45cvmg4hj8v0&#39;&gt;nevent1q…j8v0&lt;/a&gt;&lt;br/&gt;_________________________&lt;br/&gt;&lt;br/&gt;📅 Original date posted:2023-08-09&lt;br/&gt;🗒️ Summary of this message: The author thanks Johan for their comments and implementation. They discuss the ordering of parameters and the use cases for the deferred output amount check in CCV.&lt;br/&gt;📝 Original message:&lt;br/&gt;Hi Johan,&lt;br/&gt;&lt;br/&gt;Thanks a lot for the comments, and the independent implementation!&lt;br/&gt;&lt;br/&gt;&amp;gt; - For the opcode parameter ordering, it feels unnatural for the two&lt;br/&gt;&amp;gt; tweaks (data, taptree) to be separated by the internal key. A more&lt;br/&gt;&amp;gt; natural ordering of parameters IMO would be (of course this is all&lt;br/&gt;&amp;gt; subjective):&lt;br/&gt;&amp;gt; &amp;lt;data&amp;gt; &amp;lt;taptree&amp;gt; &amp;lt;internalkey&amp;gt; &amp;lt;index&amp;gt; &amp;lt;flags&amp;gt; OP_CCV.&lt;br/&gt;&amp;gt;&lt;br/&gt;&amp;gt; If you disagree, I would love some rationale for the ordering you&lt;br/&gt;&amp;gt; chose! (looks like you also changed it again after your last post?).&lt;br/&gt;&lt;br/&gt;The main concern for the reordering was to put &amp;lt;data&amp;gt; at the bottom,&lt;br/&gt;as that&amp;#39;s typically passed via the witness stack.&lt;br/&gt;&lt;br/&gt;I put the &amp;lt;index&amp;gt; right next, as I suspect there are use cases for&lt;br/&gt;specifying via the witness what is the input index where a certain&lt;br/&gt;(CCV-encumbered) UTXO is to be found, or which output should funds&lt;br/&gt;be sent to, instead of hard-coding this in the script. This might&lt;br/&gt;help in designing contracts that are more flexible in the way they&lt;br/&gt;are spent, for example by allowing batching their transactions.&lt;br/&gt;&lt;br/&gt;Instead, I expect the other parameters to almost always be hardcoded,&lt;br/&gt;or propagated from the current input with the &amp;lt;-1&amp;gt; special values.&lt;br/&gt;&lt;br/&gt;I agree that your ordering is more aesthetically pleasing, though.&lt;br/&gt;&lt;br/&gt;&amp;gt; I&amp;#39;m wondering what other use cases you had in mind for the deferred&lt;br/&gt;&amp;gt; output amount check? Maybe I have missed something, but if not it&lt;br/&gt;&amp;gt; would perhaps be better to leave out the amount preservation check, or&lt;br/&gt;&amp;gt; go the extra mile and propose a more powerful amount introspection&lt;br/&gt;&amp;gt; machinery.&lt;br/&gt;&lt;br/&gt;Yes, the deferred output amount check is not enough for coinpools;&lt;br/&gt;however, it comes at no cost if we have a &amp;lt;flags&amp;gt; parameter anyway,&lt;br/&gt;as OP_2 (value for CCV_IGNORE_OUTPUT_AMOUNT) is a single byte opcode.&lt;br/&gt;&lt;br/&gt;The intent of preserving amounts for many-to-one contracts (vaults),&lt;br/&gt;or the one-to-one cases (channels, any 2-party contract, etc.) seems&lt;br/&gt;common enough to deserve 1 bit in the flags, IMHO.&lt;br/&gt;Efforts to define and add explicit introspection to cover your&lt;br/&gt;(exciting!) use cases can proceed independently, but I don&amp;#39;t think&lt;br/&gt;they would nullify the advantages of this (optional) feature of CCV.&lt;br/&gt;&lt;br/&gt;Best,&lt;br/&gt;Salvatore&lt;br/&gt;-------------- next part --------------&lt;br/&gt;An HTML attachment was scrubbed...&lt;br/&gt;URL: &amp;lt;&lt;a href=&#34;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20230809/72053c9c/attachment.html&amp;gt&#34;&gt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20230809/72053c9c/attachment.html&amp;gt&lt;/a&gt;;
    </content>
    <updated>2023-08-09T18:03:59&#43;02:00</updated>
  </entry>

  <entry>
    <id>https://nostr.ae/nevent1qqs9ax7ghe58nmq92l7fy3pmc8qpqfwgx7aj58a4745v7gwwpc0jx7czyruxmvc8ag27ea69a3d5t6r2h0uh2kkmc7n9prw2zfzrem0kwxqgg56df05</id>
    
      <title type="html">📅 Original date posted:2023-08-07 🗒️ Summary of this ...</title>
    
    <link rel="alternate" href="https://nostr.ae/nevent1qqs9ax7ghe58nmq92l7fy3pmc8qpqfwgx7aj58a4745v7gwwpc0jx7czyruxmvc8ag27ea69a3d5t6r2h0uh2kkmc7n9prw2zfzrem0kwxqgg56df05" />
    <content type="html">
      In reply to &lt;a href=&#39;/nevent1qqszzsem5hqr6grcu4lpsmd7srpw40wjc2ge6qs2pz9sq656fcmh46qdrgc8v&#39;&gt;nevent1q…gc8v&lt;/a&gt;&lt;br/&gt;_________________________&lt;br/&gt;&lt;br/&gt;📅 Original date posted:2023-08-07&lt;br/&gt;🗒️ Summary of this message: The sender apologizes for confusion and inconsistent use of plurals. They explain that the opcode is now functionally complete and ready for experimentation.&lt;br/&gt;📝 Original message:&lt;br/&gt;Hi Dave,&lt;br/&gt;&lt;br/&gt;I apologize for the confusion and the inconsistent use of plurals.&lt;br/&gt;The reason I called it a &amp;#34;complete proposal&amp;#34; is that the opcode is&lt;br/&gt;now functionally complete, unlike the previous attempt where the&lt;br/&gt;approach for the output amount introspection was not yet specified.&lt;br/&gt;&lt;br/&gt;The semantics are informally defined in the previous e-mail, and&lt;br/&gt;implemented in the code [1], which is the only formal specification&lt;br/&gt;at this time. I believe the code is now fairly stable and ready to&lt;br/&gt;experiment with.&lt;br/&gt;My own and (hopefully) others&amp;#39; experimentation will help in writing&lt;br/&gt;a more informed BIP proposal in the next few months.&lt;br/&gt;&lt;br/&gt;About the plurals: OP_CHECKCONTRACTVERIFY is indeed now a single&lt;br/&gt;opcode that is useful on its own, but I will also be maintaining a&lt;br/&gt;separate branch [2] that contains both OP_CHECKCONTRACTVERIFY and&lt;br/&gt;OP_CAT, which enables the full generality of the MATT proposal.&lt;br/&gt;&lt;br/&gt;Best,&lt;br/&gt;Salvatore&lt;br/&gt;&lt;br/&gt;[1] -&lt;br/&gt;&lt;a href=&#34;https://github.com/bitcoin-inquisition/bitcoin/compare/24.0...Merkleize:bitcoin:checkcontractverify&#34;&gt;https://github.com/bitcoin-inquisition/bitcoin/compare/24.0...Merkleize:bitcoin:checkcontractverify&lt;/a&gt;&lt;br/&gt;[2] - &lt;a href=&#34;https://github.com/Merkleize/bitcoin/tree/matt&#34;&gt;https://github.com/Merkleize/bitcoin/tree/matt&lt;/a&gt;&lt;br/&gt;-------------- next part --------------&lt;br/&gt;An HTML attachment was scrubbed...&lt;br/&gt;URL: &amp;lt;&lt;a href=&#34;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20230807/1d9c4af8/attachment-0001.html&amp;gt&#34;&gt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20230807/1d9c4af8/attachment-0001.html&amp;gt&lt;/a&gt;;
    </content>
    <updated>2023-08-08T16:20:52&#43;02:00</updated>
  </entry>

  <entry>
    <id>https://nostr.ae/nevent1qqstqne5z930rylz39fs9fdzjwv652ylx2knh9rx7zyxgg9r04f37agzyruxmvc8ag27ea69a3d5t6r2h0uh2kkmc7n9prw2zfzrem0kwxqggzwlsdz</id>
    
      <title type="html">📅 Original date posted:2023-05-28 🗒️ Summary of this ...</title>
    
    <link rel="alternate" href="https://nostr.ae/nevent1qqstqne5z930rylz39fs9fdzjwv652ylx2knh9rx7zyxgg9r04f37agzyruxmvc8ag27ea69a3d5t6r2h0uh2kkmc7n9prw2zfzrem0kwxqggzwlsdz" />
    <content type="html">
      In reply to &lt;a href=&#39;/nevent1qqsx7h0235rp8p6azasyy3h3hpmt59j2se3k0ewc325ugdgdh0lqejc3uklsa&#39;&gt;nevent1q…klsa&lt;/a&gt;&lt;br/&gt;_________________________&lt;br/&gt;&lt;br/&gt;📅 Original date posted:2023-05-28&lt;br/&gt;🗒️ Summary of this message: The author suggests making OP_CICV and OP_COCV symmetrical and exploring the use of OP_CHECKINPUTCONTRACTVERIFY for eltoo-style replacement. They also discuss the possibility of a single OP_CHECK_IN_OUT_CONTRACT_VERIFY opcode for greater flexibility. Additionally, they mention the use of taproot internal pubkey with &amp;#34;dynamic key aggregation&amp;#34; and storing pubkeys of members in embedded data for CoinPools.&lt;br/&gt;📝 Original message:Hi Johan,&lt;br/&gt;&lt;br/&gt;Exciting to finally see some merkleization, which was only confined&lt;br/&gt;within the meme, up to this point!&lt;br/&gt;&lt;br/&gt;&amp;gt; A simpler way IMO, would be to make OP_CICV and OP_COCV symmetrical:&lt;br/&gt;&amp;gt; Have OP_CICV take an optional taproot and do the same check as is&lt;br/&gt;&amp;gt; done for the output: Q == tweak(tweak(X,D), T).&lt;br/&gt;&lt;br/&gt;I think that&amp;#39;s an excellent suggestion, which I was already exploring&lt;br/&gt;for a different purpose: bringing externally signed data onto the&lt;br/&gt;stack. My goal there was to allow eltoo-style replacement.&lt;br/&gt;&lt;br/&gt;Until recently, I thought that a clean/efficient version of eltoo&lt;br/&gt;would require OP_CHECKSIGFROMSTACK or ANYPREVOUT. However, extending&lt;br/&gt;OP_CHECKINPUTCONTRACTVERIFY to enable introspection of other inputs&lt;br/&gt;allows a reasonable workaround: producing a separate UTXO signed with&lt;br/&gt;ANYONECANPAY, with the required data embedded as usual. Spending that&lt;br/&gt;UTXO together with the channel&amp;#39;s UTXO allows one to get that data&lt;br/&gt;on the stack (with its signature already checked by consensus rules).&lt;br/&gt;I drafted this idea in a gist [1].&lt;br/&gt;&lt;br/&gt;Remark: it still seems easier (and probably slightly more efficient)&lt;br/&gt;to build eltoo replacement with CSFS or APO in addition to MATT&lt;br/&gt;opcodes.&lt;br/&gt;&lt;br/&gt;A possible semantics for OP_CHECKINPUTCONTRACTVERIFY could then be&lt;br/&gt;exactly symmetrical to that of OP_CHECKOUTPUTCONTRACTVERIFY, with&lt;br/&gt;the exception that the special input index -1 would represent the&lt;br/&gt;current input.&lt;br/&gt;&lt;br/&gt;Pushing this further, another option that could be be worth exploring&lt;br/&gt;is to have a single OP_CHECK_IN_OUT_CONTRACT_VERIFY opcode, with the&lt;br/&gt;same semantics as OP_CHECKOUTPUTCONTRACTVERIFY from [2], but with an&lt;br/&gt;additional `flags` argument, which is a bitmap where:&lt;br/&gt;- the lowest-significant bit determines if the index refers to inputs&lt;br/&gt;  or outputs (where input index -1 refers to the current input)&lt;br/&gt;- the second bit specifies if amounts should be preserved with&lt;br/&gt;  deferred checks as described in [2] (only applicable to outputs)&lt;br/&gt;- other bits are OP_SUCCESS and reserved for future behaviors.&lt;br/&gt;&lt;br/&gt;This would make the opcodes 1-2 bytes larger, but might allow greater&lt;br/&gt;flexibility, and keep some room for future extensions.&lt;br/&gt;&lt;br/&gt;&amp;gt; 2.To make fully functioning CoinPools, one would need functionality&lt;br/&gt;&amp;gt; similar to OP_MERKLESUB[4]: remove some data from the merkle tree,&lt;br/&gt;&amp;gt; and remove a key from the aggregated internal key.&lt;br/&gt;&lt;br/&gt;It seems likely that efficient use of the taproot internal pubkey with&lt;br/&gt;&amp;#34;dynamic key aggregation&amp;#34; is not possible with the current semantics&lt;br/&gt;(unless one ventures into the fraud proof machinery, which seems&lt;br/&gt;overkill!).&lt;br/&gt;&lt;br/&gt;However, in constructions with MATT opcodes, I would never expect the&lt;br/&gt;need for data to be stored in the taptree. In particular, for the case&lt;br/&gt;of CoinPools, the pubkeys of the members could also be stored in the&lt;br/&gt;embedded data, having a single &amp;#34;unilateral withdrawal&amp;#34; tapleaf.&lt;br/&gt;Removing a key would then amount to replacing it with a fixed NUMS key&lt;br/&gt;and computing the new root (re-using the same Merkle proof).&lt;br/&gt;Note that this is not a lot costlier than using a tapleaf per user:&lt;br/&gt;instead of paying the cost for the Merkle proof in the control block,&lt;br/&gt;you pay for it explicitly in the Script witness.&lt;br/&gt;&lt;br/&gt;Therefore, I would expect there to be reasonable CoinPools designs&lt;br/&gt;without additional opcodes − but I am only moderately confident as&lt;br/&gt;this is beyond the level of sophistication I&amp;#39;ve been exploring so far.&lt;br/&gt;&lt;br/&gt;Best,&lt;br/&gt;Salvatore&lt;br/&gt;&lt;br/&gt;[1] - &lt;a href=&#34;https://gist.github.com/bigspider/041ebd0842c0dcc74d8af087c1783b63&#34;&gt;https://gist.github.com/bigspider/041ebd0842c0dcc74d8af087c1783b63&lt;/a&gt;&lt;br/&gt;[2] -&lt;br/&gt;&lt;a href=&#34;https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2023-April/021588.html&#34;&gt;https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2023-April/021588.html&lt;/a&gt;&lt;br/&gt;-------------- next part --------------&lt;br/&gt;An HTML attachment was scrubbed...&lt;br/&gt;URL: &amp;lt;&lt;a href=&#34;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20230528/e5be3369/attachment.html&amp;gt&#34;&gt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20230528/e5be3369/attachment.html&amp;gt&lt;/a&gt;;
    </content>
    <updated>2023-06-08T01:21:09&#43;02:00</updated>
  </entry>

  <entry>
    <id>https://nostr.ae/nevent1qqsgeavevzr9jpumqgn727l99000gul95dt98s9wplxy3naad6d2jgszyruxmvc8ag27ea69a3d5t6r2h0uh2kkmc7n9prw2zfzrem0kwxqgg48s4ca</id>
    
      <title type="html">📅 Original date posted:2023-05-01 🗒️ Summary of this ...</title>
    
    <link rel="alternate" href="https://nostr.ae/nevent1qqsgeavevzr9jpumqgn727l99000gul95dt98s9wplxy3naad6d2jgszyruxmvc8ag27ea69a3d5t6r2h0uh2kkmc7n9prw2zfzrem0kwxqgg48s4ca" />
    <content type="html">
      In reply to &lt;a href=&#39;/nevent1qqs9v3q83nd3h5hlyerd5j3kceslcz729qy0uxpfaqh9qve2fxfch8cjzv22a&#39;&gt;nevent1q…v22a&lt;/a&gt;&lt;br/&gt;_________________________&lt;br/&gt;&lt;br/&gt;📅 Original date posted:2023-05-01&lt;br/&gt;🗒️ Summary of this message: The email discusses oversights in a previous email regarding a contract&amp;#39;s embedded data and suggests a solution to store a hash instead. It also proposes a fix for a potential cheating scenario in a game played offline.&lt;br/&gt;📝 Original message:Hi all,&lt;br/&gt;&lt;br/&gt;I apologize for a couple of oversights in my last e-mail.&lt;br/&gt;&lt;br/&gt;The first is that m_B can&amp;#39;t be committed as-is in the contract&amp;#39;s&lt;br/&gt;embedded data, with the current semantics of OP_COCV, which&lt;br/&gt;only allows 32-byte values. A solution could be to store its&lt;br/&gt;hash SHA256(m_B), instead.&lt;br/&gt;&lt;br/&gt;(I didn&amp;#39;t test the Scripts, so there could be other bugs − hopefully the&lt;br/&gt;general idea is clear, anyway)&lt;br/&gt;&lt;br/&gt;On Mon, 1 May 2023 at 15:11, Salvatore Ingala &amp;lt;salvatore.ingala at gmail.com&amp;gt;&lt;br/&gt;wrote:&lt;br/&gt;&lt;br/&gt;&amp;gt; If the internal_pubkey is a musig-aggregated key of Alice and Bob,&lt;br/&gt;&amp;gt; the game can be settled entirely offline after the first transaction.&lt;br/&gt;&amp;gt; Simply, Bob communicates his move to Alice, Alice reveals her move to&lt;br/&gt;&amp;gt; Bob, and they can settle the bet. The game would be played without&lt;br/&gt;&amp;gt; any script being executed, therefore all transactions could look like&lt;br/&gt;&amp;gt; any other P2TR, with the only possible fingerprinting being due to the&lt;br/&gt;&amp;gt; input amounts.&lt;br/&gt;&amp;gt;&lt;br/&gt;&lt;br/&gt;This is incomplete: Alice can&amp;#39;t trust Bob by revealing her move, as&lt;br/&gt;he could then cheat on-chain and play a different move.&lt;br/&gt;&lt;br/&gt;The fix should be straightforward, after adding the requirement that the&lt;br/&gt;internal pubkey of [S1] is a musig2 of both players.&lt;br/&gt;After Bob reveals his move (say, Rock), Alice will only agree to continue&lt;br/&gt;the game off-chain if Bob pre-signs transactions for the state [S1] (where&lt;br/&gt;m_B = Paper, and m_B = Scissors) that send all the money to Alice.&lt;br/&gt;This guarantees that a cheating Bob is punished.&lt;br/&gt;&lt;br/&gt;Best,&lt;br/&gt;Salvatore Ingala&lt;br/&gt;-------------- next part --------------&lt;br/&gt;An HTML attachment was scrubbed...&lt;br/&gt;URL: &amp;lt;&lt;a href=&#34;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20230501/a850251d/attachment.html&amp;gt&#34;&gt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20230501/a850251d/attachment.html&amp;gt&lt;/a&gt;;
    </content>
    <updated>2023-06-08T01:21:08&#43;02:00</updated>
  </entry>

  <entry>
    <id>https://nostr.ae/nevent1qqs9v3q83nd3h5hlyerd5j3kceslcz729qy0uxpfaqh9qve2fxfch8czyruxmvc8ag27ea69a3d5t6r2h0uh2kkmc7n9prw2zfzrem0kwxqggcv0lva</id>
    
      <title type="html">📅 Original date posted:2023-05-01 🗒️ Summary of this ...</title>
    
    <link rel="alternate" href="https://nostr.ae/nevent1qqs9v3q83nd3h5hlyerd5j3kceslcz729qy0uxpfaqh9qve2fxfch8czyruxmvc8ag27ea69a3d5t6r2h0uh2kkmc7n9prw2zfzrem0kwxqggcv0lva" />
    <content type="html">
      In reply to &lt;a href=&#39;/nevent1qqs9qrg4sd59yf88szf60v0ffd2luj82ja2w3rn9vazwp7j7jjgp3uqga4z3u&#39;&gt;nevent1q…4z3u&lt;/a&gt;&lt;br/&gt;_________________________&lt;br/&gt;&lt;br/&gt;📅 Original date posted:2023-05-01&lt;br/&gt;🗒️ Summary of this message: The author suggests that games where all possible futures can be enumerated are not ideal to showcase MATT, and proposes rock-paper-scissors as an academic example. They provide a protocol for playing the game and explain how it can be implemented with CICV/COCV.&lt;br/&gt;📝 Original message:Hi Johan,&lt;br/&gt;&lt;br/&gt;Thanks for your message.&lt;br/&gt;&lt;br/&gt;I think games where all the possible futures can be enumerated are&lt;br/&gt;not ideal to showcase MATT, as one could just fully represent them&lt;br/&gt;with just CTV or COCV, and not use the &amp;#34;data embedding&amp;#34; at all.&lt;br/&gt;&lt;br/&gt;Perhaps rock-paper-scissors could be a better academic example. [1]&lt;br/&gt;&lt;br/&gt;I&amp;#39;m not sure this will fully address your question; however I think&lt;br/&gt;it&amp;#39;s quite an instructive example, and I wanted to work it out for&lt;br/&gt;quite some time.&lt;br/&gt;&lt;br/&gt;It would be interesting to explore some contracts where the size&lt;br/&gt;of the embedded data is substantially larger, and that could be&lt;br/&gt;a natural next step to think about.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;### Rock paper scissors&lt;br/&gt;&lt;br/&gt;We want a protocol between Alice and Bob, where they bet 1 coin each:&lt;br/&gt;&lt;br/&gt;1. Alice chooses and publishes her move;&lt;br/&gt;2. Bob chooses his move, and the pot is adjudicated as per the rules.&lt;br/&gt;&lt;br/&gt;Of course, if implemented naively, this wouldn&amp;#39;t be a very fun game:&lt;br/&gt;Bob would just wait to see Alice&amp;#39;s move and play accordingly.&lt;br/&gt;&lt;br/&gt;That&amp;#39;s easy to fix, though:&lt;br/&gt;&lt;br/&gt;1. Alice publishes a commitment to her move&lt;br/&gt;2. Bob publishes his move in clear&lt;br/&gt;3. Alice reveals her move, and the pot is adjudicated.&lt;br/&gt;&lt;br/&gt;We can encode Rock = 0, Paper = 1, Scissors = 2. Let m_A, m_B be&lt;br/&gt;Alice&amp;#39;s and Bob&amp;#39;s move, respectively. Then, it&amp;#39;s easy to verify that:&lt;br/&gt;− m_B - m_A == 0 (mod 3) ==&amp;gt; it&amp;#39;s a tie&lt;br/&gt;− m_B - m_A == 1 (mod 3) ==&amp;gt; Bob wins&lt;br/&gt;− m_B - m_A == 2 (mod 3) ==&amp;gt; Alice wins&lt;br/&gt;&lt;br/&gt;In order to create a hiding commitment for Alice, she can choose a&lt;br/&gt;256-bit random number r_A, and compute:&lt;br/&gt;&lt;br/&gt;  c_A = SHA256(m_A || r_A)&lt;br/&gt;&lt;br/&gt;With that in mind, the full protocol can go like this:&lt;br/&gt;&lt;br/&gt;1. Alice chooses her move m_A and a large random number r_A;&lt;br/&gt;   she posts c_A computed as above;&lt;br/&gt;2. Bob chooses m_B and publishes it;&lt;br/&gt;3. Alice publishes m_A and r_A, then the winner is adjudicated.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;### MATT playing RPS&lt;br/&gt;&lt;br/&gt;To implement this with CICV/COCV, we can use just 3 transactions: in&lt;br/&gt;fact, Alice can already compute c_A and share it with Bob before they&lt;br/&gt;both commit their coins into an encumbered UTXO. That also means that&lt;br/&gt;c_A can actually be hardcoded in the Scripts, rather than taking&lt;br/&gt;space in the UTXO&amp;#39;s embedded data.&lt;br/&gt;&lt;br/&gt;Therefore, they both put one coin each, and they send to an output&lt;br/&gt;whose script is the state S0 described below.&lt;br/&gt;&lt;br/&gt;We assume that the keypath in the P2TR defined below is either a NUMS&lt;br/&gt;point, or perhaps a Musig2 aggregate key that can be used to settle&lt;br/&gt;the game collaboratively.&lt;br/&gt;&lt;br/&gt;Note that there are 3 possible payout options that are fully known&lt;br/&gt;when the game starts: either Alice takes all the money, or they split&lt;br/&gt;evenly, or Bob takes all the money.&lt;br/&gt;Similarly to the vault implementation [2], this seems to be another&lt;br/&gt;case where CTV fits very well, as it allows to very efficiently&lt;br/&gt;describe the three possible outcomes by their CTV hashes. Let them&lt;br/&gt;be &amp;lt;ctv-alice-wins&amp;gt;, &amp;lt;ctv-split&amp;gt;, &amp;lt;ctv-bob-wins&amp;gt;, respectively.&lt;br/&gt;&lt;br/&gt;Therefore, this avoids the need for 64-bit maths, and explicit amount&lt;br/&gt;introspection − at least for these contracts.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;[State S0] (Start of the game, Alice moved; Bob&amp;#39;s turn)&lt;br/&gt;Spending conditions:&lt;br/&gt; - after &amp;lt;forfait-delay&amp;gt;, Alice takes the money    // (Bob forfaits)&lt;br/&gt; - Bob posts m_B (0, 1 or 2); the next output is [S1] with data m_B&lt;br/&gt;&lt;br/&gt;The first script is:&lt;br/&gt;  // witness: []&lt;br/&gt;  &amp;lt;forfait-delay&amp;gt;&lt;br/&gt;  OP_CHECKSEQUENCEVERIFY&lt;br/&gt;  OP_DROP&lt;br/&gt;  &amp;lt;ctv-alice-wins&amp;gt;&lt;br/&gt;  OP_CHECKTEMPLATEVERIFY&lt;br/&gt;&lt;br/&gt;The second is&lt;br/&gt;  // witness: [&amp;lt;bob_sig&amp;gt; &amp;lt;m_B&amp;gt;]&lt;br/&gt;  OP_DUP 0 3 OP_WITHIN     // check that m_B is 0, 1 or 2&lt;br/&gt;&lt;br/&gt;  &amp;lt;internal_pubkey&amp;gt; OP_SWAP&lt;br/&gt;  &amp;lt;S1&amp;#39;s taptree&amp;gt;&lt;br/&gt;  OP_CHECKOUTPUTCONTRACTVERIFY // check that the output is correct&lt;br/&gt;&lt;br/&gt;  &amp;lt;bob_pubkey&amp;gt;&lt;br/&gt;  OP_CHECKSIG&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;[State S1] (Alice reveals m_A and adjudicates)&lt;br/&gt; - after &amp;lt;forfait-timeout&amp;gt;, Bob takes the money    // (Alice forfaits)&lt;br/&gt; - Alice posts correct m_A and r_A compatible with c_A;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;The first script is symmetric to Bob&amp;#39;s forfait script above.&lt;br/&gt;&lt;br/&gt;The second condition can be split into three leaf scripts, one for&lt;br/&gt;each possible value of m_B - m_A (mod 3):&lt;br/&gt;&lt;br/&gt;  // witness: [&amp;lt;m_B&amp;gt; &amp;lt;m_A&amp;gt; &amp;lt;r_A&amp;gt;]&lt;br/&gt;&lt;br/&gt;  OP_OVER OP_DUP OP_TOALTSTACK  // save m_A&lt;br/&gt;  0 3 OP_WITHIN OP_VERIFY       // check that m_A is 0, 1 or 2&lt;br/&gt;&lt;br/&gt;  // check that SHA256(m_A || r_A) equals c_A&lt;br/&gt;  OP_2DUP&lt;br/&gt;  OP_CAT OP_SHA256&lt;br/&gt;  &amp;lt;c_A&amp;gt;&lt;br/&gt;  OP_EQUALVERIFY&lt;br/&gt;&lt;br/&gt;  OP_DUP&lt;br/&gt;  &amp;lt;internal_pubkey&amp;gt;, OP_SWAP&lt;br/&gt;  OP_CHECKINPUTCONTRACTVERIFY&lt;br/&gt;&lt;br/&gt;  OP_FROMALTSTACK&lt;br/&gt;  OP_SUB           // stack now contains m_B - m_A&lt;br/&gt;&lt;br/&gt;  OP_DUP           // if the result is negative, add 3&lt;br/&gt;  0 OP_LESSTHAN&lt;br/&gt;  OP_IF&lt;br/&gt;    3&lt;br/&gt;    OP_ADD&lt;br/&gt;  OP_ENDIF&lt;br/&gt;&lt;br/&gt;  {0, 1, 2}       // draw / Bob wins / Alice wins, respectively&lt;br/&gt;  OP_EQUALVERIFY&lt;br/&gt;&lt;br/&gt;  {&amp;lt;ctv-split&amp;gt;, &amp;lt;ctv-bob-wins&amp;gt;, &amp;lt;ctv-alice-wins&amp;gt;}  // respectively&lt;br/&gt;  OP_CHECKTEMPLATEVERIFY&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;### Comments&lt;br/&gt;&lt;br/&gt;In general, we would have to worry about the possible&lt;br/&gt;malleability of the witness elements, when they are not signatures&lt;br/&gt;or preimages themselves. Here, in particular, it might seem that&amp;#39;s&lt;br/&gt;an issue when &amp;lt;m_B&amp;gt; is provided while spending the state [S0].&lt;br/&gt;However, here the value of &amp;lt;m_B&amp;gt; is also committed to in the output&lt;br/&gt;thanks to COCV; therefore, Bob&amp;#39;s signature prevents malleability&lt;br/&gt;also for m_B.&lt;br/&gt;&lt;br/&gt;In general, it seems to be the case in MATT contracts that one would&lt;br/&gt;want the signature of the authorized party performing a transition to&lt;br/&gt;some other state of the smart contract with contains embedded data;&lt;br/&gt;this makes the malleability issue less of a problem in practice than&lt;br/&gt;I initially thought.&lt;br/&gt;&lt;br/&gt;If the internal_pubkey is a musig-aggregated key of Alice and Bob,&lt;br/&gt;the game can be settled entirely offline after the first transaction.&lt;br/&gt;Simply, Bob communicates his move to Alice, Alice reveals her move to&lt;br/&gt;Bob, and they can settle the bet. The game would be played without&lt;br/&gt;any script being executed, therefore all transactions could look like&lt;br/&gt;any other P2TR, with the only possible fingerprinting being due to the&lt;br/&gt;input amounts.&lt;br/&gt;&lt;br/&gt;It should be possible to generalize the protocol so that many rounds&lt;br/&gt;can be played off-chain within the same UTXO, but I didn&amp;#39;t try to&lt;br/&gt;figure out the details.&lt;br/&gt;&lt;br/&gt;Best,&lt;br/&gt;Salvatore Ingala&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;[1] - &lt;a href=&#34;https://en.wikipedia.org/wiki/Rock_paper_scissors&#34;&gt;https://en.wikipedia.org/wiki/Rock_paper_scissors&lt;/a&gt;&lt;br/&gt;[2] -&lt;br/&gt;&lt;a href=&#34;https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2023-April/021588.html&#34;&gt;https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2023-April/021588.html&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;On Fri, 28 Apr 2023 at 10:48, Johan Torås Halseth &amp;lt;johanth at gmail.com&amp;gt; wrote:&lt;br/&gt;&lt;br/&gt;&amp;gt; Hi, Salvatore.&lt;br/&gt;&amp;gt;&lt;br/&gt;&amp;gt; I find this proposal very interesting. Especially since you seemingly&lt;br/&gt;&amp;gt; can achieve such powerful capabilities by such simple opcodes.&lt;br/&gt;&amp;gt;&lt;br/&gt;&amp;gt; I&amp;#39;m still trying to grok how this would look like on-chain (forget&lt;br/&gt;&amp;gt; about the off-chain part for now), if we were to play out such a&lt;br/&gt;&amp;gt; computation.&lt;br/&gt;&amp;gt;&lt;br/&gt;&amp;gt; Let&amp;#39;s say you have a simple game like &amp;#34;one player tic-tac-toe&amp;#34; with&lt;br/&gt;&amp;gt; only two tiles: [ _ | _ ]. The player wins if he can get two in a row&lt;br/&gt;&amp;gt; (pretty easy game tbh).&lt;br/&gt;&amp;gt;&lt;br/&gt;&amp;gt; Could you give a complete example how you would encode one such state&lt;br/&gt;&amp;gt; transition (going from [ X, _ ] -&amp;gt; [ X, X ] for instance) in Bitcoin&lt;br/&gt;&amp;gt; script?&lt;br/&gt;&amp;gt;&lt;br/&gt;&amp;gt; Feel free to choose a different game or program if you prefer :)&lt;br/&gt;&amp;gt;&lt;br/&gt;&amp;gt; Thanks!&lt;br/&gt;&amp;gt; Johan&lt;br/&gt;&amp;gt;&lt;br/&gt;&amp;gt;&lt;br/&gt;&amp;gt;&lt;br/&gt;&amp;gt; On Tue, Dec 13, 2022 at 2:08 PM Billy Tetrud via bitcoin-dev&lt;br/&gt;&amp;gt; &amp;lt;bitcoin-dev at lists.linuxfoundation.org&amp;gt; wrote:&lt;br/&gt;&amp;gt; &amp;gt;&lt;br/&gt;&amp;gt; &amp;gt; Re Verkle trees, that&amp;#39;s a very interesting construction that would be&lt;br/&gt;&amp;gt; super useful as a tool for something like Utreexo. A potentially&lt;br/&gt;&amp;gt; substantial downside is that it seems the cryptography used to get those&lt;br/&gt;&amp;gt; nice properties of Verkle trees isn&amp;#39;t quantum safe. While a lot of things&lt;br/&gt;&amp;gt; in Bitcoin seems to be going down the path of quantum-unsafe (I&amp;#39;m looking&lt;br/&gt;&amp;gt; at you, taproot), there are still a lot of people who think quantum safety&lt;br/&gt;&amp;gt; is important in a lot of contexts.&lt;br/&gt;&amp;gt; &amp;gt;&lt;br/&gt;&amp;gt; &amp;gt; On Thu, Dec 1, 2022 at 5:52 AM Salvatore Ingala via bitcoin-dev &amp;lt;&lt;br/&gt;&amp;gt; bitcoin-dev at lists.linuxfoundation.org&amp;gt; wrote:&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; Hello Rijndael,&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; On Wed, 30 Nov 2022 at 23:09, Rijndael &amp;lt;rot13maxi at protonmail.com&amp;gt;&lt;br/&gt;&amp;gt; wrote:&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&amp;gt; Hello Salvatore,&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&amp;gt; I found my answer re-reading your original post:&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&amp;gt; &amp;gt; During the arbitration phase (say at the i-th leaf node of M_T), any&lt;br/&gt;&amp;gt; party can win the challenge by providing correct values for tr_i = (st_i,&lt;br/&gt;&amp;gt; op_i, st_{i &#43; 1}). Crucially, only one party is able to provide correct&lt;br/&gt;&amp;gt; values, and Script can verify that indeed the state moves from st_i to&lt;br/&gt;&amp;gt; st_{i &#43; 1} by executing op_i. The challenge is over.&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; You are correct, the computation step encoded in a leaf needs to be&lt;br/&gt;&amp;gt; simple enough for Script to verify it.&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; For the academic purpose of proving completeness (that is, any&lt;br/&gt;&amp;gt; computation can be successfully &amp;#34;proved&amp;#34; by the availability of the&lt;br/&gt;&amp;gt; corresponding fraud proof), one can imagine reducing the computation all&lt;br/&gt;&amp;gt; the way down to a circuit, where each step (leaf) is as simple as what can&lt;br/&gt;&amp;gt; be checked with {OP_NOT, OP_BOOLAND, OP_BOOLOR, OP_EQUAL}.&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; In practice, you would want to utilize Script to its fullest, so for&lt;br/&gt;&amp;gt; example you wouldn&amp;#39;t compile a SHA256 computation to something else – you&amp;#39;d&lt;br/&gt;&amp;gt; rather use OP_SHA256 directly.&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&amp;gt; That raises leads to a different question: Alice initially posts a&lt;br/&gt;&amp;gt; commitment to an execution trace of `f(x) = y`, `x`, and `y`. Bob Disagrees&lt;br/&gt;&amp;gt; with `y` so starts the challenge protocol. Is there a commitment to `f`? In&lt;br/&gt;&amp;gt; other words, the dispute protocol (as I read it) finds the leftmost step in&lt;br/&gt;&amp;gt; Alice and Bob&amp;#39;s execution traces that differ, and then rewards the coins to&lt;br/&gt;&amp;gt; the participant who&amp;#39;s &amp;#34;after-value&amp;#34; is computed by the step&amp;#39;s operation&lt;br/&gt;&amp;gt; applied to the &amp;#34;before value&amp;#34;. But if the participants each present valid&lt;br/&gt;&amp;gt; steps but with different operations, who wins? In other words, Alice could&lt;br/&gt;&amp;gt; present [64, DECREMENT, 63] and Bob could present [64, INCREMENT, 65].&lt;br/&gt;&amp;gt; Those steps don&amp;#39;t match, but both are valid. Is there something to ensure&lt;br/&gt;&amp;gt; that before the challenge protocol starts, that the execution trace that&lt;br/&gt;&amp;gt; Alice posts is for the right computation and not a different computation&lt;br/&gt;&amp;gt; that yields a favorable result for her (and for which she can generate a&lt;br/&gt;&amp;gt; valid merkle tree)?&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; The function f is already hard-coded in the contract itself, by means&lt;br/&gt;&amp;gt; of the tree of scripts − that already commits to the possible futures.&lt;br/&gt;&amp;gt; Therefore, once you are at state S14, you know that you are verifying the&lt;br/&gt;&amp;gt; 6th step of the computation; and the operation in the 6th step of the&lt;br/&gt;&amp;gt; computation depends solely on f, not its inputs. In fact, you made me&lt;br/&gt;&amp;gt; realize that I could drop op_i from the i-th leaf commitment, and just&lt;br/&gt;&amp;gt; embed the information in the Script of that corresponding state.&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; Note that the states S0 to S14 of the 256x game are not _all_ the&lt;br/&gt;&amp;gt; possible states, but only the ones that occurred in that execution of the&lt;br/&gt;&amp;gt; contract (corresponding to a path from the root to the leaf of the Merkle&lt;br/&gt;&amp;gt; tree of the computation trace), and therefore the ones that materialized in&lt;br/&gt;&amp;gt; a UTXO. Different choices made by the parties (by providing different data,&lt;br/&gt;&amp;gt; and therefore choosing different branches) would lead to a different leaf,&lt;br/&gt;&amp;gt; and therefore to different (but in a certain sense &amp;#34;symmetric&amp;#34;) states.&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; ========&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; Since we are talking about the fact that f is committed to in the&lt;br/&gt;&amp;gt; contract, I&amp;#39;ll take the chance to extend on this a bit with a fun&lt;br/&gt;&amp;gt; construction on top.&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; It is well-known in the academic literature of state channels that you&lt;br/&gt;&amp;gt; can create contracts where even the function (&amp;#34;program&amp;#34;, or &amp;#34;contract&amp;#34;) is&lt;br/&gt;&amp;gt; not decided when the channel is created.&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; Since f is generic, we can choose f itself to be a universal Turing&lt;br/&gt;&amp;gt; machine. That is, we can imagine a function f(code, data) that executes a&lt;br/&gt;&amp;gt; program (&amp;#34;code&amp;#34;) on the &amp;#34;data&amp;#34; given to it as input.&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; Since we can do fraud proofs on statements &amp;#34;f(code, data) == output&amp;#34;,&lt;br/&gt;&amp;gt; we could build contracts where the &amp;#34;code&amp;#34; itself is chosen later.&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; For example, one could build a universal state channel, where parties&lt;br/&gt;&amp;gt; can enter any contract among themselves (e.g.: start playing a chess game)&lt;br/&gt;&amp;gt; entirely inside the channel. The state of this universal channel would&lt;br/&gt;&amp;gt; contain all the states of the individual contracts that are currently open&lt;br/&gt;&amp;gt; in the channel, and even starting/closing contracts can happen entirely&lt;br/&gt;&amp;gt; off-chain.&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; I believe these constructions are practical (the code of universal&lt;br/&gt;&amp;gt; Turing machines is not really complicated), so it might be worth exploring&lt;br/&gt;&amp;gt; further to figure out useful applications of this approach (supercharging&lt;br/&gt;&amp;gt; lightning?).&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; We should probably start by implementing testnet rock-paper-scissors in&lt;br/&gt;&amp;gt; MATT, though :)&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt;&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; Best,&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; Salvatore Ingala&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; _______________________________________________&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; bitcoin-dev mailing list&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; bitcoin-dev at lists.linuxfoundation.org&lt;br/&gt;&amp;gt; &amp;gt;&amp;gt; &lt;a href=&#34;https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev&#34;&gt;https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev&lt;/a&gt;&lt;br/&gt;&amp;gt; &amp;gt;&lt;br/&gt;&amp;gt; &amp;gt; _______________________________________________&lt;br/&gt;&amp;gt; &amp;gt; bitcoin-dev mailing list&lt;br/&gt;&amp;gt; &amp;gt; bitcoin-dev at lists.linuxfoundation.org&lt;br/&gt;&amp;gt; &amp;gt; &lt;a href=&#34;https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev&#34;&gt;https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev&lt;/a&gt;&lt;br/&gt;&amp;gt;&lt;br/&gt;-------------- next part --------------&lt;br/&gt;An HTML attachment was scrubbed...&lt;br/&gt;URL: &amp;lt;&lt;a href=&#34;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20230501/2f7ae5a8/attachment-0001.html&amp;gt&#34;&gt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20230501/2f7ae5a8/attachment-0001.html&amp;gt&lt;/a&gt;;
    </content>
    <updated>2023-06-08T01:21:07&#43;02:00</updated>
  </entry>

  <entry>
    <id>https://nostr.ae/nevent1qqsvjmhrtlqqd3xzqkvgm9axanpuzkdcvnwpyk2trxm76fxy7rcz9cqzyruxmvc8ag27ea69a3d5t6r2h0uh2kkmc7n9prw2zfzrem0kwxqggs9exyk</id>
    
      <title type="html">📅 Original date posted:2022-11-08 📝 Original message:Hi ...</title>
    
    <link rel="alternate" href="https://nostr.ae/nevent1qqsvjmhrtlqqd3xzqkvgm9axanpuzkdcvnwpyk2trxm76fxy7rcz9cqzyruxmvc8ag27ea69a3d5t6r2h0uh2kkmc7n9prw2zfzrem0kwxqggs9exyk" />
    <content type="html">
      In reply to &lt;a href=&#39;/nevent1qqst5g5eu2qu3ldvjl772jcagc0x5235grtkj5muqj540s9g0c66g4q3a800l&#39;&gt;nevent1q…800l&lt;/a&gt;&lt;br/&gt;_________________________&lt;br/&gt;&lt;br/&gt;📅 Original date posted:2022-11-08&lt;br/&gt;📝 Original message:Hi list,&lt;br/&gt;&lt;br/&gt;I have been working on some notes to describe an approach that uses&lt;br/&gt;covenants in order to enable general smart contracts in bitcoin. You can&lt;br/&gt;find them here:&lt;br/&gt;&lt;br/&gt;    &lt;a href=&#34;https://merkle.fun&#34;&gt;https://merkle.fun&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;The approach has a number of desirable features:&lt;br/&gt;&lt;br/&gt;- small impact to layer 1;&lt;br/&gt;- not application-specific, very general;&lt;br/&gt;- it fits well into P2TR;&lt;br/&gt;- it does not require new cryptographic assumptions, nor any construction&lt;br/&gt;that has not withstood the test of time.&lt;br/&gt;&lt;br/&gt;This content was presented at the BTCAzores unconference, where it received&lt;br/&gt;the name of MATT − short for Merkleize All The Things.&lt;br/&gt;In fact, no other cryptographic primitive is required, other than Merkle&lt;br/&gt;trees.&lt;br/&gt;&lt;br/&gt;I believe this construction gets close to answering the question of how&lt;br/&gt;small a change on bitcoin&amp;#39;s layer 1 would suffice to enable arbitrary smart&lt;br/&gt;contracts.&lt;br/&gt;&lt;br/&gt;It is not yet at the stage where a formal proposal can be made, therefore&lt;br/&gt;the proposed specs are only for illustrative purposes.&lt;br/&gt;&lt;br/&gt;The same content is reformatted below for the mailing list.&lt;br/&gt;&lt;br/&gt;Looking forward to hearing about your comments and improvements.&lt;br/&gt;Salvatore Ingala&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;==========================================&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;# General smart contracts in bitcoin via covenants&lt;br/&gt;&lt;br/&gt;Covenants are UTXOs that are encumbered with restrictions on the outputs of&lt;br/&gt;the transaction spending the UTXO. More formally, we can define a covenant&lt;br/&gt;any UTXO such that at least one of its spending conditions is valid only if&lt;br/&gt;one or more of the outputs’ scriptPubKey satisfies certain restrictions.&lt;br/&gt;&lt;br/&gt;Generally, covenant proposals also add some form of introspection (that is,&lt;br/&gt;the ability for Script to access parts of the inputs/outputs, or the&lt;br/&gt;blockchain history).&lt;br/&gt;&lt;br/&gt;In this note, we want to explore the possibilities unleashed by the&lt;br/&gt;addition of a covenant with the following properties:&lt;br/&gt;&lt;br/&gt;- introspection limited to a single hash attached to the UTXO (the&lt;br/&gt;“covenant data”), and input/output amounts;&lt;br/&gt;- pre-commitment to every possible future script (but not their data);&lt;br/&gt;- few simple opcodes operating with the covenant data.&lt;br/&gt;&lt;br/&gt;We argue that such a simple covenant construction is enough to extend the&lt;br/&gt;power of bitcoin’s layer 1 to become a universal settlement layer for&lt;br/&gt;arbitrary computation.&lt;br/&gt;&lt;br/&gt;Moreover, the covenant can elegantly fit within P2TR transactions, without&lt;br/&gt;any substantial increase for the workload of bitcoin nodes.&lt;br/&gt;&lt;br/&gt;A preliminary version of these notes was presented and discussed at the&lt;br/&gt;BTCAzores Unconference [1], on 23rd September 2022.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;# Preliminaries&lt;br/&gt;&lt;br/&gt;We can think of a smart contract as a “program” that updates a certain&lt;br/&gt;state according to predetermined rules (which typically include access&lt;br/&gt;control by authorizing only certain public keys to perform certain&lt;br/&gt;actions), and that can possibly lock/unlock some coins of the underlying&lt;br/&gt;blockchain according to the same rules.&lt;br/&gt;&lt;br/&gt;The exact definition will be highly dependent on the properties of the&lt;br/&gt;underlying blockchain.&lt;br/&gt;&lt;br/&gt;In bitcoin, the only state upon which all the nodes reach consensus is the&lt;br/&gt;UTXO set; other blockchains might have other data structures as part of the&lt;br/&gt;consensus, like a key-value store that can be updated as a side effect of&lt;br/&gt;transaction execution.&lt;br/&gt;&lt;br/&gt;In this section we explore the following concepts in order to set the&lt;br/&gt;framework for a definition of smart contracts that fits the structure of&lt;br/&gt;bitcoin:&lt;br/&gt;&lt;br/&gt;- the contract’s state: the “memory” the smart contract operates on;&lt;br/&gt;- state transitions: the rules to update the contract’s state;&lt;br/&gt;- covenants: the technical means that can allow contracts to function in&lt;br/&gt;the context of a bitcoin UTXO.&lt;br/&gt;&lt;br/&gt;In the following, an on-chain smart contract is always represented as a&lt;br/&gt;single UTXO that implicitly embeds the contract’s state and possibly&lt;br/&gt;controls some coins that are “locked” in it. More generally, one could&lt;br/&gt;think of smart contracts that are represented in a set of multiple UTXOs;&lt;br/&gt;we leave the exploration of generalizations of the framework to future&lt;br/&gt;research.&lt;br/&gt;&lt;br/&gt;## State&lt;br/&gt;&lt;br/&gt;Any interesting “state” of a smart contract can ultimately be encoded as a&lt;br/&gt;list, where each element is either a bit, a fixed-size integers, or an&lt;br/&gt;arbitrary byte string.&lt;br/&gt;&lt;br/&gt;Whichever the choice, it does not really affect what kinds of computations&lt;br/&gt;are expressible, as long as one is able to perform some basic computations&lt;br/&gt;on those elements.&lt;br/&gt;&lt;br/&gt;In the following, we will assume without loss of generality that&lt;br/&gt;computations happen on a state which is a list of fixed length S = [s_1,&lt;br/&gt;s_2, …, s_n], where each s_i is a byte string.&lt;br/&gt;&lt;br/&gt;### Merkleized state&lt;br/&gt;&lt;br/&gt;By constructing a Merkle tree that has the (hashes of) the elements of S in&lt;br/&gt;the leaves, we can produce a short commitment h_S to the entire list S with&lt;br/&gt;the following properties (that hold for a verifier that only knows h_S):&lt;br/&gt;&lt;br/&gt;- a (log n)-sized proof can prove the value of an element s_i;&lt;br/&gt;- a (log n &#43; |x|)-sized proof can prove the new commitment h_S’, where S’&lt;br/&gt;is a new list obtained by replacing the value of a certain leaf with x.&lt;br/&gt;&lt;br/&gt;This allows to compactly commit to a RAM, and to prove correctness of RAM&lt;br/&gt;updates.&lt;br/&gt;&lt;br/&gt;In other words, a stateful smart contract can represent an arbitrary state&lt;br/&gt;in just a single hash, for example a 32-byte SHA256 output.&lt;br/&gt;&lt;br/&gt;### State transitions and UTXOs&lt;br/&gt;&lt;br/&gt;We can conveniently represent a smart contract as a finite state machine&lt;br/&gt;(FSM), where exactly one node can be active at a given time. Each node has&lt;br/&gt;an associated state as defined above, and a set of transition rules that&lt;br/&gt;define:&lt;br/&gt;&lt;br/&gt;- who can use the rule;&lt;br/&gt;- what is the next active node in the FSM;&lt;br/&gt;- what is the state of the next active node.&lt;br/&gt;&lt;br/&gt;It is then easy to understand how covenants can conveniently represent and&lt;br/&gt;enforce the smart contracts in this framework:&lt;br/&gt;&lt;br/&gt;- The smart contract is instantiated by creating a UTXO encumbered with a&lt;br/&gt;covenant; the smart contract is in the initial node of the FSM.&lt;br/&gt;- The UTXO’s scriptPubKey specifies the current state and the valid&lt;br/&gt;transitions.&lt;br/&gt;- The UTXO(s) produced after a valid transition might or might not be&lt;br/&gt;further encumbered, according to the rules.&lt;br/&gt;&lt;br/&gt;Therefore, what is necessary in order to enable this framework in bitcoin&lt;br/&gt;Script is a covenant that allows the enforcement of such state transitions,&lt;br/&gt;by only allowing outputs that commit to a valid next node (and&lt;br/&gt;corresponding state) in the FSM.&lt;br/&gt;&lt;br/&gt;It is not difficult to show that arbitrary computation is possible over the&lt;br/&gt;committed state, as long as relatively simple arithmetic or logical&lt;br/&gt;operations are available over the state.&lt;br/&gt;&lt;br/&gt;Remark: using an acyclic FSM does not reduce the expressivity of the smart&lt;br/&gt;contracts, as any terminating computation on bounded-size inputs which&lt;br/&gt;requires cycles can be unrolled into an acyclic one.&lt;br/&gt;&lt;br/&gt;### Merkleized state transitions&lt;br/&gt;&lt;br/&gt;Similarly to how using Merkle trees allows to succinctly represent&lt;br/&gt;arbitrary data with a short, 32-byte long summary, the same trick allows to&lt;br/&gt;succinctly represent arbitrary state transitions (the smart contract’s&lt;br/&gt;code) with a single 32-byte hash. Each of the possible state transitions is&lt;br/&gt;encoded as a Script which is put in a leaf of a Merkle tree; the Merkle&lt;br/&gt;root of this tree is a commitment to all the possible state transitions.&lt;br/&gt;This is exactly what the taptree achieves in Taproot (see BIP-0341 [2]).&lt;br/&gt;&lt;br/&gt;Later sections in this document will suggest a possible way of how both the&lt;br/&gt;contract’s state and valid transition rules could be represented in UTXOs.&lt;br/&gt;&lt;br/&gt;## On-chain computation?!&lt;br/&gt;&lt;br/&gt;Should the chain actually do computation?&lt;br/&gt;&lt;br/&gt;If naively designed, the execution of a contract might require a large&lt;br/&gt;number of transactions, which is not feasible.&lt;br/&gt;&lt;br/&gt;While the covenant approach does indeed enable a chain of transactions to&lt;br/&gt;perform arbitrary computation, simple economic considerations will push&lt;br/&gt;protocol designers to perform any non-trivial computation off-chain, and&lt;br/&gt;instead use the blockchain consensus only to verify the computation; or, if&lt;br/&gt;possible, skip the verification altogether.&lt;br/&gt;&lt;br/&gt;The fundamental fact that a blockchain’s layer 1 never actually needs to&lt;br/&gt;run complex programs in order to enable arbitrary complex smart contracting&lt;br/&gt;was observed in the past, for example in a 2016 post by Greg Maxwell [3].&lt;br/&gt;&lt;br/&gt;Vitalik Buterin popularized the concept of &amp;#34;functionality escape velocity&amp;#34;&lt;br/&gt;[4] to signify the minimum amount of functionality required on layer 1 in&lt;br/&gt;order to enable anything else to be built on top (that is, on layer 2 and&lt;br/&gt;beyond).&lt;br/&gt;&lt;br/&gt;In the following section, we will argue that a simple covenant construction&lt;br/&gt;suffices to achieve the functionality escape velocity in the UTXO model.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;# Commitments to computation and fraud challenges&lt;br/&gt;&lt;br/&gt;In this section, we explore how a smart contract that requires any&lt;br/&gt;non-trivial computation f : X --&amp;gt; Y (that is too expensive or not feasible&lt;br/&gt;with on-chain Script state transitions) can be implemented with the simple&lt;br/&gt;covenants described in the previous section.&lt;br/&gt;&lt;br/&gt;The ideas in this section appeared in literature; the reader is referred to&lt;br/&gt;the references for a more comprehensive discussion.&lt;br/&gt;&lt;br/&gt;We want to be able to build contracts that allow conditions of the type&lt;br/&gt;&amp;#34;f(x) = y&amp;#34;; yet, we do not want layer 1 to be forced to perform any&lt;br/&gt;expensive computation.&lt;br/&gt;&lt;br/&gt;In the following, we assume for simplicity that Alice and Bob are the only&lt;br/&gt;participants of the covenant, and they both locked some funds bond_A and&lt;br/&gt;bond_B (respectively) inside the covenant’s UTXO.&lt;br/&gt;&lt;br/&gt;1. Alice posts the statement “f(x) = y”.&lt;br/&gt;2. After a challenge period, if no challenge occurs, Alice is free to&lt;br/&gt;continue and unlock the funds; the statement is true.&lt;br/&gt;3. At any time before the challenge period expires, Bob can start a&lt;br/&gt;challenge: “actually, f(x) = z”.&lt;br/&gt;&lt;br/&gt;In case of a challenge, Alice and Bob enter a challenge resolution&lt;br/&gt;protocol, arbitrated by layer 1; the winner takes the other party’s bond&lt;br/&gt;(details and the exact game theory vary based on the type of protocol the&lt;br/&gt;challenge is part of; choosing the right amount of bonds is crucial for&lt;br/&gt;protocol design).&lt;br/&gt;&lt;br/&gt;The remainder of this section sketches an instantiation of the challenge&lt;br/&gt;protocol.&lt;br/&gt;&lt;br/&gt;## The bisection protocol for arbitrary computation&lt;br/&gt;&lt;br/&gt;In this section, we sketch the challenge protocol for an arbitrary&lt;br/&gt;computation f : X --&amp;gt; Y.&lt;br/&gt;&lt;br/&gt;### Computation trace&lt;br/&gt;&lt;br/&gt;Given the function f, it is possible to decompose the entire computation in&lt;br/&gt;simple elementary steps, each performing a simple, atomic operation. For&lt;br/&gt;example, if the domain of x and y is that of binary strings of a fixed&lt;br/&gt;length, it is possible to create a boolean circuit that takes x and&lt;br/&gt;produces y; in practice, some form of assembly-like language operating on a&lt;br/&gt;RAM might be more efficient and fitting for bitcoin Script.&lt;br/&gt;&lt;br/&gt;In the following, we assume each elementary operation is operating on a&lt;br/&gt;RAM, encoded in the state via Merkle trees as sketched above. Therefore,&lt;br/&gt;one can represent all the steps of the computation as triples tri = (st_i,&lt;br/&gt;op_i, st_{i &#43; 1}), where st_i is the state (e.g. a canonical Merkle tree of&lt;br/&gt;the RAM) before the i-th operation, st_{i &#43; 1} is the state after, and op_i&lt;br/&gt;is the description of the operation (implementation-specific; it could be&lt;br/&gt;something like “add a to b and save the result in c).&lt;br/&gt;&lt;br/&gt;Finally, a Merkle tree M_T is constructed that has as leaves the values of&lt;br/&gt;the individual computation steps T = {tr_0, tr_1, …, tr_{N - 1}} if the&lt;br/&gt;computation requires N steps, producing the Merkle root h_T. The height of&lt;br/&gt;the Merkle tree is log N. Observe that each internal node commits to the&lt;br/&gt;portion of the computation trace corresponding to its own subtree.&lt;br/&gt;&lt;br/&gt;Let’s assume that the Merkle tree commitments for internal nodes are&lt;br/&gt;further augmented with the states st_{start} and st_{end}, respectively the&lt;br/&gt;state before the operation of in the leftmost leaf of the subtree, and&lt;br/&gt;after the rightmost leaf of the subtree.&lt;br/&gt;&lt;br/&gt;### Bisection protocol&lt;br/&gt;&lt;br/&gt;The challenge protocol begins with Alice posting what she claims is the&lt;br/&gt;computation trace h_A, while Bob disagrees with the trace h_B != h_A;&lt;br/&gt;therefore, the challenge starts at the root of M_T, and proceeds in steps&lt;br/&gt;in order to find a leaf where Alice and Bob disagree (which is guaranteed&lt;br/&gt;to exist, hence the disagreement). Note that the arbitration mechanism&lt;br/&gt;knows f, x and y, but not the correct computation trace hash h_T.&lt;br/&gt;&lt;br/&gt;(Bisection phase): While the challenge is at a non-leaf node of M_T, Alice&lt;br/&gt;and Bob take turns to post the two hashes corresponding to the left and&lt;br/&gt;right child of their claimed computation trace hash; moreover, they post&lt;br/&gt;the start/end state for each child node. The protocol enforces that Alice’s&lt;br/&gt;transaction is only valid if the posted hashes h_{l; A} and h_{r; A}, and&lt;br/&gt;the declared start/end state for each child are consistent with the&lt;br/&gt;commitment in the current node.&lt;br/&gt;&lt;br/&gt;(Arbitration phase): If the protocol has reached the i-th leaf node, then&lt;br/&gt;each party reveals (st_i, op_i, st_{i &#43; 1}); in fact, only the honest party&lt;br/&gt;will be able to reveal correct values, therefore the protocol can&lt;br/&gt;adjudicate the winner.&lt;br/&gt;&lt;br/&gt;Remark: there is definitely a lot of room for optimizations; it is left for&lt;br/&gt;future work to find the optimal variation of the approach; moreover,&lt;br/&gt;different challenge mechanisms could be more appropriate for different&lt;br/&gt;functions f.&lt;br/&gt;&lt;br/&gt;### Game theory (or why the chain will not see any of this)&lt;br/&gt;&lt;br/&gt;With the right economic incentives, protocol designers can guarantee that&lt;br/&gt;playing a losing game always loses money compared to cooperating.&lt;br/&gt;Therefore, the challenge game is never expected to be played on-chain. The&lt;br/&gt;size of the bonds need to be appropriate to disincentivize griefing attacks.&lt;br/&gt;&lt;br/&gt;### Implementing the bisection protocol&amp;#39;s state transitions&lt;br/&gt;&lt;br/&gt;It is not difficult to see that the entire challenge-response protocol&lt;br/&gt;above can be implemented using the simple state transitions described above.&lt;br/&gt;&lt;br/&gt;Before a challenge begins, the state of the covenant contains the value of&lt;br/&gt;x, y and the computation trace computed by Alice. When starting the&lt;br/&gt;challenge, Bob also adds its claim for the correct computation trace, and&lt;br/&gt;the covenant enters the bisection phase.&lt;br/&gt;&lt;br/&gt;During the bisaction phase, the covenant contains the claimed computation&lt;br/&gt;trace for that node of the computation protocol, according to each party.&lt;br/&gt;In turns, each party has to reveal the corresponding computation trace for&lt;br/&gt;both the children of the current node; the transaction is only valid if the&lt;br/&gt;hash of the current node can be computed correctly from the information&lt;br/&gt;provided by each party about the child nodes. The protocol repeats on one&lt;br/&gt;of the two child nodes on whose computation trace the two parties disagree&lt;br/&gt;(which is guaranteed to exist). If a leaf of M_T is reached, the covenant&lt;br/&gt;enters the final arbitration phase.&lt;br/&gt;&lt;br/&gt;During the arbitration phase (say at the i-th leaf node of M_T), any party&lt;br/&gt;can win the challenge by providing correct values for tr_i = (st_i, op_i,&lt;br/&gt;st_{i &#43; 1}). Crucially, only one party is able to provide correct values,&lt;br/&gt;and Script can verify that indeed the state moves from st_i to st_{i &#43; 1}&lt;br/&gt;by executing op_i. The challenge is over.&lt;br/&gt;&lt;br/&gt;At any time, the covenant allows one player to automatically win the&lt;br/&gt;challenge after a certain timeout if the other party (who is expected to&lt;br/&gt;“make his move”) does not spend the covenant. This guarantees that the&lt;br/&gt;protocol can always find a resolution.&lt;br/&gt;&lt;br/&gt;### Security model&lt;br/&gt;&lt;br/&gt;As for other protocols (like the lightning network), a majority of miners&lt;br/&gt;can allow a player to win a challenge by censoring the other player’s&lt;br/&gt;transactions. Therefore, the bisection protocol operates under the honest&lt;br/&gt;miner majority assumption. This is acceptable for many protocols, but it&lt;br/&gt;should certainly be taken into account during protocol design.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;# MATT covenants&lt;br/&gt;&lt;br/&gt;We argued that the key to arbitrary, fully general smart contracts in the&lt;br/&gt;UTXO model is to use Merkle trees, at different levels:&lt;br/&gt;&lt;br/&gt;1. succinctly represent arbitrary state with a single hash. Merkleize the&lt;br/&gt;state!&lt;br/&gt;2. succinctly represent the possible state transitions with a single hash.&lt;br/&gt;Merkleize the Script!&lt;br/&gt;3. succinctly represent arbitrary computations with a single hash.&lt;br/&gt;Merkleize the execution!&lt;br/&gt;&lt;br/&gt;(1) and (2) alone allow contracts with arbitrary computations; (3) makes&lt;br/&gt;them scale.&lt;br/&gt;&lt;br/&gt;   Merkleize All The Things!&lt;br/&gt;&lt;br/&gt;In this section we sketch a design of covenant opcodes that are&lt;br/&gt;taproot-friendly and could easily be added in a soft fork to the existing&lt;br/&gt;SegWitv1 Script.&lt;br/&gt;&lt;br/&gt;## Embedding covenant data in P2TR outputs&lt;br/&gt;&lt;br/&gt;We can take advantage of the double-commitment structure of taproot outputs&lt;br/&gt;(that is, committing to both a public key and a Merkle tree of scripts) to&lt;br/&gt;compactly encode both the covenant and the state transition rules inside&lt;br/&gt;taproot outputs.&lt;br/&gt;&lt;br/&gt;The idea is to replace the internal pubkey Q with a key Q’ obtained by&lt;br/&gt;tweaking Q with the covenant data (the same process that is used to commit&lt;br/&gt;to the root of the taptree). More precisely, if d is the data committed to&lt;br/&gt;the covenant, the covenant-data-augmented internal key Q’ is defined as:&lt;br/&gt;&lt;br/&gt;    Q’ = Q &#43; int(hashTapCovenantData(Q || h_{data}))G&lt;br/&gt;&lt;br/&gt;where h_{data} is the sha256-hash of the covenant data. It is then easy to&lt;br/&gt;prove that the point is constructed in this way, by repeating the&lt;br/&gt;calculation.&lt;br/&gt;&lt;br/&gt;If there is no useful key path spend, similarly to what is suggested in&lt;br/&gt;BIP-0341 [5] for the case of scripts with no key path spends, we can use&lt;br/&gt;the NUMS point:&lt;br/&gt;    H =&lt;br/&gt;lift_x(0x0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0).&lt;br/&gt;&lt;br/&gt;TODO: please double check if the math above is sound.&lt;br/&gt;&lt;br/&gt;## Changes to Script&lt;br/&gt;&lt;br/&gt;The following might be some minimal new opcodes to add for taproot&lt;br/&gt;transactions in order to enable the construction above. This is a very&lt;br/&gt;preliminary proposal, and not yet complete nor correct.&lt;br/&gt;&lt;br/&gt;- OP_SHA256CAT: returns the SHA256 hash of the concatenation of the second&lt;br/&gt;and the first (top) element of the stack. (redundant if OP_CAT is enabled,&lt;br/&gt;even just on operands with total length up to 64 bytes)&lt;br/&gt;- OP_CHECKINPUTCOVENANTVERIFY: let x, d be the two top elements of the&lt;br/&gt;stack; behave like OP_SUCCESS if any of x and d is not exactly 32 bytes;&lt;br/&gt;otherwise, check that the x is a valid x-only pubkey, and the internal&lt;br/&gt;pubkey P is indeed obtained by tweaking lift_x(x) with d.&lt;br/&gt;- OP_INSPECTNUMINPUTS, OP_INSPECTNUMOUTPUTS, OP_INSPECTINPUTVALUE and&lt;br/&gt;OP_INSPECTOUTPUTVALUE - opcodes to push number on the stack of&lt;br/&gt;inputs/outputs and their amounts.&lt;br/&gt;- OP_CHECKOUTPUTCOVENANTVERIFY: given a number out_i and three 32-byte hash&lt;br/&gt;elements x, d and taptree on top of the stack, verifies that the out_i-th&lt;br/&gt;output is a P2TR output with internal key computed as above, and tweaked&lt;br/&gt;with taptree. This is the actual covenant opcode.&lt;br/&gt;&lt;br/&gt;TODO:&lt;br/&gt;&lt;br/&gt;- Many contracts need parties to provide additional data; simply passing it&lt;br/&gt;via the witness faces the problem that it could be malleated. Therefore, a&lt;br/&gt;way of passing signed data is necessary. One way to address this problem&lt;br/&gt;could be to add a commitment to the data in the annex, and add an opcode to&lt;br/&gt;verify such commitment. Since the annex is covered by the signature, this&lt;br/&gt;removes any malleability. Another option is an OP_CHECKSIGFROMSTACK opcode,&lt;br/&gt;but that would cost an additional signature check.&lt;br/&gt;- Bitcoin numbers in current Script are not large enough for amounts.&lt;br/&gt;&lt;br/&gt;Other observations:&lt;br/&gt;&lt;br/&gt;- OP_CHECKINPUTCOVENANTVERIFY and OP_CHECKOUTPUTCOVENANTVERIFY could have a&lt;br/&gt;mode where x is replaced with a NUMS pubkey, for example if the first&lt;br/&gt;operand is an empty array of bytes instead of a 32 byte pubkey; this saves&lt;br/&gt;about 31 bytes when no internal pubkey is needed (so about 62 bytes for a&lt;br/&gt;typical contract transition using both opcodes)&lt;br/&gt;- Is it worth adding other introspection opcodes, for example&lt;br/&gt;OP_INSPECTVERSION, OP_INSPECTLOCKTIME? See Liquid&amp;#39;s Tapscript Opcodes [6].&lt;br/&gt;- Is there any malleability issue? Can covenants “run” without signatures,&lt;br/&gt;or is a signature always to be expected when using spending conditions with&lt;br/&gt;the covenant encumbrance? That might be useful in contracts where no&lt;br/&gt;signature is required to proceed with the protocol (for example, any party&lt;br/&gt;could feed valid data to the bisection protocol above).&lt;br/&gt;- Adding some additional opcodes to manipulate stack elements might also&lt;br/&gt;bring performance improvements in applications (but not strictly necessary&lt;br/&gt;for feasibility).&lt;br/&gt;&lt;br/&gt;Remark: the additional introspection opcodes available in Blockstream&lt;br/&gt;Liquid [6] do indeed seem to allow MATT covenants; in fact, the opcodes&lt;br/&gt;OP_CHECKINPUTCOVENANTVERIFY and OP_CHECKOUTPUTCOVENANTVERIFY could be&lt;br/&gt;replaced by more general opcodes like the group {OP_TWEAKVERIFY,&lt;br/&gt;OP_INSPECTINPUTSCRIPTPUBKEY, OP_PUSHCURRENTINPUTINDEX,&lt;br/&gt;OP_INSPECTOUTPUTSCRIPTPUBKEY }.&lt;br/&gt;&lt;br/&gt;### Variant: bounded recursivity&lt;br/&gt;&lt;br/&gt;In the form described above, the covenant essentially allows fully&lt;br/&gt;recursive constructions (an arbitrary depth of the covenant execution tree&lt;br/&gt;is in practice equivalent to full recursion).&lt;br/&gt;&lt;br/&gt;If recursivity is not desired, one could modify the covenants in a way that&lt;br/&gt;only allows a limited depth: a counter could be attached to the covenant,&lt;br/&gt;with the constraint that the counter must be decreased for&lt;br/&gt;OP_CHECKOUTPUTCOVENANTVERIFY. That would still allow arbitrary fraud proofs&lt;br/&gt;as long as the maximum depth is sufficient.&lt;br/&gt;&lt;br/&gt;However, that would likely reduce its utility and prevent certain&lt;br/&gt;applications where recursivity seems to be a requirement.&lt;br/&gt;&lt;br/&gt;The full exploration of the design space is left for future research.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;# Applications&lt;br/&gt;&lt;br/&gt;This section explores some of the potential use cases of the techniques&lt;br/&gt;presented above. The list is not exhaustive.&lt;br/&gt;&lt;br/&gt;Given the generality of fraud proofs, some variant of every kind of smart&lt;br/&gt;contracts or layer two construction should be possible with MATT covenants,&lt;br/&gt;although the additional requirements (for example the capital lockup and&lt;br/&gt;the challenge period delays) needs to be accurately considered; further&lt;br/&gt;research is necessary to assess for what applications the tradeoffs are&lt;br/&gt;acceptable.&lt;br/&gt;&lt;br/&gt;## State channels&lt;br/&gt;&lt;br/&gt;A state channel is a generalization of a payment channel where,&lt;br/&gt;additionally to the balance at the end of each channel, some additional&lt;br/&gt;state is stored. The state channel also specifies what are the rules on how&lt;br/&gt;to update the channel’s state.&lt;br/&gt;&lt;br/&gt;For example, two people might play a chess game, where the state encodes&lt;br/&gt;the current configuration of the board. The valid state transitions&lt;br/&gt;correspond to the valid moves; and, once the game is over, the winner takes&lt;br/&gt;a specified amount of the channel’s money.&lt;br/&gt;&lt;br/&gt;With eltoo-style updates, such a game could be played entirely off-chain,&lt;br/&gt;as long as both parties are cooperating (by signing the opponent’s state&lt;br/&gt;update).&lt;br/&gt;&lt;br/&gt;The role of the blockchain is to guarantee that the game can be moved&lt;br/&gt;forward and eventually terminated in case the other party does not&lt;br/&gt;cooperate.&lt;br/&gt;&lt;br/&gt;In stateful blockchain, this is simply achieved by publishing the latest&lt;br/&gt;state (Merkleized or not) and then continuing the entire game on-chain.&lt;br/&gt;This is expensive, especially if the state transitions require some complex&lt;br/&gt;computation.&lt;br/&gt;&lt;br/&gt;An alternative that avoids moving computations on-chain is the use of a&lt;br/&gt;challenge-response protocol, as sketched above.&lt;br/&gt;&lt;br/&gt;Similarly to the security model of lightning channels, an honest party can&lt;br/&gt;always win a challenge under the honest-majority of miners. Therefore, it&lt;br/&gt;is game-theoretically losing to attempt cheating in a channel.&lt;br/&gt;&lt;br/&gt;## CoinPool&lt;br/&gt;&lt;br/&gt;Multiparty state channels are possible as well; therefore, constructions&lt;br/&gt;like CoinPool [7] should be possible, enabling multiple parties to share a&lt;br/&gt;single UTXO.&lt;br/&gt;&lt;br/&gt;## Zero knowledge proofs in L2 protocols&lt;br/&gt;&lt;br/&gt;Protocols based on ZK-proofs require the blockchain to be the verifier; the&lt;br/&gt;verifier is a function that takes a zero-knowledge proof and returns&lt;br/&gt;true/false based on its correctness.&lt;br/&gt;&lt;br/&gt;Instead of an OP_STARK operator in L1, one could think of compiling the&lt;br/&gt;OP_STARK as the function f in the protocol above.&lt;br/&gt;&lt;br/&gt;Note that covenants with a bounded “recursion depth” are sufficient to&lt;br/&gt;express OP_STARK, which in turns imply the ability to express arbitrary&lt;br/&gt;functions within contracts using the challenge protocol.&lt;br/&gt;&lt;br/&gt;One advantage of this approach is that no new cryptographic assumptions are&lt;br/&gt;added to bitcoin’s layer 1 even if OP_STARK does require it; moreover, if a&lt;br/&gt;different or better OP_STARK2 is discovered, the innovation can reach layer&lt;br/&gt;2 contracts without any change needed in layer 1.&lt;br/&gt;&lt;br/&gt;## Optimistic rollups&lt;br/&gt;&lt;br/&gt;John Light recently posted a research report on how Validity Rollups could&lt;br/&gt;be added to bitcoin’s layer 1 [8]. While no exact proposal is pushed&lt;br/&gt;forward, the suggested changes required might include a combination of&lt;br/&gt;recursive covenants, and specific opcodes for validity proof verification.&lt;br/&gt;&lt;br/&gt;Fraud proofs are the core for optimistic rollups; exploring the possibility&lt;br/&gt;of implementing optimistic rollups with MATT covenants seems a promising&lt;br/&gt;direction. Because of the simplicity of the required changes to Script,&lt;br/&gt;this might answer some of the costs and risks analyzed in the report, while&lt;br/&gt;providing many of the same benefits. Notably, no novel cryptography needs&lt;br/&gt;to become part of bitcoin’s layer 1.&lt;br/&gt;&lt;br/&gt;Optimistic Rollups would probably require a fully recursive version of the&lt;br/&gt;covenant (while fraud proofs alone are possible with a limited recursion&lt;br/&gt;depth).&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;# Acknowledgments&lt;br/&gt;&lt;br/&gt;Antoine Poinsot suggested an improvement to the original proposed covenant&lt;br/&gt;opcodes, which were limited to taproot outputs without a valid key-path&lt;br/&gt;spend.&lt;br/&gt;&lt;br/&gt;The author would also like to thank catenocrypt, Antoine Riard, Ruben&lt;br/&gt;Somsen and the participants of the BTCAzores unconference for many useful&lt;br/&gt;discussions and comments on early versions of this proposal.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;# References&lt;br/&gt;&lt;br/&gt;The core idea of the bisection protocol appears to have been independently&lt;br/&gt;rediscovered multiple times. In blockchain research, it is at the core of&lt;br/&gt;fraud proof constructions with similar purposes, although not focusing on&lt;br/&gt;bitcoin or covenants; see for example:&lt;br/&gt;&lt;br/&gt;- Harry Kalodner et al. “Arbitrum: Scalable, private smart contracts.” −&lt;br/&gt;27th USENIX Security Symposium. 2018.&lt;br/&gt;&lt;a href=&#34;https://www.usenix.org/system/files/conference/usenixsecurity18/sec18-kalodner.pdf&#34;&gt;https://www.usenix.org/system/files/conference/usenixsecurity18/sec18-kalodner.pdf&lt;/a&gt;&lt;br/&gt;- Jason Teutsch and Christian Reitwiessner. “A scalable verification&lt;br/&gt;solution for blockchains” − TrueBit protocol. 2017.&lt;br/&gt;&lt;a href=&#34;https://people.cs.uchicago.edu/~teutsch/papers/truebit.pdf&#34;&gt;https://people.cs.uchicago.edu/~teutsch/papers/truebit.pdf&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;The same basic idea was already published prior to blockchain use cases;&lt;br/&gt;see for example:&lt;br/&gt;&lt;br/&gt;Ran Canetti, Ben Riva, and Guy N. Rothblum. “Practical delegation of&lt;br/&gt;computation using multiple servers.” − Proceedings of the 18th ACM&lt;br/&gt;conference on Computer and communications security. 2011.&lt;br/&gt;&lt;a href=&#34;http://diyhpl.us/~bryan/papers2/bitcoin/Practical%20delegation%20of%20computation%20using%20multiple%20servers.pdf&#34;&gt;http://diyhpl.us/~bryan/papers2/bitcoin/Practical%20delegation%20of%20computation%20using%20multiple%20servers.pdf&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;# Footnotes&lt;br/&gt;&lt;br/&gt;[1] - &lt;a href=&#34;https://btcazores.com&#34;&gt;https://btcazores.com&lt;/a&gt;&lt;br/&gt;[2] - &lt;a href=&#34;https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki&#34;&gt;https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki&lt;/a&gt;&lt;br/&gt;[3] -&lt;br/&gt;&lt;a href=&#34;https://bitcointalk.org/index.php?topic=1427885.msg14601127#msg14601127&#34;&gt;https://bitcointalk.org/index.php?topic=1427885.msg14601127#msg14601127&lt;/a&gt;&lt;br/&gt;[4] - &lt;a href=&#34;https://vitalik.ca/general/2019/12/26/mvb.html&#34;&gt;https://vitalik.ca/general/2019/12/26/mvb.html&lt;/a&gt;&lt;br/&gt;[5] -&lt;br/&gt;&lt;a href=&#34;https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#constructing-and-spending-taproot-outputs&#34;&gt;https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#constructing-and-spending-taproot-outputs&lt;/a&gt;&lt;br/&gt;[6] -&lt;br/&gt;&lt;a href=&#34;https://github.com/ElementsProject/elements/blob/master/doc/tapscript_opcodes.md&#34;&gt;https://github.com/ElementsProject/elements/blob/master/doc/tapscript_opcodes.md&lt;/a&gt;&lt;br/&gt;[7] - &lt;a href=&#34;https://coinpool.dev/v0.1.pdf&#34;&gt;https://coinpool.dev/v0.1.pdf&lt;/a&gt;&lt;br/&gt;[8] - &lt;a href=&#34;https://bitcoinrollups.org&#34;&gt;https://bitcoinrollups.org&lt;/a&gt;&lt;br/&gt;-------------- next part --------------&lt;br/&gt;An HTML attachment was scrubbed...&lt;br/&gt;URL: &amp;lt;&lt;a href=&#34;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20221108/d6f2d8a3/attachment-0001.html&amp;gt&#34;&gt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20221108/d6f2d8a3/attachment-0001.html&amp;gt&lt;/a&gt;;
    </content>
    <updated>2023-06-08T01:16:50&#43;02:00</updated>
  </entry>

  <entry>
    <id>https://nostr.ae/nevent1qqswx5yhry30kfzndda2k2qtjmzkx75l05ksl6s584pdt02ql5gnpuszyruxmvc8ag27ea69a3d5t6r2h0uh2kkmc7n9prw2zfzrem0kwxqgg9wxffg</id>
    
      <title type="html">📅 Original date posted:2021-06-28 📝 Original message:Hi ...</title>
    
    <link rel="alternate" href="https://nostr.ae/nevent1qqswx5yhry30kfzndda2k2qtjmzkx75l05ksl6s584pdt02ql5gnpuszyruxmvc8ag27ea69a3d5t6r2h0uh2kkmc7n9prw2zfzrem0kwxqgg9wxffg" />
    <content type="html">
      In reply to &lt;a href=&#39;/nevent1qqs9xyr9gc0lk44zexwpymmdycgf483xyx8l7tcl6l0en3gsnxfqs4ghakfpf&#39;&gt;nevent1q…kfpf&lt;/a&gt;&lt;br/&gt;_________________________&lt;br/&gt;&lt;br/&gt;📅 Original date posted:2021-06-28&lt;br/&gt;📝 Original message:Hi Andrew,&lt;br/&gt;&lt;br/&gt;I just have a small suggestion on this proposal.&lt;br/&gt;&lt;br/&gt;On Tue, 22 Jun 2021 at 23:29, Andrew Chow via bitcoin-dev &amp;lt;&lt;br/&gt;bitcoin-dev at lists.linuxfoundation.org&amp;gt; wrote:&lt;br/&gt;&lt;br/&gt;&amp;gt; | Taproot Leaf Script&lt;br/&gt;&amp;gt; | &amp;lt;tt&amp;gt;PSBT_IN_TAP_LEAF_SCRIPT = 0x15&amp;lt;/tt&amp;gt;&lt;br/&gt;&amp;gt; | &amp;lt;tt&amp;gt;&amp;lt;control block&amp;gt;&amp;lt;/tt&amp;gt;&lt;br/&gt;&amp;gt; | The control block for this leaf as specified in BIP 341. The control&lt;br/&gt;&amp;gt; block contains the merkle tree path to this leaf.&lt;br/&gt;&amp;gt; | &amp;lt;tt&amp;gt;&amp;lt;script&amp;gt; &amp;lt;8-bit uint&amp;gt;&amp;lt;/tt&amp;gt;&lt;br/&gt;&amp;gt; | The script for this leaf as would be provided in the witness stack&lt;br/&gt;&amp;gt; followed by the single byte leaf version.&lt;br/&gt;&amp;gt;&lt;br/&gt;&lt;br/&gt;So far, all the defined PSBT types had a relatively short keydata (not much&lt;br/&gt;bigger than a couple of pubkeys).&lt;br/&gt;I think that is a desirable property to keep, as it is often a reasonable&lt;br/&gt;assumption that dictionary keys are not very large.&lt;br/&gt;The control block as per BIP 341 can be up to 33 &#43; 32*128 = 4129 bytes long.&lt;br/&gt;&lt;br/&gt;Perhaps it would be better to split this into PSBT_IN_TAP_LEAF_SCRIPT&lt;br/&gt;and PSBT_IN_TAP_LEAF_CONTROL_BLOCK (both with no keydata)?&lt;br/&gt;&lt;br/&gt;Best,&lt;br/&gt;Salvatore Ingala&lt;br/&gt;-------------- next part --------------&lt;br/&gt;An HTML attachment was scrubbed...&lt;br/&gt;URL: &amp;lt;&lt;a href=&#34;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20210628/ce41048c/attachment.html&amp;gt&#34;&gt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20210628/ce41048c/attachment.html&amp;gt&lt;/a&gt;;
    </content>
    <updated>2023-06-08T00:55:20&#43;02:00</updated>
  </entry>

  <entry>
    <id>https://nostr.ae/nevent1qqsy7pkqvcjzd4h9quz7rl00l0sj60nh59hhhdquacrv04gdr5qa39szyruxmvc8ag27ea69a3d5t6r2h0uh2kkmc7n9prw2zfzrem0kwxqggfjrehc</id>
    
      <title type="html">📅 Original date posted:2021-04-12 📝 Original message:Hi ...</title>
    
    <link rel="alternate" href="https://nostr.ae/nevent1qqsy7pkqvcjzd4h9quz7rl00l0sj60nh59hhhdquacrv04gdr5qa39szyruxmvc8ag27ea69a3d5t6r2h0uh2kkmc7n9prw2zfzrem0kwxqggfjrehc" />
    <content type="html">
      In reply to &lt;a href=&#39;/nevent1qqsyth5hwrfvmhgk9hv3a0d053yr9vfxdr80urenk2t2w3qc8ej8m4sdl6x23&#39;&gt;nevent1q…6x23&lt;/a&gt;&lt;br/&gt;_________________________&lt;br/&gt;&lt;br/&gt;📅 Original date posted:2021-04-12&lt;br/&gt;📝 Original message:Hi Hugo,&lt;br/&gt;&lt;br/&gt;First of all, thank you for the impressive work on leading the&lt;br/&gt;standardization efforts!&lt;br/&gt;&lt;br/&gt;I believe one ought to more clearly distinguish the &amp;#34;Signer&amp;#34; (as in: one of&lt;br/&gt;the parties in the multisig setup), from the &amp;#34;*Signing device*&amp;#34; (which is&lt;br/&gt;likely a hardware wallet). BSMS defines a &amp;#34;Signer&amp;#34; as &amp;#34;a participating&lt;br/&gt;member in the multisig&amp;#34;,  therefore a person/entity who is likely using&lt;br/&gt;both a hardware wallet and some BSMS-friendly software wallet (e.g. the&lt;br/&gt;next version of Specter Desktop). It is therefore relevant to discuss which&lt;br/&gt;parts of the BSMS mechanism are implemented in the Signer&amp;#39;s software&lt;br/&gt;wallet, and which should be in the Signer&amp;#39;s hardware wallet.&lt;br/&gt;&amp;gt;From the discussion, it appears to me that different people might have&lt;br/&gt;different expectations on what the signing device/HWW should do, so I would&lt;br/&gt;like to comment on this point specifically (while I reckon that it mostly&lt;br/&gt;falls within the realm of concerns #4 and #5 of the motivation paragraph,&lt;br/&gt;which are explicitly left out of scope).&lt;br/&gt;&lt;br/&gt;I fully agree that a *Signer* must persist the full wallet&amp;#39;s description,&lt;br/&gt;and should also create physical backups which include the full descriptor&lt;br/&gt;and the cosigner&amp;#39;s information. I would disagree, however, if any standards&lt;br/&gt;were to force *hardware wallets* to persist any substantial amount of state&lt;br/&gt;other than the seed, as I believe that it gives no substantial advantage&lt;br/&gt;over externally stored signed data for many use cases.&lt;br/&gt;&lt;br/&gt;The following is the *wallet registration flow* I am currently working on&lt;br/&gt;(in the context of adding support to multisig wallets at Ledger). The goal&lt;br/&gt;is to allow a *Signer* (the person) to persist a multisig setup in its&lt;br/&gt;storage, while achieving a similar level of security you would have if you&lt;br/&gt;were storing it on the hardware wallet itself (note that the following flow&lt;br/&gt;would happen as part of Round 2):&lt;br/&gt;&lt;br/&gt;1) The desktop wallet of the requests the HWW to register a new multisig&lt;br/&gt;wallet. The request includes the full multisig wallet description, and some&lt;br/&gt;extra metadata (e.g.: a name to be associated to this multisig wallet).&lt;br/&gt;2) The HWW validates the wallet and verifies it with the user with the&lt;br/&gt;trusted screen (as per BSMS Round 2); on confirmation, it returns a wallet&lt;br/&gt;id (which is a vendor-specific hash of all the wallet description &#43;&lt;br/&gt;metadata) and signature&lt;br/&gt;3) The desktop wallet stores the full wallet description/id/signature.&lt;br/&gt;(Optionally, a backup could be stored elsewhere).&lt;br/&gt;&lt;br/&gt;Whenever an operation related to the multisig wallet is required (verifying&lt;br/&gt;a receiving address, or signing a spending transaction), the HWW first&lt;br/&gt;receives and verifies all the data stored at step 3 above (without any user&lt;br/&gt;interaction). Then it proceeds exactly the same way as if it had always&lt;br/&gt;stored the multisig wallet in their own storage. I think this is basically&lt;br/&gt;the same flow Michael Flaxman is suggesting here:&lt;br/&gt;&lt;a href=&#34;https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2021-April/018775.html&#34;&gt;https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2021-April/018775.html&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;(Note that none of this is flow specific to Multisig wallet, as the same&lt;br/&gt;flow would be unchanged for any arbitrary supported script that needs to be&lt;br/&gt;&amp;#34;registered&amp;#34; on a stateless device, and can be generalized for MPC&lt;br/&gt;protocols)&lt;br/&gt;&lt;br/&gt;The only caveat I can think of is that the script registration is never&lt;br/&gt;revocable if a signing key derived from the seed is used in step (2), which&lt;br/&gt;might or might not be desirable. One could instead prefer to use a&lt;br/&gt;different signing key that is destroyed if the device is wiped, which would&lt;br/&gt;therefore need to be stored on the device. Note that the only thing that is&lt;br/&gt;lost is the on-device multisig wallet registration, which could easily be&lt;br/&gt;repeated from a backup.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;On Sun, 11 Apr 2021 at 19:11, Hugo Nguyen via bitcoin-dev &amp;lt;&lt;br/&gt;bitcoin-dev at lists.linuxfoundation.org&amp;gt; wrote:&lt;br/&gt;&lt;br/&gt;&amp;gt; I reiterate that I strongly disagree that going stateless is the direction&lt;br/&gt;&amp;gt; we want to pursue when it comes to multisig.&lt;br/&gt;&amp;gt;&lt;br/&gt;&amp;gt; In a multisig or any type of MPC smart contract, any Signer in the&lt;br/&gt;&amp;gt; contract must know who the other co-Signers are at all times. You can&lt;br/&gt;&amp;gt; choose to do this verification once at setup and persist this info on the&lt;br/&gt;&amp;gt; Signer, or you&amp;#39;d have to re-do the verification for every single&lt;br/&gt;&amp;gt; transaction. There is no other choice.&lt;br/&gt;&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;gt;&lt;br/&gt;Signing the descriptor record is insufficient, while also introducing a&lt;br/&gt;&amp;gt; great deal of complexity. Here are the problems:&lt;br/&gt;&amp;gt; 1) The signature needs to be stored somewhere. Who stores it if it&amp;#39;s not&lt;br/&gt;&amp;gt; the Signer itself? What if it gets lost? (If the Signer stores its own&lt;br/&gt;&amp;gt; signature, then the scheme is no longer stateless. You might as well store&lt;br/&gt;&amp;gt; the full descriptor).&lt;br/&gt;&amp;gt;&lt;br/&gt;&lt;br/&gt;In the flow I describe above, the desktop wallet would indeed store the&lt;br/&gt;signed descriptor record and wallet metadata. So yes, the *Signer* as in *the&lt;br/&gt;party in the protocol* stores it, but not the signing device*. *The same&lt;br/&gt;method could be used to store state temporarily between round 1 and 2,&lt;br/&gt;where the only *state* on the hardware wallet would be the TOKEN, while&lt;br/&gt;everything else is stored (encrypted and signed) on the Signer&amp;#39;s desktop.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&amp;gt; 2) When the signature is &amp;#34;played back&amp;#34; to the Signer, a copy of the&lt;br/&gt;&amp;gt; original descriptor must be included. Who stores the descriptor? What if it&lt;br/&gt;&amp;gt; gets lost? This is an under-appreciated aspect of the stateful approach:&lt;br/&gt;&amp;gt; every participant in the multisig has a full copy of the original contract,&lt;br/&gt;&amp;gt; which adds resilience to the wallet backup / recovery process.&lt;br/&gt;&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;#34;Playing back&amp;#34; the signature and wallet&amp;#39;s setup data to the hardware wallet&lt;br/&gt;would indeed happen transparently from the Signer&amp;#39;s wallet software. If the&lt;br/&gt;Signer lost this data due to malware, faulty hardware, etc., the user would&lt;br/&gt;indeed have to recover from backup, which seems ok to me.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&amp;gt; 3) Because the full descriptor must be &amp;#34;played back&amp;#34; for every single&lt;br/&gt;&amp;gt; transaction, this means every detail of the contract must be shared again&lt;br/&gt;&amp;gt; and again, indefinitely. Not only does this add overhead (engineering and&lt;br/&gt;&amp;gt; cognitive) to the spending process, it has massive privacy implications,&lt;br/&gt;&amp;gt; since the descriptor contains everything you need to know about the wallets&lt;br/&gt;&amp;gt; and its participants.&lt;br/&gt;&amp;gt;&lt;br/&gt;&lt;br/&gt;I agree with some of these concerns, but I observe:&lt;br/&gt;- The engineering overhead in handling externally-stored-signed-data is&lt;br/&gt;paid once, and would mostly fall on the hardware wallet vendor. External&lt;br/&gt;software only cares about storing certain data and sending it back later.&lt;br/&gt;- Storing xpubs/descriptors in the desktop software that interacts with&lt;br/&gt;the HWW is already common practice, and necessary for using any watch-only&lt;br/&gt;wallet.&lt;br/&gt;&lt;br/&gt;Summarizing, I argue that the stateful/stateless characteristic of a&lt;br/&gt;hardware wallet does not really affect (modulo some extra work) the ability&lt;br/&gt;to participate in the BSMS ceremony, whose *Signers* should indeed be&lt;br/&gt;stateful.&lt;br/&gt;Some more clarifications on the trust assumptions might help at clarifying&lt;br/&gt;the best possible software/hardware implementation tradeoffs, either in&lt;br/&gt;this or a follow-up BIP.&lt;br/&gt;&lt;br/&gt;Best,&lt;br/&gt;Salvatore Ingala&lt;br/&gt;-------------- next part --------------&lt;br/&gt;An HTML attachment was scrubbed...&lt;br/&gt;URL: &amp;lt;&lt;a href=&#34;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20210412/0e23254c/attachment.html&amp;gt&#34;&gt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20210412/0e23254c/attachment.html&amp;gt&lt;/a&gt;;
    </content>
    <updated>2023-06-08T00:51:21&#43;02:00</updated>
  </entry>

  <entry>
    <id>https://nostr.ae/nevent1qqsvrzhs42ak3h970nsuregj3r99jxlxrw87jtjew5tg9vayzcn5l3gzyruxmvc8ag27ea69a3d5t6r2h0uh2kkmc7n9prw2zfzrem0kwxqgg2j275u</id>
    
      <title type="html">📅 Original date posted:2021-04-12 📝 Original message:Hi ...</title>
    
    <link rel="alternate" href="https://nostr.ae/nevent1qqsvrzhs42ak3h970nsuregj3r99jxlxrw87jtjew5tg9vayzcn5l3gzyruxmvc8ag27ea69a3d5t6r2h0uh2kkmc7n9prw2zfzrem0kwxqgg2j275u" />
    <content type="html">
      In reply to &lt;a href=&#39;/nevent1qqstu6m97yymptm6acqjgjpmr4rf08mene74agqyux3gnmxhwvlv9pgy8t5u7&#39;&gt;nevent1q…t5u7&lt;/a&gt;&lt;br/&gt;_________________________&lt;br/&gt;&lt;br/&gt;📅 Original date posted:2021-04-12&lt;br/&gt;📝 Original message:Hi Hugo,&lt;br/&gt;&lt;br/&gt;First of all, thank you for the impressive work on leading the&lt;br/&gt;standardization efforts!&lt;br/&gt;&lt;br/&gt;I believe one ought to more clearly distinguish the &amp;#34;Signer&amp;#34; (as in: one of&lt;br/&gt;the parties in the multisig setup), from the &amp;#34;*Signing device*&amp;#34; (which is&lt;br/&gt;likely a hardware wallet). BSMS defines a &amp;#34;Signer&amp;#34; as &amp;#34;a participating&lt;br/&gt;member in the multisig&amp;#34;,  therefore a person/entity who is likely using&lt;br/&gt;both a hardware wallet and some BSMS-friendly software wallet (e.g. the&lt;br/&gt;next version of Specter Desktop). It is therefore relevant to discuss which&lt;br/&gt;parts of the BSMS mechanism are implemented in the Signer&amp;#39;s software&lt;br/&gt;wallet, and which should be in the Signer&amp;#39;s hardware wallet.&lt;br/&gt;&amp;gt;From the discussion, it appears to me that different people might have&lt;br/&gt;different expectations on what the signing device/HWW should do, so I would&lt;br/&gt;like to comment on this point specifically (while I reckon that it mostly&lt;br/&gt;falls within the realm of concerns #4 and #5 of the motivation paragraph,&lt;br/&gt;which are explicitly left out of scope).&lt;br/&gt;&lt;br/&gt;I fully agree that a *Signer* must persist the full wallet&amp;#39;s description,&lt;br/&gt;and should also create physical backups which include the full descriptor&lt;br/&gt;and the cosigner&amp;#39;s information. I would disagree, however, if any standards&lt;br/&gt;were to force *hardware wallets* to persist any substantial amount of state&lt;br/&gt;other than the seed, as I believe that it gives no substantial advantage&lt;br/&gt;over externally stored signed data for many use cases.&lt;br/&gt;&lt;br/&gt;The following is the *wallet registration flow* I am currently working on&lt;br/&gt;(in the context of adding support to multisig wallets at Ledger). The goal&lt;br/&gt;is to allow a *Signer* (the person) to persist a multisig setup in its&lt;br/&gt;storage, while achieving a similar level of security you would have if you&lt;br/&gt;were storing it on the hardware wallet itself (note that the following flow&lt;br/&gt;would happen as part of Round 2):&lt;br/&gt;&lt;br/&gt;1) The desktop wallet of the requests the HWW to register a new multisig&lt;br/&gt;wallet. The request includes the full multisig wallet description, and some&lt;br/&gt;extra metadata (e.g.: a name to be associated to this multisig wallet).&lt;br/&gt;2) The HWW validates the wallet and verifies it with the user with the&lt;br/&gt;trusted screen (as per BSMS Round 2); on confirmation, it returns a wallet&lt;br/&gt;id (which is a vendor-specific hash of all the wallet description &#43;&lt;br/&gt;metadata) and signature&lt;br/&gt;3) The desktop wallet stores the full wallet description/id/signature.&lt;br/&gt;(Optionally, a backup could be stored elsewhere).&lt;br/&gt;&lt;br/&gt;Whenever an operation related to the multisig wallet is required (verifying&lt;br/&gt;a receiving address, or signing a spending transaction), the HWW first&lt;br/&gt;receives and verifies all the data stored at step 3 above (without any user&lt;br/&gt;interaction). Then it proceeds exactly the same way as if it had always&lt;br/&gt;stored the multisig wallet in their own storage. I think this is basically&lt;br/&gt;the same flow Michael Flaxman is suggesting here:&lt;br/&gt;&lt;a href=&#34;https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2021-April/018775.html&#34;&gt;https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2021-April/018775.html&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;(Note that none of this is flow specific to Multisig wallet, as the same&lt;br/&gt;flow would be unchanged for any arbitrary supported script that needs to be&lt;br/&gt;&amp;#34;registered&amp;#34; on a stateless device, and can be generalized for MPC&lt;br/&gt;protocols)&lt;br/&gt;&lt;br/&gt;The only caveat I can think of is that the script registration is never&lt;br/&gt;revocable if a signing key derived from the seed is used in step (2), which&lt;br/&gt;might or might not be desirable. One could instead prefer to use a&lt;br/&gt;different signing key that is destroyed if the device is wiped, which would&lt;br/&gt;therefore need to be stored on the device. Note that the only thing that is&lt;br/&gt;lost is the on-device multisig wallet registration, which could easily be&lt;br/&gt;repeated from a backup.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;On Sun, 11 Apr 2021 at 19:11, Hugo Nguyen via bitcoin-dev &amp;lt;&lt;br/&gt;bitcoin-dev at lists.linuxfoundation.org&amp;gt; wrote:&lt;br/&gt;&lt;br/&gt;&amp;gt; I reiterate that I strongly disagree that going stateless is the direction&lt;br/&gt;&amp;gt; we want to pursue when it comes to multisig.&lt;br/&gt;&amp;gt;&lt;br/&gt;&amp;gt; In a multisig or any type of MPC smart contract, any Signer in the&lt;br/&gt;&amp;gt; contract must know who the other co-Signers are at all times. You can&lt;br/&gt;&amp;gt; choose to do this verification once at setup and persist this info on the&lt;br/&gt;&amp;gt; Signer, or you&amp;#39;d have to re-do the verification for every single&lt;br/&gt;&amp;gt; transaction. There is no other choice.&lt;br/&gt;&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;gt;&lt;br/&gt;Signing the descriptor record is insufficient, while also introducing a&lt;br/&gt;&amp;gt; great deal of complexity. Here are the problems:&lt;br/&gt;&amp;gt; 1) The signature needs to be stored somewhere. Who stores it if it&amp;#39;s not&lt;br/&gt;&amp;gt; the Signer itself? What if it gets lost? (If the Signer stores its own&lt;br/&gt;&amp;gt; signature, then the scheme is no longer stateless. You might as well store&lt;br/&gt;&amp;gt; the full descriptor).&lt;br/&gt;&amp;gt;&lt;br/&gt;&lt;br/&gt;In the flow I describe above, the desktop wallet would indeed store the&lt;br/&gt;signed descriptor record and wallet metadata. So yes, the *Signer* as in *the&lt;br/&gt;party in the protocol* stores it, but not the signing device*. *The same&lt;br/&gt;method could be used to store state temporarily between round 1 and 2,&lt;br/&gt;where the only *state* on the hardware wallet would be the TOKEN, while&lt;br/&gt;everything else is stored (encrypted and signed) on the Signer&amp;#39;s desktop.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&amp;gt; 2) When the signature is &amp;#34;played back&amp;#34; to the Signer, a copy of the&lt;br/&gt;&amp;gt; original descriptor must be included. Who stores the descriptor? What if it&lt;br/&gt;&amp;gt; gets lost? This is an under-appreciated aspect of the stateful approach:&lt;br/&gt;&amp;gt; every participant in the multisig has a full copy of the original contract,&lt;br/&gt;&amp;gt; which adds resilience to the wallet backup / recovery process.&lt;br/&gt;&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;#34;Playing back&amp;#34; the signature and wallet&amp;#39;s setup data to the hardware wallet&lt;br/&gt;would indeed happen transparently from the Signer&amp;#39;s wallet software. If the&lt;br/&gt;Signer lost this data due to malware, faulty hardware, etc., the user would&lt;br/&gt;indeed have to recover from backup, which seems ok to me.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&amp;gt; 3) Because the full descriptor must be &amp;#34;played back&amp;#34; for every single&lt;br/&gt;&amp;gt; transaction, this means every detail of the contract must be shared again&lt;br/&gt;&amp;gt; and again, indefinitely. Not only does this add overhead (engineering and&lt;br/&gt;&amp;gt; cognitive) to the spending process, it has massive privacy implications,&lt;br/&gt;&amp;gt; since the descriptor contains everything you need to know about the wallets&lt;br/&gt;&amp;gt; and its participants.&lt;br/&gt;&amp;gt;&lt;br/&gt;&lt;br/&gt;I agree with some of these concerns, but I observe:&lt;br/&gt;- The engineering overhead in handling externally-stored-signed-data is&lt;br/&gt;paid once, and would mostly fall on the hardware wallet vendor. External&lt;br/&gt;software only cares about storing certain data and sending it back later.&lt;br/&gt;- Storing xpubs/descriptors in the desktop software that interacts with&lt;br/&gt;the HWW is already common practice, and necessary for using any watch-only&lt;br/&gt;wallet.&lt;br/&gt;&lt;br/&gt;Summarizing, I argue that the stateful/stateless characteristic of a&lt;br/&gt;hardware wallet does not really affect (modulo some extra work) the ability&lt;br/&gt;to participate in the BSMS ceremony, whose *Signers* should indeed be&lt;br/&gt;stateful.&lt;br/&gt;Some more clarifications on the trust assumptions might help at clarifying&lt;br/&gt;the best possible software/hardware implementation tradeoffs, either in&lt;br/&gt;this or a follow-up BIP.&lt;br/&gt;&lt;br/&gt;Best,&lt;br/&gt;Salvatore Ingala&lt;br/&gt;-------------- next part --------------&lt;br/&gt;An HTML attachment was scrubbed...&lt;br/&gt;URL: &amp;lt;&lt;a href=&#34;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20210412/0e23254c/attachment.html&amp;gt&#34;&gt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20210412/0e23254c/attachment.html&amp;gt&lt;/a&gt;;
    </content>
    <updated>2023-06-07T20:31:17&#43;02:00</updated>
  </entry>

  <entry>
    <id>https://nostr.ae/nevent1qqsx7nrt8q44ydc23xnsmn6uu6awjypvstu8umuhqrjm63ez6y4vk4czyruxmvc8ag27ea69a3d5t6r2h0uh2kkmc7n9prw2zfzrem0kwxqggwvm0u3</id>
    
      <title type="html">📅 Original date posted:2020-06-08 📝 Original message:Dear ...</title>
    
    <link rel="alternate" href="https://nostr.ae/nevent1qqsx7nrt8q44ydc23xnsmn6uu6awjypvstu8umuhqrjm63ez6y4vk4czyruxmvc8ag27ea69a3d5t6r2h0uh2kkmc7n9prw2zfzrem0kwxqggwvm0u3" />
    <content type="html">
      In reply to &lt;a href=&#39;/nevent1qqstja9j3djpnn4c6afcsy7uk8gfn6pexpgf5g0nvhc8g0g23hzda7quk2ch9&#39;&gt;nevent1q…2ch9&lt;/a&gt;&lt;br/&gt;_________________________&lt;br/&gt;&lt;br/&gt;📅 Original date posted:2020-06-08&lt;br/&gt;📝 Original message:Dear all,&lt;br/&gt;&lt;br/&gt;I have been working on some constructions for cryptographic accumulators&lt;br/&gt;that optimise for quick insertion.&lt;br/&gt;&lt;br/&gt;As a brief background, an accumulator is a data structure that maintains&lt;br/&gt;compact commitments to a potentially very large (and dynamic) set, while&lt;br/&gt;keeping proofs of membership short. Unsurprisingly, they are getting more&lt;br/&gt;popular, and one notable application in Bitcoin is to create light-weight&lt;br/&gt;full nodes that do not need to store the UTXO set (Utreexo accumulator[1]).&lt;br/&gt;&lt;br/&gt;In this work, I focus on additive accumulators that supports adding new&lt;br/&gt;elements, but not removing them. My motivation is to support extending&lt;br/&gt;Script with access to an arbitrarily large portion of the blockchain&lt;br/&gt;history and state (e.g., past blocks, txids, or any more complex state&lt;br/&gt;obtained from them - with all due care). The additional storage and&lt;br/&gt;computation cost for nodes is small, and the cost (in additional bytesize)&lt;br/&gt;for any transaction that wishes to access state committed in the&lt;br/&gt;accumulator should be just slightly bigger than typical Merkle proofs.&lt;br/&gt;&lt;br/&gt;I have focused on:&lt;br/&gt;- An accumulator with insertion time O(1) and proof size O(log^2 n)&lt;br/&gt;- A construction with insertion time O(log log n) and proof size O(log n&lt;br/&gt;log log n)&lt;br/&gt;&lt;br/&gt;All the performance metrics above are in &amp;#34;number of hashes&amp;#34;.&lt;br/&gt;&lt;br/&gt;You can find:&lt;br/&gt;- draft writeup:&lt;br/&gt;&lt;a href=&#34;https://github.com/bigspider/accumulator/blob/master/docs/paper-draft.pdf&#34;&gt;https://github.com/bigspider/accumulator/blob/master/docs/paper-draft.pdf&lt;/a&gt;&lt;br/&gt;- sample python code (only for the first construction at this time):&lt;br/&gt;&lt;a href=&#34;https://github.com/bigspider/accumulator&#34;&gt;https://github.com/bigspider/accumulator&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;While this is still an unfinished work, the ideas in the draft are&lt;br/&gt;hopefully clear enough and easy to understand. I wanted to share it at this&lt;br/&gt;stage as it can benefit from comments to improve the constructions, to&lt;br/&gt;cover any related work or to find potential applications in Bitcoin (e.g.&lt;br/&gt;Script, layer2, side chains, etc).&lt;br/&gt;&lt;br/&gt;Best,&lt;br/&gt;Salvatore Ingala&lt;br/&gt;&lt;br/&gt;[1] - Thaddeus Dryja, Utreexo: A dynamic hash-based accumulator optimized&lt;br/&gt;for the Bitcoin UTXO set - &lt;a href=&#34;https://eprint.iacr.org/2019/611.pdf&#34;&gt;https://eprint.iacr.org/2019/611.pdf&lt;/a&gt;&lt;br/&gt;-------------- next part --------------&lt;br/&gt;An HTML attachment was scrubbed...&lt;br/&gt;URL: &amp;lt;&lt;a href=&#34;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20200608/562ce529/attachment.html&amp;gt&#34;&gt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20200608/562ce529/attachment.html&amp;gt&lt;/a&gt;;
    </content>
    <updated>2023-06-07T20:25:19&#43;02:00</updated>
  </entry>

</feed>