Hi everyone,
In December I proposed CHIP 2024-12 OP_EVAL: Function Evaluation
to enable reusable functions in Bitcoin Cash contracts. In the due diligence for that proposal, I concluded that the two-opcode approach is a better technical choice (see comparison).
I’ve withdrawn my advocacy for the single-opcode OP_EVAL
approach, and modified the CHIP’s technical specification to use the two-opcode approach: OP_DEFINE
and OP_INVOKE
.
Most of the CHIP remains unchanged, but to minimize confusion, I’ve bumped the version to v2.0.0
and updated the title: CHIP-2025-05 Functions: Function Definition and Invocation
.
Questions, feedback, and continued review are appreciated!
Summary
This proposal introduces the OP_DEFINE
and OP_INVOKE
opcodes, enabling Bitcoin Cash contract bytecode to be factored into reusable functions.
Motivation & Benefits
-
Reduced transaction sizes – By eliminating duplicated bytecode, contract lengths can be optimized for a wider variety of use cases: finite field arithmetic, pairing-based cryptography, zero-knowledge proof systems, homomorphic encryption, post-quantum cryptography, and other important applications for the future security and competitiveness of Bitcoin Cash.
-
Stronger privacy and operational security – By enabling contract designs which leak less information about security measures, current assets, and transaction history, this proposal strengthens privacy and operational security for a variety of use cases.
-
Improved auditability – Without reusable functions, contracts are forced to unnecessarily duplicate significant logic. This proposal enables contracts to be written using more succinct, auditable patterns.