arnaucube
arnaucube/sonobe-docsPublic Self-hosted repository
sonobe-docs/src/usage/frontend-circom.md
src/usage/frontend-circom.mdRaw
 1# Circom frontend
 2 > Experimental frontend using [arkworks/circom-compat](https://github.com/arkworks-rs/circom-compat).
 3 
 4We can define the circuit to be folded in Circom. The only interface that we need to fit in is:
 5
 6```c
 7template FCircuit() {
 8    signal input ivc_input[1]; // IVC state
 9    signal input external_inputs[2]; // not state
10
11    signal output ivc_output[1]; // next IVC state
12    
13    // [...]
14}
15component main {public [ivc_input]} = Example();
16```
17
18The `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.
19
20So 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]`):
21
22```c
23pragma circom 2.0.3;
24
25template Example () {
26    signal input ivc_input[1]; // IVC state
27    signal input external_inputs[2]; // not state
28
29    signal output ivc_output[1]; // next IVC state
30
31    signal temp1;
32    signal temp2;
33    
34    temp1 <== ivc_input[0] * ivc_input[0];
35    temp2 <== ivc_input[0] * external_inputs[0];
36    ivc_output[0] <== temp1 * ivc_input[0] + temp2 + external_inputs[1];
37}
38
39component main {public [ivc_input]} = Example();
40```