-
Notifications
You must be signed in to change notification settings - Fork 504
feat: add separate Bytes API in std/math/uints package for handling bytes (U8) directly
#1541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a dedicated Bytes API within the std/math/uints package for direct byte (U8) operations, refactors the existing BinaryField implementation to use the new Bytes helper, and makes the uints constructors cacheable. It also enhances the range checker to handle zero- and one-bit variables directly.
- Add
Bytestype andNewBytesconstructor for byte-level operations with caching instd/math/uints/bytes.go - Refactor
std/math/uints/uint8.goto use the newBytesAPI, updateBinaryField, and deprecate direct rangechecker usage - Update range checker (
std/rangecheck/rangecheck_commit.go) to store theAPIand handle 0- and 1-bit cases - Register uints hints and update hash tests to use
NewBytesandAssertIsEqual
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| std/rangecheck/rangecheck_commit.go | Cache frontend.API in commitChecker and add direct handling for 0/1-bit checks |
| std/math/uints/bytes.go | New Bytes type, NewBytes constructor with caching, bitwise ops, and assertion methods |
| std/math/uints/uint8.go | Refactor U8/U32/U64 and BinaryField to use Bytes, remove inline precomputes |
| std/hints.go | Register hints for the new uints package and additional curve modules |
| std/hash/sha3/sha3_test.go | Switch from uints.New[...] to uints.NewBytes and use AssertIsEqual |
| std/hash/sha2/sha2_test.go | Update constructors and assertions to use the Bytes API |
| std/hash/ripemd160/ripemd160_test.go | Migrate to NewBytes and unified equality assertion |
| internal/kvstore/kvstore_test.go | Adds tests for generic key/value store behavior |
Comments suppressed due to low confidence (2)
std/math/uints/uint8.go:334
- You cannot iterate over an int with
range bf.lenBts(). Either use a traditional for-loop (for j := 0; j < bf.lenBts(); j++) or iterate overretwithfor j := range ret.
for j := range bf.lenBts() {
std/hints.go:50
- The
std/math/uintspackage does not define aGetHintsfunction. You should either implementGetHints()in that package or remove this registration.
solver.RegisterHint(uints.GetHints()...)
Description
Previously the operations were define over U32 and U64 (as needed or hash functions). But for working directly with bytes didn't allow using boolean operations directly on bytes etc.
Additionally, made the uints API cacheable.
It also resolved #911.
Needed for #1489 refactoring what I'm working on.
Type of change
How has this been tested?
Checklist:
golangci-lintdoes not output errors locally