Skip to content

Commit

Permalink
fix verifier circuits keys loading
Browse files Browse the repository at this point in the history
  • Loading branch information
nulltea committed Jan 5, 2024
1 parent 9bdd7b4 commit fa5692d
Showing 1 changed file with 42 additions and 17 deletions.
59 changes: 42 additions & 17 deletions prover/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use lightclient_circuits::halo2_proofs::{
};
use lightclient_circuits::sync_step_circuit::StepCircuit;
use lightclient_circuits::util::AppCircuit;
use snark_verifier_sdk::halo2::aggregation::AggregationCircuit;
use std::collections::BTreeMap;
use std::path::{Path, PathBuf};

Expand Down Expand Up @@ -44,14 +45,12 @@ impl ProverState {
config_path: PathBuf,
pk_path: PathBuf,
params_map: &mut BTreeMap<u32, ParamsKZG<Bn256>>,
) -> CircuitContext
where
Circuit::Witness: Default,
{
default_witness: Circuit::Witness,
) -> CircuitContext {
let degree = Circuit::get_degree(&config_path);
let params = gen_srs(degree);

let pk = Circuit::read_pk(&params, pk_path, &config_path, &Circuit::Witness::default());
let pk = Circuit::read_pk(&params, pk_path, &config_path, &default_witness);

params_map.insert(degree, params);

Expand All @@ -62,26 +61,52 @@ impl ProverState {
}
}

let step = load_ctx::<StepCircuit<S, Fr>>(
config_dir.join(format!("sync_step_{}.json", S::NAME)),
build_dir.join(format!("sync_step_{}.pkey", S::NAME)),
&mut params_map,
Default::default(),
);

let step_snark = StepCircuit::<S, Fr>::gen_snark_shplonk(
params_map.get(step.degree()).unwrap(),
step.pk(),
step.config_path(),
None::<String>,
&Default::default(),
)
.unwrap();

let committee_update = load_ctx::<CommitteeUpdateCircuit<S, Fr>>(
config_dir.join(format!("committee_update_{}.json", S::NAME)),
build_dir.join(format!("committee_update_{}.pkey", S::NAME)),
&mut params_map,
Default::default(),
);

let committee_update_snark = CommitteeUpdateCircuit::<S, Fr>::gen_snark_shplonk(
params_map.get(committee_update.degree()).unwrap(),
committee_update.pk(),
committee_update.config_path(),
None::<String>,
&Default::default(),
)
.unwrap();

Self {
step: load_ctx::<StepCircuit<S, Fr>>(
config_dir.join(format!("sync_step_{}.json", S::NAME)),
build_dir.join(format!("sync_step_{}.pkey", S::NAME)),
&mut params_map,
),
step_verifier: load_ctx::<StepCircuit<S, Fr>>(
step,
step_verifier: load_ctx::<AggregationCircuit>(
config_dir.join(format!("sync_step_verifier_{}.json", S::NAME)),
build_dir.join(format!("sync_step_verifier_{}.pkey", S::NAME)),
&mut params_map,
vec![step_snark],
),
committee_update: load_ctx::<CommitteeUpdateCircuit<S, Fr>>(
config_dir.join(format!("committee_update_{}.json", S::NAME)),
build_dir.join(format!("committee_update_{}.pkey", S::NAME)),
&mut params_map,
),
committee_update_verifier: load_ctx::<CommitteeUpdateCircuit<S, Fr>>(
committee_update,
committee_update_verifier: load_ctx::<AggregationCircuit>(
config_dir.join(format!("committee_update_verifier_{}.json", S::NAME)),
build_dir.join(format!("committee_update_verifier_{}.pkey", S::NAME)),
&mut params_map,
vec![committee_update_snark],
),
params: params_map,
}
Expand Down

0 comments on commit fa5692d

Please sign in to comment.