rpc, wallet: Support BIP322 simple message signing #36809

Open
jaromil wants to merge 7 commits from bip322-segwit into master AGit
jaromil commented 2026-11-09 02:04:03 +00:00 (Migrated from github.com)

Description

The message RPCs currently support legacy compact signatures for P2PKH addresses. This adds BIP322 simple proofs for native P2WPKH, P2WSH and P2TR addresses, allowing users to sign and verify messages for these addresses without creating an on-chain transaction.

signmessage uses the wallet’s existing descriptor signing machinery and requires a complete satisfaction. This includes P2WSH multisig and supported Miniscript satisfactions, and Taproot key and script paths. It returns smp followed by the base64-encoded serialized witness stack.

verifymessage uses Core’s script interpreter to check the proof against the address and message. Verification requires no wallet or chain data and accepts both prefixed and older unprefixed simple proofs. Malformed base64 or witness serialization raises an RPC error; invalid proofs, unsupported signature formats and inconclusive results return false.

The RPC names and argument counts are unchanged. P2PKH compact signatures and signmessagewithprivkey retain their existing behavior. Full signatures, proofs of funds and P2SH addresses, including wrapped SegWit, are outside this change. Signing remains limited to satisfactions available to the wallet.

No consensus rules or signing-provider interfaces are changed. Help and release notes describe the supported formats and limitations.

Related earlier work: #24058.

Tests

A shared fixture imports the applicable CC0 vectors from the pinned BIP: eight simple rows containing ten proofs, three hash cases and sixteen error cases. Published proofs are checked independently of locally generated signatures.

Coverage includes:

  • bip322_tests and bip322_wallet_tests: transaction construction, parsing bounds, address binding, sighash and script rules, descriptor signing, incomplete satisfactions and wallet locking.
  • rpc_bip322.py: published proofs in both encodings, invalid proofs and network-specific address parsing.
  • Both existing message tests: legacy behavior, RPC errors and native witness signing.
  • rpc_help.py: updated help.
## Description The message RPCs currently support legacy compact signatures for P2PKH addresses. This adds [BIP322](https://github.com/bitcoin/bips/blob/a34f044bb8d5cd684d7a742d2f6483c14b719046/bip-0322.mediawiki) simple proofs for native P2WPKH, P2WSH and P2TR addresses, allowing users to sign and verify messages for these addresses without creating an on-chain transaction. signmessage uses the wallet’s existing descriptor signing machinery and requires a complete satisfaction. This includes P2WSH multisig and supported Miniscript satisfactions, and Taproot key and script paths. It returns smp followed by the base64-encoded serialized witness stack. verifymessage uses Core’s script interpreter to check the proof against the address and message. Verification requires no wallet or chain data and accepts both prefixed and older unprefixed simple proofs. Malformed base64 or witness serialization raises an RPC error; invalid proofs, unsupported signature formats and inconclusive results return false. The RPC names and argument counts are unchanged. P2PKH compact signatures and signmessagewithprivkey retain their existing behavior. Full signatures, proofs of funds and P2SH addresses, including wrapped SegWit, are outside this change. Signing remains limited to satisfactions available to the wallet. No consensus rules or signing-provider interfaces are changed. Help and release notes describe the supported formats and limitations. Related earlier work: #24058. ## Tests A shared fixture imports the applicable CC0 vectors from the pinned BIP: eight simple rows containing ten proofs, three hash cases and sixteen error cases. Published proofs are checked independently of locally generated signatures. Coverage includes: - bip322_tests and bip322_wallet_tests: transaction construction, parsing bounds, address binding, sighash and script rules, descriptor signing, incomplete satisfactions and wallet locking. - rpc_bip322.py: published proofs in both encodings, invalid proofs and network-specific address parsing. - Both existing message tests: legacy behavior, RPC errors and native witness signing. - rpc_help.py: updated help.
DrahtBot commented 2026-11-09 02:04:12 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36808 (iwyu: Fix warnings in src/test/fuzz and treat them as errors by hebasto)
  • #36074 (scripted-diff: [test] Add util/check.h includes for assertions by maflcko)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

