diff --git a/crates/cli/src/app_builder.rs b/crates/cli/src/app_builder.rs index 4e93f2817..4f78e931e 100644 --- a/crates/cli/src/app_builder.rs +++ b/crates/cli/src/app_builder.rs @@ -15,7 +15,6 @@ use crate::exec::exec_dry_run; use super::command::CommandBuilder; use super::exec::exec_create_proof; use super::exec::exec_dry_run_service; -use super::exec::exec_image_checksum; use super::exec::exec_setup; use super::exec::exec_verify_proof; @@ -71,7 +70,6 @@ pub trait AppBuilder: CommandBuilder { let app = Self::append_dry_run_subcommand(app); let app = Self::append_create_single_proof_subcommand(app); let app = Self::append_verify_single_proof_subcommand(app); - let app = Self::append_image_checksum_subcommand(app); app } @@ -92,8 +90,7 @@ pub trait AppBuilder: CommandBuilder { let md5 = format!("{:X}", md5::compute(&wasm_binary)); let phantom_functions = Self::parse_phantom_functions(&top_matches); - let param_dir = - load_or_generate_output_path(&md5, top_matches.get_one::("param")); + let param_dir = load_or_generate_output_path(&md5, top_matches.get_one::("param")); let output_dir = load_or_generate_output_path(&md5, top_matches.get_one::("output")); @@ -109,9 +106,6 @@ pub trait AppBuilder: CommandBuilder { &output_dir, ¶m_dir, ), - Some(("checksum", _)) => { - exec_image_checksum(zkwasm_k, wasm_binary, phantom_functions, &output_dir) - } Some(("dry-run", sub_matches)) => { let public_inputs: Vec = Self::parse_single_public_arg(&sub_matches); let private_inputs: Vec = Self::parse_single_private_arg(&sub_matches); @@ -182,11 +176,7 @@ pub trait AppBuilder: CommandBuilder { let _proof_path: PathBuf = Self::parse_proof_path_arg(&sub_matches); let _instance_path: PathBuf = Self::parse_single_instance_arg(&sub_matches); - exec_verify_proof( - Self::NAME, - &output_dir, - ¶m_dir - ) + exec_verify_proof(Self::NAME, &output_dir, ¶m_dir) } Some((_, _)) => todo!(), None => todo!(), diff --git a/crates/cli/src/command.rs b/crates/cli/src/command.rs index 92d7466b4..f4bbed778 100644 --- a/crates/cli/src/command.rs +++ b/crates/cli/src/command.rs @@ -10,12 +10,6 @@ pub trait CommandBuilder: ArgBuilder { app.subcommand(command) } - fn append_image_checksum_subcommand(app: App) -> App { - let command = Command::new("checksum"); - - app.subcommand(command) - } - fn append_dry_run_subcommand(app: App) -> App { let command = Command::new("dry-run") .arg(Self::single_public_arg()) diff --git a/crates/cli/src/exec.rs b/crates/cli/src/exec.rs index 9d0ee48fe..fa9dfc53a 100644 --- a/crates/cli/src/exec.rs +++ b/crates/cli/src/exec.rs @@ -29,7 +29,6 @@ use std::path::Path; use std::path::PathBuf; use std::rc::Rc; use wasmi::RuntimeValue; -use std::io::Write; //const AGGREGATE_PREFIX: &'static str = "aggregate-circuit"; @@ -82,33 +81,6 @@ pub fn exec_setup( Ok(()) } -pub fn exec_image_checksum( - zkwasm_k: u32, - wasm_binary: Vec, - phantom_functions: Vec, - output_dir: &PathBuf, -) -> Result<()> { - let loader = ZkWasmLoader::::new(zkwasm_k, wasm_binary, phantom_functions, None)?; - - let params = load_or_build_unsafe_params::( - zkwasm_k, - Some(&output_dir.join(format!("K{}.params", zkwasm_k))), - ); - - let checksum = loader.checksum(¶ms)?; - assert_eq!(checksum.len(), 1); - let checksum = checksum[0]; - - println!("image checksum: {:?}", checksum); - - let mut fd = - std::fs::File::create(&output_dir.join(format!("checksum.data",)).as_path()).unwrap(); - - write!(fd, "{:?}", checksum)?; - - Ok(()) -} - pub fn exec_dry_run_service( zkwasm_k: u32, wasm_binary: Vec, @@ -268,12 +240,12 @@ pub fn exec_create_proof( info!("Mock test passed"); } - let circuit: CircuitInfo> = CircuitInfo::new( + let circuit: CircuitInfo> = CircuitInfo::new( circuit, prefix.to_string(), vec![instances], zkwasm_k as usize, - circuits_batcher::args::HashType::Poseidon + circuits_batcher::args::HashType::Poseidon, ); circuit.proofloadinfo.save(output_dir); circuit.exec_create_proof( @@ -281,7 +253,7 @@ pub fn exec_create_proof( param_dir, PKEY_CACHE.lock().as_mut().unwrap(), 0, - K_PARAMS_CACHE.lock().as_mut().unwrap() + K_PARAMS_CACHE.lock().as_mut().unwrap(), ); info!("Proof has been created."); @@ -296,17 +268,21 @@ pub fn exec_verify_proof( ) -> Result<()> { let load_info = output_dir.join(format!("{}.loadinfo.json", prefix)); let proofloadinfo = ProofLoadInfo::load(&load_info); - let proofs:Vec> = ProofInfo::load_proof(&output_dir, ¶m_dir, &proofloadinfo); + let proofs: Vec> = + ProofInfo::load_proof(&output_dir, ¶m_dir, &proofloadinfo); let params = load_or_build_unsafe_params::( proofloadinfo.k as u32, Some(¶m_dir.join(format!("K{}.params", proofloadinfo.k))), ); let mut public_inputs_size = 0; for proof in proofs.iter() { - public_inputs_size = - usize::max(public_inputs_size, - proof.instances.iter().fold(0, |acc, x| usize::max(acc, x.len())) - ); + public_inputs_size = usize::max( + public_inputs_size, + proof + .instances + .iter() + .fold(0, |acc, x| usize::max(acc, x.len())), + ); } let params_verifier: ParamsVerifier = params.verifier(public_inputs_size).unwrap(); diff --git a/crates/zkwasm/src/checksum/mod.rs b/crates/zkwasm/src/checksum/mod.rs deleted file mode 100644 index 5d03b8743..000000000 --- a/crates/zkwasm/src/checksum/mod.rs +++ /dev/null @@ -1,24 +0,0 @@ -use halo2_proofs::arithmetic::best_multiexp_gpu_cond; -use halo2_proofs::arithmetic::CurveAffine; -use halo2_proofs::poly::commitment::Params; -use specs::CompilationTable; - -use crate::circuits::image_table::EncodeCompilationTableValues; - -pub trait ImageCheckSum { - fn checksum(&self) -> Output; -} - -pub(crate) struct CompilationTableWithParams<'a, 'b, C: CurveAffine> { - pub(crate) table: &'a CompilationTable, - pub(crate) params: &'b Params, -} - -impl<'a, 'b, C: CurveAffine> ImageCheckSum> for CompilationTableWithParams<'a, 'b, C> { - fn checksum(&self) -> Vec { - let cells = self.table.encode_compilation_table_values().plain(); - - let c = best_multiexp_gpu_cond(&cells[..], &self.params.get_g_lagrange()[0..cells.len()]); - vec![c.into()] - } -} diff --git a/crates/zkwasm/src/circuits/etable/assign.rs b/crates/zkwasm/src/circuits/etable/assign.rs index 8d0695e07..c8a3e851d 100644 --- a/crates/zkwasm/src/circuits/etable/assign.rs +++ b/crates/zkwasm/src/circuits/etable/assign.rs @@ -22,9 +22,6 @@ use crate::circuits::utils::Context; pub(in crate::circuits) struct EventTablePermutationCells { pub(in crate::circuits) rest_mops: Option, pub(in crate::circuits) rest_jops: Option, - pub(in crate::circuits) fid_of_entry: Cell, - pub(in crate::circuits) initial_memory_pages: Cell, - pub(in crate::circuits) maximal_memory_pages: Cell, } impl EventTableChip { @@ -119,7 +116,7 @@ impl EventTableChip { configure_table: &ConfigureTable, fid_of_entry: u32, rest_ops: Vec<(u32, u32)>, - ) -> Result<(Cell, Cell, Cell), Error> { + ) -> Result<(), Error> { macro_rules! assign_advice { ($cell:ident, $value:expr) => { self.config.common_config.$cell.assign(ctx, $value)? @@ -155,18 +152,18 @@ impl EventTableChip { external_host_call_index_cell, F::from(external_host_call_call_index as u64) ); - let initial_memory_pages_cell = assign_advice!( + assign_constant!( mpages_cell, F::from(configure_table.init_memory_pages as u64) ); - let maximal_memory_pages_cell = assign_advice!( + assign_constant!( maximal_memory_pages_cell, F::from(configure_table.maximal_memory_pages as u64) ); assign_constant!(sp_cell, F::from(DEFAULT_VALUE_STACK_LIMIT as u64 - 1)); assign_constant!(frame_id_cell, F::zero()); assign_constant!(eid_cell, F::one()); - let fid_of_entry_cell = assign_advice!(fid_cell, F::from(fid_of_entry as u64)); + assign_constant!(fid_cell, F::from(fid_of_entry as u64)); assign_constant!(iid_cell, F::zero()); /* @@ -175,11 +172,7 @@ impl EventTableChip { { let assigned_cell = assign_advice!(enabled_cell, F::zero()); if assigned_cell.value().is_none() { - return Ok(( - fid_of_entry_cell.cell(), - initial_memory_pages_cell.cell(), - maximal_memory_pages_cell.cell(), - )); + return Ok(()); } } @@ -187,11 +180,7 @@ impl EventTableChip { * The length of event_table equals 0: without_witness */ if event_table.0.len() == 0 { - return Ok(( - fid_of_entry_cell.cell(), - initial_memory_pages_cell.cell(), - maximal_memory_pages_cell.cell(), - )); + return Ok(()); } let status = { @@ -320,11 +309,7 @@ impl EventTableChip { F::from(external_host_call_call_index as u64) ); - Ok(( - fid_of_entry_cell.cell(), - initial_memory_pages_cell.cell(), - maximal_memory_pages_cell.cell(), - )) + Ok(()) } pub(in crate::circuits) fn assign( @@ -349,7 +334,7 @@ impl EventTableChip { )?; ctx.reset(); - let (fid_of_entry, initial_memory_pages, maximal_memory_pages) = self.assign_entries( + self.assign_entries( ctx, &self.config.op_configs, event_table, @@ -362,9 +347,6 @@ impl EventTableChip { Ok(EventTablePermutationCells { rest_mops: Some(rest_mops_cell), rest_jops: Some(rest_jops_cell), - fid_of_entry, - initial_memory_pages, - maximal_memory_pages, }) } } diff --git a/crates/zkwasm/src/circuits/image_table/assign.rs b/crates/zkwasm/src/circuits/image_table/assign.rs index bb9c5fe43..44469127b 100644 --- a/crates/zkwasm/src/circuits/image_table/assign.rs +++ b/crates/zkwasm/src/circuits/image_table/assign.rs @@ -1,71 +1,29 @@ use halo2_proofs::arithmetic::FieldExt; -use halo2_proofs::circuit::Cell; use halo2_proofs::circuit::Layouter; use halo2_proofs::plonk::Error; use super::ImageTableChip; use super::ImageTableLayouter; -use crate::circuits::utils::Context; impl ImageTableChip { pub fn assign( self, layouter: &mut impl Layouter, image_table: ImageTableLayouter, - permutation_cells: ImageTableLayouter, ) -> Result<(), Error> { - layouter.assign_region( + layouter.assign_table( || "image table", - |region| { - let mut ctx = Context::new(region); + |mut table| { + let mut offset = 0; macro_rules! assign_one_line { ($v: expr) => {{ - let cell = ctx - .region - .assign_advice( - || "image table", - self.config.col, - ctx.offset, - || Ok($v), - )? - .cell(); + table.assign_cell(|| "image table", self.config.col, offset, || Ok($v))?; - ctx.next(); - - cell + offset += 1; }}; } - let entry_fid_cell = assign_one_line!(image_table.entry_fid); - ctx.region - .constrain_equal(permutation_cells.entry_fid, entry_fid_cell)?; - - let initial_memory_pages_cell = assign_one_line!(image_table.initial_memory_pages); - ctx.region.constrain_equal( - permutation_cells.initial_memory_pages, - initial_memory_pages_cell, - )?; - - let maximal_memory_pages_cell = assign_one_line!(image_table.maximal_memory_pages); - ctx.region.constrain_equal( - permutation_cells.maximal_memory_pages, - maximal_memory_pages_cell, - )?; - - for (static_frame_entry, cell_in_frame_table) in image_table - .static_frame_entries - .iter() - .zip(permutation_cells.static_frame_entries.iter()) - { - // Enable cell - let cell = assign_one_line!(static_frame_entry.0); - ctx.region.constrain_equal(cell, cell_in_frame_table.0)?; - - let cell = assign_one_line!(static_frame_entry.1); - ctx.region.constrain_equal(cell, cell_in_frame_table.1)?; - } - for value in image_table.lookup_entries.as_ref().unwrap() { assign_one_line!(*value); } diff --git a/crates/zkwasm/src/circuits/image_table/configure.rs b/crates/zkwasm/src/circuits/image_table/configure.rs index 02c36cc54..242bd7f9d 100644 --- a/crates/zkwasm/src/circuits/image_table/configure.rs +++ b/crates/zkwasm/src/circuits/image_table/configure.rs @@ -7,15 +7,11 @@ use halo2_proofs::plonk::VirtualCells; use specs::encode::image_table::ImageTableEncoder; use super::ImageTableConfig; -use super::IMAGE_COL_NAME; -use crate::curr; impl ImageTableConfig { pub(in crate::circuits) fn configure(meta: &mut ConstraintSystem) -> Self { - let col = meta.named_advice_column(IMAGE_COL_NAME.to_owned()); - meta.enable_equality(col); Self { - col, + col: meta.lookup_table_column(), _mark: PhantomData, } } @@ -26,11 +22,8 @@ impl ImageTableConfig { key: &'static str, expr: impl FnOnce(&mut VirtualCells<'_, F>) -> Expression, ) { - meta.lookup_any(key, |meta| { - vec![( - ImageTableEncoder::Instruction.encode(expr(meta)), - curr!(meta, self.col), - )] + meta.lookup(key, |meta| { + vec![(ImageTableEncoder::Instruction.encode(expr(meta)), self.col)] }); } @@ -40,11 +33,8 @@ impl ImageTableConfig { key: &'static str, expr: impl FnOnce(&mut VirtualCells<'_, F>) -> Expression, ) { - meta.lookup_any(key, |meta| { - vec![( - ImageTableEncoder::InitMemory.encode(expr(meta)), - curr!(meta, self.col), - )] + meta.lookup(key, |meta| { + vec![(ImageTableEncoder::InitMemory.encode(expr(meta)), self.col)] }); } @@ -54,11 +44,8 @@ impl ImageTableConfig { key: &'static str, expr: impl FnOnce(&mut VirtualCells<'_, F>) -> Expression, ) { - meta.lookup_any(key, |meta| { - vec![( - ImageTableEncoder::BrTable.encode(expr(meta)), - curr!(meta, self.col), - )] + meta.lookup(key, |meta| { + vec![(ImageTableEncoder::BrTable.encode(expr(meta)), self.col)] }); } } diff --git a/crates/zkwasm/src/circuits/image_table/mod.rs b/crates/zkwasm/src/circuits/image_table/mod.rs index 777f2a8d6..79300ddeb 100644 --- a/crates/zkwasm/src/circuits/image_table/mod.rs +++ b/crates/zkwasm/src/circuits/image_table/mod.rs @@ -1,13 +1,11 @@ use halo2_proofs::arithmetic::FieldExt; -use halo2_proofs::plonk::Advice; -use halo2_proofs::plonk::Column; +use halo2_proofs::plonk::TableColumn; use num_bigint::BigUint; use specs::brtable::BrTable; use specs::brtable::ElemTable; use specs::encode::image_table::ImageTableEncoder; use specs::imtable::InitMemoryTable; use specs::itable::InstructionTable; -use specs::jtable::StaticFrameEntry; use specs::mtable::LocationType; use specs::CompilationTable; use std::marker::PhantomData; @@ -21,10 +19,6 @@ mod configure; pub const IMAGE_COL_NAME: &str = "img_col"; pub struct ImageTableLayouter { - pub entry_fid: T, - pub initial_memory_pages: T, - pub maximal_memory_pages: T, - pub static_frame_entries: Vec<(T, T)>, /* * include: * instruction table @@ -37,24 +31,7 @@ pub struct ImageTableLayouter { impl ImageTableLayouter { pub fn plain(&self) -> Vec { - let mut buf = vec![]; - - buf.push(self.entry_fid.clone()); - buf.push(self.initial_memory_pages.clone()); - buf.push(self.maximal_memory_pages.clone()); - buf.append( - &mut self - .static_frame_entries - .clone() - .to_vec() - .into_iter() - .map(|(enable, fid)| vec![enable, fid]) - .collect::>>() - .concat(), - ); - buf.append(&mut self.lookup_entries.clone().unwrap()); - - buf + self.lookup_entries.clone().unwrap() } } @@ -136,51 +113,6 @@ impl EncodeCompilationTableValues for CompilationTable { cells } - fn msg_of_static_frame_table( - static_frame_table: &Vec, - ) -> Vec<(F, F)> { - let mut cells = static_frame_table - .into_iter() - .map(|entry| (F::one(), bn_to_field(&entry.encode()))) - .collect::>(); - - cells.resize( - 2, - ( - F::zero(), - bn_to_field( - &StaticFrameEntry { - enable: false, - frame_id: 0, - next_frame_id: 0, - callee_fid: 0, - fid: 0, - iid: 0, - } - .encode(), - ), - ), - ); - - cells - } - - fn msg_of_memory_pages( - init_memory_pages: u32, - maximal_memory_pages: u32, - ) -> (F, F) { - ( - F::from(init_memory_pages as u64), - F::from(maximal_memory_pages as u64), - ) - } - - let entry_fid = F::from(self.fid_of_entry as u64); - let static_frame_entries = msg_of_static_frame_table(&self.static_jtable); - let (initial_memory_pages, maximal_memory_pages) = msg_of_memory_pages( - self.configure_table.init_memory_pages, - self.configure_table.maximal_memory_pages, - ); let lookup_entries = msg_of_image_table( &self.itable, &self.itable.create_brtable(), @@ -189,10 +121,6 @@ impl EncodeCompilationTableValues for CompilationTable { ); ImageTableLayouter { - entry_fid, - static_frame_entries, - initial_memory_pages, - maximal_memory_pages, lookup_entries: Some(lookup_entries), } } @@ -200,7 +128,7 @@ impl EncodeCompilationTableValues for CompilationTable { #[derive(Clone)] pub struct ImageTableConfig { - col: Column, + col: TableColumn, _mark: PhantomData, } diff --git a/crates/zkwasm/src/circuits/jtable/assign.rs b/crates/zkwasm/src/circuits/jtable/assign.rs index 89fab14ca..6ff346e81 100644 --- a/crates/zkwasm/src/circuits/jtable/assign.rs +++ b/crates/zkwasm/src/circuits/jtable/assign.rs @@ -95,11 +95,11 @@ impl JumpTableChip { let enable_cell = ctx .region - .assign_advice( + .assign_advice_from_constant( || "jtable enable", self.config.data, ctx.offset, - || Ok(F::from(entry.enable as u64)), + F::from(entry.enable as u64), )? .cell(); ctx.next(); @@ -114,11 +114,11 @@ impl JumpTableChip { let entry_cell = ctx .region - .assign_advice( + .assign_advice_from_constant( || "jtable entry", self.config.data, ctx.offset, - || Ok(bn_to_field(&entry.encode())), + bn_to_field(&entry.encode()), )? .cell(); ctx.next(); diff --git a/crates/zkwasm/src/circuits/test_circuit/mod.rs b/crates/zkwasm/src/circuits/test_circuit/mod.rs index 08816e8e5..c6d774bdb 100644 --- a/crates/zkwasm/src/circuits/test_circuit/mod.rs +++ b/crates/zkwasm/src/circuits/test_circuit/mod.rs @@ -22,7 +22,6 @@ use crate::circuits::external_host_call_table::ExternalHostCallChip; use crate::circuits::external_host_call_table::ExternalHostCallTableConfig; use crate::circuits::image_table::EncodeCompilationTableValues; use crate::circuits::image_table::ImageTableChip; -use crate::circuits::image_table::ImageTableLayouter; use crate::circuits::jtable::JumpTableChip; use crate::circuits::jtable::JumpTableConfig; use crate::circuits::mtable::MemoryTableChip; @@ -195,75 +194,66 @@ impl Circuit for TestCircuit { )? ); - let (entry_fid, static_frame_entries, initial_memory_pages, maximal_memory_pages) = - layouter.assign_region( - || "jtable mtable etable", - |region| { - let mut ctx = Context::new(region); - - let memory_writing_table: MemoryWritingTable = - self.tables.execution_tables.mtable.clone().into(); - - let etable = exec_with_profile!( - || "Prepare memory info for etable", - EventTableWithMemoryInfo::new( - &self.tables.execution_tables.etable, + layouter.assign_region( + || "jtable mtable etable", + |region| { + let mut ctx = Context::new(region); + + let memory_writing_table: MemoryWritingTable = + self.tables.execution_tables.mtable.clone().into(); + + let etable = exec_with_profile!( + || "Prepare memory info for etable", + EventTableWithMemoryInfo::new( + &self.tables.execution_tables.etable, + &memory_writing_table, + ) + ); + + let etable_permutation_cells = exec_with_profile!( + || "Assign etable", + echip.assign( + &mut ctx, + &etable, + &self.tables.compilation_tables.configure_table, + self.tables.compilation_tables.fid_of_entry, + )? + ); + + { + ctx.reset(); + exec_with_profile!( + || "Assign mtable", + mchip.assign( + &mut ctx, + etable_permutation_cells.rest_mops, &memory_writing_table, - ) + &self.tables.compilation_tables.imtable + )? ); + } - let etable_permutation_cells = exec_with_profile!( - || "Assign etable", - echip.assign( + { + ctx.reset(); + exec_with_profile!( + || "Assign frame table", + jchip.assign( &mut ctx, - &etable, - &self.tables.compilation_tables.configure_table, - self.tables.compilation_tables.fid_of_entry, + &self.tables.execution_tables.jtable, + etable_permutation_cells.rest_jops, + &self.tables.compilation_tables.static_jtable, )? - ); + ) + }; - { - ctx.reset(); - exec_with_profile!( - || "Assign mtable", - mchip.assign( - &mut ctx, - etable_permutation_cells.rest_mops, - &memory_writing_table, - &self.tables.compilation_tables.imtable - )? - ); - } - - let jtable_info = { - ctx.reset(); - exec_with_profile!( - || "Assign frame table", - jchip.assign( - &mut ctx, - &self.tables.execution_tables.jtable, - etable_permutation_cells.rest_jops, - &self.tables.compilation_tables.static_jtable, - )? - ) - }; - - { - ctx.reset(); - exec_with_profile!( - || "Assign bit table", - bit_chip.assign(&mut ctx, &etable)? - ); - } - - Ok(( - etable_permutation_cells.fid_of_entry, - jtable_info, - etable_permutation_cells.initial_memory_pages, - etable_permutation_cells.maximal_memory_pages, - )) - }, - )?; + { + ctx.reset(); + exec_with_profile!(|| "Assign bit table", bit_chip.assign(&mut ctx, &etable)?); + } + + Ok(()) + }, + )?; exec_with_profile!( || "Assign context cont chip", @@ -281,13 +271,6 @@ impl Circuit for TestCircuit { self.tables .compilation_tables .encode_compilation_table_values(), - ImageTableLayouter { - entry_fid, - static_frame_entries, - initial_memory_pages, - maximal_memory_pages, - lookup_entries: None - } )? ); diff --git a/crates/zkwasm/src/lib.rs b/crates/zkwasm/src/lib.rs index 6b12c49ae..cc49716e1 100644 --- a/crates/zkwasm/src/lib.rs +++ b/crates/zkwasm/src/lib.rs @@ -3,7 +3,6 @@ #![deny(unused_imports)] #![feature(thread_local)] -pub mod checksum; pub mod circuits; pub mod foreign; pub mod loader; diff --git a/crates/zkwasm/src/loader/mod.rs b/crates/zkwasm/src/loader/mod.rs index 0757eba42..300374048 100644 --- a/crates/zkwasm/src/loader/mod.rs +++ b/crates/zkwasm/src/loader/mod.rs @@ -5,7 +5,6 @@ use std::rc::Rc; use anyhow::Result; use halo2_proofs::arithmetic::MultiMillerLoop; use halo2_proofs::dev::MockProver; -use halo2_proofs::plonk::get_advice_commitments_from_transcript; use halo2_proofs::plonk::keygen_vk; use halo2_proofs::plonk::verify_proof; use halo2_proofs::plonk::SingleVerifier; @@ -24,11 +23,8 @@ use wasmi::ImportsBuilder; use wasmi::NotStartedModuleRef; use wasmi::RuntimeValue; -use crate::checksum::CompilationTableWithParams; -use crate::checksum::ImageCheckSum; use crate::circuits::config::init_zkwasm_runtime; use crate::circuits::config::set_zkwasm_k; -use crate::circuits::image_table::IMAGE_COL_NAME; use crate::circuits::TestCircuit; use crate::circuits::ZkWasmCircuitBuilder; use crate::loader::err::Error; @@ -163,24 +159,6 @@ impl ZkWasmLoader { Ok(keygen_vk(¶ms, &circuit).unwrap()) } - - pub fn checksum(&self, params: &Params) -> Result> { - let (env, _) = HostEnv::new_with_full_foreign_plugins( - vec![], - vec![], - vec![], - Rc::new(RefCell::new(vec![])), - None, - ); - let compiled = self.compile(&env)?; - - let table_with_params = CompilationTableWithParams { - table: &compiled.tables, - params, - }; - - Ok(table_with_params.checksum()) - } } impl ZkWasmLoader { @@ -302,25 +280,6 @@ impl ZkWasmLoader { ) .unwrap(); - { - let img_col_idx = vkey - .cs - .named_advices - .iter() - .find(|(k, _)| k == IMAGE_COL_NAME) - .unwrap() - .1; - let img_col_commitment: Vec = - get_advice_commitments_from_transcript::( - &vkey, - &mut PoseidonRead::init(&proof[..]), - ) - .unwrap(); - let checksum = self.checksum(params)?; - - assert!(vec![img_col_commitment[img_col_idx as usize]] == checksum) - } - Ok(()) } }