Skip to content

Commit e0326cd

Browse files
wip
1 parent 41bd86e commit e0326cd

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/redux.nr

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ impl<let NumBytes: u16, let NumPackedFields: u16, let TranscriptEntries: u16> JS
432432
let NumWholeLimbs = NumBytes / 31;
433433
for i in 0..NumWholeLimbs {
434434
let mut limb: Field = 0;
435-
for j in 0..NumBytes {
435+
for j in 0..31 {
436436
limb *= 0x100;
437437
limb += self.json[i * 31 + j] as Field;
438438
}
@@ -530,6 +530,9 @@ impl<let NumBytes: u16, let NumPackedFields: u16, let TranscriptEntries: u16> JS
530530

531531
// fn process_transcript_entry(entry: TranscriptEntry)
532532
fn create_json_entries(&mut self) {
533+
// TODO put somewhere different?
534+
self.compute_packed_json();
535+
533536
let mut entry_ptr = 0;
534537
let mut depth: Field = 1;
535538
let mut num_entries_at_current_depth: Field = 0;
@@ -718,6 +721,15 @@ impl<let NumBytes: u16, let NumPackedFields: u16, let TranscriptEntries: u16> JS
718721
}
719722
}
720723

724+
fn extend_array<let InBytes: u32, let OutBytes: u32>(input: [u8; InBytes]) -> [u8; OutBytes] {
725+
assert(InBytes <= OutBytes);
726+
let mut result: [u8; OutBytes] = [0; OutBytes];
727+
for i in 0..InBytes {
728+
result[i] = input[i];
729+
}
730+
result
731+
}
732+
721733
#[test]
722734
fn test_redux() {
723735
/*
@@ -793,7 +805,7 @@ fn test_redux() {
793805
// TODO FIX PADDING ISSUE
794806
let text = "{ \"foo\": 1234, \"bar\": { \"foo\": 9876, \"bar\": true }, \"baz\": \"hello\" } ";
795807

796-
let mut json= JSON {
808+
let mut json = JSON {
797809
json: text.as_bytes(),
798810
transcript: [0; 30],
799811
transcript_length: 0,
@@ -1149,7 +1161,7 @@ struct JSONEntry {
11491161
#[test]
11501162
fn test_literal() {
11511163
let text = "{ \"name\": \"Adeel Solangi\", \"testA\": false, \"testB\": true, \"testC\": null } ";
1152-
let mut json = JSON {
1164+
let mut json: JSON<142, 10, 20> = JSON {
11531165
json: text.as_bytes(),
11541166
transcript: [0; 20],
11551167
transcript_length: 0,
@@ -1159,7 +1171,7 @@ fn test_literal() {
11591171
layer_context: OBJECT_LAYER,
11601172
layer_index_in_transcript: 0,
11611173
packed_json_entries: [0; 20],
1162-
packed_json: [0, 10]
1174+
packed_json: [0; 10]
11631175
};
11641176

11651177
json = json.build_transcript();
@@ -1206,7 +1218,7 @@ fn test_arrays() {
12061218
layer_context: OBJECT_LAYER,
12071219
layer_index_in_transcript: 0,
12081220
packed_json_entries: [0; 60],
1209-
packed_json: [0, 10]
1221+
packed_json: [0; 10]
12101222
};
12111223

12121224
json = json.build_transcript();

0 commit comments

Comments
 (0)