Skip to content

feat(torrent): add common SHA-256 and v2 Merkle integrity - #170

Closed
linroid wants to merge 4 commits into
torrent-v2-01-storage-admissionfrom
torrent-v2-05-sha256
Closed

linroid wants to merge 4 commits into
torrent-v2-01-storage-admissionfrom
torrent-v2-05-sha256

Conversation

@linroid

@linroid linroid commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Add the pure Kotlin integrity primitives required to verify BitTorrent v2 content: incremental SHA-256, a streaming per-file Merkle root builder, and bounded single-block proof verification against a trusted file root.

Part of #162, stacked on torrent-v2-01-storage-admission (#169). The file root builder retains a logarithmic frontier, hashes short final blocks at their actual length, and folds missing leaves as zero hashes. The verifier checks exact block/proof lengths, sibling hashes, block indices, and out-of-file padding before accepting a root match. Empty files have no pieces root.

Validation: all 11 focused JVM tests passed and the native-runtime dependency guard passed. Tests include known SHA-256 vectors, every split of short vectors, a streamed million-byte vector, independent JDK comparisons at padding/block boundaries, independent full-tree comparisons across uneven shapes, and proof tampering—including a forged root matching malformed nonzero padding.

These primitives are internal and do not yet advertise v2 downloads. Format identity, bounded wire decoding and proof acquisition, piece-layer storage, hybrid verification, and durable verified commits remain separate roadmap slices. The integrity design note documents that boundary.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-12T13:28:31.200578Z d8ec4be PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

  500 files  +24    500 suites  +24   4m 0s ⏱️ +9s
2 352 tests +27  2 352 ✅ +27  0 💤 ±0  0 ❌ ±0 
2 988 runs  +49  2 988 ✅ +49  0 💤 ±0  0 ❌ ±0 

Results for commit d8ec4be. ± Comparison against base commit f1a8568.

@linroid

linroid commented Sep 20, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #232 (V2 identity, metainfo and Merkle integrity) in the consolidated eight-PR stack for #162.

The replacement preserves this PR's code and subsequent fixes; its description links the original head and review discussions. The only additional consolidation fix is the CI-discovered listener cancellation regression, documented on the replacement. All eight replacements have passed their required CI checks.

Closing without merging. This branch and its discussions remain available for reference. Review index: #162 (comment)

@linroid linroid closed this Sep 20, 2026
linroid added a commit that referenced this pull request Sep 20, 2026
Consolidates #170–#173, preserving source 3ba4a64.
Includes the foundation listener cancellation regression fix discovered by consolidation CI.
@linroid
linroid deleted the torrent-v2-05-sha256 branch September 20, 2026 11:12
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