From 2df1e216624381961ad6b18cc5c1a46c0935676b Mon Sep 17 00:00:00 2001 From: Soham Zemse <22412996+zemse@users.noreply.github.com> Date: Fri, 6 Sep 2024 12:46:31 +0530 Subject: [PATCH] use hash set for table --- ceno_zkvm/src/scheme/mock_prover.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ceno_zkvm/src/scheme/mock_prover.rs b/ceno_zkvm/src/scheme/mock_prover.rs index eb6504e44..5a7cbb2f8 100644 --- a/ceno_zkvm/src/scheme/mock_prover.rs +++ b/ceno_zkvm/src/scheme/mock_prover.rs @@ -8,7 +8,7 @@ use ff_ext::ExtensionField; use goldilocks::SmallField; use itertools::Itertools; use multilinear_extensions::virtual_poly_v2::ArcMultilinearExtension; -use std::{marker::PhantomData, ops::Neg}; +use std::{collections::HashSet, hash::Hash, marker::PhantomData, ops::Neg}; #[allow(clippy::enum_variant_names)] #[derive(Debug, PartialEq, Clone)] @@ -192,7 +192,10 @@ pub(crate) struct MockProver { _phantom: PhantomData, } -impl<'a, E: ExtensionField> MockProver { +impl<'a, E: ExtensionField> MockProver +where + E: Hash, +{ #[allow(dead_code)] pub fn run( cb: &mut CircuitBuilder, @@ -266,6 +269,7 @@ impl<'a, E: ExtensionField> MockProver { load_u5_table(&mut table_vec, cb, challenge); load_u16_table(&mut table_vec, cb, challenge); load_lt_table(&mut table_vec, cb, challenge); + let table: HashSet = table_vec.into_iter().collect(); // Lookup expressions for (expr, name) in cb @@ -279,7 +283,7 @@ impl<'a, E: ExtensionField> MockProver { // Check each lookup expr exists in t vec for (inst_id, element) in expr_evaluated.iter().enumerate() { - if !table_vec.contains(element) { + if !table.contains(element) { errors.push(MockProverError::LookupError { expression: expr.clone(), evaluated: *element,