Compute v5 transaction IDs locally per ZIP 244#547
Open
zmanian wants to merge 1 commit intozcash:masterfrom
Open
Compute v5 transaction IDs locally per ZIP 244#547zmanian wants to merge 1 commit intozcash:masterfrom
zmanian wants to merge 1 commit intozcash:masterfrom
Conversation
lightwalletd has returned incorrect txids for v5 transactions since NU5 activation (issue zcash#392). The workaround fetches txids from zcashd via a verbose getblock RPC call. This commit implements the ZIP 244 BLAKE2b-256 hash tree so v5 txids are computed during parsing. The core blocker was that Go's golang.org/x/crypto/blake2b package lacks personalization support. This is resolved by vendoring the pure-Go BLAKE2b implementation into an internal package and adding the ~3 lines needed for personalization parameter injection. The ZIP 244 hash tree re-parses Transaction.rawBytes to feed fields into 18 personalized BLAKE2b-256 digests. The v5 shared sapling anchor is buffered and replayed per-spend in the noncompact digest. All 10 test vectors from testdata/tx_v5.json now validate txids. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
golang.org/x/crypto@v0.45.0intoparser/internal/blake2b/, adding personalization parameter support (~3 lines of modification to thedigeststruct andReset())Transaction.rawBytesincomputeV5TxID()to feed fields into 18 personalized BLAKE2b-256 digests matching the ZIP 244 hash tree, including correct handling of the v5 shared sapling anchor (buffered and replayed per-spend in the noncompact digest)testdata/tx_v5.jsonnow validate txids (previously skipped with a TODO comment)Motivation
lightwalletd returns incorrect txids for v5 transactions. The workaround (PR #393) fetches txids from zcashd/zebrad via a verbose
getblockRPC call instead of computing them locally. This creates a trust dependency on the backing node for txid correctness. The core blocker was that Go'sgolang.org/x/crypto/blake2bpackage doesn't support the personalization parameter required by ZIP 244.Changes
parser/internal/blake2b/blake2b.goparser/internal/blake2b/compress.goparser/internal/blake2b/LICENSEparser/internal/blake2b/blake2b_test.goparser/zip244.gocomputeV5TxID+ sub-functions for header, transparent, sapling, orchard digestsparser/zip244_test.goparser/transaction.goParseFromSliceto callcomputeV5TxIDfor v5 transactionsparser/transaction_test.goDeferred to follow-up PRs
common.go:getBlockFromRPC(simplify to singlegetblock verbose=0call)Test plan
go test ./parser/internal/blake2b/...-- blake2b unit tests pass (standard + personalized vectors)go test ./parser/...-- all parser tests pass including new txid validation against 10 test vectorsgo vet ./parser/... ./parser/internal/blake2b/-- cleango build ./...-- clean buildCloses #392
Generated with Claude Code