Skip to content

Commit 2fdeeea

Browse files
committed
Modify for single nested recursion
1 parent 67121cd commit 2fdeeea

File tree

12 files changed

+135
-83
lines changed

12 files changed

+135
-83
lines changed

how-to/recursive-proofs/circuits/not_odd/src/main.nr

Lines changed: 0 additions & 25 deletions
This file was deleted.

how-to/recursive-proofs/circuits/recurse/src/main.nr

Lines changed: 0 additions & 22 deletions
This file was deleted.

how-to/recursive-proofs/circuits/recurse/Nargo.toml renamed to how-to/recursive-proofs/circuits/recurseLeaf/Nargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ authors = [""]
55
compiler_version = ">=0.26.0"
66

77
[dependencies]
8+
sumLib = { path = "../sumLib" }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use dep::std;
2+
use dep::sumLib::secretSum;
3+
4+
#[recursive]
5+
fn main(
6+
verification_key: [Field; 114],
7+
public_inputs: pub [Field; 3],
8+
key_hash: Field,
9+
proof: [Field; 93],
10+
num: u64
11+
) -> pub u64 {
12+
// verify sum so far was computed correctly
13+
std::verify_proof(
14+
verification_key.as_slice(),
15+
proof.as_slice(),
16+
public_inputs.as_slice(),
17+
key_hash
18+
);
19+
secretSum((public_inputs[2] as u64), num)
20+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "recurse"
3+
type = "bin"
4+
authors = [""]
5+
compiler_version = ">=0.26.0"
6+
7+
[dependencies]
8+
sumLib = { path = "../sumLib" }
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use dep::std;
2+
3+
fn main(
4+
verification_key: [Field; 114],
5+
public_inputs: pub [Field; 6],
6+
key_hash: Field,
7+
proof: [Field; 109]
8+
) -> pub u64 {
9+
// verify sum was computed correctly
10+
std::verify_proof(
11+
verification_key.as_slice(),
12+
proof.as_slice(),
13+
public_inputs.as_slice(),
14+
key_hash
15+
);
16+
public_inputs[5] as u64
17+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "sum"
3+
type = "bin"
4+
authors = [""]
5+
compiler_version = ">=0.26.0"
6+
7+
[dependencies]
8+
sumLib = { path = "../sumLib" }
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use dep::sumLib::secretSum;
2+
3+
#[recursive]
4+
fn main(a: pub u64, b: pub u64) -> pub u64 {
5+
secretSum(a, b)
6+
}
7+
8+
#[test]
9+
fn test_not_equal() {
10+
assert(main(1, 3) == 4);
11+
}

how-to/recursive-proofs/circuits/not_odd/Nargo.toml renamed to how-to/recursive-proofs/circuits/sumLib/Nargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
2-
name = "simple"
3-
type = "bin"
2+
name = "sumLib"
3+
type = "lib"
44
authors = [""]
55
compiler_version = ">=0.26.0"
66

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
pub fn secretSum(a: u64, b: u64) -> u64 {
2+
a + b
3+
}
4+
5+
#[test]
6+
fn test_sum() {
7+
assert(secretSum(1, 2) == 3);
8+
// Uncomment to make test fail
9+
// assert(secretSum(1, 1) == 3);
10+
}

0 commit comments

Comments
 (0)