Skip to content

BIP143: specify which CHECKMULTISIG keys must be compressed - #2370

Open
jeanpablojp wants to merge 2 commits into
bitcoin:masterfrom
jeanpablojp:bip143-multisig-pubkeys
Open

jeanpablojp wants to merge 2 commits into
bitcoin:masterfrom
jeanpablojp:bip143-multisig-pubkeys

Conversation

@jeanpablojp

Copy link
Copy Markdown
Contributor

BIP143 says each public key passed to a sigop in a v0 witness program must be compressed. In OP_CHECKMULTISIG, Bitcoin Core only checks the keys the opcode reaches, and script_tests.json asserts that an uncompressed key that is never reached passes with WITNESS_PUBKEYTYPE.

bitcoin/bitcoin#33759 proposed checking every key instead. Reviewers preferred updating the BIP to match the implementation, and the author of that PR was fine with clarifying the BIP. Item 4 of bitcoin/bitcoin#33882 lists both options.

The second commit adds a paragraph describing the deployed behavior. The first adds a version header and changelog per BIP 3, with 1.0.0 as the move to Proposed in 0402dd2 and 1.0.1 as the move to Final in #584.

Version 1.0.0 is the move to Proposed in 0402dd2 and 1.0.1 is the
move to Final in bitcoin#584.
@jonatack jonatack added Proposed BIP modification PR by non-owner to update BIP content Pending acceptance This BIP modification requires sign-off by the champion of the BIP being modified labels Nov 30, 2026
@jonatack

Copy link
Copy Markdown
Member

cc BIP authors @sipa @jl2012 for feedback or sign-off

@connectybot

Copy link
Copy Markdown

ACK d562c0f

Checked the new paragraph against OP_CHECKMULTISIG in Bitcoin Core master (interpreter.cpp): keys are visited from the top of the stack, CheckPubKeyEncoding runs on each visited key before the signature check, and the loop exits once all signatures are matched or nSigsCount > nKeysCount. The OP_1 P1 P2 OP_2 OP_CHECKMULTISIG example matches the "second key uncompressed and signing with the first key" vectors in script_tests.json, which pass under WITNESS_PUBKEYTYPE.

Also checked the changelog: 1.0.0 matches 0402dd2 (Proposed, 2017-10-29) and 1.0.1 matches the Final move merged from #584 (2018-02-12). The Version header and entry format match BIP 3. link-format-chk.sh, diffcheck.sh and buildtable.pl pass on this branch merged with master.

Optional: the example only shows a key that is not checked. One sentence saying a reached key is checked even if it does not match the signature would make the boundary clearer; the "first key uncompressed and signing with the second key" vectors fail with WITNESS_PUBKEYTYPE.

@jonatack

jonatack commented Dec 3, 2026

Copy link
Copy Markdown
Member

Thank you for reviewing, @connectybot.

@nickspaargaren

Copy link
Copy Markdown

@jeanpablojp, quick check on d562c0f: in OP_CHECKMULTISIG, is an uncompressed key allowed if the script never reaches it? And if it's reached but doesn't match the signature, is it rejected? Would you add the reviewer's suggested sentence to make that explicit?

In OP_CHECKMULTISIG, Bitcoin Core only checks the public keys the opcode
reaches, and its script tests have vectors where an uncompressed key
that is not reached passes with WITNESS_PUBKEYTYPE. Reviewers of
bitcoin/bitcoin#33759 preferred changing the BIP to match, see also
item 4 of bitcoin/bitcoin#33882.
@jeanpablojp
jeanpablojp force-pushed the bip143-multisig-pubkeys branch from d562c0f to 34978d3 Compare December 3, 2026 21:21
@jeanpablojp

Copy link
Copy Markdown
Contributor Author

Thanks, I added the suggested sentence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Pending acceptance This BIP modification requires sign-off by the champion of the BIP being modified Proposed BIP modification PR by non-owner to update BIP content

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants