Skip to content

Add the unified opt-in signature hash - #1

Merged
kwsantiago merged 3 commits into
0.32.xxfrom
unified-sighash
Oct 6, 2026
Merged

kwsantiago merged 3 commits into
0.32.xxfrom
unified-sighash

Conversation

@kwsantiago

Copy link
Copy Markdown

Adds the unified opt-in signature hash: the digest a signature commits to when its hash type sets SIGHASH_UNIFIED (0x20), as Bitcoin Knots defines it.

  • SighashCache::unified_signature_hash and unified_encode_signing_data_to, taking a UnifiedSpend that carries the data each script type commits to: the script code for bare, P2SH and segwit v0, the annex for taproot, and the leaf hash and codeseparator position for tapscript.
  • UnifiedSighash, the UnifiedSighash-tagged hash, convertible to a secp256k1::Message.
  • Taproot and tapscript accept only SIGHASH_ALL, SIGHASH_NONE and SIGHASH_SINGLE, with or without SIGHASH_ANYONECANPAY; bare, P2SH and segwit v0 commit to any byte. A hash type without the opt-in bit is refused.

Purely additive: no existing API changes. Producing a signature in this form is left to the caller, since EcdsaSighashType cannot carry the bit.

Tested against Bitcoin Knots' 166 vectors (bitcoin/tests/data/unified_sighash.json) across all four script types, plus the refusals. The full bitcoin test suite passes, and the crate builds on its MSRV, 1.56.1.

@kwsantiago
kwsantiago merged commit 3c8cd57 into 0.32.xx Oct 6, 2026
14 of 15 checks passed
@kwsantiago
kwsantiago deleted the unified-sighash branch October 6, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant