WIP: BIP460: CISA for Taproot key path spends

bitcoin/bitcoin: PR #36122

3 minor findings · 5 suggestions

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

Findings

Link

[minor] · Finalized CISA witnesses bypass PSBT aggregate verification

PSBT tools can report malformed finalized CISA groups as complete and extract transactions that CISA-enforcing nodes reject; no in-tree producer of such invalid finalized groups was identified.

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

Details and suggested fix

A participant can supply a PSBT with a witness-v2 spent output and a final_script_witness containing one empty element or one 32-byte member. VerifyWitnessProgram accepts these structurally valid members, and PSBTInputSignedAndVerified calls only VerifyScript. FinalizeCISAInputs leaves an already-finalized group untouched, while extraction simply copies its witnesses. A missing group final or a corrupted, well-formed aggregate therefore passes the completeness checks used by finalizepsbt, walletprocesspsbt, and descriptorprocesspsbt; AnalyzePSBT and the Qt dialog likewise report extraction or broadcast readiness. Node validation still rejects the transaction through VerifyCISATransaction. Add a shared transaction-level completion check that assembles the final witnesses and spent outputs and requires VerifyCISATransaction before these paths report completion or extract. Cover both member-only witnesses and corrupted final aggregates.


Link

[minor] · descriptorprocesspsbt cannot retain full-aggregation secret nonces

Full-aggregation signing through descriptorprocesspsbt with a private cisa() descriptor returns an unusable public nonce in release builds, or aborts in Debug builds, because its provider has no secret-nonce store.

Location: src/rpc/rawtransaction.cpp:2145 (head).

Details and suggested fix

For an input selected with cisa_mode="fullagg" or already marked for full aggregation, SignTaproot calls MakeCISANonce. The RPC's local FlatSigningProvider has cisa_secnonces == nullptr, so SetCISASecNonce returns without storing the secret in ordinary release builds. MakeCISANonce still returns the public nonce, which reaches the returned PSBT. A later call selects partial signing but cannot retrieve the corresponding secret, so retrying that PSBT cannot complete the session. Debug builds instead abort at the failed Assume. Reject operations requiring local full-aggregation nonce generation or signing in this stateless RPC with a clear error, and propagate nonce-storage failure rather than publishing an unusable nonce. Half-aggregation signing and finalization of externally supplied partial signatures can remain available.


Link

[minor] · Full-aggregation signing consumes nonces against a changing group

With reserved nonces, walletprocesspsbt can sign an early input before resolving later inputs' sighash types or modes, leaving incompatible partial signatures that require a fresh signing session.

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

Details and suggested fix

SignPSBTInput writes the current input's sighash_type and aggregation mode, then builds its group from every input's current fields. For two marked inputs with reserved nonces but absent sighash fields, a signing pass requesting ALL can sign input 0 over [ALL, DEFAULT] before input 1 changes the transcript to [ALL, ALL]. Similarly, an already-marked input with a reserved nonce can sign a one-member group before cisa_mode="fullagg" adds a later unmarked input. This occurs when no earlier descriptor-manager pass has initialized those fields. CreateFullAggPartialSig consumes the nonce, and SignTaproot retains the resulting partial signature on retries, so FinalizeCISAInputs cannot aggregate it against the final group. Run a transaction-wide preflight that resolves and validates all eligible inputs' sighash types and modes before creating any partial signature, then sign a stable group. Add regressions for both arrangements.


Optional improvements

Link

[suggestion] · Aggregate verification lacks reuse between mempool passes

With CISA active and script-execution cache misses, mempool acceptance verifies a valid aggregate twice because CISACheck does not use the signature cache.

Location: src/validation.cpp:2022 (head).

Details and suggested fix

PolicyScriptChecks runs the aggregate check with cacheFullScriptStore=false, then ConsensusScriptChecks checks the transaction again under the tip's consensus flags. Per-input Schnorr checks can reuse signature-cache entries, but CISACheck calls the aggregate verifiers directly and recomputes their cryptographic work. Cache successful aggregate verifications when cacheSigStore is enabled, using a salted, mode-separated key committing to the public keys, messages, and aggregate signature. Keep group-structure and message checks outside that cached result. This removes repeated cryptographic verification without changing acceptance rules. This is a source-level operation-count observation; no timings were taken.


