Skip to content

Commit b31c3a7

Browse files
kashbrtiKhashayar BarootiTomAFrench
authored
feat!: update to support Noir 0.37.0 (#16)
Co-authored-by: Khashayar Barooti <[email protected]> Co-authored-by: Tom French <[email protected]>
1 parent 5c5030c commit b31c3a7

25 files changed

+7422
-4190
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
toolchain: [nightly, 0.34.0]
19+
toolchain: [nightly, 0.37.0]
2020
steps:
2121
- name: Checkout sources
2222
uses: actions/checkout@v4
@@ -38,7 +38,7 @@ jobs:
3838
- name: Install Nargo
3939
uses: noir-lang/[email protected]
4040
with:
41-
toolchain: 0.34.0
41+
toolchain: 0.37.0
4242

4343
- name: Run formatter
4444
run: nargo fmt --check

Nargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "json_parser"
33
type = "lib"
44
authors = [""]
5-
compiler_version = ">=0.34.0"
5+
compiler_version = ">=0.37.0"
66

77
[dependencies]
8-
noir_sort = {tag = "v0.1.0", git = "https://github.com/noir-lang/noir_sort"}
8+
noir_sort = {tag = "v0.2.0", git = "https://github.com/noir-lang/noir_sort"}

src/_comparison_tools/bounds_checker.nr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
/*
42
53
when iterating from 0 to N, validate i < M efficiently

src/_comparison_tools/lt.nr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/**
22
* @file helper methods that evaluate comparison operations on Field elements that are known to be of a fixed size (e.g. <2^16)
33
**/
4-
unconstrained pub fn get_lt_predicate_f(x: Field, y: Field) -> bool {
4+
pub unconstrained fn get_lt_predicate_f(x: Field, y: Field) -> bool {
55
let a = x as u32;
66
let b = y as u32;
77
let r = a < b;
88
r
99
}
1010

11-
unconstrained pub fn get_lte_predicate_large(x: Field, y: Field) -> bool {
11+
pub unconstrained fn get_lte_predicate_large(x: Field, y: Field) -> bool {
1212
let r = x.lt(y) | (x == y);
1313
r
1414
}
@@ -17,33 +17,33 @@ pub fn lte_field_240_bit(x: Field, y: Field) -> bool {
1717
let predicate = get_lte_predicate_large(x, y);
1818
let delta = y as Field - x as Field;
1919

20-
// (x - y) * predicate
20+
// (x - y) * predicate
2121
// if true, y - x >= 0
2222
// if false, x <= y is wrong therefore x > y => x - y > 0 => x - y + 1 >= 0
2323
// (y - x) * p + (1 - p) * (x - y + 1)
2424
// (y - x) * p + x - y + 1 + p * (y - x)
2525
let lt_parameter = 2 * (predicate as Field) * delta - predicate as Field - delta + 1;
26-
lt_parameter.assert_max_bit_size(240);
26+
lt_parameter.assert_max_bit_size::<240>();
2727

2828
predicate
2929
}
3030

3131
pub fn assert_lte_240_bit(x: Field, y: Field) {
3232
let delta = y as Field - x as Field;
3333

34-
// (x - y) * predicate
34+
// (x - y) * predicate
3535
// if true, y - x >= 0
3636
// if false, x <= y is wrong therefore x > y => x - y > 0 => x - y + 1 >= 0
3737
// (y - x) * p + (1 - p) * (x - y + 1)
3838
// (y - x) * p + x - y + 1 + p * (y - x)
39-
delta.assert_max_bit_size(240);
39+
delta.assert_max_bit_size::<240>();
4040
}
4141

4242
pub fn lt_field_16_bit(x: Field, y: Field) -> bool {
4343
let predicate = get_lt_predicate_f(x, y);
4444
let delta = y as Field - x as Field;
4545
let lt_parameter = 2 * (predicate as Field) * delta - predicate as Field - delta;
46-
lt_parameter.assert_max_bit_size(16);
46+
lt_parameter.assert_max_bit_size::<16>();
4747

4848
predicate
4949
}
@@ -52,7 +52,7 @@ pub fn lt_field_8_bit(x: Field, y: Field) -> bool {
5252
let predicate = get_lt_predicate_f(x, y);
5353
let delta = y as Field - x as Field;
5454
let lt_parameter = 2 * (predicate as Field) * delta - predicate as Field - delta;
55-
lt_parameter.assert_max_bit_size(8);
55+
lt_parameter.assert_max_bit_size::<8>();
5656

5757
predicate
5858
}
@@ -62,13 +62,13 @@ pub fn assert_gt_240_bit(lhs: Field, rhs: Field) {
6262
// -> lhs - rhs > 0
6363
// -> lhs - rhs - 1 >= 0
6464
let diff = lhs - rhs - 1;
65-
diff.assert_max_bit_size(240);
65+
diff.assert_max_bit_size::<240>();
6666
}
6767

6868
pub fn assert_lt_240_bit(lhs: Field, rhs: Field) {
6969
// lhs < rhs
7070
// -> rhs - lhs > 0
7171
// -> rhs - lhs - 1 >= 0
7272
let diff = rhs - lhs - 1;
73-
diff.assert_max_bit_size(240);
73+
diff.assert_max_bit_size::<240>();
7474
}

src/_string_tools/slice_field.nr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ struct Slice200 {
88
hihi: u64, // 7 bytes
99
hilo: u64, // 7 bytes
1010
lohi: u64, // 7 bytes
11-
lolo: u32 // 4 bytes
11+
lolo: u32, // 4 bytes
1212
}
1313
global PHI_54: u64 = 0x30644E72E131A0;
1414
global PLO_200: Slice200 = Slice200 {
@@ -66,11 +66,11 @@ unconstrained fn __slice_200_bits_from_field(f: Field) -> (Field, Field, bool) {
6666
pub fn slice_200_bits_from_field(f: Field) -> Field {
6767
let (lo, hi, borrow) = __slice_200_bits_from_field(f);
6868
assert(hi * TWO_POW_200 + lo == f);
69-
lo.assert_max_bit_size(200);
70-
hi.assert_max_bit_size(56);
69+
lo.assert_max_bit_size::<200>();
70+
hi.assert_max_bit_size::<56>();
7171
let lo_diff = PLO_200_felt - lo + (borrow as Field * TWO_POW_200);
7272
let hi_diff = PHI_54_felt - hi - borrow as Field;
73-
lo_diff.assert_max_bit_size(200);
74-
hi_diff.assert_max_bit_size(56);
73+
lo_diff.assert_max_bit_size::<200>();
74+
hi_diff.assert_max_bit_size::<56>();
7575
lo
7676
}

0 commit comments

Comments
 (0)