Bitcoin Forum
May 08, 2024, 08:23:44 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: CHECKMULTISIG vs. CHECKMULTISIGVERIFY - inconsistency on bitcoin.it?  (Read 3390 times)
cjp (OP)
Full Member
***
Offline Offline

Activity: 210
Merit: 124



View Profile WWW
September 26, 2014, 08:07:42 PM
 #1

I'm trying to decide what kind of Bitcoin scripts to use for my application, based on information from bitcoin.it.

https://en.bitcoin.it/wiki/Script:
A transaction is valid if nothing in the combined script triggers failure and the top stack item is true (non-zero).
OP_CHECKMULTISIGFor each signature and public key pair, OP_CHECKSIG is executed. If more public keys than signatures are listed, some key/sig pairs can fail. All signatures need to match a public key. If all signatures are valid, 1 is returned, 0 otherwise. Due to a bug, one extra unused value is removed from the stack.
OP_CHECKMULTISIGVERIFYSame as OP_CHECKMULTISIG, but OP_VERIFY is executed afterward.
OP_VERIFYMarks transaction as invalid if top stack value is not true.

https://en.bitcoin.it/wiki/Contracts:
Section "Theory":
2 <pubkey1> <pubkey2> 2 CHECKMULTISIGVERIFY

I don't understand this: if this is signed with two signatures, then the boolean output of the CHECKMULTISIG part will be popped from the stack by the VERIFY part. So, evaluation of correct signatures ends with an empty stack, unless scriptPubKey contains another, redundant "True". I'd say that, according to the validity condition described on the Script page, an empty stack would NOT be valid, since it does not contain a top element that is True. So, CHECKMULTISIG should be used here instead of CHECKMULTISIGVERIFY.

Should I fix the wiki page? Is the use of CHECKMULTISIGVERIFY really wrong here? Why does it say CHECKMULTISIGVERIFY in the first place? Is this old obsolete/deprecated? I see CHECKMULTISIG being used in other places, so I suppose that, at least, that one is not wrong.

Which of the two is considered to be a "standard" multisig script by the Satoshi client?

I have basically the same question about EQUALVERIFY vs. EQUAL, but I suppose this isn't a standard script yet:
<key> CHECKSIGVERIFY SHA256 <hash of secret x> EQUAL[VERIFY]

PS. I just read about the bug in CHECKMULTISIG (popping an extra value). Is it also present in CHECKMULTISIGVERIFY? Does this mean that, in the CHECKMULTISIGVERIFY example above, the signer is supposed to add an extra unused value to scriptSig?

Donate to: 1KNgGhVJx4yKupWicMenyg6SLoS68nA6S8
http://cornwarecjp.github.io/amiko-pay/
1715199824
Hero Member
*
Offline Offline

Posts: 1715199824

View Profile Personal Message (Offline)

Ignore
1715199824
Reply with quote  #2

1715199824
Report to moderator
According to NIST and ECRYPT II, the cryptographic algorithms used in Bitcoin are expected to be strong until at least 2030. (After that, it will not be too difficult to transition to different algorithms.)
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715199824
Hero Member
*
Offline Offline

Posts: 1715199824

View Profile Personal Message (Offline)

Ignore
1715199824
Reply with quote  #2

1715199824
Report to moderator
theymos
Administrator
Legendary
*
Offline Offline

Activity: 5194
Merit: 12976


View Profile
September 26, 2014, 09:53:37 PM
 #2

You're right. You shouldn't end a script with a -VERIFY opcode because the stack needs to contain a non-false value when it completes. You can use a -VERIFY opcode, but doing so requires adding wasteful data in the scriptSig.

Quote
PS. I just read about the bug in CHECKMULTISIG (popping an extra value). Is it also present in CHECKMULTISIGVERIFY? Does this mean that, in the CHECKMULTISIGVERIFY example above, the signer is supposed to add an extra unused value to scriptSig?

Yes. Bitcoin Core always uses OP_0 as a dummy value.

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
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!