From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id B037D710 for ; Wed, 21 Nov 2018 17:07:44 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-it1-f175.google.com (mail-it1-f175.google.com [209.85.166.175]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 9AAC880F for ; Wed, 21 Nov 2018 17:07:43 +0000 (UTC) Received: by mail-it1-f175.google.com with SMTP id o19so9900397itg.5 for ; Wed, 21 Nov 2018 09:07:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blockstream.io; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=Uz7z/vEi+6wsgVytaogdSHyWPMOvsT7hQakAIwGD8lg=; b=p6JcfvyyBsPqY8C/0zKTqyGLHnj7XOtiD4AbmyU0hhewyh4wJRc8MeX6o0PAuw9uaB xTnEhiJPrlDtDwkjMuglH66Kp7XZIm8Khd9ijZ1n3mDYf42uT4vPfCamBlg7xMffZJz+ GYe/0pcuLD8y//x/iKHGm4SwqvgUU/Fqezg/4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=Uz7z/vEi+6wsgVytaogdSHyWPMOvsT7hQakAIwGD8lg=; b=Tul4rHWArisYvQ9hOP1khgZrsxafQNZhWaAAGO0eRPot6eA+OvB8OOcJn+0y7iZNDL kpUk0uHBIH1Cp/pmuhb0/CfP8FxdBefUkOK4Ra7k533LsWQ00PiQ++djxPdE3tqP0ndk V0oUP5GdX9Q0R42wVJOeNBhD5myB5fBL82//uF+rwsqx10xNMf3EPLmLfQng7es93QYP evToyZoqaFPInHI4yj+Ns/YGNv7A5FzQ8L7sYH4LRPm2pR7J2MYue46/pY9CQlu9JGun vuaGTdRoBB++8J4Rkr/Z2idJVeaOKyNiwR2xnwA76wou5UZjtB6qWUMFN3wQxtuHN2dx KwFA== X-Gm-Message-State: AGRZ1gKvieAaIO+9oAzQI9t1s6fe1ibCDgj9nqAiWsZpFAl3nt6V+fh6 /F0HIZlHyxrjuIW1IR4u6NqBWh0j089OHzq3ipGd4w== X-Google-Smtp-Source: AJdET5eabbfvK4+SeAdpjH6OdNU+vdJkxIB4iKzCuyQsGMiRYxRe/PPuON6mGnYobndIW35m1yu50odVloWmkbI3p30= X-Received: by 2002:a24:aa04:: with SMTP id b4-v6mr6369799itf.127.1542820062637; Wed, 21 Nov 2018 09:07:42 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: "Russell O'Connor" Date: Wed, 21 Nov 2018 12:07:30 -0500 Message-ID: To: Pieter Wuille , Bitcoin Protocol Discussion Content-Type: multipart/alternative; boundary="000000000000c96a34057b2fc954" 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, 22 Nov 2018 14:08:02 +0000 Subject: Re: [bitcoin-dev] Safer sighashes and more granular SIGHASH_NOINPUT 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, 21 Nov 2018 17:07:44 -0000 --000000000000c96a34057b2fc954 Content-Type: text/plain; charset="UTF-8" On Mon, Nov 19, 2018 at 10:22 PM Pieter Wuille via bitcoin-dev < bitcoin-dev@lists.linuxfoundation.org> wrote: > So my question is whether anyone can see ways in which this introduces > redundant flexibility, or misses obvious use cases? > Hopefully my comment is on-topic for this thread: Given that we want to move away from OP_CODESEPARATOR, because each call to this operation effectively takes O(script-size) time, we need a replacement for the functionality it currently provides. While perhaps the original motivation for OP_CODESEPARTOR is surrounded in mystery, it currently can be used (or perhaps abused) for the task of creating signature that covers, not only which input is being signed, but which specific branch within that input Script code is being signed for. For example, one can place an OP_CODESEPARATOR within each branch of an IF block, or by placing an OP_CODESEPARATOR before each OP_CHECKSIG operation. By doing so, signatures created for one clause cannot be used as signatures for another clause. Since different clauses in Bitcoin Script may be enforcing different conditions (such as different time-locks, hash-locks, etc), it is useful to be able to sign in such a way that your signature is only valid when the conditions for a particular branch are satisfied. In complex Scripts, it may not be practical or possible to use different public keys for every different clause. (In practice, you will be able to get away with fewer OP_CODESEPARATORS than one in every IF block). One suggestion I heard (I think I heard it from Pieter) to achieve the above is to add an internal counter that increments on every control flow operator, OP_IF, OP_NOTIF, OP_ELSE, OP_ENDIF, and have the signature cover the value of this counter. Equivalently we divide every Bitcoin Script program into blocks deliminated by these control flow operator and have the signature cover the index of the block that the OP_CHECKSIG occurs within. More specifically, we will want a SigHash flag to enables/disable the signature covering this counter. There are many different ways one might go about replacing the remaining useful behaviour of OP_CODESEPARATOR than the one I gave above. I would be happy with any solution. --000000000000c96a34057b2fc954 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, Nov 19= , 2018 at 10:22 PM Pieter Wuille via bitcoin-dev <bitcoin-dev@lists.linuxfoundation.org> wrote:
So my question is whet= her anyone can see ways in which this introduces
redundant flexibility, or misses obvious use cases?

For example, one can place an OP_CODESEPARATOR within each branch o= f an IF block, or by placing an OP_CODESEPARATOR before each OP_CHECKSIG op= eration.=C2=A0 By doing so, signatures created for one clause cannot be use= d as signatures for another clause.=C2=A0 Since different clauses in Bitcoi= n Script may be enforcing different conditions (such as different time-lock= s, hash-locks, etc), it is useful to be able to sign in such a way that you= r signature is only valid when the conditions for a particular branch are s= atisfied.=C2=A0 In complex Scripts, it may not be practical or possible to = use different public keys for every different clause. (In practice, you wil= l be able to get away with fewer OP_CODESEPARATORS than one in every IF blo= ck).

One suggestion I heard (I think I heard i= t from Pieter) to achieve the above is to add an internal counter that incr= ements on every control flow operator, OP_IF, OP_NOTIF, OP_ELSE, OP_ENDIF, = and have the signature cover the value of this counter.=C2=A0 Equivalently = we divide every Bitcoin Script program into blocks deliminated by these con= trol flow operator and have the signature cover the index of the block that= the OP_CHECKSIG occurs within.=C2=A0 More specifically, we will want a Sig= Hash flag to enables/disable the signature covering this counter.
=

There are many different ways one might go about replac= ing the remaining useful behaviour of OP_CODESEPARATOR than the one I gave = above. I would be happy with any solution.
--000000000000c96a34057b2fc954--