mirror of
https://github.com/arnaucube/sonobe.git
synced 2026-01-14 09:51:29 +01:00
Implement HyperNova's IVC into the FoldingScheme trait (#116)
- implement the IVC `FoldingScheme` trait for HyperNova
- refactor Nova's preprocess logic to make it simplier to use
- add to Decider trait (& Nova's DeciderEth) a preprocess method
- get rid of the `init_nova_ivc_params` and `init_ivc_and_decider_params` methods in `examples` since this is achieved with the `FS::preprocess` & `Decider::preprocess` methods
- (update the examples code to the simplified interface using
FS::preprocess & Decider::preprocess)
This commit is contained in:
@@ -20,11 +20,10 @@ use ark_bn254::{constraints::GVar, Bn254, Fr, G1Projective as Projective};
|
||||
use ark_grumpkin::{constraints::GVar as GVar2, Projective as Projective2};
|
||||
|
||||
use folding_schemes::commitment::{kzg::KZG, pedersen::Pedersen};
|
||||
use folding_schemes::folding::nova::Nova;
|
||||
use folding_schemes::folding::nova::{Nova, PreprocessorParam};
|
||||
use folding_schemes::frontend::FCircuit;
|
||||
use folding_schemes::transcript::poseidon::poseidon_canonical_config;
|
||||
use folding_schemes::{Error, FoldingScheme};
|
||||
mod utils;
|
||||
use utils::init_nova_ivc_params;
|
||||
|
||||
/// This is the circuit that we want to fold, it implements the FCircuit trait.
|
||||
/// The parameter z_i denotes the current state, and z_{i+1} denotes the next state which we get by
|
||||
@@ -109,13 +108,10 @@ fn main() {
|
||||
|
||||
let F_circuit = Sha256FCircuit::<Fr>::new(()).unwrap();
|
||||
|
||||
println!("Prepare Nova ProverParams & VerifierParams");
|
||||
let (prover_params, verifier_params, _) = init_nova_ivc_params::<Sha256FCircuit<Fr>>(F_circuit);
|
||||
|
||||
/// The idea here is that eventually we could replace the next line chunk that defines the
|
||||
/// `type NOVA = Nova<...>` by using another folding scheme that fulfills the `FoldingScheme`
|
||||
/// `type N = Nova<...>` by using another folding scheme that fulfills the `FoldingScheme`
|
||||
/// trait, and the rest of our code would be working without needing to be updated.
|
||||
type NOVA = Nova<
|
||||
type N = Nova<
|
||||
Projective,
|
||||
GVar,
|
||||
Projective2,
|
||||
@@ -125,21 +121,27 @@ fn main() {
|
||||
Pedersen<Projective2>,
|
||||
>;
|
||||
|
||||
println!("Initialize FoldingScheme");
|
||||
let mut folding_scheme = NOVA::init(&prover_params, F_circuit, initial_state.clone()).unwrap();
|
||||
let poseidon_config = poseidon_canonical_config::<Fr>();
|
||||
let mut rng = rand::rngs::OsRng;
|
||||
|
||||
println!("Prepare Nova ProverParams & VerifierParams");
|
||||
let nova_preprocess_params = PreprocessorParam::new(poseidon_config, F_circuit);
|
||||
let (nova_pp, nova_vp) = N::preprocess(&mut rng, &nova_preprocess_params).unwrap();
|
||||
|
||||
println!("Initialize FoldingScheme");
|
||||
let mut folding_scheme = N::init(&nova_pp, F_circuit, initial_state.clone()).unwrap();
|
||||
// compute a step of the IVC
|
||||
for i in 0..num_steps {
|
||||
let start = Instant::now();
|
||||
folding_scheme.prove_step(vec![]).unwrap();
|
||||
folding_scheme.prove_step(rng, vec![]).unwrap();
|
||||
println!("Nova::prove_step {}: {:?}", i, start.elapsed());
|
||||
}
|
||||
|
||||
let (running_instance, incoming_instance, cyclefold_instance) = folding_scheme.instances();
|
||||
|
||||
println!("Run the Nova's IVC verifier");
|
||||
NOVA::verify(
|
||||
verifier_params,
|
||||
N::verify(
|
||||
nova_vp,
|
||||
initial_state,
|
||||
folding_scheme.state(), // latest state
|
||||
Fr::from(num_steps as u32),
|
||||
|
||||
Reference in New Issue
Block a user