feat(wasm-utxo): add BLAKE2b-256 personalization helper#330
Conversation
OttoAllmendinger
left a comment
There was a problem hiding this comment.
Requesting changes — one item.
The block_aligned_input_is_stable test doesn't actually guard the bug this helper exists to fix. It only asserts the digest is non-zero and deterministic — the old f=0 implementation produces a deterministic, non-zero (but wrong) 32-byte output too, so it would pass this test unchanged. Same trap called out in bitgo_psbt/mod.rs test_zcash_sighash_block_aligned_outputs: a self-consistent round-trip agrees with itself on the wrong value.
Please pin a known-answer vector for a block-aligned (128-byte-multiple) input, and — importantly — source it from something external, not "whatever our implementation currently emits." Ideally reference the spec that carries the vectors, or vendor a fixture file into the repo with its provenance:
- BLAKE2b personalization / block behavior → RFC 7693 test vectors, and/or
- the Zcash ZIP-243/ZIP-244 hash-tree vectors from
zcash/zcash-test-vectors
so the value is traceable to the spec rather than self-referential. A single block-aligned KAT plus its cited source is enough to unblock; the rest of the PR looks good.
Generated by Claude Code
Shared primitive for Zcash ZIP-243/ZIP-244/ZIP-316 hashing, extracted as the base for the v6 transaction and unified-address work (PR1 of 3). The BitGo miniscript fork already has a blake2b_256_personal helper but it is pub(crate) and unreachable from this crate, so we reimplement it here on the blake2 crate (already in the tree transitively; pinned as a direct dep). Includes the block-aligned finalization fix and a variable-length variant (blake2b_var_personal) that F4Jumble needs. Ships with unit tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
d3e8371 to
4b15e9e
Compare
Shared primitive for Zcash ZIP-243/ZIP-244/ZIP-316 hashing, extracted as the base for the v6 transaction and unified-address work (PR1 of 3).
Includes the block-aligned finalization fix and a variable-length variant (blake2b_var_personal) that F4Jumble needs. Ships with unit tests.