Dealing with OP_IF and OP_NOTIF malleability



Summary:

The discussion on bitcoin-dev mailing list revolves around the usage of OP_0 and OP_PUSH opcodes for pushing data. It is mentioned that OP_0 gives a zero-length byte array because it is equivalent to pushdata with zero length, which means that empty string is not equal to a single-byte string with 0x00 byte in it. Therefore, OP_EQUAL will push "false" as the result of comparison. This "false" value is encoded as an empty string, similar to the result of OP_0. The participants of the discussion suggest that OP_0 and OP_1 should be used to push data and not any other push opcodes. One of the participants suggests defining "IF/NOTIF argument must be either zero-length array or a single byte 0x01" explicitly as it contradicts the rule of minimally-encoded "zero". The concern is to avoid any potential mutation of the transaction by changing the length of the array.


Updated on: 2023-06-11T00:55:30.308861+00:00