Skip to content

Commit

Permalink
use the latest circuit-batcher
Browse files Browse the repository at this point in the history
1. Need to manually store proof transcripts
2. batch_proof in circuit_batcher do not require directory inputs
  • Loading branch information
xgaozoyoe committed Apr 1, 2024
1 parent 5cda906 commit 02ce400
Show file tree
Hide file tree
Showing 9 changed files with 335 additions and 198 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions crates/cli/src/exec.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use anyhow::Result;
use circuits_batcher::args::HashType::Poseidon;
use circuits_batcher::proof::ParamsCache;
use circuits_batcher::proof::ProofGenerationInfo;
use circuits_batcher::proof::ProofInfo;
use circuits_batcher::proof::ProofLoadInfo;
use circuits_batcher::proof::ProofPieceInfo;
use circuits_batcher::proof::ProvingKeyCache;
use delphinus_zkwasm::loader::ZkWasmLoader;
Expand Down Expand Up @@ -158,22 +158,23 @@ pub fn exec_create_proof<Builder: HostEnvBuilder>(

let prover: ProofPieceInfo = ProofPieceInfo::new(prefix.to_string(), 0, instances.len() as u32);

let mut param_cache = ParamsCache::<Bn256>::new(5);
let mut pkey_cache = ProvingKeyCache::<Bn256>::new(5);
let mut param_cache = ParamsCache::<Bn256>::new(5, param_dir.clone());
let mut pkey_cache = ProvingKeyCache::<Bn256>::new(5, param_dir.clone());

let mut proof_load_info = ProofLoadInfo::new(prefix, zkwasm_k as usize, Poseidon);
let mut proof_load_info = ProofGenerationInfo::new(prefix, zkwasm_k as usize, Poseidon);

prover.exec_create_proof(
let transcript = prover.exec_create_proof(
&circuit,
&vec![instances],
output_dir.as_path(),
param_dir.as_path(),
format!("K{}.params", zkwasm_k),
&vec![instances.clone()],
zkwasm_k as usize,
&mut pkey_cache,
&mut param_cache,
circuits_batcher::args::HashType::Poseidon,
circuits_batcher::args::OpenSchema::GWC,
);

prover.save_proof_data(&vec![instances], &transcript, output_dir);

//prover.mock_proof(k as u32);
proof_load_info.append_single_proof(prover);
proof_load_info.save(output_dir);
Expand All @@ -189,7 +190,7 @@ pub fn exec_verify_proof(
param_dir: &PathBuf,
) -> Result<()> {
let load_info = output_dir.join(format!("{}.loadinfo.json", prefix));
let proofloadinfo = ProofLoadInfo::load(&load_info);
let proofloadinfo = ProofGenerationInfo::load(&load_info);
let proofs: Vec<ProofInfo<Bn256>> =
ProofInfo::load_proof(&output_dir, &param_dir, &proofloadinfo);
let params = load_or_build_unsafe_params::<Bn256>(
Expand Down
76 changes: 59 additions & 17 deletions crates/playground/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion crates/zkwasm/src/circuits/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use halo2_proofs::plonk::Expression;
use halo2_proofs::plonk::VirtualCells;
use num_bigint::BigUint;

use crate::circuits::config::zkwasm_k;
//use crate::circuits::config::zkwasm_k;
use crate::circuits::utils::bn_to_field;
use crate::circuits::utils::Context;
use crate::nextn;
Expand Down Expand Up @@ -110,12 +110,14 @@ macro_rules! define_cell {
ctx: &mut Context<'_, F>,
value: F,
) -> Result<AssignedCell<F, F>, Error> {
/* only for debug purpose
assert!(
value <= $limit,
"assigned value {:?} exceeds the limit {:?}",
value,
$limit
);
*/
self.0.assign(ctx, value)
}
}
Expand Down
Loading

0 comments on commit 02ce400

Please sign in to comment.