jasonbcox Mengerian deadalnix
- Group Reviewers
- Maniphest Tasks
- T667: add rule for **minimal** push only in scriptSig
Note this function is not just for checking minimal pushes, rather it checks that a script is push-only and only uses minimal pushes.
This does reuse the existing CheckMinimalPush function, however, currently there is no consensus code that requires minimal pushes aside from BIP34 & the segwit recovery exemption to P2SH, but those use special-purpose methods instead of CheckMinimalPush. So, this adds the requisite tests to ensure that minimal push enforcement is safe for consensus layer.
Note that to enforce a restriction on scriptSig alone, in general some action needs to be done in VerifyScript (not just EvalScript) since EvalScript doesn't know whether it's running a scriptSig or scriptPubKey or whatever. And there is no need to make any consensus rules about push opcodes outside of the scriptSig.
Here are some alternative methods to the same effect:
- During VerifyScript execution, use the consensus SCRIPTSIGMINPUSHONLY flag to force on the (non-consensus) MINIMALDATA flag, but only for the the scriptSig call to EvalScript
- Add an additional boolean flag argument to EvalScript named fIsScriptSig or fRequireMinimalPush or something like that.
- Split the overly-broad MINIMALDATA flag into two parts, one which deals with minimal push enforcement and one which deals with number encoding. Then, adopt the minimal push flag at consensus layer even though it unnecessarily restricts push forms in scriptPubKeys and redeemScripts.
Let me know if you prefer any of these other approaches or have a better one in mind to achieve the same goal.