chore: uint audit part 1 (operator<<, operator>>, ror)#15823
Merged
Conversation
31d2ab7 to
6434f31
Compare
iakovenkos
reviewed
Jul 21, 2025
| return result; | ||
| } | ||
|
|
||
| template <typename Builder> |
Contributor
There was a problem hiding this comment.
nice! I can re-use it in byte_array byte decomposition method
iakovenkos
reviewed
Jul 21, 2025
iakovenkos
reviewed
Jul 21, 2025
| EXPECT_TRUE(builder.err() == "slice: hi value too large."); | ||
| } | ||
|
|
||
| static void test_split_at() |
Contributor
There was a problem hiding this comment.
is it possible to produce a failure test with the current circuit design?
iakovenkos
reviewed
Jul 21, 2025
iakovenkos
reviewed
Jul 21, 2025
iakovenkos
reviewed
Jul 21, 2025
8aeeccb to
9a19b9b
Compare
iakovenkos
approved these changes
Jul 22, 2025
15593d6 to
119be39
Compare
…. next pr should remove slice function from field_t.
119be39 to
c5a2e0e
Compare
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.
🧾 Audit Context
Audit of the
uintmodule in stdlib, specifically the methods:operator>>,operator<<andror(bitwise operations).🛠️ Changes Made
split_atmethod (wrote a generic methodsplit_at1 that splits a field_t at a given bit index and returns the lower and higher slices).uintconstructor frombyte_arrayandstd::vector<bool_t>(resolving old TODO)widthso that we restrictuintto 8, 16, 32, and 64 bits only.✅ Checklist
📌 Notes for Reviewers
Please review the
split_atfunction carefully, and check if we are testing it thoroughly. We're soon going to remove the functionslice(msb, lsb)from field_t since we no longer need it (used only inlogicmodule). Instead, the new functionsplit_atwill replace the use ofsliceinlogicmodule:aztec-packages/barretenberg/cpp/src/barretenberg/stdlib/primitives/logic/logic.cpp
Line 99 in 6434f31
will be changed to:
field_pt a_slice = a.split_at(0, num_bits).second;Note: we are not going to merge any PRs that change anything in
fieldorbigfieldas they're undergoing external audits at the moment. Thus, this PR will be merged after the external audit offield(and its fixes) are done.Footnotes
The existing
slice(msb, lsb)method could be used but there were three issues in doing so:(a) found a bug in range-constraint on the
hilimb in it,(b)
slice(...)returns three limbs: hi, mid and lo so it naturally requires three range constraints. We only need two parts of a field element.(c)
slice(...)assumes a 252-bit field element which results in (unnecessary) costly range-constraints. We'd have to change the function to acceptnum_bitsas a parameter (or template parameter). ↩