From 792051de9c5726b8112f764bd2a0f6b04262c4f5 Mon Sep 17 00:00:00 2001 From: arnaucube Date: Mon, 18 Nov 2024 12:53:28 +0100 Subject: [PATCH 1/2] rename frontends to experimental-frontends to make it explicit, as discussed in the last meeting --- Cargo.toml | 2 +- README.md | 9 +++------ examples/circom_full_flow.rs | 7 ++++--- examples/noir_full_flow.rs | 5 +++-- examples/noname_full_flow.rs | 2 +- {frontends => experimental-frontends}/Cargo.toml | 2 +- {frontends => experimental-frontends}/README.md | 3 +-- {frontends => experimental-frontends}/src/circom/mod.rs | 0 .../src/circom/test_folder/circuits/is_zero.circom | 0 .../src/circom/test_folder/compile.sh | 0 .../src/circom/test_folder/cubic_circuit.circom | 0 .../src/circom/test_folder/no_external_inputs.circom | 0 .../src/circom/test_folder/with_external_inputs.circom | 0 .../src/circom/utils.rs | 0 {frontends => experimental-frontends}/src/lib.rs | 0 {frontends => experimental-frontends}/src/noir/bridge.rs | 0 {frontends => experimental-frontends}/src/noir/mod.rs | 0 .../src/noir/test_folder/compile.sh | 0 .../src/noir/test_folder/test_circuit/Nargo.toml | 0 .../src/noir/test_folder/test_circuit/src/main.nr | 0 .../src/noir/test_folder/test_mimc/Nargo.toml | 0 .../src/noir/test_folder/test_mimc/src/main.nr | 0 .../noir/test_folder/test_no_external_inputs/Nargo.toml | 0 .../noir/test_folder/test_no_external_inputs/src/main.nr | 0 .../src/noname/bridge.rs | 0 {frontends => experimental-frontends}/src/noname/mod.rs | 0 .../src/noname/utils.rs | 0 solidity-verifiers/Cargo.toml | 2 +- 28 files changed, 15 insertions(+), 17 deletions(-) rename {frontends => experimental-frontends}/Cargo.toml (97%) rename {frontends => experimental-frontends}/README.md (97%) rename {frontends => experimental-frontends}/src/circom/mod.rs (100%) rename {frontends => experimental-frontends}/src/circom/test_folder/circuits/is_zero.circom (100%) rename {frontends => experimental-frontends}/src/circom/test_folder/compile.sh (100%) rename {frontends => experimental-frontends}/src/circom/test_folder/cubic_circuit.circom (100%) rename {frontends => experimental-frontends}/src/circom/test_folder/no_external_inputs.circom (100%) rename {frontends => experimental-frontends}/src/circom/test_folder/with_external_inputs.circom (100%) rename {frontends => experimental-frontends}/src/circom/utils.rs (100%) rename {frontends => experimental-frontends}/src/lib.rs (100%) rename {frontends => experimental-frontends}/src/noir/bridge.rs (100%) rename {frontends => experimental-frontends}/src/noir/mod.rs (100%) rename {frontends => experimental-frontends}/src/noir/test_folder/compile.sh (100%) rename {frontends => experimental-frontends}/src/noir/test_folder/test_circuit/Nargo.toml (100%) rename {frontends => experimental-frontends}/src/noir/test_folder/test_circuit/src/main.nr (100%) rename {frontends => experimental-frontends}/src/noir/test_folder/test_mimc/Nargo.toml (100%) rename {frontends => experimental-frontends}/src/noir/test_folder/test_mimc/src/main.nr (100%) rename {frontends => experimental-frontends}/src/noir/test_folder/test_no_external_inputs/Nargo.toml (100%) rename {frontends => experimental-frontends}/src/noir/test_folder/test_no_external_inputs/src/main.nr (100%) rename {frontends => experimental-frontends}/src/noname/bridge.rs (100%) rename {frontends => experimental-frontends}/src/noname/mod.rs (100%) rename {frontends => experimental-frontends}/src/noname/utils.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 46e1281f..67aafb5f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,6 @@ members = [ "folding-schemes", "solidity-verifiers", "cli", - "frontends" + "experimental-frontends" ] resolver = "2" diff --git a/README.md b/README.md index 3da10531..1898025a 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,6 @@ Folding schemes implemented: - [Nova: Recursive Zero-Knowledge Arguments from Folding Schemes](https://eprint.iacr.org/2021/370.pdf), Abhiram Kothapalli, Srinath Setty, Ioanna Tzialla. 2021 - [CycleFold: Folding-scheme-based recursive arguments over a cycle of elliptic curves](https://eprint.iacr.org/2023/1192.pdf), Abhiram Kothapalli, Srinath Setty. 2023 - [HyperNova: Recursive arguments for customizable constraint systems](https://eprint.iacr.org/2023/573.pdf), Abhiram Kothapalli, Srinath Setty. 2023 - -Work in progress: - - [ProtoGalaxy: Efficient ProtoStar-style folding of multiple instances](https://eprint.iacr.org/2023/1106.pdf), Liam Eagen, Ariel Gabizon. 2023 @@ -34,7 +31,7 @@ Work in progress: Frontends allow to define the circuit to be folded (ie. `FCircuit`). The recommended frontend is directly implementing the [`FCircuit` trait](https://github.com/privacy-scaling-explorations/sonobe/blob/main/folding-schemes/src/frontend/mod.rs#L16) with the Arkworks constraint system. -Alternatively, experimental frontends for [Circom](https://github.com/iden3/circom), [Noir](https://github.com/noir-lang/noir) and [Noname](https://github.com/zksecurity/noname) can be found at the [sonobe/frontends](https://github.com/privacy-scaling-explorations/sonobe/tree/main/frontends) directory, which have some computational (and time) overhead. +Alternatively, experimental frontends for [Circom](https://github.com/iden3/circom), [Noir](https://github.com/noir-lang/noir) and [Noname](https://github.com/zksecurity/noname) can be found at the [sonobe/experimental-frontends](https://github.com/privacy-scaling-explorations/sonobe/tree/main/experimental-frontends) directory, which have some computational (and time) overhead. More details about the frontend interface and the experimental frontends can be found at the [sonobe-docs/frontend](https://privacy-scaling-explorations.github.io/sonobe-docs/usage/frontend.html) page. @@ -49,7 +46,7 @@ folding-schemes = { git = "https://github.com/privacy-scaling-explorations/sonob Available packages: - `folding-schemes`: main crate, contains the different scheme implementations, together with commitment schemes, frontend trait, arithmetization, transcript, etc. - `solidity-verifiers`: contains the templating logic to output the verifier contracts for the DeciderEth proofs. Currently only supports Nova+CycleFold DeciderEth proofs. -- `frontends`: contains the experimental frontends other than the arkworks frontend. More details at the [sonobe/frontends](https://github.com/privacy-scaling-explorations/sonobe/tree/main/frontends) directory. +- `experimental-frontends`: contains the experimental frontends other than the arkworks frontend. More details at the [sonobe/experimental-frontends](https://github.com/privacy-scaling-explorations/sonobe/tree/main/experimental-frontends) directory. Available features: - `parallel` enables some parallelization optimizations available in the crate. It is enabled by default. @@ -105,7 +102,7 @@ Sonobe is [MIT Licensed](https://github.com/privacy-scaling-explorations/sonobe/ ## Acknowledgments -This project builds on top of multiple [arkworks](https://github.com/arkworks-rs) libraries. It uses Espresso system's [virtual polynomial](https://github.com/EspressoSystems/hyperplonk/blob/main/arithmetic/src/virtual_polynomial.rs) abstraction and its [SumCheck](https://github.com/EspressoSystems/hyperplonk/tree/main/subroutines/src/poly_iop/sum_check) implementation. +This project builds on top of multiple [arkworks](https://github.com/arkworks-rs) libraries. It uses Espresso System's [virtual polynomial](https://github.com/EspressoSystems/hyperplonk/blob/main/arithmetic/src/virtual_polynomial.rs) abstraction and its [SumCheck](https://github.com/EspressoSystems/hyperplonk/tree/main/subroutines/src/poly_iop/sum_check) implementation. The Solidity templates used in `nova_cyclefold_verifier.sol`, use [iden3](https://github.com/iden3/snarkjs/blob/master/templates/verifier_groth16.sol.ejs)'s Groth16 implementation and a KZG10 Solidity template adapted from [weijiekoh/libkzg](https://github.com/weijiekoh/libkzg). diff --git a/examples/circom_full_flow.rs b/examples/circom_full_flow.rs index d9fdb0f8..96928ee0 100644 --- a/examples/circom_full_flow.rs +++ b/examples/circom_full_flow.rs @@ -17,6 +17,7 @@ use ark_grumpkin::{constraints::GVar as GVar2, Projective as G2}; use std::path::PathBuf; use std::time::Instant; +use experimental_frontends::circom::CircomFCircuit; use folding_schemes::{ commitment::{kzg::KZG, pedersen::Pedersen}, folding::{ @@ -30,7 +31,6 @@ use folding_schemes::{ transcript::poseidon::poseidon_canonical_config, Decider, FoldingScheme, }; -use frontends::circom::CircomFCircuit; use solidity_verifiers::{ evm::{compile_solidity, Evm}, utils::get_function_selector_for_nova_cyclefold_verifier, @@ -58,9 +58,10 @@ fn main() { ]; // initialize the Circom circuit - let r1cs_path = PathBuf::from("./frontends/src/circom/test_folder/with_external_inputs.r1cs"); + let r1cs_path = + PathBuf::from("./experimental-frontends/src/circom/test_folder/with_external_inputs.r1cs"); let wasm_path = PathBuf::from( - "./frontends/src/circom/test_folder/with_external_inputs_js/with_external_inputs.wasm", + "./experimental-frontends/src/circom/test_folder/with_external_inputs_js/with_external_inputs.wasm", ); let f_circuit_params = (r1cs_path.into(), wasm_path.into(), 1, 2); diff --git a/examples/noir_full_flow.rs b/examples/noir_full_flow.rs index 871dd74d..fcf8bd9a 100644 --- a/examples/noir_full_flow.rs +++ b/examples/noir_full_flow.rs @@ -14,6 +14,7 @@ use ark_bn254::{constraints::GVar, Bn254, Fr, G1Projective as G1}; use ark_groth16::Groth16; use ark_grumpkin::{constraints::GVar as GVar2, Projective as G2}; +use experimental_frontends::noir::NoirFCircuit; use folding_schemes::{ commitment::{kzg::KZG, pedersen::Pedersen}, folding::{ @@ -27,7 +28,6 @@ use folding_schemes::{ transcript::poseidon::poseidon_canonical_config, Decider, FoldingScheme, }; -use frontends::noir::NoirFCircuit; use std::{path::Path, time::Instant}; use solidity_verifiers::{ @@ -43,7 +43,8 @@ fn main() { // initialize the noir fcircuit let f_circuit = NoirFCircuit::new(( - Path::new("./frontends/src/noir/test_folder/test_mimc/target/test_mimc.json").into(), + Path::new("./experimental-frontends/src/noir/test_folder/test_mimc/target/test_mimc.json") + .into(), 1, 0, )) diff --git a/examples/noname_full_flow.rs b/examples/noname_full_flow.rs index 0bb6e41a..5c2c54b4 100644 --- a/examples/noname_full_flow.rs +++ b/examples/noname_full_flow.rs @@ -15,6 +15,7 @@ use noname::backends::r1cs::R1csBn254Field; use ark_groth16::Groth16; use ark_grumpkin::{constraints::GVar as GVar2, Projective as G2}; +use experimental_frontends::noname::NonameFCircuit; use folding_schemes::{ commitment::{kzg::KZG, pedersen::Pedersen}, folding::{ @@ -28,7 +29,6 @@ use folding_schemes::{ transcript::poseidon::poseidon_canonical_config, Decider, FoldingScheme, }; -use frontends::noname::NonameFCircuit; use std::time::Instant; use solidity_verifiers::{ diff --git a/frontends/Cargo.toml b/experimental-frontends/Cargo.toml similarity index 97% rename from frontends/Cargo.toml rename to experimental-frontends/Cargo.toml index faac937e..eadf7a3f 100644 --- a/frontends/Cargo.toml +++ b/experimental-frontends/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "frontends" +name = "experimental-frontends" version = "0.1.0" edition = "2021" diff --git a/frontends/README.md b/experimental-frontends/README.md similarity index 97% rename from frontends/README.md rename to experimental-frontends/README.md index e43cfa18..dedc9e77 100644 --- a/frontends/README.md +++ b/experimental-frontends/README.md @@ -1,9 +1,8 @@ -# frontends +# experimental-frontends This crate contains *experimental frontends* for Sonobe. The recommended frontend is to directly use [arkworks](https://github.com/arkworks-rs) to define the FCircuit, just following the [`FCircuit` trait](https://github.com/privacy-scaling-explorations/sonobe/blob/main/folding-schemes/src/frontend/mod.rs). -## Experimental frontends > Warning: the following frontends are experimental and some computational and time overhead is expected when using them compared to directly using the [arkworks frontend](https://github.com/privacy-scaling-explorations/sonobe/blob/main/folding-schemes/src/frontend/mod.rs). Available experimental frontends: diff --git a/frontends/src/circom/mod.rs b/experimental-frontends/src/circom/mod.rs similarity index 100% rename from frontends/src/circom/mod.rs rename to experimental-frontends/src/circom/mod.rs diff --git a/frontends/src/circom/test_folder/circuits/is_zero.circom b/experimental-frontends/src/circom/test_folder/circuits/is_zero.circom similarity index 100% rename from frontends/src/circom/test_folder/circuits/is_zero.circom rename to experimental-frontends/src/circom/test_folder/circuits/is_zero.circom diff --git a/frontends/src/circom/test_folder/compile.sh b/experimental-frontends/src/circom/test_folder/compile.sh similarity index 100% rename from frontends/src/circom/test_folder/compile.sh rename to experimental-frontends/src/circom/test_folder/compile.sh diff --git a/frontends/src/circom/test_folder/cubic_circuit.circom b/experimental-frontends/src/circom/test_folder/cubic_circuit.circom similarity index 100% rename from frontends/src/circom/test_folder/cubic_circuit.circom rename to experimental-frontends/src/circom/test_folder/cubic_circuit.circom diff --git a/frontends/src/circom/test_folder/no_external_inputs.circom b/experimental-frontends/src/circom/test_folder/no_external_inputs.circom similarity index 100% rename from frontends/src/circom/test_folder/no_external_inputs.circom rename to experimental-frontends/src/circom/test_folder/no_external_inputs.circom diff --git a/frontends/src/circom/test_folder/with_external_inputs.circom b/experimental-frontends/src/circom/test_folder/with_external_inputs.circom similarity index 100% rename from frontends/src/circom/test_folder/with_external_inputs.circom rename to experimental-frontends/src/circom/test_folder/with_external_inputs.circom diff --git a/frontends/src/circom/utils.rs b/experimental-frontends/src/circom/utils.rs similarity index 100% rename from frontends/src/circom/utils.rs rename to experimental-frontends/src/circom/utils.rs diff --git a/frontends/src/lib.rs b/experimental-frontends/src/lib.rs similarity index 100% rename from frontends/src/lib.rs rename to experimental-frontends/src/lib.rs diff --git a/frontends/src/noir/bridge.rs b/experimental-frontends/src/noir/bridge.rs similarity index 100% rename from frontends/src/noir/bridge.rs rename to experimental-frontends/src/noir/bridge.rs diff --git a/frontends/src/noir/mod.rs b/experimental-frontends/src/noir/mod.rs similarity index 100% rename from frontends/src/noir/mod.rs rename to experimental-frontends/src/noir/mod.rs diff --git a/frontends/src/noir/test_folder/compile.sh b/experimental-frontends/src/noir/test_folder/compile.sh similarity index 100% rename from frontends/src/noir/test_folder/compile.sh rename to experimental-frontends/src/noir/test_folder/compile.sh diff --git a/frontends/src/noir/test_folder/test_circuit/Nargo.toml b/experimental-frontends/src/noir/test_folder/test_circuit/Nargo.toml similarity index 100% rename from frontends/src/noir/test_folder/test_circuit/Nargo.toml rename to experimental-frontends/src/noir/test_folder/test_circuit/Nargo.toml diff --git a/frontends/src/noir/test_folder/test_circuit/src/main.nr b/experimental-frontends/src/noir/test_folder/test_circuit/src/main.nr similarity index 100% rename from frontends/src/noir/test_folder/test_circuit/src/main.nr rename to experimental-frontends/src/noir/test_folder/test_circuit/src/main.nr diff --git a/frontends/src/noir/test_folder/test_mimc/Nargo.toml b/experimental-frontends/src/noir/test_folder/test_mimc/Nargo.toml similarity index 100% rename from frontends/src/noir/test_folder/test_mimc/Nargo.toml rename to experimental-frontends/src/noir/test_folder/test_mimc/Nargo.toml diff --git a/frontends/src/noir/test_folder/test_mimc/src/main.nr b/experimental-frontends/src/noir/test_folder/test_mimc/src/main.nr similarity index 100% rename from frontends/src/noir/test_folder/test_mimc/src/main.nr rename to experimental-frontends/src/noir/test_folder/test_mimc/src/main.nr diff --git a/frontends/src/noir/test_folder/test_no_external_inputs/Nargo.toml b/experimental-frontends/src/noir/test_folder/test_no_external_inputs/Nargo.toml similarity index 100% rename from frontends/src/noir/test_folder/test_no_external_inputs/Nargo.toml rename to experimental-frontends/src/noir/test_folder/test_no_external_inputs/Nargo.toml diff --git a/frontends/src/noir/test_folder/test_no_external_inputs/src/main.nr b/experimental-frontends/src/noir/test_folder/test_no_external_inputs/src/main.nr similarity index 100% rename from frontends/src/noir/test_folder/test_no_external_inputs/src/main.nr rename to experimental-frontends/src/noir/test_folder/test_no_external_inputs/src/main.nr diff --git a/frontends/src/noname/bridge.rs b/experimental-frontends/src/noname/bridge.rs similarity index 100% rename from frontends/src/noname/bridge.rs rename to experimental-frontends/src/noname/bridge.rs diff --git a/frontends/src/noname/mod.rs b/experimental-frontends/src/noname/mod.rs similarity index 100% rename from frontends/src/noname/mod.rs rename to experimental-frontends/src/noname/mod.rs diff --git a/frontends/src/noname/utils.rs b/experimental-frontends/src/noname/utils.rs similarity index 100% rename from frontends/src/noname/utils.rs rename to experimental-frontends/src/noname/utils.rs diff --git a/solidity-verifiers/Cargo.toml b/solidity-verifiers/Cargo.toml index 2fff3162..2228d5cd 100644 --- a/solidity-verifiers/Cargo.toml +++ b/solidity-verifiers/Cargo.toml @@ -24,7 +24,7 @@ ark-relations = { version = "^0.5.0", default-features = false } ark-r1cs-std = { version = "^0.5.0", default-features = false, features = ["parallel"] } ark-grumpkin = { version = "^0.5.0", default-features = false } folding-schemes = { path = "../folding-schemes/", features=["light-test"]} -frontends = { path = "../frontends/"} +experimental-frontends = { path = "../experimental-frontends/"} noname = { git = "https://github.com/dmpierre/noname" } [features] From 2a5e812677b67761e3735d0e8dddc48aca890269 Mon Sep 17 00:00:00 2001 From: arnaucube Date: Fri, 22 Nov 2024 08:23:32 +0100 Subject: [PATCH 2/2] rename upper_bound_ccs to compute_concrete_ccs to describe better the method logic --- folding-schemes/src/folding/hypernova/circuits.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/folding-schemes/src/folding/hypernova/circuits.rs b/folding-schemes/src/folding/hypernova/circuits.rs index 63ea62bc..734f42d7 100644 --- a/folding-schemes/src/folding/hypernova/circuits.rs +++ b/folding-schemes/src/folding/hypernova/circuits.rs @@ -567,7 +567,7 @@ where ccs: Option>, ) -> Result { let initial_ccs = CCS { - // m, n, s, s_prime and M will be overwritten by the `upper_bound_ccs' method + // m, n, s, s_prime and M will be overwritten by the `compute_concrete_ccs' method m: 0, n: 0, l: 2, // io_len @@ -583,7 +583,7 @@ where let mut augmented_f_circuit = Self::default(poseidon_config, F, initial_ccs)?; augmented_f_circuit.ccs = ccs .ok_or(()) - .or_else(|_| augmented_f_circuit.upper_bound_ccs())?; + .or_else(|_| augmented_f_circuit.compute_concrete_ccs())?; Ok(augmented_f_circuit) } @@ -591,7 +591,7 @@ where /// dependency between the AugmentedFCircuit CCS and the CCS parameters m & n & s & s'. /// For a stable FCircuit circuit, the CCS parameters can be computed in advance and can be /// feed in as parameter for the AugmentedFCircuit::empty method to avoid computing them there. - pub fn upper_bound_ccs(&self) -> Result, Error> { + pub fn compute_concrete_ccs(&self) -> Result, Error> { let r1cs = get_r1cs_from_cs::>(self.clone())?; let mut ccs = CCS::from(r1cs); @@ -668,8 +668,6 @@ where U_i = LCCCS::::dummy(&ccs); } Ok(ccs) - - // Ok(augmented_f_circuit.compute_cs_ccs()?.1) } /// Returns the cs (ConstraintSystem) and the CCS out of the AugmentedFCircuit