Skip to content

fix(wasm-utxo): commit spent scriptPubKey, not redeem script, in v6 transparent sighash - #357

Merged
veetragjain merged 1 commit into
masterfrom
veetragjain/cshld-1448-correct-zip-244-transparent-sighash-script-digest
Aug 13, 2026
Merged

fix(wasm-utxo): commit spent scriptPubKey, not redeem script, in v6 transparent sighash#357
veetragjain merged 1 commit into
masterfrom
veetragjain/cshld-1448-correct-zip-244-transparent-sighash-script-digest

Conversation

@veetragjain

Copy link
Copy Markdown
Contributor

Compute_v6_transparent_sighash hashed the caller-supplied redeem/witness script into the ZIP-244 S.2g.iii per-input digest field. Cross-checking against the vendored zcash_primitives/zcash_transparent reference crates, that field is actually the spent output's scriptPubKey, not the redeem/witness script ("scriptCode").

The two are identical for P2PKH inputs, which is all the existing golden fixture exercised - so the bug was invisible until a real 2-of-3 P2SH multisig shielding transaction (BitGo's actual wallet shape) was signed and submitted to a live Zcash testnet node, where it was rejected with ScriptInvalid.

  • v6.rs: drop the script_code param from compute_v6_transparent_sighash; hash input_script_pubkeys[index] for the per-input field instead.
  • zcash_psbt.rs: update v6_transparent_sighash accordingly; keep the redeem/witness-script presence check as a spendability sanity check.
  • Add a real-world regression test in both Rust and TS: a mempool-accepted testnet tx spending a 2-of-3 P2SH multisig input, with its two ECDSA signatures verified against the corrected digest independently (Rust: secp256k1 crate directly; TS: @bitgo/utxo-lib's ecc.verify) rather than via this codebase's own signing code.
  • Add ZcashV6Transaction.transparentSighash (Rust wasm export + TS wrapper) so the TS test can compute a sighash from arbitrary raw v6 transaction bytes, independent of the PSBT build flow.

Ticket: CSHLD-1448

@linear-code

linear-code Bot commented Aug 11, 2026

Copy link
Copy Markdown

CSHLD-1448

}

/// Regression test for the bug where `compute_v6_transparent_sighash` hashed the redeem
/// script (scriptCode) into the ZIP-244 §S.2g.iii per-input field instead of the spent

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain a bit on scriptPubKey and redeem script?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scriptPubKey is something that utxo is locked to, when spending it you need to reveal the redeem script that hashes to the scriptPubKey that the utxo is locked to.

Comment thread packages/wasm-utxo/src/zcash/v6.rs
Base automatically changed from veetragjain/cshld-1433-surface-ironwood-v6-shielding-details-in-psbt to master August 12, 2026 15:21
@veetragjain
veetragjain force-pushed the veetragjain/cshld-1448-correct-zip-244-transparent-sighash-script-digest branch from 6ce2c01 to 179df0e Compare August 12, 2026 15:21
@veetragjain
veetragjain force-pushed the veetragjain/cshld-1448-correct-zip-244-transparent-sighash-script-digest branch from 179df0e to 10c92c2 Compare August 12, 2026 15:36
@veetragjain
veetragjain marked this pull request as ready for review August 12, 2026 19:36
@veetragjain
veetragjain requested review from a team as code owners August 12, 2026 19:36
@veetragjain
veetragjain requested a review from Ranjna-G August 12, 2026 19:41
@veetragjain
veetragjain disabled the stack merge August 13, 2026 14:47
@veetragjain
veetragjain merged commit 4ac934e into master Aug 13, 2026
13 checks passed
@veetragjain
veetragjain deleted the veetragjain/cshld-1448-correct-zip-244-transparent-sighash-script-digest branch August 13, 2026 14:47
veetragjain added a commit that referenced this pull request Aug 13, 2026
…-244-transparent-sighash-script-digest

fix(wasm-utxo): commit spent scriptPubKey, not redeem script, in v6 transparent sighash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants