Skip to content
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

Fix range check #1309

Merged
merged 10 commits into from
Nov 9, 2023
Merged

Fix range check #1309

merged 10 commits into from
Nov 9, 2023

Conversation

dark64
Copy link
Member

@dark64 dark64 commented May 16, 2023

Closes #1295 #1329

@dark64 dark64 marked this pull request as ready for review May 23, 2023 08:53
@dark64 dark64 requested a review from Schaeff May 23, 2023 08:53
Copy link
Member

@Schaeff Schaeff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, some simplifications and typos. I think we should have more test for this also, see recent issue.

zokrates_codegen/src/lib.rs Outdated Show resolved Hide resolved
zokrates_codegen/src/lib.rs Outdated Show resolved Hide resolved
@dark64 dark64 changed the title Fix uint range check Fix range check Sep 4, 2023
@@ -0,0 +1,67 @@
{
"entry_point": "./tests/tests/range_check/assert_lt_u8_constant.zok",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a test with a value which is outside the u8 range and check that it fails, or is it handled in some other test for usize inputs?

def main(field a) -> bool {
field p = FIELD_MAX + a;
// we added a = 0 to prevent the condition to be evaluated at compile time
return a < p;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other tests down below all do assert(condition). Do we cover all cases which just use the condition without asserting it, for example returning it? They are handled differently in code generation so they should be also tested separately.

@Schaeff Schaeff merged commit 6c49edc into develop Nov 9, 2023
8 checks passed
@Schaeff Schaeff deleted the uint-assert-fix branch November 9, 2023 09:25
dark64 added a commit that referenced this pull request Nov 9, 2023
* fix uint range check

* update bit cache with correct bits

* suggestions

* js fmt

* clippy

* fix range check, add more tests

* update changelog

* fieldlt improvements

* fix tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot use <= on u32 in assert
2 participants