Safer sighashes and more granular SIGHASH_NOINPUT



Summary:

In a discussion on the bitcoin-dev mailing list, Johnson Lau suggested that Merklized Abstract Syntax Trees (MAST) should be used instead of improving the functionality of OP_IF and further complicating the protocol. Russell O'Connor responded to Pieter Wuille's question about whether the introduction of MAST introduces redundant flexibility or misses obvious use cases by suggesting a replacement for the functionality of OP_CODESEPARATOR. O'Connor stated that each call to OP_CODESEPARATOR takes O(script-size) time, so a replacement is needed. One suggestion made was to add an internal counter that increments on every control flow operator, such as OP_IF, OP_NOTIF, OP_ELSE, and OP_ENDIF, and have the signature cover the value of this counter. Alternatively, dividing every Bitcoin Script program into blocks delimited by these control flow operators and having the signature cover the index of the block that the OP_CHECKSIG occurs within could work too. The aim is to sign in such a way that the signature is only valid when the conditions for a particular branch are satisfied.


Updated on: 2023-06-13T15:27:32.432443+00:00