Skip to content

Conversation

@ivokub
Copy link
Collaborator

@ivokub ivokub commented Jul 14, 2025

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How has this been tested?

  • TestKeyStore for testing caching

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I did not modify files generated from templates
  • golangci-lint does not output errors locally
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@ivokub ivokub self-assigned this Jul 14, 2025
@ivokub ivokub added the type: consolidate strengthen an existing feature label Jul 14, 2025
Copy link
Contributor

Copilot AI left a 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 Bytes type and NewBytes constructor for byte-level operations with caching in std/math/uints/bytes.go
  • Refactor std/math/uints/uint8.go to use the new Bytes API, update BinaryField, and deprecate direct rangechecker usage
  • Update range checker (std/rangecheck/rangecheck_commit.go) to store the API and handle 0- and 1-bit cases
  • Register uints hints and update hash tests to use NewBytes and AssertIsEqual

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 over ret with for j := range ret.
		for j := range bf.lenBts() {

std/hints.go:50

  • The std/math/uints package does not define a GetHints function. You should either implement GetHints() in that package or remove this registration.
	solver.RegisterHint(uints.GetHints()...)

cursor[bot]

This comment was marked as outdated.

@ivokub ivokub mentioned this pull request Jul 17, 2025
12 tasks
ThomasPiellard
ThomasPiellard previously approved these changes Jul 17, 2025
@ivokub ivokub merged commit 7abe048 into master Jul 17, 2025
7 checks passed
@ivokub ivokub deleted the feat/bytes-uints branch July 17, 2025 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: consolidate strengthen an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: range checker should handle edge cases separately

3 participants