-
Notifications
You must be signed in to change notification settings - Fork 381
assert_max_bit_size() causes panic #6839
Copy link
Copy link
Closed
Description
Aim
Verify that the the sum of two fields is less than the bit size, to prevent overflow attack.
Expected Behavior
Constraint is applied.
Bug
The application panicked (crashed).
Message: Non-numeric type variable used in expression expecting a value
Location: compiler/noirc_frontend/src/monomorphization/mod.rs:934
I also note in the docs that this field takes a parameter (field.assert_max_bit_size(32);), but it doesn't seem to in the Noir validation. I get an error if I try to use a parameter.
error: Function expects 1 parameter but 2 were given
┌─ src/main.nr:15:5
│
15 │ output_value.assert_max_bit_size(32);
│ ------------------------------------
│
To Reproduce
#[recursive]
fn main(field1: Field, field2: Field) {
let output_value = field1 + field2;
// Contrain the output value
output_value.assert_max_bit_size();
}
#[test]
fn test_main() {
main(1, 2)
}Workaround
None
Workaround Description
No response
Additional Context
No response
Project Impact
Blocker
Blocker Context
No response
Nargo Version
nargo version = 0.36.0 noirc version = 0.36.0+801c71880ecf8386a26737a5d8bb5b4cb164b2ab (git version hash: 801c718, is dirty: false)
NoirJS Version
n/a
Proving Backend Tooling & Version
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels