arnaucube
arnaucube/sonobe-docsPublic Self-hosted repository
sonobe-docs/src/usage/decider.md
src/usage/decider.mdRaw
 1# Decider
 2
 3## Decider prove
 4
 5Two options:
 6
 7- onchain (Ethereum's EVM) mode
 8- offchain mode
 9
10Once we have been folding our circuit instances, we can generate the *"final proof"*, the Decider proof.
11
12
13#### Onchain Decider
14
15![](../imgs/decider-onchain-flow-diagram.png)
16
17Generating the final proof (decider), to be able to verify it in Ethereum's EVM:
18
19```rust
20type DECIDER = Decider<
21    Projective,
22    Projective2,
23    CubicFCircuit<Fr>,
24    KZG<'static, Bn254>,
25    Pedersen<Projective2>,
26    Groth16<Bn254>, // here we define the Snark to use in the decider
27    NOVA,              // here we define the FoldingScheme to use
28>;
29
30let mut rng = rand::rngs::OsRng;
31
32// prepare the Decider prover & verifier params for the given nova_params and nova instance. This involves generating the Groth16 and KZG10 setup
33let (decider_pp, decider_vp) = DECIDER::preprocess(&mut rng, &nova_params, nova.clone()).unwrap();
34
35// decider proof generation
36let proof = DECIDER::prove(rng, decider_pp, nova.clone()).unwrap();
37
38```
39
40As in the previous sections, you can find a full examples with all the code at [sonobe/examples](https://github.com/privacy-scaling-explorations/sonobe/tree/main/examples).
41
42## Decider verify
43We can now verify the Decider proof
44
45```rust
46// this is the same that we defined for the prover
47type DECIDER = Decider<
48    Projective,
49    Projective2,
50    CubicFCircuit<Fr>,
51    KZG<'static, Bn254>,
52    Pedersen<Projective2>,
53    Groth16<Bn254>,
54    NOVA,
55>;
56
57let verified = DECIDER::verify(
58    decider_vp, nova.i, nova.z_0, nova.z_i, &nova.U_i, &nova.u_i, proof,
59)
60.unwrap();
61assert!(verified);
62```
63
64In the Ethereum Decider case, we can generate a Solidity smart contract that verifies the proofs onchain. More details in the [next section](solidity-verifier.md).