WIP: BIP460: CISA for Taproot key path spends

bitcoin/bitcoin: PR #36122

5 minor findings · 8 suggestions

Earlier concerns neither republished nor resolved: 1 major finding · 2 minor findings · 4 suggestions. See the Run archive for their assessments.

Findings

Link

[minor] · PSBT completion skips transaction-level CISA verification

With externally supplied final witnesses, PSBT completion can accept missing or invalid CISA aggregates; no in-tree producer of these witnesses was found, and CISA-enforcing node validation still rejects them.

Location: src/script/interpreter.cpp:2036 (head).

Details and suggested fix

With known UTXOs, a v2 input whose final_scriptwitness contains one empty element passes PSBTInputSignedAndVerified: parsing identifies a fullagg member, and VerifyWitnessProgram returns success without checking that the group has a final member. A corrupted finalized aggregate has the same problem. FillPSBT, descriptorprocesspsbt, and AnalyzePSBT consume that per-input result, while FinalizeCISAInputs skips supplied finalized groups. They can therefore report completion or extraction readiness without calling VerifyCISATransaction.

Once all UTXOs are known, reconstruct the transaction with its final witnesses and share a transaction-level CISA completion check across these callers and FinalizePSBT. Add negative cases for a missing final member and a corrupted aggregate supplied as final_scriptwitness. The regression is the newly incorrect per-input verified result, not a claim that PSBT finalization previously revalidated every supplied final witness.


Link

[minor] · Fullagg signing snapshots group messages before all sighashes are updated

With existing fullagg nonces and absent sighash fields, an explicit ALL signing pass can consume nonces for incompatible message lists when the owning manager signs before other managers populate those fields.

Location: src/psbt.cpp:765 (head).

Details and suggested fix

SignPSBTInput sets only the current input's sighash_type before collecting every member's field, defaulting absent fields to SIGHASH_DEFAULT. For two inputs owned by the wallet's only script manager, walletprocesspsbt with sighashtype="ALL" signs input 0 over [ALL, DEFAULT], then input 1 over [ALL, ALL]. Reserved nonces or nonces from a DEFAULT round are found through the message-independent session ID and consumed once. Finalization uses the final [ALL, ALL] fields, rejects the incompatible partial signature, and cannot repair the group on retry because the partial signatures remain and the nonces are gone. Resolve and validate every group member's effective sighash and mode before producing any partial signature. A two-input reserved-nonce test signing with explicit ALL would cover this case.


Link

[minor] · Witness v2 spends become standard before consensus activation

Although this draft activates CISA only on regtest, its standard policy accepts BIP460 spends on other networks where consensus still treats those outputs as upgradeable witness programs.

Location: src/policy/policy.h:105 (head).

Details and suggested fix

STANDARD_SCRIPT_VERIFY_FLAGS always includes SCRIPT_VERIFY_WITNESS_V2, and recognizing WITNESS_V2_CISA removes the previous unknown-witness input rejection. Policy therefore accepts otherwise-standard BIP460-valid spends even where GetBlockScriptFlags omits the flag. If this branch is used outside regtest, users creating cisa() outputs rely on local policy rather than consensus signature protection, which a miner can bypass. Gate WITNESS_V2_CISA input standardness on DeploymentActiveAfter(tip, DEPLOYMENT_CISA), treating it like WITNESS_UNKNOWN before activation. Removing the mandatory flag alone would not suffice because validation also asserts equality between mandatory and consensus flags.


Link

[minor] · Invalid cisa_mode can leave selected wallet inputs locked

With lock_unspents=true, sendall and send reject a misspelled cisa_mode only after selecting and locking inputs, leaving those in-memory locks behind when the RPC fails.

Location: src/wallet/rpc/spend.cpp:121 (head).

Details and suggested fix

The option checks accept any string, but FinishTransaction calls ParseCISAMode only after sendall has locked its inputs and after send has funded the transaction. A value such as "halfaggg" then throws RPC_INVALID_PARAMETER without undoing those locks. The user must recover with lockunspent or a wallet reload. Parse the mode alongside the initial option validation, before coin selection or locking, and pass the parsed value into FinishTransaction.


Link

[minor] · CISA signing contributions are reported as no progress in Qt

CISA extends the existing MuSig2 progress-reporting limitation: adding a signature contribution to an incomplete multi-party group leaves n_signed at zero, so Qt warns that it could not sign any more inputs.

Location: src/psbt.cpp:778 (head).

Details and suggested fix

SignPSBTInput treats a halfagg signature or fullagg partial signature as signing success, but DescriptorScriptPubKeyMan::FillPSBT increments the counter only after a final witness exists. When another participant is still missing, group finalization cannot supply that witness, and fullagg nonce generation likewise goes uncounted. Track newly added CISA signatures and nonces separately from witness finalization, and expose that progress through n_signed or a separate counter. The contributed PSBT remains available through Copy/Save; the defect is the displayed signing progress.


Optional improvements

Link

[suggestion] · Intermediate commits activate CISA before aggregate checking is wired

The intermediate regtest trees at 4ff98540 and a7eaf477 accept aggregated v2 spends without signature checks, making the series harder to validate; 351cc85e closes this gap before the head.

Location: src/script/interpreter.cpp:2036 at 4ff98540435b (commit) (commit).

