Skip to content

Commit

Permalink
feat: Enable load_witness functionallity within FCircuit
Browse files Browse the repository at this point in the history
Since the witness is generated in the browser we need a way to store it
such that it can flow from `prove_step` into `generate_constraints` due
to the API restrictions.
  • Loading branch information
CPerezz committed Oct 15, 2024
1 parent cb1b8e3 commit 39d4ee3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions folding-schemes/src/folding/nova/circuits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,9 @@ 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
// self.F.witness. This was done at `self.prove_step()` fn.
let z_i1 = self
.F
.generate_step_constraints(cs.clone(), i_usize, z_i, external_inputs)?;
Expand Down
7 changes: 7 additions & 0 deletions folding-schemes/src/frontend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ pub trait FCircuit<F: PrimeField>: Clone + Debug {
z_i: Vec<FpVar<F>>,
external_inputs: Vec<FpVar<F>>, // inputs that are not part of the state
) -> 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
/// 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.
fn load_witness(&mut self, _witness: Vec<F>) {}
}

#[cfg(test)]
Expand Down

0 comments on commit 39d4ee3

Please sign in to comment.