Pieter Wuille [ARCHIVE] on Nostr: 📅 Original date posted:2014-10-13 📝 Original message:Hi all, while working on a ...
📅 Original date posted:2014-10-13
📝 Original message: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?
Published at
2023-06-07 15:26:27Event JSON
{
"id": "d52e91fb91e060009c4bcef2f3ba3464f3b8189d1cd8defe84340bb7dc0cf278",
"pubkey": "5cb21bf5d7f25a9d46879713cbd32433bbc10e40ef813a3c28fe7355f49854d6",
"created_at": 1686151587,
"kind": 1,
"tags": [
[
"e",
"c83f6dedf4ca7c81a89476f7b8b9b295fef9059bd827880a0f714bdd8244a34b",
"",
"reply"
],
[
"p",
"a23dbf6c6cc83e14cc3df4e56cc71845f611908084cfe620e83e40c06ccdd3d0"
]
],
"content": "📅 Original date posted:2014-10-13\n📝 Original message:Hi all,\n\nwhile working on a BIP62 implementation I discovered yet another type\nof malleability: the interpretation of booleans.\n\nAny byte array with non-zero bytes in it (ignoring the highest bit of\nthe last byte, which is the sign bit when interpreting as a number) is\ninterpreted as true, anything else as false. Other than numbers,\nthey're not even restricted to 4 bytes. Worse, the code for dealing\nwith booleans is not very consistent: OP_BOOLAND and OP_BOOLOR first\ninterpret their arguments as numbers, and then compare them to 0 to\nturn them into boolean values.\n\nThis means that scripts that use booleans as inputs will be inherently\nmalleable. Given that that seems actually useful (passing in booleans\nto guide some OP_IF's during execution of several alternatives), I\nwould like to change BIP62 to also state that interpreted booleans\nmust be of minimal encoded size (in addition to numbers).\n\nAny opinions for or against?",
"sig": "aa75166266d2b941543a545b0efebd4a26ebf852233a99973558dbf39a125f0b4a706bdccea817c7e98627ef1a56b5d63dfed1061bc781f33ae403270eb89502"
}