sonobe-docs/src/usage/frontend-circom.md
src/usage/frontend-circom.mdRaw
1# Circom frontend
2We can define the circuit to be folded in Circom. The only interface that we need to fit in is:
3
4```c
5template FCircuit() {
6 signal input ivc_input[1];
7 signal output ivc_output[1];
8 // [...]
9}
10component main {public [ivc_input]} = Example();
11```
12
13The `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.
14
15So for example, the following circuit does the traditional example at each step, which proves knowledge of $x$ such that $y==x^3 + x + 5$ for a known $y$:
16
17```c
18pragma circom 2.0.3;
19
20template Example () {
21 signal input ivc_input[1];
22 signal output ivc_output[1];
23 signal temp;
24
25 temp <== ivc_input[0] * ivc_input[0];
26 ivc_output[0] <== temp * ivc_input[0] + ivc_input[0] + 5;
27}
28
29component main {public [ivc_input]} = Example();
30```