What is Nostr?
Gregory Maxwell [ARCHIVE] /
npub1f2n…rwet
2023-06-07 15:26:27
in reply to nevent1q…7hmx

Gregory Maxwell [ARCHIVE] on Nostr: 📅 Original date posted:2014-10-13 📝 Original message:On Tue, Oct 14, 2014 at ...

📅 Original date posted:2014-10-13
📝 Original message:On Tue, Oct 14, 2014 at 2:34 AM, Pieter Wuille <pieter.wuille at gmail.com> wrote:
> Hi all,
>
> while working on a BIP62 implementation I discovered yet another type
> of malleability: the interpretation of booleans.
>
> Any byte array with non-zero bytes in it (ignoring the highest bit of
> the last byte, which is the sign bit when interpreting as a number) is
> interpreted as true, anything else as false. Other than numbers,
> they're not even restricted to 4 bytes. Worse, the code for dealing
> with booleans is not very consistent: OP_BOOLAND and OP_BOOLOR first
> interpret their arguments as numbers, and then compare them to 0 to
> turn them into boolean values.
>
> This means that scripts that use booleans as inputs will be inherently
> malleable. Given that that seems actually useful (passing in booleans
> to guide some OP_IF's during execution of several alternatives), I
> would like to change BIP62 to also state that interpreted booleans
> must be of minimal encoded size (in addition to numbers).
>
> Any opinions for or against?


An argument against is that you can currently do something like this:


OP_DUP OP_IF OP_HASH160 PUSH OP_EQUALVERIFY OP_ELSE <stuff>
OP_CHECKSIGVERIFY OP_ENDIF

E.g. if your input is non-zero you're giving a hash, if it's zero
you're skipping that and running another branch.

Of course you could just encode your script another way... but by that
same logic you can 1 OP_QUALVERIFY to bool-ize any input in the true
path. The inconsistency in handling makes it more likely that script
authors will screw up with bad (for them) consequences, however.

[I just asked pieter out of band to clarify if he means "minimal
encoded size", or must be 0 or 1 minimally encoded... as the former
doesn't fix the malleability, but the later is more disruptive]
Author Public Key
npub1f2nvlx49er5c7sqa43src6ssyp6snd4qwvtkwm5avc2l84cs84esecrwet