New BIP: Dealing with OP_IF and OP_NOTIF malleability in P2WSH



Summary:

In a bitcoin-dev discussion, Russell O'Connor expressed concern regarding the effectiveness of fighting script malleability. However, the goal is to protect as many common scripts as possible. BIP146 (Low S values signatures) will eliminate all malleability for P2WPKH. Furthermore, BIP146 + null dummy value for CHECKMULTISIG ("NULLDUMMY") will eliminate all malleability for simple multi-sig in P2WSH and BIP146 + NULLDUMMY + minimal IF argument ("MINIMALIF") will eliminate malleability for any Lightning Network scripts that the author is aware of. The plan is to implement MINIMALIF as a relay policy first and enforce the softfork after further risk assessment. Peter Todd suggests an alternative approach, which may be a separate CHECKBOOLVERIFY opcode that fails unless the top item on the stack is a minimally encoded true or false value, to allow script writers to opt into this behaviour. Although all Lightning Network scripts are already compatible with MINIMALIF, if people want to have the original OP_IF behaviour, a simple way would be using "0NOTEQUAL IF". However, this works only if the argument is a valid number and one may also use alternative code to replicate the original behaviour.


Updated on: 2023-05-19T23:45:30.828765+00:00