Link

[suggestion] · Full-aggregation PSBT finalization repeats quadratic group setup

Finalizing an n-member full-aggregation group repeats linear nonce summation and transcript hashing for every partial signature, making this wallet/PSBT work quadratic in group size.

Location: src/cisa.cpp:153 (head).

Details and suggested fix

AggregateFullAggSigs initializes a session once, but each group.VerifyPartialSig calls secp256k1_fullagg_partial_sig_verify, which independently re-sums all public nonces, recomputes the nonce coefficient, and hashes the full L list. The vendored aggregate verifier already demonstrates reuse of the L midstate. Add a bulk partial-verification API that derives the shared nonce sum, coefficient, and transcript midstate locally once, then checks each signer's equation. This preserves the wrapper's promise to verify every partial signature without trusting coordinator-supplied session values, while avoiding repeated group-wide work for large consolidations. No latency was measured.


Link

[suggestion] · CISA block tests do not exercise the activation boundary

The functional fixture enables CISA from startup and unit vectors pass SCRIPT_VERIFY_WITNESS_V2 directly, so they cannot detect unconditional enforcement or an off-by-one activation gate.

Location: src/validation.cpp:2408 (head).

Details and suggested fix

Regtest sets DEPLOYMENT_CISA to ALWAYS_ACTIVE, and feature_cisa.py only checks that getdeploymentinfo reports it active. The vector helper bypasses deployment selection entirely. Add a regtest case with non-always-active CISA parameters and submit blocks directly, since mempool policy already enforces CISA. A witness-v2 spend with a structurally invalid aggregate should be accepted before activation and rejected in the first active block. Exercise the same distinction after a reorg across the boundary. This would test the DeploymentActiveAt gate in GetBlockScriptFlags, rather than only the active rules.


Link

[suggestion] · The series introduces and then replaces the nonce-generation interface

Introducing and later replacing the message-bound nonce API makes reviewers validate two signing/session designs even though only the message-independent design survives.

Location: src/script/sign.cpp:233 at 5cc2f60eade3 (parent of 84325d5533ff) (commit).

Details and suggested fix

7eccdba1ea37d7ffb3b3f9b75c08f967b2d7be2b introduces message-bound CISASessionID and CreateFullAggNonce helpers. d03c7f4acdcddf742bf74a7ab948d1b04b8b40fa adds the corresponding virtual nonce creator and signing integration. That implementation remains at the supplied location in parent 5cc2f60eade3d7a461298fa9bc434b84ce014a9e, before 84325d5533ff5f67ef35c637ca6a37bc6973406c replaces it with message-independent generation and lookup. Fold the cisa.cpp/cisa.h changes into the helper-introduction commit and the coordinated signing-side changes into the signing-integration commit. Keep ReserveCISANonce next to 65da121294d875ce73fd753d55e5d7c9b5a3110c, which adds the reservation workflow, and retain the explanation that nonces can be reserved before the transaction exists. This preserves the final design while letting reviewers check nonce derivation and session keying once.


Link

[suggestion] · The Qt dialog reports successful CISA rounds as no signing progress

Like the pre-existing MuSig2 flow, successful CISA nonce and incomplete partial-signature rounds can still trigger the Qt warning “Could not sign any more inputs.”

Location: src/script/sign.cpp:699 (head).

Details and suggested fix

For an imported PSBT already marked fullagg, an unlocked wallet can add public nonces or collaborative partial signatures without finalizing an input. DescriptorScriptPubKeyMan::FillPSBT increments n_signed only when PSBTInputSigned holds, so an incomplete round can return zero despite retaining new signing material. The dialog then selects its no-progress warning, although the updated PSBT remains available to copy or save. Track inputs that gained nonce or partial-signature material separately from completeness, and use that progress to describe the next signing or participant-exchange round.


Coverage details

Earlier concerns

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

Background

Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.

Unresolved disagreements

The literal witness-version assignment remained provisional in the inspected proposal discussion.

BIP460's author acknowledged a collision with BIP360 and suggested that deployment order should determine use of the next available witness version; a BIP editor likewise expected other proposals to shift. This matters when interpreting the head's witness-v2 constants: the need for a distinct version has historical rationale, but these discussions do not establish an exclusive deployed allocation or activation agreement.

Source 1 · Source 2