<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">ZmnSCPxj already observed in [1] that these ops would enable introspection of any field of the transactions and make both `OP_CHECKLOCKTIMEVERIFY` and `OP_CHECKSEQUENCEVERIFY` superfluous.<br class="">There is much more to this as enumerated in generic terms by Russel O’Connor below and I would like to add a concrete example.<br class=""><br class="">We could implement oracle less difficulty contracts without the need the of a CISC type OP_WORKVERIFY but instead through resurrection/extension of OP_CAT, OP_GREATERTHANOREQUAL and introduction of a new RISC opcode OP_CHECKBLOCKATHEIGHT[3] suggested by Luke Dashjr. Thanks for the pointer to Nathan Cook [4]<br class=""><br class="">Technically we could resurrect and add them without burning more than one OP_NOP by redefining it as a prefix (OP_EXTENSION), such as:<br class=""><br class="">OP_EXTENSION OP_CAT would become a two byte opcode pointing to a resurrected implementation of OP_CAT.<br class=""><br class="">This could be soft forked in.<br class=""><br class="">A concrete oracle less difficulty contract could look like:<br class="">It is an european digital call option on target difficulty after maturity and 10 blocks notice period. I gave you reasons while having these would increase bitcoin's security in [2]<br class=""><br class="">IF<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>&lt;maturity as block height + 10&gt; CHECKLOCKTIMEVERIFY DROP<br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;speculator’s key&gt; CHECKSIGVERIFY<br class="">ELSE<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>OP_DUP &nbsp;&lt;maturity as block height - 1&gt; OP_CHECKBLOCKATHEIGHT OP_LESSTHANEQUAL OP_VERIFY<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>OP_SWAP OP_CAT &nbsp;OP_CAT &nbsp;OP_HASH256 &lt;contracted target&gt; OP_LESSTHANEQUAL OP_VERIFY<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>&lt;miner’s key&gt; CHECKSIGVERIFY<br class="">ENDIF<br class=""><br class="">insurance premium could be collected by the seller of the insurance after maturity + 10 blocks if target difficulty was not reached<br class=""><br class="">&lt;speculator’s signature&gt;<br class=""><br class="">miner would get back its insurance premium plus collateral of the seller if target difficulty was not reached at maturity. Miner has 10 blocks time after maturity to claim with:<br class=""><br class="">&lt;maturity block header after prevhash&gt; &lt;maturity block version&gt; &lt;prevhash&gt;<br class=""><br class="">The stack would be in second case processed as:<br class=""><br class="">1: after pushes<br class="">&lt;maturity block prevhash&gt;<br class="">&lt;maturity block version&gt;<br class="">&lt;maturity block block header after prevhash&gt;<br class=""><br class="">2: after OP_DUP:<br class="">&lt;maturity block prevhash&gt;<br class="">&lt;maturity block prevhash&gt;<br class="">&lt;maturity block version&gt;<br class="">&lt;maturity block block header after prevhash&gt;<br class=""><br class="">3: after push<br class="">&lt;maturity as block height - 1&gt;<br class="">&lt;maturity block prevhash&gt;<br class="">&lt;maturity block prevhash&gt;<br class="">&lt;maturity block version&gt;<br class="">&lt;maturity block block header after prevhash&gt;<br class=""><br class="">4: after OP_CHECKBLOCKATHEIGHT OP_VERIFY is successful proving that prevhash is the block at maturity block height - 1<br class="">&lt;maturity block prevhash&gt;<br class="">&lt;maturity block version&gt;<br class="">&lt;maturity block block header after prevhash&gt;<br class=""><br class="">5: after OP_SWAP<br class="">&lt;block version&gt;<br class="">&lt;maturity block prevhash&gt;<br class="">&lt;block header after prevhash&gt;<br class=""><br class="">6: after OP_CAT<br class="">&lt;maturity block version concatenated with maturity prevhash&gt;<br class="">&lt;maturity block block header after maturity prevhash&gt;<br class=""><br class="">7: after OP_CAT<br class="">&lt;complete block header&gt;<br class=""><br class="">8: after OP_HASH256<br class="">&lt;block hash computed for header&gt;<br class=""><br class="">9: after push<br class="">&lt;contracted target&gt;<br class="">&lt;block hash computed for header&gt;<br class=""><br class="">10: after OP_GREATERTHANOREQUAL OP_VERIFY proves that contracted target was reached<br class=""><br class="">Tamas Blummer<br class=""><br class=""><br class="">[1]&nbsp;<a href="https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2019-May/016966.html" class="">https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2019-May/016966.html</a><br class="">[2]&nbsp;<a href="https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2019-June/017019.html" class="">https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2019-June/017019.html</a><br class="">[3]&nbsp;<a href="https://github.com/luke-jr/bips/blob/bip-cbah/bip-cbah.mediawiki" class="">https://github.com/luke-jr/bips/blob/bip-cbah/bip-cbah.mediawiki</a><br class="">[4]&nbsp;<a href="https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2019-May/016954.html" class="">https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2019-May/016954.html</a><br class="">[5]&nbsp;<a href="https://github.com/bitcoin/bitcoin/blob/master/src/script/script.h" class="">https://github.com/bitcoin/bitcoin/blob/master/src/script/script.h</a><br class=""><div><blockquote type="cite" class=""><div class="">On May 22, 2019, at 23:01, Russell O'Connor via bitcoin-dev &lt;<a href="mailto:bitcoin-dev@lists.linuxfoundation.org" class="">bitcoin-dev@lists.linuxfoundation.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class="">Recently there have been some tapscript proposals, SIGHASH_ANYPREVOUT and OP_CHECKOUTPUTHASHVERIFY, that aim to enable particular new features for Bitcoin via new Script operations.&nbsp; However, I think that these proposals miss the mark when it comes to how they approach Bitcoin Script and language features.</div><div class=""><br class=""></div><div class="">Bitcoin Script appears designed to be a flexible programmable system that provides generic features to be composed to achieve various purposes.&nbsp; Thus, when we design new language features for Script, we should be striving, as much as possible,  to similarly build general purpose tools which can in turn be used for a variety of purposes.</div><div class=""><br class=""></div><div class="">I feel the SIGHASH_ANYPREVOUT and OP_CHECKOUTPUTHASHVERIFY proposals fail to achieve these design goals.&nbsp; They are both are designed with very narrow applications in mind, while also going out of their way to extend the semantic domain of the interpretation of Bitcoin operations in new ways that complicate their specification.&nbsp; In the case of SIGHASH_ANYPREVOUT, the semantic domain is extended by adding new counters to track the use of various v0 and v2 signature types.&nbsp; In the case of OP_CHECKOUTPUTHASHVERIFY, it employs a new context-sensitive operation that peeks at the value of surrounding opcodes.</div><div class=""><br class=""></div><div class="">Instead, I propose that, for the time being, we simply implement OP_CAT and OP_CHECKSIGFROMSTACKVERIFY.&nbsp; OP_CAT pops two byte arrays off the stack and pushes their concatenation back onto the stack.&nbsp; OP_CHECKSIGFROMSTACKVERIFY pops a signature, message, and pubkey off the stack and performs a bip-schnorr verification on the SHA256 hash of the message.<br class=""></div><div class=""><br class=""></div><div class="">In concert, these two operations enable:</div><div class=""><br class=""></div><div class="">* Oracle signature verification, including discrete log contracts.</div><div class="">* Amortized secure multiparty computations (see "Amortizing Secure Computation with Penalties" by Kumaresan and Bentov).</div><div class="">* Transaction introspection including:<br class=""></div><div class=""><a class="gmail_plusreply" id="gmail-plusReplyChip-0">+</a>&nbsp;Simulated SIGHASH_ANYPREVOUT, which are necessarily chaperoned simply by the nature of the construction.<br class=""></div><div class=""><a class="gmail_plusreply" id="gmail-plusReplyChip-1">+</a> Decide if a transaction has exactly one input or not. (etc.)</div><div class="">+ Weak covenants, which can verify output scripts to see if they are among a set of predefined values or verify the output hash.<br class=""></div><div class=""><br class=""></div><div class="">and presumably more applications as well.<br class=""></div><div class=""><br class=""></div><div class="">For better or for worse, without an OP_PUBKEYTWEEK operation available, the more interesting recursive-covenants remain largely out of reach, with the exception of a recursive covenant that is only able to send back to its own address, possibly abusing its own TXO value as a state variable.</div><div class=""><br class=""></div><div class="">All this is accomplished by two straightforward opcodes whose semantics are pure computational operations on stack values.&nbsp; The only semantic side-effect is that OP_CHECKSIGFROMSTACKVERIFY would count towards the existing 'sigops_passed' count.&nbsp; Moreover, I feel that adding these operations does not preclude adding more specialized opcodes in the future as an optimization for whatever popular constructions come up, once we know what those are.<br class=""></div><div class=""><br class=""></div><div class="">I feel that this style of generic building blocks truly embodies what is meant by "programmable money".<br class=""></div></div></div></div></div></div>
_______________________________________________<br class="">bitcoin-dev mailing list<br class=""><a href="mailto:bitcoin-dev@lists.linuxfoundation.org" class="">bitcoin-dev@lists.linuxfoundation.org</a><br class="">https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev<br class=""></div></blockquote></div><br class=""></body></html>