delvingbitcoin
Draft BIP for OP_TXHASH and OP_CHECKTXHASHVERIFY
Posted on: September 30, 2023 22:21 UTC
The discussion revolves around the newly proposed Bitcoin Improvement Proposal (BIP) which aims to introduce a significant upgrade in how transactions within the Bitcoin network can be managed and verified.
At the core of this proposal is the introduction of a TxFieldSelector, a novel serialized data structure designed for selecting specific data inside a transaction. This mechanism enables the selection of various global fields such as version, locktime, number of inputs and outputs, alongside more granular details for each transaction input or output, including scriptPubkey, value, and taproot annex among others.
This BIP also proposes two new opcodes: OP_TXHASH and OP_CHECKTXHASHVERIFY. OP_TXHASH is enabled only in tapscript contexts and allows for the generation of a hash that commits to the data selected by the TxFieldSelector. The OP_CHECKTXHASHVERIFY opcode is available in all scripting contexts and serves as a verification tool that compares a provided hash value with one calculated from a TxFieldSelector, ensuring execution fails if they do not match. Additionally, the proposal outlines considerations for minimizing resource usage and avoiding excessive hashing, suggesting potential caching strategies and limitations on individual selection to enhance efficiency.
One of the pivotal achievements of this BIP, if adopted, would be its role as a strict upgrade over BIP-119. The flexibility offered by the proposed TxFieldSelector in terms of selecting transaction fields and specifying conditions on them could significantly benefit transaction chain integrity and collaborative transaction construction. Furthermore, it has the potential to simplify complex sighash constructions, making it a versatile tool for protocol designers.
However, the proposal still poses open questions regarding its implications on resource usage and quadratic hashing. There's also a debate about whether including the TxFieldSelector as part of the hash could impact the ability to prove field equality, with suggestions for minor adjustments to address these concerns without compromising the proposal’s utility.
The draft BIP is currently open for community feedback with the hope that sufficient interest will lead to formalization and implementation within Bitcoin Core. The full text of the BIP is accessible for review at this link, inviting contributions and discussions from the wider Bitcoin development community.