Bitcoin Forum
May 06, 2024, 04:25:37 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Replacing OP_CHECKMULTISIG(VERIFY) with OP_CHECKSIGADD  (Read 199 times)
Zedpastin (OP)
Sr. Member
****
Offline Offline

Activity: 363
Merit: 323

Infographics save lives


View Profile
July 13, 2021, 10:04:51 PM
Merited by Welsh (8), hugeblack (6), ABCbits (3), AverageGlabella (3), pooya87 (2), NotATether (2), vapourminer (1)
 #1

I have a question on how TapRoot improves batch validation by replacing OP_CHECKMULTISIG(VERIFY) with OP_CHECKSIGADD, to support batch validation. I have been reading through the posts and documents supplied here: https://bitcointalk.org/index.php?topic=5140134.0

But I have been struggling to find the documentation explaining how and why this is an improvement. Is there anyone here that can explain the technical differences between OP_CHECKMULTISIG(VERIFY) and OP_CHECKSIGADD and what that means for the future of Bitcoin?
1715012737
Hero Member
*
Offline Offline

Posts: 1715012737

View Profile Personal Message (Offline)

Ignore
1715012737
Reply with quote  #2

1715012737
Report to moderator
1715012737
Hero Member
*
Offline Offline

Posts: 1715012737

View Profile Personal Message (Offline)

Ignore
1715012737
Reply with quote  #2

1715012737
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715012737
Hero Member
*
Offline Offline

Posts: 1715012737

View Profile Personal Message (Offline)

Ignore
1715012737
Reply with quote  #2

1715012737
Report to moderator
NotATether
Legendary
*
Online Online

Activity: 1596
Merit: 6728


bitcoincleanup.com / bitmixlist.org


View Profile WWW
July 13, 2021, 11:04:59 PM
Last edit: July 13, 2021, 11:58:09 PM by NotATether
Merited by Welsh (4), vapourminer (2), ABCbits (2), garlonicon (2), Zedpastin (1)
 #2

OP_CHECKSIGADD's opcode looks like this: OP_CHECKSIGADD <combined public key> <n> <signature>

While OP_CHECKMULTISIG and OP_CHECKMULTISIGVERIFY opcodes take this format: <nsig> <sig1> <sig2> ... <npubkey> <pubkey1> <pubkey2> ... <dummy OP_0 value>

In segwit transactions, it appears that the public keys aren't even included in the redeem script for CHECKMULTISIG* (They're in the witness data, so disregard that). The size of the witness data, hash preimage and as a result the signed transaction is bloated as a result as the number of cosigners increases.

In contrast, OP_CHECKSIGADD only expects a 64 or 65 byte signature and 32 byte public key, so there is a massive space saving here over multisig transactions when several public keys are involved.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
gmaxwell
Moderator
Legendary
*
expert
Online Online

Activity: 4158
Merit: 8382



View Profile WWW
July 15, 2021, 01:01:08 AM
Merited by Welsh (8), NeuroticFish (4), pooya87 (4), hugeblack (4), BlackHatCoiner (4), ABCbits (3), AverageGlabella (2), vapourminer (1), Zedpastin (1)
 #3

CHECKMULTISIG has a stupid design where it has to use trial and error.

Say your stack looks like 0 [sig3] [sig2] 2 [pub3] [pub2] [pub1] 3  with sig3 and sig2 being signatures with pubkeys 3 and 2 respectively.

The validation will first attempt to verify with pub1 and sig2, which will fail. Then it will try pub2 and sig2 which will be successful.

This is pointlessly inefficient and in a batch validation *no* signature can fail or otherwise the whole batch fails. In something like a 1 of 20 signature every node could be forced to process 20 failing signatures just to find the one passing one.

Perhaps Satoshi had intended to use the dummy value to indicate which signatures were in use, but that was never implemented.

The checksigadd construction avoids the inefficiency and makes batch validation possible-- because no checksig(add) input is allowed to fail except for an empty signature regardless of what the surrounding script does.  It also works equally well for weighed thresholds without losing any efficiency.
Zedpastin (OP)
Sr. Member
****
Offline Offline

Activity: 363
Merit: 323

Infographics save lives


View Profile
August 10, 2021, 09:18:38 AM
 #4

Thank you both for your great answers.

Perhaps Satoshi had intended to use the dummy value to indicate which signatures were in use, but that was never implemented.

The checksigadd construction avoids the inefficiency and makes batch validation possible-- because no checksig(add) input is allowed to fail except for an empty signature regardless of what the surrounding script does.  It also works equally well for weighed thresholds without losing any efficiency.

If Satoshi did add the dummy value you still think that this solution is better than that?
vjudeu
Hero Member
*****
Offline Offline

Activity: 678
Merit: 1560



View Profile
August 10, 2021, 10:26:42 AM
Merited by vapourminer (1), Welsh (1)
 #5

Quote
If Satoshi did add the dummy value you still think that this solution is better than that?
Yes, OP_CHECKSIGADD is still better, because you can use combined public key and as long as there is no disagreement, then one signature is enough to cover everything.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
gmaxwell
Moderator
Legendary
*
expert
Online Online

Activity: 4158
Merit: 8382



View Profile WWW
August 10, 2021, 03:25:21 PM
 #6

If Satoshi did add the dummy value you still think that this solution is better than that?
I think it's better than checkmultisig with an extra field that specifies which pubkeys are in use-- because it's also easily adaptable to weighed thresholds.
Zedpastin (OP)
Sr. Member
****
Offline Offline

Activity: 363
Merit: 323

Infographics save lives


View Profile
August 15, 2021, 05:41:38 PM
 #7

Thank you everyone for answering my questions! I am sure I will have more Cheesy
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!