Skip to content

Add Transmission-verified golden vectors for hybrid v1+v2 hashes#8

Merged
iksnerd merged 1 commit into
mainfrom
test/hybrid-golden-vectors
Jun 13, 2026
Merged

Add Transmission-verified golden vectors for hybrid v1+v2 hashes#8
iksnerd merged 1 commit into
mainfrom
test/hybrid-golden-vectors

Conversation

@iksnerd

@iksnerd iksnerd commented Jun 13, 2026

Copy link
Copy Markdown
Owner

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-cli 4.1.2 (BEP 52 / hybrid support landed in Transmission 4.0) and had it independently re-derive hashes from raw bytes via transmission-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:

Case Layout Result
1 MB uniform 4 pieces, partial final piece 100%, no error
700 KB random 3 pieces (non-power-of-two count) 100%, no error
3-file directory multi-file hybrid 100%, no error

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 new TestHybridGoldenVectors.

🤖 Generated with Claude Code

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 iksnerd merged commit 0629a9d into main Jun 13, 2026
1 check passed
@iksnerd iksnerd deleted the test/hybrid-golden-vectors branch June 13, 2026 12:52
iksnerd added a commit that referenced this pull request Jun 21, 2026
Add Transmission-verified golden vectors for hybrid v1+v2 hashes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant