Repository navigation
Fix the custom-secret XXH3 test vectors and reach 100% coverage - #45
Merged
Merged
Conversation
…ntation Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KmuCbukmnH9zJJPoxX3tGo
Codecov Report✅ All modified and coverable lines are covered by tests.
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KmuCbukmnH9zJJPoxX3tGo
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.
Summary
Two commits. Neither changes any library output.
lib/goes to 5964/5964.1. Custom-secret XXH3 test vectors
test/xxh3_test.dart: six custom-secret tests (147-byte secret; input lengths 0, 1, 403, 512, 2048 and 2243) were commented out, and their expected values were wrong. They are now active with values from the reference C implementation, with the source cited in a comment. All six pass against the existing 64-bit code, so its output was correct all along.test/xxh_32bit_test.dart: removes two incorrect comments, added in SupportXXHash64,XXH3andXXH128on the web #41, which claimed the 64-bit XXH3/XXH128 code can't handle secrets whose length isn't a multiple of 8. The 32-bit vs 64-bit comparison now also covers secret lengths 137, 139, 143, 147 and 150.Correction to #41: #41's description reported a VM crash for such secrets. That was wrong: I inferred it from
Uint64List.view(secret.buffer)without running it. The view rounds down to whole 8-byte lanes instead of throwing, and the code never reads past them. I checked the 64-bit code against the reference C library in 112 cases: secret lengths 136–200 bytes (including 137, 139, 143, 147 and 150), inputs from 0 to 2048 bytes, for both XXH3 and XXH128. All matched.The new values come from the reference C implementation (libxxhash 0.8.4, bundled with Python's
xxhash4.1.0), called through ctypes withdataandsecretas defined inxxh3_test.dart:6775fd10343c92c33559d64878c5c66cc3382c326e24e3cd8a52451418b2da4df9c0ba5ba3af70b814546019124d43b87896e65dcfa090717564693dd526e28dd6545db87ecfd98cd32e975821d6519f887810081c32460a27bdd19f2d1689892. 100% coverage
Every remaining uncovered line was in
_32bitweb code, which the VM only reaches through the differential tests.uint64.dart: the dart2js-only branch ofsetIntUint64.highWordOfDouble, which a VM test checks againstvalue >> 32for 1,000+ values within ±2^53.setIntproduces the same value on every platform.uint64.dart:rotl(32)andshl(n ≥ 32), unused by any algorithmtest/core/uint64_test.dart(vm-only) checks everyUint64operation against native 64-bitintmath, every rotate and shift amount from 1 to 63, andmul128/mul128fold64againstBigInt(including aliased outputs).poly1305_32bit.dart: the bad-key-lengththrowkeccak_32bit.dart:reset()keccak_32bit.dart: apos == blockLengthcheck at the start of$finalize$processalways flushes and resetsposwhen a block fills, so the check could never be true. The 64-bit twin doesn't have it, and the two$finalizemethods are now identical.Verification
dart format --output=none --set-exit-if-changed .makes no changesdart analyze --fatal-infosreports no issuesdart test -p vm: all tests passdart test -p node: all tests passdart test -P wasm: all tests passbash scripts/coverage.shreports 5964/5964 lines oflib/covered🤖 Generated with Claude Code
https://claude.ai/code/session_01KmuCbukmnH9zJJPoxX3tGo