Details and suggested fix

31a846e4f5cc67f80a8401578582c71c2240d8bd makes CISA always active on regtest. 4ff98540435b64f5d4e0945503be1fd3d70eddcb then returns success for aggregation-marker witnesses, referring to a verifier introduced only in a7eaf477fc07d5fc0c1126215f5a90bcb7729c21. That verifier is not called by node validation until 351cc85ea186e18dd3e02c2db1a03a9854d90948. Reviewers and bisects therefore encounter active-CISA trees where a marker-only witness spends a v2 output without a signature check. Move the regtest ALWAYS_ACTIVE setup into the wiring commit so activation and enforcement arrive together. This keeps the parser before its verifier and leaves the final tree unchanged.


Link

[suggestion] · The wrapped-P2TR test now wraps a v2 program

SpendsNonAnchorWitnessProg loses its 32-byte wrapped-v1 case because the new CISA setup overwrites the script reused by that case.

Location: src/test/transaction_tests.cpp:1341 (head).

Details and suggested fix

The block labelled “P2SH-wrapped P2TR” copies the preceding WitnessV2Cisa script into redeem_script, so it now tests wrapped witness v2 instead. Its Solver assertion checks only the outer SCRIPTHASH type and cannot detect the changed inner version. Move the standalone CISA case after the wrapped-P2TR case to restore the v1 coverage.


Link

[suggestion] · The halfagg random-forgery test supplies buffer capacity as signature length

For every sampled group size below N_MAX, the halfagg random-forgery assertion passes on a length rejection without exercising signature parsing or verification.

Location: src/secp256k1/src/modules/schnorrsig_halfagg/tests_impl.h:246 (head).

Details and suggested fix

Test 1 allocates 32*(N_MAX + 1) bytes but fills only 32*(n + 1) bytes and passes sizeof(aggsig) to aggverify. Its initial length check returns immediately unless n == N_MAX. Set aggsig_len to 32*(n + 1) so every sample passes that guard; the API test already checks invalid lengths. Since this is vendored code, the correction belongs in the upstream halfagg change, bitcoin-core/secp256k1#1566.


Link

[suggestion] · Abandoned CISA nonce reservations have no targeted release

Abandoned reservecisanonce reservations retain wallet memory until unload, and unloading also discards unrelated live signing sessions.

Location: src/wallet/scriptpubkeyman.h:308 (head).

Details and suggested fix

Repeated authenticated reservation calls, including retries for the same outpoint, create distinct random-nonce session IDs in m_cisa_secnonces. Unused entries have no release, expiry, or retention bound. Add targeted cancellation by public nonce that securely destroys the reservation and makes subsequent signing with it fail closed. Do not replace an earlier reservation merely because it belongs to the same outpoint, since that public nonce may already have been shared.


Link

[suggestion] · The CISA functional fixture never crosses the activation boundary

The functional fixture uses always-active regtest, so its block assertions cannot distinguish the current deployment gate from unconditional CISA enforcement.

Location: test/functional/feature_cisa.py:201 (head).

Details and suggested fix

test_activation_status only checks active=True, and subsequent block cases run under that same always-active configuration. Mempool rejection cases cannot cover the distinction either, because standard flags enable SCRIPT_VERIFY_WITNESS_V2 independently of deployment. Add a clean-chain fixture with finite -vbparams that submits a CISA-invalid v2 spend in a block immediately before activation and in the first active block, asserting acceptance before the boundary and rejection at it.


Link

[suggestion] · CISA session conflicts are reported as different transactions

When the new CISA compatibility check rejects inputs after transaction IDs match, combinepsbt reports “different transactions”, obscuring the signing-session conflict.

Location: src/psbt.cpp:51 (head).

Details and suggested fix

Merge now has a failure path for conflicting CISA modes, nonces, or partial signatures after its transaction-identity check has passed. CombinePSBTs loses that reason, and the RPC labels every failure as a transaction mismatch. Return a distinguishable CISA compatibility error, ideally identifying the input, so users combining stale or duplicate signing-session data can diagnose the conflict. Keep the rejection behavior unchanged.


Link

[suggestion] · Queued CISA test coverage depends on the host CPU count

On a single-core runner, the fixture would configure both nodes with par=1 and omit queued CISACheck block-validation coverage.

Location: test/functional/feature_cisa.py:92 (head).

Details and suggested fix

Node 0 inherits the framework setting par=min(2, os.cpu_count()), while node 1 explicitly uses -par=1. A value of one leaves zero script worker threads, so ConnectBlock does not create queue control. Set self.extra_args to [["-par=2"], ["-par=1"]] so node 0 exercises the queued path even on a single-core host and node 1 retains sequential coverage.


Link

[suggestion] · Destination fuzzing drops non-32-byte witness v2 programs

Fuzz destination generation omits unknown v2 program lengths, even though only the 32-byte v2 program is recognized as CISA.

Location: src/test/fuzz/util.cpp:227 (head).

Details and suggested fix

The new WitnessV2Cisa alternative covers only 32-byte programs, and raising the WitnessUnknown minimum version to 3 removes every other v2 length. Solver still returns WITNESS_UNKNOWN for those lengths. Keep version 2 in the unknown generator and exclude only its recognized 32-byte case, for example by adjusting that length when the sampled version is 2.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.