LLM Linter (✨ experimental)

Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

  • src/test/bip322_tests.cpp: SignatureHash(script, txs.to_sign, 0, hash_type, 0, SigVersion::WITNESS_V0)
  • src/test/bip322_tests.cpp: SignatureHashSchnorr(hash, exec, txs.to_sign, 0, hash_type, ...)
  • src/test/bip322_tests.cpp (OrdinaryVerify): data.Init(tx, {txs.to_spend.vout[0]}, true)
  • src/test/bip322_tests.cpp (SignSchnorr): data.Init(txs.to_sign, {txs.to_spend.vout[0]}, true)
  • src/test/bip322_tests.cpp: MakeTapProof(CScript() << OP_1, {}, 0xc2)
  • src/test/bip322_tests.cpp: MakeTapProof(CScript() << OP_CODESEPARATOR, {}, 0xc2)
  • src/wallet/test/bip322_wallet_tests.cpp (musig_nonce_lifetime): data.Init(tx, {txs.to_spend.vout[0]}, true)
  • src/wallet/test/bip322_wallet_tests.cpp (forbidden_script_commitments): data.Init(tx, {txs.to_spend.vout[0]}, true)

2026-11-09 16:07:24

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36809 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36809.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36809#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. A summary of reviews will appear here. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36808](https://github.com/bitcoin/bitcoin/pull/36808) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36808.svg"></sub> (iwyu: Fix warnings in `src/test/fuzz` and treat them as errors by hebasto) * [#36074](https://github.com/bitcoin/bitcoin/pull/36074) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36074.svg"></sub> (scripted-diff: [test] Add util/check.h includes for assertions by maflcko) If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. <!--5faf32d7da4f0f540f40219e4f7537a3--> ### LLM Linter (✨ experimental) Possible places where named args for integral literals may be used (e.g. `func(x, /*named_arg=*/0)` in C++, and `func(x, named_arg=0)` in Python): - `src/test/bip322_tests.cpp`: `SignatureHash(script, txs.to_sign, 0, hash_type, 0, SigVersion::WITNESS_V0)` - `src/test/bip322_tests.cpp`: `SignatureHashSchnorr(hash, exec, txs.to_sign, 0, hash_type, ...)` - `src/test/bip322_tests.cpp` (`OrdinaryVerify`): `data.Init(tx, {txs.to_spend.vout[0]}, true)` - `src/test/bip322_tests.cpp` (`SignSchnorr`): `data.Init(txs.to_sign, {txs.to_spend.vout[0]}, true)` - `src/test/bip322_tests.cpp`: `MakeTapProof(CScript() << OP_1, {}, 0xc2)` - `src/test/bip322_tests.cpp`: `MakeTapProof(CScript() << OP_CODESEPARATOR, {}, 0xc2)` - `src/wallet/test/bip322_wallet_tests.cpp` (`musig_nonce_lifetime`): `data.Init(tx, {txs.to_spend.vout[0]}, true)` - `src/wallet/test/bip322_wallet_tests.cpp` (`forbidden_script_commitments`): `data.Init(tx, {txs.to_spend.vout[0]}, true)` <sup>2026-11-09 16:07:24</sup>
First-time contributor

🔵 Suggestion · Fully keyed BIP322 failures report missing private keys

An unlocked wallet can receive Private key not available despite holding all needed keys when its only spending path requires an incompatible timelock or a MuSig2 session that one-shot signing cannot complete.

Location: src/wallet/wallet.cpp:2093 (head).

🔵 Suggestion · GUI messages still describe SegWit signing as unsupported in this version

The unchanged Qt dialog rejects BIP322 proofs produced by the RPC while still describing SegWit message signing as unsupported in this version.

Location: src/rpc/signmessage.cpp:49 (head).

🔵 Suggestion · Non-upgrade BIP322 failures repeat signature verification

When the combined pass fails with a non-DISCOURAGE_* error, the required-only retry repeats the same script execution and uncached signature checks without changing the result.

Location: src/common/signmessage.cpp:238 (head).

🔵 Suggestion · Message-proof script disclosure is undocumented

Sharing a P2WSH proof or a Taproot proof produced through script fallback reveals script data that the new signmessage help and release notes do not describe.

