Remove redundant sighashes#281
Conversation
Keep transparent sighashes input- and signature-specific while reusing transaction-wide ZIP 143, ZIP 243, and ZIP 244 components through the librustzcash fork's owned precomputation context.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9071a6d481
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This comment was marked as resolved.
This comment was marked as resolved.
|
@v12 please review |
|
@v12-auditor |
|
Note Complete: Audit complete. V12 did not find any issues that need review. Open the full results here. Analyzed three files, diff |
|
committed one type change to use LRZ constants instead of re-defining, and then an extra test |
…-sighashes # Conflicts: # CHANGELOG.md
…-sighashes # Conflicts: # CHANGELOG.md # zakura-chain/CHANGELOG.md
ValarDragon
left a comment
There was a problem hiding this comment.
Lgtm after multiple review passes
I still would like to update to not pay allocation or wasted hashing overhead when it’s not needed though
Motivation
Zakura reuses one
SigHasherper transaction, but signature checks still rebuilt transaction-wide ZIP 243 components for each V4 signature and ZIP 244 amounts and scriptPubKeys digests for each non-ANYONECANPAYV5/V6 signature. With a signature on each transparent input, that repeated work grows quadratically.Solution
Cache the shared signature-hash components inside
zakura-chain. V5/V6 extend Zakura's native ZIP 244 digest tree with amounts, scriptPubKeys, per-input, andSIGHASH_SINGLEoutput digests. V4 uses a private ZIP 243 cache for prevouts, sequences, outputs, JoinSplits, and Sapling components. V3 and earlier transactions continue to use the existing librustzcash fallback.Input index, runtime hash type,
SIGHASH_SINGLEselection, and legacyscriptCoderemain finalized for each requested digest. The interpreter callback andis_validAPI stay unchanged, and Zakura continues to use released librustzcash crates.The published
HashTypebitflags andsighash_v4_rawreturn type remain unchanged. Cached paths convert to a private canonical type, while V5/V6 script validation continues to accept only the six defined hash-type bytes.Specifications & References
Testing
cargo fmt --all -- --checkcargo test -p zakura-chain --lockedcargo test -p zakura-script --lockedcargo test -p zakura-consensus --locked script::testscargo clippy -p zakura-chain -p zakura-script --all-targets --locked -- -D warningsmarkdownlint zakura-chain/CHANGELOG.md --config .trunk/configs/.markdownlint.yaml