Skip to content

Commit a65f26d

Browse files
authored
Merge pull request #55 from noir-lang/jc/update-recursion
Update recursion example and add recursion CI
2 parents fea37a5 + 479c93e commit a65f26d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+482
-14268
lines changed

.github/workflows/recursion.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Run recursion Tests on PR
2+
on:
3+
pull_request:
4+
paths:
5+
- "recursion/**"
6+
7+
jobs:
8+
test:
9+
defaults:
10+
run:
11+
working-directory: recursion
12+
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
17+
- name: Install Nargo
18+
uses: noir-lang/noirup@v0.1.2
19+
with:
20+
toolchain: stable
21+
22+
- name: Install bb
23+
run: |
24+
curl -L https://raw.githubusercontent.com/AztecProtocol/aztec-packages/refs/heads/master/barretenberg/bbup/install | bash
25+
echo "PATH=$PATH:/home/runner/.bb" >> $GITHUB_ENV
26+
27+
- name: Run bbup
28+
run: |
29+
bbup
30+
31+
- name: Build circuits
32+
run: |
33+
./build.sh
34+
working-directory: recursion/circuits
35+
36+
- name: Install JS dependencies
37+
working-directory: recursion/js
38+
run: |
39+
yarn install
40+
41+
- name: Generate proof in JS
42+
run: |
43+
yarn generate-proof
44+
working-directory: recursion/js

recursion/.gitignore

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
proofs
2-
.vscode
3-
crs
4-
.DS_Store
5-
artifacts
6-
.cache
7-
.target
8-
typechain-types
91
cache
10-
target
11-
.next
12-
node_modules
13-
next-env.d.types
2+
out
3+
proofs
4+
broadcast
5+
.env
6+
plonk_vk.sol
7+
circuits/**/target/*
8+
js/node_modules
9+
.DS_Store

recursion/.prettierignore

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

recursion/.prettierrc

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

recursion/.yarn/install-state.gz

-811 KB
Binary file not shown.

recursion/.yarn/releases/yarn-4.1.0.cjs

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

recursion/.yarnrc.yml

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

recursion/README.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
1-
# Recursive proofs with Noir
1+
# Noir Recursion Example
22

3-
Recursive proofs mean you prove that another proof is correct. A bit of a proofinception but bear
4-
with me:
3+
E2E example of generating a recursive proof using Noir and bb.js.
54

6-
- You prove that `x != y`
7-
- You pick that proof and send it to another circuit (the "outer" proof)
8-
- You generate the outer proof and verify it
5+
- Circuits in `circuits/` directory
6+
- JS code in `js/generate-proof.ts`
97

10-
Why is this useful? In this example, it doesn't do much. But you could verify two proofs within a
11-
proof, which can be incredibly useful.
8+
### Version used
129

13-
You could also avoid verifying stuff on-chain for turn-based games, for example. Check out the
14-
[Noir Docs](https://noir-lang.org/docs/explainers/explainer-recursion) for a high-level explanation.
10+
```
11+
Noir 1.0.0-beta.6
12+
bb 0.84.0
13+
```
1514

16-
## Getting Started
15+
### Steps
1716

18-
1. Install dependencies by running `yarn`
19-
2. For on-chain verification, open another terminal, and run
20-
`cd packages/hardhat && npx hardhat node`
21-
3. Run `yarn dev`
17+
1. Compile the circuits
2218

23-
## Testing
19+
```bash
20+
(cd circuits && ./build.sh)
21+
```
2422

25-
To run the [test file](./packages/hardhat/test/index.test.ts), try `yarn test`
23+
2. Generate inner and recursive proof, and verify the recursive proof
24+
25+
```bash
26+
(cd js && yarn install)
27+
(cd js && yarn generate-proof)
28+
```

recursion/circuits/build.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
set -e
2+
3+
cd inner
4+
nargo compile
5+
bb write_vk --oracle_hash keccak -b ./target/inner.json -o ./target
6+
cd ..
7+
8+
cd recursive
9+
nargo compile
10+
bb write_vk --oracle_hash keccak -b ./target/recursive.json -o ./target
11+
cd ..
12+
13+
echo "Done"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name="inner"
3+
type="bin"
4+
authors = ["saleel"]
5+
compiler_version = ">=1.0.0"
6+
7+
[dependencies]

0 commit comments

Comments
 (0)