Skip to content

Commit ec163ab

Browse files
authored
feat!: update to 0.34.0 (#6)
1 parent ce3926a commit ec163ab

File tree

13 files changed

+94
-71
lines changed

13 files changed

+94
-71
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.32.0]
19+
toolchain: [nightly, 0.34.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.32.0
41+
toolchain: 0.34.0
4242

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

Nargo.toml

Lines changed: 1 addition & 1 deletion
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.32.0"
5+
compiler_version = ">=0.34.0"
66

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

src/_string_tools/slice_field.nr

Lines changed: 2 additions & 3 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 {
@@ -19,7 +19,7 @@ global PLO_200: Slice200 = Slice200 {
1919
};
2020

2121
unconstrained fn __slice_200_bits_from_field(f: Field) -> (Field, Field, bool) {
22-
let b = f.to_be_bytes(32);
22+
let b: [u8; 32] = f.to_be_bytes();
2323

2424
let mut res200: Slice200 = Slice200 { hihi: 0, hilo: 0, lohi: 0, lolo: 0 };
2525
let mut res54: u64 = 0;
@@ -74,4 +74,3 @@ pub fn slice_200_bits_from_field(f: Field) -> Field {
7474
hi_diff.assert_max_bit_size(56);
7575
lo
7676
}
77-

src/_string_tools/slice_packed_field.nr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ global PATH_LOOKUP: [[bool; 5]; 32] = [
371371
**/
372372
unconstrained fn __slice_field(f: Field, num_bytes: Field) -> [Field; 5] {
373373
let head_path = PATH_LOOKUP[num_bytes];
374-
let bytes = f.to_be_bytes(32);
374+
let bytes: [u8; 32] = f.to_be_bytes();
375375
let bytes = bytes.map(|b: u8| b as Field);
376376

377377
let mut chunks: [Field; 5] = [0; 5];
@@ -401,22 +401,22 @@ unconstrained fn __slice_field(f: Field, num_bytes: Field) -> [Field; 5] {
401401
tail_ptr += 4;
402402
}
403403
if head_path[3] {
404-
chunks[3] =
404+
chunks[3] =
405405
bytes[head_ptr] * 0x100000000000000 + bytes[head_ptr + 1] * 0x1000000000000
406406
+ bytes[head_ptr + 2] * 0x10000000000 + bytes[head_ptr + 3] * 0x100000000
407407
+ bytes[head_ptr + 4] * 0x1000000 + bytes[head_ptr + 5] * 0x10000
408408
+ bytes[head_ptr + 6] * 0x100 + bytes[head_ptr + 7];
409409
head_ptr += 8;
410410
} else {
411-
chunks[3] =
411+
chunks[3] =
412412
bytes[tail_ptr] * 0x100000000000000 + bytes[tail_ptr + 1] * 0x1000000000000
413413
+ bytes[tail_ptr + 2] * 0x10000000000 + bytes[tail_ptr + 3] * 0x100000000
414414
+ bytes[tail_ptr + 4] * 0x1000000 + bytes[tail_ptr + 5] * 0x10000
415415
+ bytes[tail_ptr + 6] * 0x100 + bytes[tail_ptr + 7];
416416
tail_ptr += 8;
417417
}
418418
if head_path[4] {
419-
chunks[4] =
419+
chunks[4] =
420420
bytes[head_ptr] * 0x1000000000000000000000000000000 + bytes[head_ptr + 1] * 0x10000000000000000000000000000
421421
+ bytes[head_ptr + 2] * 0x100000000000000000000000000 + bytes[head_ptr + 3] * 0x1000000000000000000000000
422422
+ bytes[head_ptr + 4] * 0x10000000000000000000000 + bytes[head_ptr + 5] * 0x100000000000000000000
@@ -426,7 +426,7 @@ unconstrained fn __slice_field(f: Field, num_bytes: Field) -> [Field; 5] {
426426
+ bytes[head_ptr + 12] * 0x1000000 + bytes[head_ptr + 13] * 0x10000
427427
+ bytes[head_ptr + 14] * 0x100 + bytes[head_ptr + 15];
428428
} else {
429-
chunks[4] =
429+
chunks[4] =
430430
bytes[tail_ptr] * 0x1000000000000000000000000000000 + bytes[tail_ptr + 1] * 0x10000000000000000000000000000
431431
+ bytes[tail_ptr + 2] * 0x100000000000000000000000000 + bytes[tail_ptr + 3] * 0x1000000000000000000000000
432432
+ bytes[tail_ptr + 4] * 0x10000000000000000000000 + bytes[tail_ptr + 5] * 0x100000000000000000000
@@ -548,7 +548,7 @@ pub fn slice_field(f: Field, num_bytes: Field) -> (Field, Field) {
548548

549549
/**
550550
* @brief Given an array of fields that pack 31 bytes, return an array that slices the packed byte array at a given index for a given number of bytes
551-
* @description Some serious dark black magic nonsense going on here. TODO: document
551+
* @description Some serious dark black magic nonsense going on here. TODO: document
552552
**/
553553
pub fn slice_fields<let InputFields: u16, let OutputFields: u16>(
554554
data: [Field; InputFields],
@@ -783,7 +783,7 @@ fn test_slice_fields() {
783783
fn test_slice_field() {
784784
let input = 0xffeebbccbbaa99887766554433221100112233445566778899aabbccddeeff;
785785

786-
let input_bytes: [u8; 32] = input.to_be_bytes(32).as_array();
786+
let input_bytes: [u8; 32] = input.to_be_bytes();
787787

788788
for i in 0..32 {
789789
println(f"i = {i}");

src/_string_tools/string_chopper.nr

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ impl<let NeedlePackedFields: u16> StringChopper<NeedlePackedFields> {
1313

1414
let sliced: [Field; NeedlePackedFields] = slice_fields(haystack, start_bytes, num_bytes);
1515

16-
let sliced_bytes = sliced.map(|x: Field| { let r: [u8; 31] = x.to_be_bytes(31).as_array(); r });
16+
let sliced_bytes = sliced.map(|x: Field| { let r: [u8; 31] = x.to_be_bytes(); r });
1717

1818
let num_slices = StringBytes / 31;
1919
let overflow = StringBytes % 31;
@@ -28,4 +28,3 @@ impl<let NeedlePackedFields: u16> StringChopper<NeedlePackedFields> {
2828
parsed_string
2929
}
3030
}
31-

src/_table_generation/make_tables.nr

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/**
2-
* @file Contains methods used to generate tables in `json_tables.nr`. These table generation methods shouldn't be used inside of actual circuits.
3-
**/
1+
//! Contains methods used to generate tables in `json_tables.nr`. These table generation methods shouldn't be used inside of actual circuits.
42

53
mod CaptureMode {
64
global GRAMMAR_CAPTURE = 0;

src/getters.nr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl<let NumBytes: u32, let NumPackedFields: u16, let MaxNumTokens: u16, let Max
2727

2828
/**
2929
* @brief If the root JSON is an object, extract a JSONEntry that describes an array, object or value that maps to a given key
30-
* @description returns an Option<JSONEntry> which will be null if the entry does not exist
30+
* @description returns an Option<JSONEntry> which will be null if the entry does not exist
3131
**/
3232
fn get_json_entry<let KeyBytes: u16>(self, key: [u8; KeyBytes]) -> (bool, JSONEntry) {
3333
// let key_index = self.find_key_in_map(keyhash);
@@ -251,7 +251,7 @@ impl<let NumBytes: u32, let NumPackedFields: u16, let MaxNumTokens: u16, let Max
251251
* @brief figures out if `target` exists as a key in `self.key_hashes`
252252
* @details if `target` does not exist, we return the two indicies of adjacent
253253
* entries in `self.key_hashes`, lhs_index, rhs_index, where
254-
* lhs_index < key_hash < rhs_index
254+
* lhs_index < key_hash < rhs_index
255255
**/
256256
unconstrained fn search_for_key_in_map(self, target: Field) -> KeySearchResult {
257257
let mut found_index: Field = 0;
@@ -322,7 +322,7 @@ impl<let NumBytes: u32, let NumPackedFields: u16, let MaxNumTokens: u16, let Max
322322
If key does NOT exist. 3 cases
323323
case 1: keyhash < first entry
324324
case 2: keyhash > last entry
325-
case 3: entry A > keyhash > entryB
325+
case 3: entry A > keyhash > entryB
326326
327327
*/
328328
let hasher: ByteHasher<MaxKeyFields> = ByteHasher {};
@@ -380,7 +380,7 @@ impl<let NumBytes: u32, let NumPackedFields: u16, let MaxNumTokens: u16, let Max
380380
If key does NOT exist. 3 cases
381381
case 1: keyhash < first entry
382382
case 2: keyhash > last entry
383-
case 3: entry A > keyhash > entryB
383+
case 3: entry A > keyhash > entryB
384384
385385
*/
386386
let hasher: ByteHasher<MaxKeyFields> = ByteHasher {};
@@ -424,7 +424,7 @@ impl<let NumBytes: u32, let NumPackedFields: u16, let MaxNumTokens: u16, let Max
424424
(search_result.found, search_result.lhs_index)
425425
}
426426

427-
unconstrained fn __get_keys_at_root<let MaxNumKeys: u16, let MaxKeyBytes: u16>(self) -> BoundedVec<Field, MaxNumKeys> {
427+
unconstrained fn __get_keys_at_root<let MaxNumKeys: u16>(self) -> BoundedVec<Field, MaxNumKeys> {
428428
let mut result: BoundedVec<Field, MaxNumKeys> = BoundedVec { len: 0, storage: [0; MaxNumKeys] };
429429

430430
let root_object: JSONEntry = JSONEntry::from(self.json_entries_packed[self.root_index_in_transcript]);

src/json.nr

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,18 @@ struct JSON<let NumBytes: u32, let NumPackedFields: u16, let MaxNumTokens: u16,
6161
**/
6262
impl<let NumBytes: u16, let NumPackedFields: u16, let MaxNumTokens: u16, let MaxNumValues: u16, let MaxKeyFields: u16> std::cmp::Eq for JSON<NumBytes, NumPackedFields, MaxNumTokens, MaxNumValues, MaxKeyFields> {
6363
fn eq(self, other: Self) -> bool {
64-
(self.json == other.json) & (self.raw_transcript == other.raw_transcript)
65-
& (self.transcript == other.transcript)
66-
& (self.transcript_length == other.transcript_length)
67-
& (self.key_data == other.key_data)
68-
& (self.key_hashes == other.key_hashes)
69-
& (self.layer_type_of_root == other.layer_type_of_root)
70-
& (self.root_id == other.root_id)
71-
& (self.root_index_in_transcript == other.root_index_in_transcript)
72-
& (self.json_entries_packed == other.json_entries_packed)
73-
& (self.json_packed == other.json_packed)
64+
(self.json == other.json)
65+
& (self.raw_transcript == other.raw_transcript)
66+
& (self.transcript == other.transcript)
67+
& (self.transcript_length == other.transcript_length)
68+
& (self.key_data == other.key_data)
69+
& (self.key_hashes == other.key_hashes)
70+
& (self.layer_type_of_root == other.layer_type_of_root)
71+
& (self.root_id == other.root_id)
72+
& (self.root_index_in_transcript
73+
== other.root_index_in_transcript)
74+
& (self.json_entries_packed == other.json_entries_packed)
75+
& (self.json_packed == other.json_packed)
7476
}
7577
}
7678

src/json_entry.nr

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct JSONContextStackEntry {
1010
}
1111
impl JSONContextStackEntry {
1212
unconstrained fn __from_field(f: Field) -> Self {
13-
let bytes = f.to_be_bytes(11);
13+
let bytes: [u8; 11] = f.to_be_bytes();
1414
let context = bytes[0] as Field;
1515
let num_entries = bytes[1] as Field * 0x100 + bytes[2] as Field;
1616
let current_key_length = bytes[3] as Field * 0x100 + bytes[4] as Field;
@@ -59,7 +59,7 @@ struct JSONEntry {
5959
entry_type: Field, // is this an OBJECT_TOKEN, ARRAY_TOKEN, STRING_TOKEN, NUMERIC_TOKEN or LITERAL_TOKEN?
6060
id: Field, // if this is an object or array, describes the unique identifier assigned to this item
6161
parent_index: Field, // if parent is an object or array, describes the unique identifier assigned to our parent
62-
array_pointer: Field, // if parent is an array, where in the array are we?
62+
array_pointer: Field, // if parent is an array, where in the array are we?
6363
child_pointer: Field, // if this is an object or array, points to the location in `json_entries_packed` of this item's first child
6464
num_children: Field, // if this is an object or array, how many child elements do we contain?
6565
json_pointer: Field, // points to the json that describes the first byte of this entry
@@ -145,7 +145,7 @@ impl JSONEntry {
145145
parent_index
146146
}
147147
unconstrained fn __from_field(f: Field) -> Self {
148-
let bytes: [u8; 20] = f.to_be_bytes(20).as_array(); // 10.5 gates
148+
let bytes: [u8; 20] = f.to_be_bytes(); // 10.5 gates
149149

150150
let entry_type = bytes[0] as Field;
151151

@@ -230,6 +230,7 @@ impl std::cmp::Eq for JSONEntryPacked {
230230
}
231231

232232
impl std::default::Default for JSONEntryPacked {
233-
fn default() -> Self { JSONEntryPacked{ value: 0 }}
233+
fn default() -> Self {
234+
JSONEntryPacked { value: 0 }
235+
}
234236
}
235-

src/keymap.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl KeyIndexData {
2626
}
2727

2828
unconstrained fn __from_field(packed: Field) -> Self {
29-
let unpacked = packed.to_be_bytes(8);
29+
let unpacked: [u8; 8] = packed.to_be_bytes();
3030
let array_index: Field = unpacked[1] as Field + unpacked[0] as Field * 0x100;
3131
let json_length: Field = unpacked[3] as Field + unpacked[2] as Field * 0x100;
3232
let json_index: Field = unpacked[5] as Field + unpacked[4] as Field * 0x100;

0 commit comments

Comments
 (0)