-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
test_programs/execution_success/array_dynamic_nested_blackbox_input/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "array_dynamic_nested_blackbox_input" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.24.0" | ||
|
||
[dependencies] |
23 changes: 23 additions & 0 deletions
23
test_programs/execution_success/array_dynamic_nested_blackbox_input/Prover.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
y = "3" | ||
hash_result = [50, 53, 90, 252, 105, 236, 223, 30, 135, 229, 193, 172, 51, 139, 8, 32, 188, 104, 151, 115, 129, 168, 27, 71, 203, 47, 40, 228, 89, 177, 129, 100] | ||
|
||
[[x]] | ||
a = "1" | ||
b = ["2", "3", "20"] | ||
|
||
[x.bar] | ||
inner = ["100", "101", "102"] | ||
|
||
[[x]] | ||
a = "4" # idx = 3, flattened start idx = 7 | ||
b = ["5", "6", "21"] # idx = 4, flattened start idx = 8 | ||
|
||
[x.bar] | ||
inner = ["103", "104", "105"] # idx = 5, flattened start idx = 11 | ||
|
||
[[x]] | ||
a = "7" | ||
b = ["8", "9", "22"] | ||
|
||
[x.bar] | ||
inner = ["106", "107", "108"] |
20 changes: 20 additions & 0 deletions
20
test_programs/execution_success/array_dynamic_nested_blackbox_input/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
struct Bar { | ||
inner: [u8; 3], | ||
} | ||
|
||
struct Foo { | ||
a: Field, | ||
b: [Field; 3], | ||
bar: Bar, | ||
} | ||
|
||
fn main(mut x: [Foo; 3], y: pub Field, hash_result: pub [u8; 32]) { | ||
// Simple dynamic array set for entire inner most array | ||
x[y - 1].bar.inner = [106, 107, 10]; | ||
let mut hash_input = x[y - 1].bar.inner; | ||
// Make sure that we are passing a dynamic array to the black box function call | ||
// by setting the array using a dynamic index here | ||
hash_input[y - 1] = 0; | ||
let hash = dep::std::hash::sha256(hash_input); | ||
assert_eq(hash, hash_result); | ||
} |