feat: standalone checksum-only integrity API (#13)#50
Open
27Bslash6 wants to merge 7 commits into
Open
Conversation
Extracts xxHash3-64 checksum and verify_checksum as a standalone public primitive in src/checksum.rs, gated on the 'checksum' feature alone. Usable without compression or messagepack. Includes 6 unit tests: 5 behavioral + 1 known-answer regression locking algorithm and big-endian byte order. Wire value is identical to StorageEnvelope's embedded checksum.
DRY: replace inline xxh3_64(data).to_be_bytes() with crate::checksum::checksum(data). The DRY-guard test (envelope_embeds_canonical_checksum) confirms byte-identical wire output before and after the refactor. xxh3_64 import retained — extract() still uses it.
DRY: replace inline xxh3_64(&decompressed).to_be_bytes() + manual compare with crate::checksum::verify_checksum(). ChecksumMismatch error variant is preserved on false return. Removes the now-dead xxhash_rust import from byte_storage.rs — single canonical xxHash3-64 definition lives in checksum.rs.
Updates the xxHash3-64 security property bullet to call out standalone availability via checksum/verify_checksum without requiring compression.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughA new ChangesStandalone Checksum Module
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
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 cachekit-core half of #13. (PyO3 bindings + py-vs-FFI benchmark land in a follow-up cachekit-py PR once 0.3.0 publishes.)
What
Exposes xxHash3-64 integrity as a standalone primitive, decoupled from compression — two free functions gated on
feature = "checksum"alone:checksum(data: &[u8]) -> [u8; 8]verify_checksum(data: &[u8], expected: &[u8; 8]) -> boolUsable with
default-features = false, features = ["checksum"](no LZ4/messagepack). This unblocks callers (e.g. Python Arrow/JSON serializers) that want the fast 8-byte xxHash3 checksum where LZ4 compression is ineffective, without reaching for Blake3.DRY
StorageEnvelope::{new,extract}now consume the new primitive — one canonical xxHash3-64 definition. The inlinexxh3_64is gone frombyte_storage.rs. No wire-format change: the stored checksum bytes are byte-identical (big-endian), test-locked byenvelope_embeds_canonical_checksum.Design notes (deliberate — please don't "fix")
checksum()is intentionally unbounded (no size cap): a pure O(n) hash over already-materialized bytes; theMAX_UNCOMPRESSED_SIZEcap isStorageEnvelope's decompression-bomb concern, not applicable here.verify_checksumis plain (non-constant-time) equality: correct for a non-cryptographic corruption check. Tamper-resistance is AES-256-GCM's job.Tests
checksum(b"cachekit-kat")), reproduced independently against Pythonxxhash.extractreturns theChecksumMismatchvariant on corruption).Verification
cargo fmt --check·cargo clippy --all-features -- -D warnings·cargo test --all-features(198 pass) ·cargo test --no-default-features --features checksum --lib(feature-gating) — all green.Release
feat:→ release-please cuts 0.3.0, co-tenant with #48 (perf: borrow input…). Both are already on this branch's base.Summary by CodeRabbit
Release Notes
New Features
Improvements