Repository navigation
Conversation
Both new cases drove sponge directly, so they reached the platform assembly with no useASM check and would SIGILL on a CPU without it. Fold them into keccak_asm_test.go, which already carries that convention, and compare Read(rate)+Read(k) against x/crypto instead of only pinning readIdx.
Deferring the permutation cannot change the output, so the docstring's claim was wrong: readIdx is the discriminating assertion.
Contributor
FoundThe docstring overclaimed. It called FixedReworded to say what each assertion actually pins. e610be5 The byte comparison still earns its place — dropping the permutation from the boundary branch fails all five sub-tests. Nothing else found: the |
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
Readstops exactly on a 136-byte boundaryWhy
The current loop always computes the next Keccak permutation after copying byte 136, even when the caller asks for no more output. Moving that check to the top of the next loop iteration keeps the output unchanged and computes the next block only when it is requested.
This is an independent, focused split of the squeeze optimization in #13.
TDD
The regression test initially failed with:
Benchmark
Apple M2 Max, Go 1.25.7, representative results:
The exact-boundary case avoids one full permutation. Adjacent sizes remain in the same range; the 135-byte variation is benchmark noise across runs.
Verification
go test ./...go test -race ./...go test -tags purego ./...go vet ./...go mod tidy -diffgolangci-lint run