Skip to content

Commit

Permalink
update: Remove wasm feature
Browse files Browse the repository at this point in the history
As @arnaucube correctly suggested to me, the `wasm` feature can be omitted as the `wasmer` loader does not require it.

Therefore, feature set, CI and code has been updated accordingly.
Also, the browser feature has been renamed to `circom-browser`.
  • Loading branch information
CPerezz committed Oct 18, 2024
1 parent 0cf1aae commit 7ec21d6
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/wasm-target-test-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cp "${GIT_ROOT}/rust-toolchain" .
rustup target add wasm32-unknown-unknown wasm32-wasi

# add dependencies
cargo add --path "${GIT_ROOT}/folding-schemes" --features wasm, parallel
cargo add --path "${GIT_ROOT}/folding-schemes" --features circom-browser, parallel
cargo add getrandom --features js --target wasm32-unknown-unknown

# test build for wasm32-* targets
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: build
args: -p folding-schemes --no-default-features --target ${{ matrix.target }} --features "wasm, parallel"
args: -p folding-schemes --no-default-features --target ${{ matrix.target }} --features "parallel"
- name: Run wasm-compat script
run: |
chmod +x .github/scripts/wasm-target-test-build.sh
Expand Down Expand Up @@ -156,13 +156,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
feature_set: [basic, wasm]
feature_set: [basic, circom-browser]
include:
- feature_set: basic
features: --features default,light-test
# We only want to test `folding-schemes` package with `wasm` feature.
- feature_set: wasm
features: -p folding-schemes --features wasm,parallel --target wasm32-unknown-unknown
# We only want to test `folding-schemes` package with `circom-browser` feature.
- feature_set: circom-browser
features: -p folding-schemes --features circom-browser, parallel --target wasm32-unknown-unknown
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
Expand Down
3 changes: 1 addition & 2 deletions folding-schemes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ getrandom = { version = "0.2", features = ["js"] }
[features]
default = ["ark-circom/default", "parallel"]
parallel = []
wasm = ["ark-circom/wasm"]
browser = ["wasm", "byteorder"]
circom-browser = ["ark-circom/wasm", "byteorder"]
light-test = []


Expand Down
2 changes: 1 addition & 1 deletion folding-schemes/src/folding/nova/circuits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ where
// get z_{i+1} from the F circuit
let i_usize = self.i_usize.unwrap_or(0);

// If we are in the browser-frontend case. The witness is already loaded within
// If we are in the circom-browser-frontend case. The witness is already loaded within
// self.F.witness. This was done at `self.prove_step()` fn.
let z_i1 = self
.F
Expand Down
6 changes: 3 additions & 3 deletions folding-schemes/src/folding/nova/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,12 +642,12 @@ where
fn prove_step(
&mut self,
mut rng: impl RngCore,
// This contains the full witness when we're in the browser-frontend case
// This contains the full witness when we're in the circom-browser-frontend case
external_inputs: Vec<C1::ScalarField>,
// Nova does not support multi-instances folding
_other_instances: Option<Self::MultiCommittedInstanceWithWitness>,
) -> Result<(), Error> {
#[cfg(feature = "browser")]
#[cfg(feature = "circom-browser")]
{
// Slice and separate between external inputs and frontend witness.
let (frontend_witness, external_inputs) =
Expand All @@ -664,7 +664,7 @@ where
(None, external_inputs)
};

// If we are in the browser-case (frontend_witness = Some(witness)) then we load the witness into the FCircuit.
// If we are in the circom-browser-case (frontend_witness = Some(witness)) then we load the witness into the FCircuit.
if let Some(witness) = frontend_witness {
self.F.load_witness(witness)
};
Expand Down
6 changes: 3 additions & 3 deletions folding-schemes/src/frontend/circom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ use num_bigint::BigInt;
use std::rc::Rc;
use std::{fmt, usize};

#[cfg(feature = "browser")]
#[cfg(feature = "circom-browser")]
pub mod browser;
pub mod utils;

#[cfg(feature = "browser")]
#[cfg(feature = "circom-browser")]
pub use browser::{load_witness_from_bin_reader, CircomFCircuitBrowser};
use utils::CircomWrapper;

Expand All @@ -38,7 +38,7 @@ impl<F: PrimeField> fmt::Debug for CustomStepNative<F> {
}
}

/// This circuit is the one we will use in order to fold circom circuits
/// This circuit is the one we will use in order to fold Circom circuits
/// from a non-browser environment.
#[derive(Clone, Debug)]
pub struct CircomFCircuit<F: PrimeField> {
Expand Down
4 changes: 2 additions & 2 deletions folding-schemes/src/frontend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ pub trait FCircuit<F: PrimeField>: Clone + Debug {
) -> Result<Vec<FpVar<F>>, SynthesisError>;

/// Allows to load pre-generated witness into the FCircuit implementor.
/// This is only needed by the browser use cases where we have already computed our
/// This is only needed by the circom-browser use cases where we have already computed our
/// witness there. And we need a way to load it into the FCircuit since it's already computed.
///
/// By default this method will simply do nothing. Only in the browser FCircuit implementors this will have usage.
/// By default this method will simply do nothing. Only in the circom-browser FCircuit implementors this will have usage.
fn load_witness(&mut self, _witness: Vec<F>) {}
}

Expand Down

0 comments on commit 7ec21d6

Please sign in to comment.