New BIP: Dealing with OP_IF and OP_NOTIF malleability in P2WSH



Summary:

A new Bitcoin Improvement Proposal (BIP) has been proposed by Johnson Lau to deal with OP_IF and OP_NOTIF malleability in P2WSH scripts. The proposal is available on Github. OP_IF and OP_NOTIF are flow control codes in the Bitcoin script system that allow a third party to replace a True (False) stack item with any other True (False) value without invalidating the transaction, creating a source of malleability. The proposed rules apply only to pay-to-witness-script-hash (P2WSH) scripts described in BIP141, which has not been activated on the Bitcoin mainnet as of writing. The specification states that in P2WSH, the argument for OP_IF and OP_NOTIF MUST be exactly an empty vector or 0x01, or the script evaluation fails immediately. This is deployed using BIP9 after segregated witness (BIP141) is activated. The proposal is a softfork on top of BIP141 and the rules are enforced as a relay policy by the reference client since the first release of BIP141 (v0.13.1). To avoid risks of fund loss, users MUST NOT create P2WSH scripts that are incompatible with this BIP. An OP_0NOTEQUAL may be used before OP_IF or OP_NOTIF to imitate the original behaviour (which may also re-enable the malleability vector depending on the exact script).The implementation details can be found on Github pull request #8526. This work is placed in the public domain.


Updated on: 2023-05-19T23:44:16.391919+00:00