Review report

bitcoin/bitcoin: PR #36809

1 minor finding · 5 suggestions

Findings

Link

[minor] · One-shot BIP322 signing retains unusable MuSig2 secret nonces

An unlocked wallet holding a MuSig2 participant key accumulates an unusable nonce entry on each BIP322 signing attempt, including successful script-path fallback, until the wallet is unloaded.

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

Details and suggested fix

For an imported tr(musig(A,B)) descriptor holding A's private key and only B's public key, an authenticated signmessage call tries MuSig2 signing and stores a fresh secret nonce in the descriptor manager. The generic signer then discards the public nonce with its local SignatureData. Deleting the secret nonce requires a later partial-signature round, which this one-shot API cannot perform. The call returns Private key not available, but the entry remains; adding a satisfiable pk(A) leaf lets signing succeed without reclaiming it either. The shared raw-transaction signer already has this behavior, but this PR introduces it to message signing, where those sessions cannot be resumed. Give this operation a call-local nonce store while preserving ordinary key-path and script-path signing, and test repeated failure and successful fallback. This is retained memory per call, not nonce reuse or key exposure.


Optional improvements

Link

[suggestion] · Valid BIP322 proofs repeat potentially block-scale script validation

Consensus-sized Taproot proofs can require roughly 80,000 uncached Schnorr checks per pass, and valid proofs repeat that work even though one pass can establish success.

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

Details and suggested fix

The limit is a 4,000,000-WU virtual transaction, whose roughly 5.3 MB base64 proof fits the 32 MiB HTTP body limit. A near-limit tapscript witness permits roughly 80,000 signature checks through the uncached transaction checker. An authenticated RPC client can request that bounded work for an address it controls; third-party exposure depends on a service forwarding such proofs. Valid proofs, and otherwise valid annex proofs, execute both interpreter passes. Large item counts also reserve and copy vectors before stack-limit rejection. Run REQUIRED|UPGRADE first and fall back to REQUIRED only on failure. Retain the committed-script CODESEPARATOR check on both paths, required-failure precedence, annex/unknown classifications and separate diagnostic state. This preserves the outcomes while valid proofs need only one pass. If consensus-sized proofs remain supported, document the limit and cost rather than implicitly treating verification as a compact-signature-sized operation.


Link

[suggestion] · Unsatisfiable timelocks are reported as missing private keys

Policies requiring a positive absolute timelock or active relative timelock report missing keys even when the wallet has them, without explaining the simple-proof format restriction.

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

Details and suggested fix

For a wallet holding every required key, a branch such as and_v(v:pk(key),after(1)) or its older(1) counterpart still cannot sign: BIP322 simple proofs fix version, nLockTime and nSequence at zero, and the satisfier checks those fields. This helper maps that failure to PRIVATE_KEY_NOT_AVAILABLE, which signmessage exposes as RPC error -4, Private key not available. The nonzero_timelocks test already asserts this case with the private key imported. Add a help and release-note sentence explaining that simple proofs cannot use branches requiring positive absolute timelocks or active relative timelocks, although an alternative untimelocked branch may still sign. That explains the correct rejection without suggesting a key-import or backup problem.


Link

[suggestion] · The GUI still describes RPC-supported SegWit signing as unavailable

The unchanged GUI rejects native witness proofs produced by this release's RPC and incorrectly describes SegWit message signing as unsupported by the entire version.

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

Details and suggested fix

The RPC handlers now support native P2WPKH, P2WSH and P2TR message proofs, but the dialog still accepts only PKHash for signing and calls legacy MessageVerify for verification. Pasting an RPC-generated proof therefore reaches the message saying SegWit signing “is not supported in this version,” and the sign tab gives the same explanation. The GUI restriction predates this PR, so no previously working GUI feature regresses. Update both status messages to explain that native witness message proofs are available through RPC only in this version. GUI support can remain a follow-up without presenting an inaccurate release-wide limitation.


Link

[suggestion] · Taproot message signatures carry an avoidable sighash byte

The explicit SIGHASH_ALL request adds one byte to each Taproot signature; SIGHASH_DEFAULT would keep v0 signatures unchanged and match ordinary wallet signing.

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

Details and suggested fix

Pass SIGHASH_DEFAULT here, as the ordinary wallet transaction-signing wrapper already does. CreateSig translates it to SIGHASH_ALL for witness v0, while CreateSchnorrSig produces 64-byte Taproot signatures without an explicit hash-type byte for both key and script paths. The BIP322 verifier accepts that form. The current 65-byte output remains valid, and no verifier rejecting it was identified; the benefit is compactness and consistency, not a demonstrated compatibility fix. Update the comment and the official_vectors and taproot_paths unit assertions that currently require 65-byte signatures ending in SIGHASH_ALL.


Link

[suggestion] · Independent commitments restrict BIP322 script fuzzing

Independent program and proof bytes make script mutations fail commitment checks, so the message fuzz target mainly explores BIP322's post-verification classification for scripts already supplied in valid seeds.

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

Details and suggested fix

The target reads the P2WSH hash or Taproot output key separately from the witness. Mutating a witness script or leaf therefore normally fails commitment verification before execution, while CODESEPARATOR inspection and upgrade classification require the first verification pass to succeed. Valid seeds still permit argument, message and encoding mutations, and unit tests cover fixed rule cases. Keep the existing parsing modes and add a script-derived commitment mode: hash the fuzzed script for P2WSH, or construct the Taproot output key and control block from a fixed internal key plus a fuzzed leaf and version. This preserves the production commitment checks while allowing script mutations to explore CODESEPARATOR placement and required-versus-upgrade precedence.


Coverage details