sonobe-docs/src/usage/frontend.md
src/usage/frontend.mdRaw
1# Frontend
2
3The frontend interface allows to define the circuit to be folded. The available frontends are arkworks are Circom.
4
5We just need to fulfill the [`FCircuit` trait](https://github.com/privacy-scaling-explorations/sonobe/blob/main/sonobe/src/frontend/mod.rs):
6
7```rust
8/// FCircuit defines the trait of the circuit of the F function, which is the one being folded (ie.
9/// inside the agmented F' function).
10/// The parameter z_i denotes the current state, and z_{i+1} denotes the next state after applying
11/// the step.
12pub trait FCircuit<F: PrimeField>: Clone + Debug {
13 type Params: Debug;
14
15 /// returns a new FCircuit instance
16 fn new(params: Self::Params) -> Self;
17
18 /// returns the number of elements in the state of the FCircuit, which corresponds to the
19 /// FCircuit inputs.
20 fn state_len(&self) -> usize;
21
22 /// computes the next state values in place, assigning z_{i+1} into z_i, and computing the new
23 /// z_{i+1}
24 fn step_native(
25 // this method uses self, so that each FCircuit implementation (and different frontends)
26 // can hold a state if needed to store data to compute the next state.
27 &self,
28 i: usize,
29 z_i: Vec<F>,
30 ) -> Result<Vec<F>, Error>;
31
32 /// generates the constraints for the step of F for the given z_i
33 fn generate_step_constraints(
34 // this method uses self, so that each FCircuit implementation (and different frontends)
35 // can hold a state if needed to store data to generate the constraints.
36 &self,
37 cs: ConstraintSystemRef<F>,
38 i: usize,
39 z_i: Vec<FpVar<F>>,
40 ) -> Result<Vec<FpVar<F>>, SynthesisError>;
41}
42```
43