sonobe-docs/src/usage/frontend-circom.md
src/usage/frontend-circom.mdRaw
1# Circom frontend
2 > **Note**: Circom frontend will be significantly slower than the Arkworks frontend.
3
4Experimental frontend using [arkworks/circom-compat](https://github.com/arkworks-rs/circom-compat).
5
6We can define the circuit to be folded in Circom. The only interface that we need to fit in is:
7
8```c
9template FCircuit() {
10 signal input ivc_input[1]; // IVC state
11 signal input external_inputs[2]; // not state
12
13 signal output ivc_output[1]; // next IVC state
14
15 // [...]
16}
17component main {public [ivc_input]} = Example();
18```
19
20The `ivc_input` is the array that defines the initial state, and the `ivc_output` is the array that defines the output state after the step.
21
22So for example, the following circuit does the traditional example at each step, which proves knowledge of $x$ such that $y==x^3 + x + e_0 + e_1$ for a known $y$ ($e_i$ are the `external_inputs[i]`):
23
24```c
25pragma circom 2.0.3;
26
27template Example () {
28 signal input ivc_input[1]; // IVC state
29 signal input external_inputs[2]; // not state
30
31 signal output ivc_output[1]; // next IVC state
32
33 signal temp1;
34 signal temp2;
35
36 temp1 <== ivc_input[0] * ivc_input[0];
37 temp2 <== ivc_input[0] * external_inputs[0];
38 ivc_output[0] <== temp1 * ivc_input[0] + temp2 + external_inputs[1];
39}
40
41component main {public [ivc_input]} = Example();
42```