From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Xe7F5-0006Hc-V2 for bitcoin-development@lists.sourceforge.net; Tue, 14 Oct 2014 18:54:44 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of gmail.com designates 209.85.213.169 as permitted sender) client-ip=209.85.213.169; envelope-from=pieter.wuille@gmail.com; helo=mail-ig0-f169.google.com; Received: from mail-ig0-f169.google.com ([209.85.213.169]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1Xe7F4-0007kr-Rp for bitcoin-development@lists.sourceforge.net; Tue, 14 Oct 2014 18:54:43 +0000 Received: by mail-ig0-f169.google.com with SMTP id uq10so18490941igb.0 for ; Tue, 14 Oct 2014 11:54:36 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.50.164.194 with SMTP id ys2mr8720775igb.43.1413312876360; Tue, 14 Oct 2014 11:54:36 -0700 (PDT) Received: by 10.50.65.9 with HTTP; Tue, 14 Oct 2014 11:54:36 -0700 (PDT) In-Reply-To: <20141014080905.GA10545@savin.petertodd.org> References: <20141014080905.GA10545@savin.petertodd.org> Date: Tue, 14 Oct 2014 11:54:36 -0700 Message-ID: From: Pieter Wuille To: Peter Todd Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: -1.6 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (pieter.wuille[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1Xe7F4-0007kr-Rp Cc: Bitcoin Dev Subject: Re: [Bitcoin-development] Malleable booleans X-BeenThere: bitcoin-development@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Oct 2014 18:54:44 -0000 To be clear: I indeed meant to only allow 0 and 1 as booleans (or, more precisely: [] and [0x01]). Evaluating any stack element as a boolean that is not any of these would result in script failure. The only places where this is relevant: * Inputs to OP_IF and OP_NOTIF (which are currently allowed to be any byte array). * Inputs to OP_BOOLAND and OP_BOOLOR (which are currently allowed to be any valid number). * The resulting final element on the stack for validity. The code for converting stack elements to booleans is also invoked for all OP_*VERIFY operators, but for those it is always the output of a previous operator, so it will not have any semantic impact. On Tue, Oct 14, 2014 at 1:09 AM, Peter Todd wrote: > I noticed this awhile back myself. More interestingly, I remember > noticing some non-std scripts on mainnet that had opcodes that appeared > to be attempts to solve this issue with variations of the following: > > DUP > IF > 1 EQUALVERIFY > > ELSE > 0 EQUALVERIFY > > ENDIFo. > > I'll have to admit, I decided to keep quiet about it because it's a good > example of how relying on BIP62 for specialty contract applications that > absolutely need to avoid malleability for security reasons is a dubious > idea; it's hard to be sure that we've really gotten every relevant case > correct. I think my goal is to have the property that for every possible script, there is an equivalent one that is non-malleable. There are likely still holes in that idea, but at least for just standard scripts I think BIP62 (as is) covers this. And as your example points out (Greg and I discussed this, though we didn't come up with such a concise one), it is already possible for boolean inputs too. > I think a decent argument *for* doing this is that if a script author > fails to properly 'bool-ize' every boolean-using path that can have > non-minimal encodings in normal execution, you can always create a > nVersion=1 transaction manually to spend the output, preventing funds > from getting lost. Meanwhile in the general case of a compenent script > author having the canonical bool testing in every boolean-using opcode > saves a lot of bytes. The real question is whether there are use cases for not having this requirement. I can't come up with any, as that would imply a boolean that is also interpretable as a hash, a pubkey or a signature - all of which seems crpytographically impossible to ever result in false. -- Pieter