Add Transmission-verified golden vectors for hybrid v1+v2 hashes#8
Merged
Conversation
Closes the review's open 'is the v2 Merkle padding BEP 52-correct?' question. Verified empirically with Transmission 4.1.2: for single-file (partial final piece), non-power-of-two piece count, and multi-file layouts, transmission-remote --verify recomputed the v1 piece SHA-1s and the v2 block/Merkle piece-layer from raw bytes and reported 100% / no error — i.e. a real reference client accepts our hybrid torrents as valid. The flagged 'critical' Merkle finding was a false positive. This test pins the v1+v2 info hashes for two fixed inputs (1MB uniform -> 4 pieces; 700KB pattern -> 3 pieces) so the Merkle construction can't silently regress. Regeneration steps are in the test doc comment.
iksnerd
added a commit
that referenced
this pull request
Jun 21, 2026
Add Transmission-verified golden vectors for hybrid v1+v2 hashes
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.
Closes the one open question from the 2026-06-13 review: is the v2 Merkle piece-layer padding actually BEP 52-correct for multi-piece files? The review flagged it "critical (pending reference-client confirmation)" — and the tell was that the agent's own worked examples kept coinciding with the spec.
What I did
Installed
transmission-cli4.1.2 (BEP 52 / hybrid support landed in Transmission 4.0) and had it independently re-derive hashes from raw bytes viatransmission-remote --verify— which recomputes the v1 piece SHA-1s and the v2 block + Merkle piece-layer and checks them against our.torrent. Tested the exact cases the review worried about:A real reference client accepts our hybrid torrents as fully valid. The "critical" Merkle finding was a false positive.
This PR
Pins the v1+v2 info hashes for two fixed (deterministic) inputs as a golden-vector regression test, so the Merkle construction can't silently break. The values are trustworthy because Transmission verified the corresponding data. Regeneration steps are in the test doc comment.
Pure unit test — no Transmission dependency in CI.
Verification
go test ./...passes including the newTestHybridGoldenVectors.🤖 Generated with Claude Code