MultiversX Tracker is Live!

How does the CHECKSIGADD opcode work? How does it compare to its predecessor CHECKMULTISIG?

Bitcoin Stack Exchange

Bitcoin News / Bitcoin Stack Exchange 155 Views

James Chiang explained how the CHECKSIGADD opcode works in this Bitcoin Optech workshop. (The code for CHECKSIGADD in the Bitcoin Core codebase is here.)

As you can see on the left we have an output script that uses CHECKSIGADD and CHECKSIG opcodes to express a n-of-n multisig output.

pk0
checksig
pk1
checksigadd
pk2
checksigadd
3
equal

This is our initial stack which is populated with 3 signatures:

sig0
sig1
sig2

In the first step we will push this public key (pk0) onto the stack and evaluate that against sig0 with the opcode CHECKSIG. Let’s assume this evaluates to TRUE. Since it evaluates to TRUE we will now have a 1 byte on the top of the stack:

1
sig1
sig2

We will use a counter.

2
sig2

As we evaluate the signatures against other public keys, if that script evaluates successfully we will then have a counter of 3 on the stack and that counter can then be compared to the one encoded in the output script. If they are equal we have successfully spent a 3-of-3 multisig output which uses CHECKSIGADD to encode that multisig.

3

How does it compare to its predecessor CHECKMULTISIG?

CHECKMULTISIG doesn't (it is still used for SegWit v0 spends) use an increasing counter. The equivalent locking script using CHECKMULTISIG would be:

3
pk0
pk1
pk2
3
checkmultisig

CHECKMULTISIG also contains a longstanding bug which means the unlocking script requires a 0 at the bottom to satisfy the locking script.

sig0
sig1
sig2
0

The operation of CHECKMULTISIG is explained in this StackExchange question.


Get BONUS $200 for FREE!

You can get bonuses upto $100 FREE BONUS when you:
πŸ’° Install these recommended apps:
πŸ’² SocialGood - 100% Crypto Back on Everyday Shopping
πŸ’² xPortal - The DeFi For The Next Billion
πŸ’² CryptoTab Browser - Lightweight, fast, and ready to mine!
πŸ’° Register on these recommended exchanges:
🟑 Binance🟑 Bitfinex🟑 Bitmart🟑 Bittrex🟑 Bitget
🟑 CoinEx🟑 Crypto.com🟑 Gate.io🟑 Huobi🟑 Kucoin.



Comments