<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://en.bitcoin.it/w/index.php?action=history&amp;feed=atom&amp;title=OP_CHECKMULTISIG</id>
	<title>OP CHECKMULTISIG - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://en.bitcoin.it/w/index.php?action=history&amp;feed=atom&amp;title=OP_CHECKMULTISIG"/>
	<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=OP_CHECKMULTISIG&amp;action=history"/>
	<updated>2026-05-13T11:16:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=OP_CHECKMULTISIG&amp;diff=68759&amp;oldid=prev</id>
		<title>NotATether: fix minor typo</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=OP_CHECKMULTISIG&amp;diff=68759&amp;oldid=prev"/>
		<updated>2021-07-14T00:19:20Z</updated>

		<summary type="html">&lt;p&gt;fix minor typo&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 00:19, 14 July 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&#039;&#039;&#039;OP_CHECKMULTISIG&#039;&#039;&#039; and &#039;&#039;&#039;OP_CHECKMULTISIGVERIFY&#039;&#039;&#039; are [[Script|script]] opcodes used to verify that the &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;signature &lt;/del&gt;for an M-of-&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;n &lt;/del&gt;multisig transaction input &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;is &lt;/del&gt;valid. It is usually found in P2SH-P2WSH scripts (a P2WSH script that&#039;s wrapped inside a [[P2SH|P2SH]] script) Both of them pop a variable number of values on the stack. In order of stack depth, these are:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&#039;&#039;&#039;OP_CHECKMULTISIG&#039;&#039;&#039; and &#039;&#039;&#039;OP_CHECKMULTISIGVERIFY&#039;&#039;&#039; are [[Script|script]] opcodes used to verify that the &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;signatures &lt;/ins&gt;for an M-of-&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;N &lt;/ins&gt;multisig transaction input &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;are &lt;/ins&gt;valid. It is usually found in P2SH-P2WSH scripts (a P2WSH script that&#039;s wrapped inside a [[P2SH|P2SH]] script) Both of them pop a variable number of values on the stack. In order of stack depth, these are:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* The number of public keys &amp;lt;M&amp;gt;, as a constant opcode, such as OP_2&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* The number of public keys &amp;lt;M&amp;gt;, as a constant opcode, such as OP_2&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>NotATether</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=OP_CHECKMULTISIG&amp;diff=68758&amp;oldid=prev</id>
		<title>NotATether: Create OP_CHECKMULTISIG page</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=OP_CHECKMULTISIG&amp;diff=68758&amp;oldid=prev"/>
		<updated>2021-07-14T00:18:51Z</updated>

		<summary type="html">&lt;p&gt;Create OP_CHECKMULTISIG page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;OP_CHECKMULTISIG&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;OP_CHECKMULTISIGVERIFY&amp;#039;&amp;#039;&amp;#039; are [[Script|script]] opcodes used to verify that the signature for an M-of-n multisig transaction input is valid. It is usually found in P2SH-P2WSH scripts (a P2WSH script that&amp;#039;s wrapped inside a [[P2SH|P2SH]] script) Both of them pop a variable number of values on the stack. In order of stack depth, these are:&lt;br /&gt;
&lt;br /&gt;
* The number of public keys &amp;lt;M&amp;gt;, as a constant opcode, such as OP_2&lt;br /&gt;
** The next &amp;lt;M&amp;gt; parameters that follow are the values of each public key, depending on the value of &amp;lt;M&amp;gt;.&lt;br /&gt;
* The number of signatures &amp;lt;N&amp;gt;, as a constant opcode, such as OP_2&lt;br /&gt;
** The next &amp;lt;N&amp;gt; parameters that follow are the values of each signature, depending on the value of &amp;lt;N&amp;gt;.&lt;br /&gt;
* A dummy value, unused because of a bug in OP_CHECKMULTISIG code that removes an extra value from the stack. Required to be OP_0 to prevent a malleability attack vector described in [[BIP_0147|BIP 147]].&lt;br /&gt;
&lt;br /&gt;
OP_CHECKMULTISIG and OP_CHECKMULTISIGVERIFY both consume 20 signature operations (sigops). Because there&amp;#039;s a hard limit of 20,000 sigops per block, this means a maximum of 1,000 OP_CHECKMULTISIG(VERIFY) transactions can be included in any block.&lt;br /&gt;
&lt;br /&gt;
== How it works ==&lt;br /&gt;
&lt;br /&gt;
In this example&amp;lt;ref&amp;gt;https://bitcoin.stackexchange.com/questions/40669/checkmultisig-a-worked-out-example&amp;lt;/ref&amp;gt;, before OP_CHECKMULTISIG(VERIFY) executes, the stack looks like this:&lt;br /&gt;
&lt;br /&gt;
    3&lt;br /&gt;
    (pubKey3)&lt;br /&gt;
    (pubKey2)&lt;br /&gt;
    (pubKey1)&lt;br /&gt;
    2&lt;br /&gt;
    (sig2)&lt;br /&gt;
    (sig1)&lt;br /&gt;
    0&lt;br /&gt;
