You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OP_NUM2BIN can be used to generate a lot of zeros on the stack (520 bytes with 1 opcode and 3 bytes). Combined with OP_HASH256 or other opcodes, this can be quite slow.
Also, numbers will never be longer than 68 bytes, so it's kinda ridiculous to allow 520 bytes.
Why 68 bytes?
There's a neat trick for reducing the size of the preimage for the OP_CHECKDATASIG/OP_CHECKSIG transaction introspection. You use ANYONECANPAY, and then with 2 68 OP_NUM2BIN you generate parts 1. (nVersion, here 02000000), 2. (hashPrevouts, here a uint256 of 0x0000......0000) and 3. (hashSequence, here a uint256 of 0x0000......0000).
This saves around 64 bytes for a transaction and only costs 1 opcode. Reducing the OP_NUM2BIN size to 68 keeps that optimization.
The text was updated successfully, but these errors were encountered:
OP_NUM2BIN
can be used to generate a lot of zeros on the stack (520 bytes with 1 opcode and 3 bytes). Combined withOP_HASH256
or other opcodes, this can be quite slow.Also, numbers will never be longer than 68 bytes, so it's kinda ridiculous to allow 520 bytes.
Why 68 bytes?
There's a neat trick for reducing the size of the preimage for the OP_CHECKDATASIG/OP_CHECKSIG transaction introspection. You use ANYONECANPAY, and then with
2 68 OP_NUM2BIN
you generate parts 1. (nVersion
, here02000000
), 2. (hashPrevouts
, here auint256
of0x0000......0000
) and 3. (hashSequence
, here auint256
of0x0000......0000
).This saves around 64 bytes for a transaction and only costs 1 opcode. Reducing the OP_NUM2BIN size to 68 keeps that optimization.
The text was updated successfully, but these errors were encountered: