1

In this answer Vojtěch Strnad wrote the following:

OP_CHECKSIGADD always performs one check per signature, since unused public keys are required to be paired with an empty witness item and are skipped.

I'm interested in the following. If we provide zero (OP_0 / no item on a stack / empty witness item) and public key to OP_CHECKSIG (pre-segWit/post-segWit), to OP_CHECKSIGADD or to OP_CHECKMULTISIG (pre-segWit/post-segWit) will it perform any check operation or it will just skip the check (as Vojtěch said) and put 0 on the stack?

0

1 Answer 1

3

For pre-Tapscript opcodes (CHECKSIG and CHECKMULTISIG), the empty signature is checked against the public key. Note that by standardness if the check fails, the signature is required to be the empty vector.

For Tapscript opcodes (CHECKSIG and CHECKSIGADD), the signature check is not performed at all if the empty vector is passed as the signature. Note that by consensus if the check fails, the signature is required to be the empty vector.

10
  • What is the purpose of OP_CHECKSIGVERIFY then? According to what you said, OP_CHECKSIG and OP_CHECKSIGVERIFY then have the same meaning.
    – Cosmos
    Nov 24, 2023 at 22:41
  • Nvm, I found it in BIP342.
    – Cosmos
    Nov 24, 2023 at 22:52
  • Yes, CHECKSIG and CHECKSIGVERIFY behave in the very same way with regard to signature checking. CHECKSIGVERIFY just immediately stops execution if the signature check failed. Nov 24, 2023 at 23:06
  • 2
    OP_CHECKSIGVERIFY is exactly equivalent to OP_CHECKSIG by OP_VERIFY. The stack consists of a list of byte vectors. E.g. OP_0 pushes the empty vector, which represents the number 0 (to numeric opcodesk). Nov 24, 2023 at 23:32
  • 1
    That's true for invalid signatures in general, but not for empty signatures, which causes OP_CHECKSIG to leave an empty element on the stack, while it causes OP_CHECKSIGVERIFY to abort. Nov 25, 2023 at 2:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.