Combined summary - Draft BIP for OP_TXHASH and OP_CHECKTXHASHVERIFY
The conversation highlights the technical nuances surrounding transaction hashing and script validation in Bitcoin's protocol.
It begins by addressing whether a non-verify transaction hash (TXHASH) is meaningful without the concurrent use of CSFS or CAT, establishing that TXHASH alone can validate the equality between specific fields of a transaction. Further elaboration reveals the synergy between TXHASH and CSFS, and how their combination with CAT significantly expands the possibilities for transaction design.
A particular focus is given to the
TXFS_SPECIAL_TEMPLATE and its difference from CTV (CHECKTEMPLATEVERIFY). In contrast to CTV, which excludes input values leading to awkward fee additions, TXHASH allows for a more versatile TxFieldSelector enabling the inclusion of input values. This approach mitigates the risk of a hash being limited to a UTXO of a specific size and advocates for hashing as much relevant data as possible without causing recursive hashing issues.
The discussion also delves into the comparison between adding CSFS and APO-style keys, noting the minimal size difference but highlighting an advantage of APO-style keys compatibility with CHECKSIGADD. Various options are considered, including the potential use of "magic" keys for internal and external Taproot keys or introducing new opcodes. The email suggests that combining
OP_CHECKSIGFROMSTACK may offer intriguing scripting capabilities, such as requiring signatures from two keys on the same hash. Although emulating
OP_CHECKSIGADD appears cumbersome, it is only marginally less efficient in terms of byte size.
Further suggestions include contemplating a default mode for
TXFS_OUTPUTS to simplify logic by eliminating the need for specifying bytes three and four under certain conditions. Additionally, the rationale behind opting to commit to the control block rather than the tapleaf_hash within the BIP is clarified; the control block commitment implicitly includes the leaf hash through existing BIP341 rules.
The email concludes by recognizing the potential utility of the TxFieldSelector mechanism for future introspection opcodes and proposes the necessity of selecting the current input's script code, possibly repurposing
TXFS_CONTROL. It also mentions that the BIP has advanced beyond the draft stage and that a corresponding implementation has been introduced in Bitcoin Core, accessible via the provided GitHub link: https://github.com/bitcoin/bitcoin/pull/29050.