2

Asked here but still no answer.

What would happen if we provide to OP_CHECKMULTISIG opcode more than threshold number (m) of signatures?

For example, if the m = 3 and n = 6 and the output script is:

3 <pubkey_1> ... <pubkey_6> 6 CHECKMULTISIG

And we provide, for example, this input script (or witness stack for segWit 0):

0 <signature_1> <signature_2> <signature_3> <signature_4> <signature_5>

Will it pass or fail?

1 Answer 1

4

Since the activation of BIP147 (nulldummy softfork) in 2017, the answer is no, this will fail. Before that point it would have been generally non-standard but allowed.

An input to OP_CHECKMULISIG expects on the stack: (from back to front):

  • the number n
  • n public keys
  • the number k
  • k signatures
  • a dummy element (ignored pre-BIP147, must be 0 post-BIP147)

In your example, n=6 is read, followed by 6 keys, then k=3, and then 3 signatures. These 3 signatures do match the penultimate 3 keys, which on itself would work. However, after that a 0 is expected, yet instead there is another signature, which fails.

Before BIP147, the signature_2 would function as the dummy, and signature_1, plus a 1 (from the evaluation of OP_CHECKMULTISIG) and 0 would be left on the stack.

2
  • Actually I provided just 5 signatures (not 6) and the last one is signature_5 (not signature_6). Thus, (before BIP147) signature_3, signature_4 and signature_5 would be taken by the OP_CHECKMULTISIG, signature_2 is dummy (instead of zero), signature_1 plus 1 (as a result of OP_CHECKMULTISIG) would left on the stack. Also zero would left on the stack. Is that more correct or I missed something?
    – Cosmos
    Commented Nov 24, 2023 at 20:02
  • @MudjaAdjum That sounds right. Commented Nov 24, 2023 at 20:03

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.