Skip to content

Commit

Permalink
add frontend features to reduce the amount of dependencies and compil…
Browse files Browse the repository at this point in the history
…ation time

The reasoning behind this is that compilation time now is too long, in
part because dependencies on specific frontends, so if the compilation
don't use some frontend it can be turned off by default.
  • Loading branch information
arnaucube committed Aug 12, 2024
1 parent f6a70fe commit c5bab2b
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ jobs:
- name: Build
# This build will be reused by nextest,
# and also checks (--all-targets) that benches don't bit-rot
run: cargo build --release --all-targets --no-default-features --features "light-test,${{ matrix.feature }}"
run: cargo build --release --all-targets --no-default-features --features "light-test,circom,noname,noir,${{ matrix.feature }}"
- name: Test
run: |
cargo nextest run --profile ci --release --workspace --no-default-features --features "light-test,${{ matrix.feature }}"
cargo nextest run --profile ci --release --workspace --no-default-features --features "light-test,circom,noname,noir,${{ matrix.feature }}"
- name: Doctests # nextest does not support doc tests
run: |
cargo test --doc
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Available frontends to define the folded circuit:
- [arkworks](https://github.com/arkworks-rs), arkworks contributors
- [Circom](https://github.com/iden3/circom), iden3, 0Kims Association
- [Noname](https://github.com/zksecurity/noname), zkSecurity
- [Noir](https://github.com/noir-lang/noir), Aztec

## Usage

Expand Down
3 changes: 3 additions & 0 deletions examples/circom_full_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#![allow(non_camel_case_types)]
#![allow(clippy::upper_case_acronyms)]
///
/// To run:
/// > cargo run --release --example noir_full_flow -- --nocapture
///
/// This example performs the full flow:
/// - define the circuit to be folded
/// - fold the circuit with Nova+CycleFold's IVC
Expand Down
3 changes: 3 additions & 0 deletions examples/external_inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#![allow(non_camel_case_types)]
#![allow(clippy::upper_case_acronyms)]

///
/// To run:
/// > cargo run --release --example external_inputs -- --nocapture
use ark_bn254::{constraints::GVar, Bn254, Fr, G1Projective as Projective};
use ark_crypto_primitives::{
crh::{
Expand Down
3 changes: 3 additions & 0 deletions examples/full_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#![allow(non_camel_case_types)]
#![allow(clippy::upper_case_acronyms)]
///
/// To run:
/// > cargo run --release --example full_flow -- --nocapture
///
/// This example performs the full flow:
/// - define the circuit to be folded
/// - fold the circuit with Nova+CycleFold's IVC
Expand Down
3 changes: 3 additions & 0 deletions examples/multi_inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#![allow(non_camel_case_types)]
#![allow(clippy::upper_case_acronyms)]

///
/// To run:
/// > cargo run --release --example multi_inputs -- --nocapture
use ark_ff::PrimeField;
use ark_r1cs_std::alloc::AllocVar;
use ark_r1cs_std::fields::fp::FpVar;
Expand Down
3 changes: 3 additions & 0 deletions examples/noir_full_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#![allow(non_camel_case_types)]
#![allow(clippy::upper_case_acronyms)]
///
/// To run:
/// > cargo run --release --example noir_full_flow -- --nocapture
///
/// This example performs the full flow:
/// - define the circuit to be folded
/// - fold the circuit with Nova+CycleFold's IVC
Expand Down
3 changes: 3 additions & 0 deletions examples/noname_full_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#![allow(non_camel_case_types)]
#![allow(clippy::upper_case_acronyms)]
///
/// To run:
/// > cargo run --release --example noname_full_flow -- --nocapture
///
/// This example performs the full flow:
/// - define the circuit to be folded
/// - fold the circuit with Nova+CycleFold's IVC
Expand Down
3 changes: 3 additions & 0 deletions examples/sha256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#![allow(non_camel_case_types)]
#![allow(clippy::upper_case_acronyms)]

///
/// To run:
/// > cargo run --release --example sha256 -- --nocapture
use ark_crypto_primitives::crh::{
sha256::{
constraints::{Sha256Gadget, UnitVar},
Expand Down
19 changes: 14 additions & 5 deletions folding-schemes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ ark-relations = { version = "^0.4.0", default-features = false }
ark-r1cs-std = { version = "0.4.0", default-features = false } # this is patched at the workspace level
ark-snark = { version = "^0.4.0"}
ark-serialize = "^0.4.0"
ark-circom = { git = "https://github.com/arnaucube/circom-compat" }
thiserror = "1.0"
rayon = "1.7.0"
num-bigint = "0.4"
Expand All @@ -24,17 +23,20 @@ color-eyre = "=0.6.2"
ark-bn254 = {version="0.4.0"}
ark-groth16 = { version = "^0.4.0" }
sha3 = "0.10"
ark-noname = { git = "https://github.com/dmpierre/ark-noname", branch="feat/sonobe-integration" }
noname = { git = "https://github.com/dmpierre/noname" }
serde_json = "1.0.85" # to (de)serialize JSON
serde = "1.0.203"
acvm = { git = "https://github.com/noir-lang/noir", rev="2b4853e", default-features = false }
arkworks_backend = { git = "https://github.com/dmpierre/arkworks_backend", branch="feat/sonobe-integration" }
log = "0.4"

# tmp import for espresso's sumcheck
espresso_subroutines = {git="https://github.com/EspressoSystems/hyperplonk", package="subroutines"}

# frontend dependencies:
ark-circom = { git = "https://github.com/arnaucube/circom-compat", optional=true }
noir_arkworks_backend = { package="arkworks_backend", git = "https://github.com/dmpierre/arkworks_backend", branch="feat/sonobe-integration", optional=true }
acvm = { git = "https://github.com/noir-lang/noir", rev="2b4853e", default-features = false, optional=true }
noname = { git = "https://github.com/dmpierre/noname", optional=true }
ark-noname = { git = "https://github.com/dmpierre/ark-noname", branch="feat/sonobe-integration", optional=true }

[dev-dependencies]
ark-pallas = {version="0.4.0", features=["r1cs"]}
ark-vesta = {version="0.4.0", features=["r1cs"]}
Expand All @@ -46,7 +48,14 @@ tracing-subscriber = { version = "0.2" }

[features]
default = ["parallel"]
# 'light-test' is a feature disabled by default, that when enabled will affect
# the DeciderEthCircuit implementations, skipping the heavy-weight parts of the
# circuit, allowing to run light tests of it taking less time.
light-test = []
# frontend features:
circom = ["dep:ark-circom"]
noname = ["dep:noname", "dep:ark-noname"]
noir = ["dep:acvm", "dep:noir_arkworks_backend"]

parallel = [
"ark-std/parallel",
Expand Down
5 changes: 5 additions & 0 deletions folding-schemes/src/frontend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ use ark_r1cs_std::fields::fp::FpVar;
use ark_relations::r1cs::{ConstraintSystemRef, SynthesisError};
use ark_std::fmt::Debug;

// we use features to activate specific frontends, to reduce the amount of dependencies and compile
// time
#[cfg(feature = "circom")]
pub mod circom;
#[cfg(feature = "noir")]
pub mod noir;
#[cfg(feature = "noname")]
pub mod noname;

/// FCircuit defines the trait of the circuit of the F function, which is the one being folded (ie.
Expand Down
2 changes: 1 addition & 1 deletion folding-schemes/src/frontend/noir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use ark_ff::PrimeField;
use ark_r1cs_std::{alloc::AllocVar, fields::fp::FpVar, R1CSVar};
use ark_relations::r1cs::ConstraintSynthesizer;
use ark_relations::r1cs::{ConstraintSystemRef, SynthesisError};
use arkworks_backend::{read_program_from_file, sonobe_bridge::AcirCircuitSonobe};
use noir_arkworks_backend::{read_program_from_file, sonobe_bridge::AcirCircuitSonobe};

#[derive(Clone, Debug)]
pub struct NoirFCircuit<F: PrimeField> {
Expand Down
4 changes: 2 additions & 2 deletions solidity-verifiers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ tracing-subscriber = { version = "0.2" }
ark-bn254 = {version="0.4.0", features=["r1cs"]}
ark-grumpkin = {version="0.4.0", features=["r1cs"]}
rand = "0.8.5"
folding-schemes = { path = "../folding-schemes/", features=["light-test"]}
# use the diverse frontend features for the examples
folding-schemes = { path = "../folding-schemes/", features=["light-test", "circom", "noname", "noir"]}
noname = { git = "https://github.com/dmpierre/noname" }

[features]
Expand Down Expand Up @@ -56,4 +57,3 @@ path = "../examples/noname_full_flow.rs"
[[example]]
name = "noir_full_flow"
path = "../examples/noir_full_flow.rs"

0 comments on commit c5bab2b

Please sign in to comment.