In some documentation about Script we sometimes have to use
OP_PUSHDATAx to indicate that some number of bytes will be an element to read.
They seem to do the same thing so is there a reason they have different names ?
In what documentation ? I believe you are talking about how
rust-bitcoin refers to the OPs
> OP_FALSE and
< OP_PUSHDATA1 and will answer as such.
There are multiple OP codes pushing bytes to the stack, defined as integers.
Special case: pushing small integers
There are dedicating OP codes for pushing integers from
OP_16 and valued
They are used for instance for (small-ish) multisigs as it saves you 1 byte per number pushed compared to using a "real" push opcode.
PUSHBYTES": pushing small byte arrays
The (not named in the reference implementation) OP codes valued from
0x4b allow to push from 1 (
0x01) to 75 (
0x4b) bytes to the stack.
They are commonly used to push pubkeys and signatures.
PUSHADATA: pushing byte arrays
0x4e) operands are used to push a byte array to the stack which size is defined as a variable-length integer .
Further: too many encodings!
This flexibility of encoding introduced malleability in the
scriptSig, which was not protected by the signature (which it carries).
BIP62 proposed to restrict this encoding to avoid possible malleation.