Return-Path: Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 78FC4AC7 for ; Wed, 22 May 2019 21:01:34 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-io1-f46.google.com (mail-io1-f46.google.com [209.85.166.46]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C78B65D0 for ; Wed, 22 May 2019 21:01:33 +0000 (UTC) Received: by mail-io1-f46.google.com with SMTP id m7so3053087ioa.6 for ; Wed, 22 May 2019 14:01:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blockstream.io; s=google; h=mime-version:from:date:message-id:subject:to; bh=lfNja15zaKVr8gEVTZx2JdSjlWLKih/VOjRD1uTiKFQ=; b=XVd+0f94hxPR4kaEfHIWhC/+9llxTVPxf4h99zTRLBboE2H1qeES9r2lkJJhr5mBVS Gr1fnHcbNX37L/cSOGwdr+eiYIp5PKOTS6U7xbN/cICEO6VH2pGdfqNNvSxl/iASKBs5 8yzqsK2OyR+yftSpEcVQKBu9iIB7pTFDMiKvs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=lfNja15zaKVr8gEVTZx2JdSjlWLKih/VOjRD1uTiKFQ=; b=dSANB0fzT7UmsCj81xJfN3NsylcCa0p4RBFZ+b2bajQn+38lRUMhFgucEGZU/EmQJl KsflISpEW5Btax7o8q3kgep6oDr2b/gN69R20rC9mabHxuR42M33IG7XvBWmLDap5Ev+ dn+PNrVgf+h06KR2Hlmw1zSSmN0sCgm4oY35/iUiHuMlNUJHYQsVhMRMFCr2i3VH+Y3S vm/CBGn8Sauwbbh53Hw4GLwTm0NSWpfXuAYSzxpt4LKB1ahMUti/YTwIBbMGonRrwSa2 OxVdrps4RhCdnKZmIrbEYqSmpRleRgAy67dpO0q7C+S+Otz3TW3ZwHeDmTmF0lrA52s3 fCNg== X-Gm-Message-State: APjAAAWKag7RABOjisKwMZ8cIH6exoWcYzLuaY0G4h7lxjIZ2iK7u5kx qLKvUDpecduRpQFa/2FhsU9JHqC2CXVihHSnYzjfgrXelkg= X-Google-Smtp-Source: APXvYqw0JQGbZETkOzpeOUvBj9wFSyb2uEmiirfkLuvi3XWgvcCJJrmLafoPlPOuzme2pPEJ+JIdFU8bhT93buJAgWg= X-Received: by 2002:a5e:c817:: with SMTP id y23mr5567901iol.290.1558558892722; Wed, 22 May 2019 14:01:32 -0700 (PDT) MIME-Version: 1.0 From: "Russell O'Connor" Date: Wed, 22 May 2019 17:01:21 -0400 Message-ID: To: Bitcoin Protocol Discussion Content-Type: multipart/alternative; boundary="00000000000029a5ce05898045db" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HTML_MESSAGE, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org X-Mailman-Approved-At: Thu, 23 May 2019 13:31:42 +0000 Subject: [bitcoin-dev] An alternative: OP_CAT & OP_CHECKSIGFROMSTACK X-BeenThere: bitcoin-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Bitcoin Protocol Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 May 2019 21:01:34 -0000 --00000000000029a5ce05898045db Content-Type: text/plain; charset="UTF-8" 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. However, I think that these proposals miss the mark when it comes to how they approach Bitcoin Script and language features. Bitcoin Script appears designed to be a flexible programmable system that provides generic features to be composed to achieve various purposes. 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. I feel the SIGHASH_ANYPREVOUT and OP_CHECKOUTPUTHASHVERIFY proposals fail to achieve these design goals. 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. 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. In the case of OP_CHECKOUTPUTHASHVERIFY, it employs a new context-sensitive operation that peeks at the value of surrounding opcodes. Instead, I propose that, for the time being, we simply implement OP_CAT and OP_CHECKSIGFROMSTACKVERIFY. OP_CAT pops two byte arrays off the stack and pushes their concatenation back onto the stack. OP_CHECKSIGFROMSTACKVERIFY pops a signature, message, and pubkey off the stack and performs a bip-schnorr verification on the SHA256 hash of the message. In concert, these two operations enable: * Oracle signature verification, including discrete log contracts. * Amortized secure multiparty computations (see "Amortizing Secure Computation with Penalties" by Kumaresan and Bentov). * Transaction introspection including: + Simulated SIGHASH_ANYPREVOUT, which are necessarily chaperoned simply by the nature of the construction. + Decide if a transaction has exactly one input or not. (etc.) + Weak covenants, which can verify output scripts to see if they are among a set of predefined values or verify the output hash. and presumably more applications as well. 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. All this is accomplished by two straightforward opcodes whose semantics are pure computational operations on stack values. The only semantic side-effect is that OP_CHECKSIGFROMSTACKVERIFY would count towards the existing 'sigops_passed' count. 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. I feel that this style of generic building blocks truly embodies what is meant by "programmable money". --00000000000029a5ce05898045db Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Recently there have been some tapscript proposals, SIGHASH_A= NYPREVOUT and OP_CHECKOUTPUTHASHVERIFY, that aim to enable particular new f= eatures for Bitcoin via new Script operations.=C2=A0 However, I think that = these proposals miss the mark when it comes to how they approach Bitcoin Sc= ript and language features.

Bitcoin Script appears= designed to be a flexible programmable system that provides generic featur= es to be composed to achieve various purposes.=C2=A0 Thus, when we design n= ew 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.

I feel the SIGHASH_ANYPREVOU= T and OP_CHECKOUTPUTHASHVERIFY proposals fail to achieve these design goals= .=C2=A0 They are both are designed with very narrow applications in mind, w= hile also going out of their way to extend the semantic domain of the inter= pretation of Bitcoin operations in new ways that complicate their specifica= tion.=C2=A0 In the case of SIGHASH_ANYPREVOUT, the semantic domain is exten= ded by adding new counters to track the use of various v0 and v2 signature = types.=C2=A0 In the case of OP_CHECKOUTPUTHASHVERIFY, it employs a new cont= ext-sensitive operation that peeks at the value of surrounding opcodes.

Instead, I propose that, for the time being, we simpl= y implement OP_CAT and OP_CHECKSIGFROMSTACKVERIFY.=C2=A0 OP_CAT pops two by= te arrays off the stack and pushes their concatenation back onto the stack.= =C2=A0 OP_CHECKSIGFROMSTACKVERIFY pops a signature, message, and pubkey off= the stack and performs a bip-schnorr verification on the SHA256 hash of th= e message.

In concert, these two operations en= able:

* Oracle signature verification, including d= iscrete log contracts.
* Amortized secure multiparty computations= (see "Amortizing Secure Computation with Penalties" by Kumaresan= and Bentov).
* Transaction introspection including:
+=C2=A0Simu= lated SIGHASH_ANYPREVOUT, which are necessarily chaperoned simply by the na= ture of the construction.
+ Decide if a transaction has exactly one input = or not. (etc.)
+ Weak covenants, which can verify output scripts = to see if they are among a set of predefined values or verify the output ha= sh.

and presumably more applications as well.<= br>

For better or for worse, without an OP_PUBKEYT= WEEK operation available, the more interesting recursive-covenants remain l= argely out of reach, with the exception of a recursive covenant that is onl= y able to send back to its own address, possibly abusing its own TXO value = as a state variable.

All this is accomplished by t= wo straightforward opcodes whose semantics are pure computational operation= s on stack values.=C2=A0 The only semantic side-effect is that OP_CHECKSIGF= ROMSTACKVERIFY would count towards the existing 'sigops_passed' cou= nt.=C2=A0 Moreover, I feel that adding these operations does not preclude a= dding more specialized opcodes in the future as an optimization for whateve= r popular constructions come up, once we know what those are.

I feel that this style of generic building blocks truly emb= odies what is meant by "programmable money".
--00000000000029a5ce05898045db--