Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
toolchain: [nightly, 0.34.0]
toolchain: [nightly, 0.37.0]
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand All @@ -38,7 +38,7 @@ jobs:
- name: Install Nargo
uses: noir-lang/noirup@v0.1.3
with:
toolchain: 0.34.0
toolchain: 0.37.0

- name: Run formatter
run: nargo fmt --check
Expand Down
4 changes: 2 additions & 2 deletions Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "json_parser"
type = "lib"
authors = [""]
compiler_version = ">=0.34.0"
compiler_version = ">=0.37.0"

[dependencies]
noir_sort = {tag = "v0.1.0", git = "https://github.com/noir-lang/noir_sort"}
noir_sort = {tag = "v0.2.0", git = "https://github.com/noir-lang/noir_sort"}
2 changes: 0 additions & 2 deletions src/_comparison_tools/bounds_checker.nr
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


/*

when iterating from 0 to N, validate i < M efficiently
Expand Down
20 changes: 10 additions & 10 deletions src/_comparison_tools/lt.nr
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* @file helper methods that evaluate comparison operations on Field elements that are known to be of a fixed size (e.g. <2^16)
**/
unconstrained pub fn get_lt_predicate_f(x: Field, y: Field) -> bool {
pub unconstrained fn get_lt_predicate_f(x: Field, y: Field) -> bool {
let a = x as u32;
let b = y as u32;
let r = a < b;
r
}

unconstrained pub fn get_lte_predicate_large(x: Field, y: Field) -> bool {
pub unconstrained fn get_lte_predicate_large(x: Field, y: Field) -> bool {
let r = x.lt(y) | (x == y);
r
}
Expand All @@ -17,33 +17,33 @@ pub fn lte_field_240_bit(x: Field, y: Field) -> bool {
let predicate = get_lte_predicate_large(x, y);
let delta = y as Field - x as Field;

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

predicate
}

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

// (x - y) * predicate
// (x - y) * predicate
// if true, y - x >= 0
// if false, x <= y is wrong therefore x > y => x - y > 0 => x - y + 1 >= 0
// (y - x) * p + (1 - p) * (x - y + 1)
// (y - x) * p + x - y + 1 + p * (y - x)
delta.assert_max_bit_size(240);
delta.assert_max_bit_size::<240>();
}

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

predicate
}
Expand All @@ -52,7 +52,7 @@ pub fn lt_field_8_bit(x: Field, y: Field) -> bool {
let predicate = get_lt_predicate_f(x, y);
let delta = y as Field - x as Field;
let lt_parameter = 2 * (predicate as Field) * delta - predicate as Field - delta;
lt_parameter.assert_max_bit_size(8);
lt_parameter.assert_max_bit_size::<8>();

predicate
}
Expand All @@ -62,13 +62,13 @@ pub fn assert_gt_240_bit(lhs: Field, rhs: Field) {
// -> lhs - rhs > 0
// -> lhs - rhs - 1 >= 0
let diff = lhs - rhs - 1;
diff.assert_max_bit_size(240);
diff.assert_max_bit_size::<240>();
}

pub fn assert_lt_240_bit(lhs: Field, rhs: Field) {
// lhs < rhs
// -> rhs - lhs > 0
// -> rhs - lhs - 1 >= 0
let diff = rhs - lhs - 1;
diff.assert_max_bit_size(240);
diff.assert_max_bit_size::<240>();
}
10 changes: 5 additions & 5 deletions src/_string_tools/slice_field.nr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct Slice200 {
hihi: u64, // 7 bytes
hilo: u64, // 7 bytes
lohi: u64, // 7 bytes
lolo: u32 // 4 bytes
lolo: u32, // 4 bytes
}
global PHI_54: u64 = 0x30644E72E131A0;
global PLO_200: Slice200 = Slice200 {
Expand Down Expand Up @@ -66,11 +66,11 @@ unconstrained fn __slice_200_bits_from_field(f: Field) -> (Field, Field, bool) {
pub fn slice_200_bits_from_field(f: Field) -> Field {
let (lo, hi, borrow) = __slice_200_bits_from_field(f);
assert(hi * TWO_POW_200 + lo == f);
lo.assert_max_bit_size(200);
hi.assert_max_bit_size(56);
lo.assert_max_bit_size::<200>();
hi.assert_max_bit_size::<56>();
let lo_diff = PLO_200_felt - lo + (borrow as Field * TWO_POW_200);
let hi_diff = PHI_54_felt - hi - borrow as Field;
lo_diff.assert_max_bit_size(200);
hi_diff.assert_max_bit_size(56);
lo_diff.assert_max_bit_size::<200>();
hi_diff.assert_max_bit_size::<56>();
lo
}
Loading