Bitcoin Forum
September 27, 2018, 10:26:44 PM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: CHECKMULTISIG vs. CHECKMULTISIGVERIFY - inconsistency on bitcoin.it?  (Read 3299 times)
cjp
Full Member
***
Offline Offline

Activity: 210
Merit: 100



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/
1538087204
Hero Member
*
Offline Offline

Posts: 1538087204

View Profile Personal Message (Offline)

Ignore
1538087204
Reply with quote  #2

1538087204
Report to moderator
1538087204
Hero Member
*
Offline Offline

Posts: 1538087204

View Profile Personal Message (Offline)

Ignore
1538087204
Reply with quote  #2

1538087204
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
theymos
Administrator
Legendary
*
expert
Offline Offline

Activity: 3164
Merit: 3725


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:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!