sonobe-docs/src/usage/fold.md
src/usage/fold.mdRaw
1# Fold
2
3We plug our `FCircuit` into the library:
4
5```rust
6// The idea here is that eventually we could replace the next line chunk that defines the
7// `type NOVA = Nova<...>` by using another folding scheme that fulfills the `FoldingScheme`
8// trait, and the rest of our code would be working without needing to be updated.
9type NOVA = Nova<
10 Projective,
11 GVar,
12 Projective2,
13 GVar2,
14 Sha256FCircuit<Fr>,
15 KZG<'static, Bn254>,
16 Pedersen<Projective2>,
17>;
18
19let num_steps = 10;
20let initial_state = vec![Fr::from(1_u32)];
21
22let F_circuit = Sha256FCircuit::<Fr>::new(());
23
24println!("Prepare Nova ProverParams & VerifierParams");
25let (prover_params, verifier_params) = nova_setup::<Sha256FCircuit<Fr>>(F_circuit);
26
27println!("Initialize FoldingScheme");
28let mut folding_scheme = NOVA::init(&prover_params, F_circuit, initial_state.clone()).unwrap();
29
30// compute a step of the IVC
31for i in 0..num_steps {
32 let start = Instant::now();
33 folding_scheme.prove_step().unwrap();
34 println!("Nova::prove_step {}: {:?}", i, start.elapsed());
35}
36
37let (running_instance, incoming_instance, cyclefold_instance) = folding_scheme.instances();
38
39println!("Run the Nova's IVC verifier");
40NOVA::verify(
41 verifier_params,
42 initial_state,
43 folding_scheme.state(), // latest state
44 Fr::from(num_steps as u32),
45 running_instance,
46 incoming_instance,
47 cyclefold_instance,
48)
49.unwrap();
50```