&lt;br /&gt;
1. Perform basic sanity checks, such as the number of public keys and signatures on the stack match &amp;lt;M&amp;gt; and &amp;lt;N&amp;gt; respectively, and there aren&amp;#039;t more signatures than public keys.&lt;br /&gt;
&lt;br /&gt;
2. Pop &amp;lt;M&amp;gt;, the public keys, &amp;lt;N&amp;gt;, the signatures, and an unused OP_0 value from the stack.&lt;br /&gt;
&lt;br /&gt;
3. Loop through the public keys and signatures starting with the ones at the top of the stack. In this case, the public key and signature indices will be at pubKey3 and sig2 like this:&lt;br /&gt;
&lt;br /&gt;
    n-&amp;gt;    3&lt;br /&gt;
    ikey-&amp;gt; (pubKey3)&lt;br /&gt;
           (pubKey2)&lt;br /&gt;
           (pubKey1)&lt;br /&gt;
    m-&amp;gt;    2&lt;br /&gt;
    isig-&amp;gt; (sig2)&lt;br /&gt;
           (sig1)&lt;br /&gt;
           0&lt;br /&gt;
&lt;br /&gt;
4. The signature at the index is validated against the public key at the other index. If they match, both indices are advanced to the next public key and signature. Otherwise, only the public key index is advanced to the next position, while the signature index stays the same. For this example, signature validation fails once and then succeeds the next time, so the indices advance like this:&lt;br /&gt;
&lt;br /&gt;
Failed validation index advancement:&lt;br /&gt;
&lt;br /&gt;
    n-&amp;gt;    3&lt;br /&gt;
           (pubKey3)&lt;br /&gt;
    ikey-&amp;gt; (pubKey2)&lt;br /&gt;
           (pubKey1)&lt;br /&gt;
    m-&amp;gt;    2&lt;br /&gt;
    isig-&amp;gt; (sig2)&lt;br /&gt;
           (sig1)&lt;br /&gt;
           0&lt;br /&gt;
&lt;br /&gt;
Passed validation index advancement:&lt;br /&gt;
&lt;br /&gt;
    n-&amp;gt;    3&lt;br /&gt;
           (pubKey3)&lt;br /&gt;
           (pubKey2)&lt;br /&gt;
    ikey-&amp;gt; (pubKey1)&lt;br /&gt;
    m-&amp;gt;    2&lt;br /&gt;
           (sig2)&lt;br /&gt;
    isig-&amp;gt; (sig1)&lt;br /&gt;
           0&lt;br /&gt;
&lt;br /&gt;
If not all the signatures can be verified then these opcodes return false (OP_0), otherwise, they return true (OP_1).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional details ==&lt;br /&gt;
&lt;br /&gt;
=== OP_CHECKMULTISIGVERIFY ===&lt;br /&gt;
&lt;br /&gt;
OP_CHECKMULTISIGVERIFY is equivalent to OP_CHECKMULTISIG except that OP_VERIFY is executed after the operation.&lt;br /&gt;
&lt;br /&gt;
=== Segwit ===&lt;br /&gt;
&lt;br /&gt;
[[Segwit|Segwit]] has moved the contents of the scriptSig to the witness data to thwart malleability problems in the scriptSig. Besides that, the operation of OP_CHECKMULTISIG and OP_CHECKMULTISIGVERIFY aren&amp;#039;t affected.&lt;br /&gt;
&lt;br /&gt;
=== Taproot ===&lt;br /&gt;
&lt;br /&gt;
There is a new opcode, OP_CHECKSIGADD, for validating the signatures of [[Schnorr|Schnorr]]-aggregated public keys and has a much smaller transaction size than OP_CHECKMULTISIG.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>NotATether</name></author>
	</entry>
</feed>