Location: src/wallet/rpc/signmessage.cpp:25 (head).

🔵 Suggestion · Opaque Taproot leaves lack a fuzz classification oracle

The new script-derived fuzz branch ignores verification outcomes, so it cannot detect incorrect classification of opaque Taproot leaves even though the generator supplies matching commitments.

Location: src/test/fuzz/message.cpp:105 (head).

Review coverage was incomplete.


Reviewed: 48749389577f · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:7eebed8027c96ac27bcd79eeb7a88e35799cd96eb8fbacf34d3257986a959f64:6952af7d31ef83bb85ac4ee73e8c979307f4998f73396eb2a639b474cdfe83e6 --> <!-- ralph-base:44901d8f64cb617714707bd025ecd83f108353c2 --> <!-- ralph-head:48749389577f886e701856bcce772ca31adec165 --> <!-- ralph-case:608bdd864ef44468ffd4cc635148b528c56deabea9882f2139321828104e0b5c --> **🔵 Suggestion · Fully keyed BIP322 failures report missing private keys** An unlocked wallet can receive `Private key not available` despite holding all needed keys when its only spending path requires an incompatible timelock or a MuSig2 session that one-shot signing cannot complete. Location: [`src/wallet/wallet.cpp:2093`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/48749389577f886e701856bcce772ca31adec165/src/wallet/wallet.cpp#L2093>) (head). **🔵 Suggestion · GUI messages still describe SegWit signing as unsupported in this version** The unchanged Qt dialog rejects BIP322 proofs produced by the RPC while still describing SegWit message signing as unsupported in this version. Location: [`src/rpc/signmessage.cpp:49`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/48749389577f886e701856bcce772ca31adec165/src/rpc/signmessage.cpp#L49>) (head). **🔵 Suggestion · Non-upgrade BIP322 failures repeat signature verification** When the combined pass fails with a non-`DISCOURAGE_*` error, the required-only retry repeats the same script execution and uncached signature checks without changing the result. Location: [`src/common/signmessage.cpp:238`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/48749389577f886e701856bcce772ca31adec165/src/common/signmessage.cpp#L238>) (head). **🔵 Suggestion · Message-proof script disclosure is undocumented** Sharing a P2WSH proof or a Taproot proof produced through script fallback reveals script data that the new `signmessage` help and release notes do not describe. Location: [`src/wallet/rpc/signmessage.cpp:25`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/48749389577f886e701856bcce772ca31adec165/src/wallet/rpc/signmessage.cpp#L25>) (head). **🔵 Suggestion · Opaque Taproot leaves lack a fuzz classification oracle** The new script-derived fuzz branch ignores verification outcomes, so it cannot detect incorrect classification of opaque Taproot leaves even though the generator supplies matching commitments. Location: [`src/test/fuzz/message.cpp:105`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/48749389577f886e701856bcce772ca31adec165/src/test/fuzz/message.cpp#L105>) (head). Review coverage was incomplete. <!-- Review tier: sensitive --> --- Reviewed: [`48749389577f`](<https://git.fish.foo/bitcoin/bitcoin/commit/48749389577f886e701856bcce772ca31adec165>) · [Review report](<https://review.fish.foo/report/36809-48749389577f886e701856bcce772ca31adec165-2416-4.html>) · [Previous reports](<https://review.fish.foo/traces/36809/>) [permalink](<https://review.fish.foo/report/36809-48749389577f886e701856bcce772ca31adec165-2416-4.html>)
DrahtBot commented 2026-11-09 03:04:08 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task lint: https://github.com/bitcoin/bitcoin/actions/runs/42548857757/job/128939706261
LLM reason (✨ experimental): CI failed because the locale-dependence lint flagged std::to_string in src/wallet/test/bip322_wallet_tests.cpp.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `lint`: https://github.com/bitcoin/bitcoin/actions/runs/42548857757/job/128939706261</sub> <sub>LLM reason (✨ experimental): CI failed because the locale-dependence lint flagged `std::to_string` in `src/wallet/test/bip322_wallet_tests.cpp`.</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
DrahtBot commented 2026-11-10 13:47:51 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36809
No description provided.