Skip to content

Commit 2bb66c1

Browse files
committed
Move the experimental frontends into a separate crate, so that when not using them they don't take several minutes to compile (and indirect dependencies).
This saves several minutes (and MBs of data) on compilation time both when running tests in this repo, but also when using the sonobe lib as a dependency in external repos.
1 parent cb1b8e3 commit 2bb66c1

32 files changed

Lines changed: 136 additions & 97 deletions

File tree

.github/scripts/wasm-target-test-build.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ cp "${GIT_ROOT}/rust-toolchain" .
1515
rustup target add wasm32-unknown-unknown wasm32-wasi
1616

1717
# add dependencies
18-
cargo add --path "${GIT_ROOT}/folding-schemes" --features wasm, parallel
18+
cargo add --path "${GIT_ROOT}/frontends" --features wasm, parallel
19+
cargo add --path "${GIT_ROOT}/folding-schemes" --features parallel
1920
cargo add getrandom --features js --target wasm32-unknown-unknown
2021

2122
# test build for wasm32-* targets
@@ -26,4 +27,4 @@ cargo build --release --target wasm32-wasi
2627

2728
# delete test project
2829
cd ../
29-
rm -rf foobar
30+
rm -rf foobar

.github/workflows/ci.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ jobs:
6161
curl -sSfL https://github.com/ethereum/solidity/releases/download/v0.8.4/solc-static-linux -o /usr/local/bin/solc
6262
chmod +x /usr/local/bin/solc
6363
- name: Execute compile.sh to generate .r1cs and .wasm from .circom
64-
run: ./folding-schemes/src/frontend/circom/test_folder/compile.sh
64+
run: ./frontends/src/circom/test_folder/compile.sh
6565
- name: Execute compile.sh to generate .json from noir
66-
run: ./folding-schemes/src/frontend/noir/test_folder/compile.sh
66+
run: ./frontends/src/noir/test_folder/compile.sh
6767
- name: Run tests
6868
uses: actions-rs/cargo@v1
6969
with:
@@ -95,11 +95,16 @@ jobs:
9595
default: true
9696
- name: Add target
9797
run: rustup target add ${{ matrix.target }}
98-
- name: Wasm-compat build
98+
- name: Wasm-compat frontends build
9999
uses: actions-rs/cargo@v1
100100
with:
101101
command: build
102-
args: -p folding-schemes --no-default-features --target ${{ matrix.target }} --features "wasm, parallel"
102+
args: -p frontends --no-default-features --target ${{ matrix.target }} --features "wasm, parallel"
103+
- name: Wasm-compat folding-schemes build
104+
uses: actions-rs/cargo@v1
105+
with:
106+
command: build
107+
args: -p folding-schemes --no-default-features --target ${{ matrix.target }} --features "default,light-test"
103108
- name: Run wasm-compat script
104109
run: |
105110
chmod +x .github/scripts/wasm-target-test-build.sh
@@ -127,9 +132,9 @@ jobs:
127132
curl -sSfL https://github.com/ethereum/solidity/releases/download/v0.8.4/solc-static-linux -o /usr/local/bin/solc
128133
chmod +x /usr/local/bin/solc
129134
- name: Execute compile.sh to generate .r1cs and .wasm from .circom
130-
run: ./folding-schemes/src/frontend/circom/test_folder/compile.sh
135+
run: ./frontends/src/circom/test_folder/compile.sh
131136
- name: Execute compile.sh to generate .json from noir
132-
run: ./folding-schemes/src/frontend/noir/test_folder/compile.sh
137+
run: ./frontends/src/noir/test_folder/compile.sh
133138
- name: Run examples tests
134139
run: cargo test --examples
135140
- name: Run examples
@@ -160,9 +165,9 @@ jobs:
160165
include:
161166
- feature_set: basic
162167
features: --features default,light-test
163-
# We only want to test `folding-schemes` package with `wasm` feature.
168+
# We only want to test `frontends` package with `wasm` feature.
164169
- feature_set: wasm
165-
features: -p folding-schemes --features wasm,parallel --target wasm32-unknown-unknown
170+
features: -p frontends --features wasm,parallel --target wasm32-unknown-unknown
166171
steps:
167172
- uses: actions/checkout@v2
168173
- uses: actions-rs/toolchain@v1

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
Cargo.lock
33

44
# Circom generated files
5-
folding-schemes/src/frontend/circom/test_folder/*_js/
5+
frontends/src/circom/test_folder/*_js/
66
*.r1cs
77
*.sym
88

99
# Noir generated files
10-
folding-schemes/src/frontend/noir/test_folder/*/target/*
10+
frontends/src/noir/test_folder/*/target/*
1111

12-
# generated contracts at test time
12+
# generated contracts data
1313
solidity-verifiers/generated
1414
examples/*.sol
1515
examples/*.calldata

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
members = [
33
"folding-schemes",
44
"solidity-verifiers",
5-
"cli"
5+
"cli",
6+
"frontends"
67
]
78
resolver = "2"
89

README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ Work in progress:
2727

2828
- [ProtoGalaxy: Efficient ProtoStar-style folding of multiple instances](https://eprint.iacr.org/2023/1106.pdf), Liam Eagen, Ariel Gabizon. 2023
2929

30-
## Available frontends
31-
32-
Available frontends to define the folded circuit:
33-
34-
- [arkworks](https://github.com/arkworks-rs), arkworks contributors
35-
- [Circom](https://github.com/iden3/circom), iden3, 0Kims Association
36-
- [Noname](https://github.com/zksecurity/noname), zkSecurity
37-
3830
## Usage
3931

4032
### Build & test

examples/circom_full_flow.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ use folding_schemes::{
2323
decider_eth::{prepare_calldata, Decider as DeciderEth},
2424
Nova, PreprocessorParam,
2525
},
26-
frontend::{circom::CircomFCircuit, FCircuit},
26+
frontend::FCircuit,
2727
transcript::poseidon::poseidon_canonical_config,
2828
Decider, FoldingScheme,
2929
};
30+
use frontends::circom::CircomFCircuit;
3031
use solidity_verifiers::{
3132
evm::{compile_solidity, Evm},
3233
utils::get_function_selector_for_nova_cyclefold_verifier,
@@ -54,11 +55,9 @@ fn main() {
5455
];
5556

5657
// initialize the Circom circuit
57-
let r1cs_path = PathBuf::from(
58-
"./folding-schemes/src/frontend/circom/test_folder/with_external_inputs.r1cs",
59-
);
58+
let r1cs_path = PathBuf::from("./frontends/src/circom/test_folder/with_external_inputs.r1cs");
6059
let wasm_path = PathBuf::from(
61-
"./folding-schemes/src/frontend/circom/test_folder/with_external_inputs_js/with_external_inputs.wasm",
60+
"./frontends/src/circom/test_folder/with_external_inputs_js/with_external_inputs.wasm",
6261
);
6362

6463
let f_circuit_params = (r1cs_path.into(), wasm_path.into(), 1, 2);

examples/noir_full_flow.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@ use folding_schemes::{
2020
decider_eth::{prepare_calldata, Decider as DeciderEth},
2121
Nova, PreprocessorParam,
2222
},
23-
frontend::{
24-
noir::{load_noir_circuit, NoirFCircuit},
25-
FCircuit,
26-
},
23+
frontend::FCircuit,
2724
transcript::poseidon::poseidon_canonical_config,
2825
Decider, FoldingScheme,
2926
};
27+
use frontends::noir::{load_noir_circuit, NoirFCircuit};
3028
use std::{env, time::Instant};
3129

3230
use solidity_verifiers::{
@@ -44,7 +42,7 @@ fn main() {
4442
let cur_path = env::current_dir().unwrap();
4543

4644
let circuit_path = format!(
47-
"{}/folding-schemes/src/frontend/noir/test_folder/test_mimc/target/test_mimc.json",
45+
"{}/frontends/src/noir/test_folder/test_mimc/target/test_mimc.json",
4846
cur_path.to_str().unwrap()
4947
);
5048

examples/noname_full_flow.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ use folding_schemes::{
2121
decider_eth::{prepare_calldata, Decider as DeciderEth},
2222
Nova, PreprocessorParam,
2323
},
24-
frontend::{noname::NonameFCircuit, FCircuit},
24+
frontend::FCircuit,
2525
transcript::poseidon::poseidon_canonical_config,
2626
Decider, FoldingScheme,
2727
};
28+
use frontends::noname::NonameFCircuit;
2829
use std::time::Instant;
2930

3031
use solidity_verifiers::{

folding-schemes/Cargo.toml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,20 @@ ark-ff = { version = "^0.4.0", default-features = false, features = ["parallel",
99
ark-poly = { version = "^0.4.0", default-features = false, features = ["parallel"] }
1010
ark-std = { version = "^0.4.0", default-features = false, features = ["parallel"] }
1111
ark-crypto-primitives = { version = "^0.4.0", default-features = false, features = ["r1cs", "sponge", "crh", "parallel"] }
12-
ark-grumpkin = { version = "0.4.0", default-features = false }
1312
ark-poly-commit = { version = "^0.4.0", default-features = false, features = ["parallel"] }
1413
ark-relations = { version = "^0.4.0", default-features = false }
15-
# this is patched at the workspace level
14+
# ark-r1cs-std is patched at the workspace level
1615
ark-r1cs-std = { version = "0.4.0", default-features = false, features = ["parallel"] }
1716
ark-snark = { version = "^0.4.0", default-features = false }
1817
ark-serialize = { version = "^0.4.0", default-features = false }
19-
ark-circom = { git = "https://github.com/arnaucube/circom-compat", default-features = false }
2018
ark-groth16 = { version = "^0.4.0", default-features = false, features = ["parallel"]}
2119
ark-bn254 = { version = "^0.4.0", default-features = false }
20+
ark-grumpkin = { version = "0.4.0", default-features = false }
2221
thiserror = "1.0"
2322
rayon = "1"
2423
num-bigint = "0.4"
2524
num-integer = "0.1"
26-
color-eyre = "=0.6.2"
2725
sha3 = "0.10"
28-
ark-noname = { git = "https://github.com/dmpierre/ark-noname", branch = "feat/sonobe-integration" }
29-
noname = { git = "https://github.com/dmpierre/noname" }
30-
serde_json = "1.0.85" # to (de)serialize JSON
31-
serde = "1.0.203"
32-
acvm = { git = "https://github.com/noir-lang/noir", rev="2b4853e", default-features = false }
33-
noir_arkworks_backend = { package="arkworks_backend", git = "https://github.com/dmpierre/arkworks_backend", branch = "feat/sonobe-integration" }
3426
log = "0.4"
3527

3628
# tmp import for espresso's sumcheck
@@ -46,6 +38,7 @@ ark-grumpkin = {version="0.4.0", features=["r1cs"]}
4638
ark-mnt4-298 = {version="0.4.0", features=["r1cs"]}
4739
ark-mnt6-298 = {version="0.4.0", features=["r1cs"]}
4840
rand = "0.8.5"
41+
num-bigint = {version = "0.4", features = ["rand"]}
4942
tracing = { version = "0.1", default-features = false, features = [ "attributes" ] }
5043
tracing-subscriber = { version = "0.2" }
5144

@@ -55,9 +48,8 @@ tracing-subscriber = { version = "0.2" }
5548
getrandom = { version = "0.2", features = ["js"] }
5649

5750
[features]
58-
default = ["ark-circom/default", "parallel"]
51+
default = ["parallel"]
5952
parallel = []
60-
wasm = ["ark-circom/wasm"]
6153
light-test = []
6254

6355

folding-schemes/src/frontend/circom/test_folder/compile.sh

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

0 commit comments

Comments
 (0)