diff --git a/crates/prover/src/core/air/mod.rs b/crates/prover/src/core/air/mod.rs index 8e3c3e43..19dbb388 100644 --- a/crates/prover/src/core/air/mod.rs +++ b/crates/prover/src/core/air/mod.rs @@ -6,6 +6,7 @@ use super::fields::qm31::SecureField; use super::pcs::TreeVec; use super::poly::circle::{CircleEvaluation, CirclePoly}; use super::poly::BitReversedOrder; +use super::prover::VerificationError; use super::{ColumnVec, InteractionElements, LookupValues}; pub mod accumulation; @@ -22,6 +23,9 @@ pub use air_ext::{AirExt, AirProverExt}; // TODO(spapini): consider renaming this struct. pub trait Air { fn components(&self) -> Vec<&dyn Component>; + + /// Verifies the lookups done in the Air. + fn verify_lookups(&self, lookup_values: &LookupValues) -> Result<(), VerificationError>; } pub trait AirProver: Air { diff --git a/crates/prover/src/core/prover/mod.rs b/crates/prover/src/core/prover/mod.rs index 5fd5fb43..7cd5a358 100644 --- a/crates/prover/src/core/prover/mod.rs +++ b/crates/prover/src/core/prover/mod.rs @@ -224,6 +224,8 @@ pub fn verify( ); } + air.verify_lookups(&proof.lookup_values)?; + channel.mix_felts( &proof .lookup_values @@ -332,6 +334,8 @@ pub enum ProvingError { pub enum VerificationError { #[error("Proof has invalid structure: {0}.")] InvalidStructure(String), + #[error("{0} lookup values do not match.")] + InvalidLookup(String), #[error(transparent)] Merkle(#[from] MerkleVerificationError), #[error( @@ -349,6 +353,7 @@ pub enum VerificationError { mod tests { use num_traits::Zero; + use super::VerificationError; use crate::core::air::accumulation::{DomainEvaluationAccumulator, PointEvaluationAccumulator}; use crate::core::air::{Air, AirProver, Component, ComponentProver, ComponentTrace}; use crate::core::backend::cpu::CpuCircleEvaluation; @@ -378,6 +383,10 @@ mod tests { fn components(&self) -> Vec<&dyn Component> { vec![&self.component] } + + fn verify_lookups(&self, _lookup_values: &LookupValues) -> Result<(), VerificationError> { + Ok(()) + } } impl AirTraceVerifier for TestAir { diff --git a/crates/prover/src/examples/fibonacci/air.rs b/crates/prover/src/examples/fibonacci/air.rs index 2cb61ff1..b6a8b472 100644 --- a/crates/prover/src/examples/fibonacci/air.rs +++ b/crates/prover/src/examples/fibonacci/air.rs @@ -7,7 +7,8 @@ use crate::core::channel::Blake2sChannel; use crate::core::fields::m31::BaseField; use crate::core::poly::circle::CircleEvaluation; use crate::core::poly::BitReversedOrder; -use crate::core::{ColumnVec, InteractionElements}; +use crate::core::prover::VerificationError; +use crate::core::{ColumnVec, InteractionElements, LookupValues}; use crate::trace_generation::registry::ComponentGenerationRegistry; use crate::trace_generation::{AirTraceGenerator, AirTraceVerifier, ComponentTraceGenerator}; @@ -79,6 +80,10 @@ impl Air for FibonacciAir { fn components(&self) -> Vec<&dyn Component> { vec![&self.component] } + + fn verify_lookups(&self, _lookup_values: &LookupValues) -> Result<(), VerificationError> { + Ok(()) + } } impl AirTraceVerifier for FibonacciAir { @@ -133,6 +138,10 @@ impl Air for MultiFibonacciAir { .map(|c| c as &dyn Component) .collect_vec() } + + fn verify_lookups(&self, _lookup_values: &LookupValues) -> Result<(), VerificationError> { + Ok(()) + } } impl AirTraceVerifier for MultiFibonacciAir { diff --git a/crates/prover/src/examples/poseidon/mod.rs b/crates/prover/src/examples/poseidon/mod.rs index 4d42f086..38da4e4f 100644 --- a/crates/prover/src/examples/poseidon/mod.rs +++ b/crates/prover/src/examples/poseidon/mod.rs @@ -23,6 +23,7 @@ use crate::core::fields::{FieldExpOps, FieldOps}; use crate::core::pcs::TreeVec; use crate::core::poly::circle::{CanonicCoset, CircleEvaluation, PolyOps}; use crate::core::poly::BitReversedOrder; +use crate::core::prover::VerificationError; use crate::core::{ColumnVec, InteractionElements, LookupValues}; use crate::trace_generation::{AirTraceGenerator, AirTraceVerifier, ComponentTraceGenerator}; @@ -65,6 +66,10 @@ impl Air for PoseidonAir { fn components(&self) -> Vec<&dyn Component> { vec![&self.component] } + + fn verify_lookups(&self, _lookup_values: &LookupValues) -> Result<(), VerificationError> { + Ok(()) + } } impl AirTraceVerifier for PoseidonAir { diff --git a/crates/prover/src/examples/wide_fibonacci/component.rs b/crates/prover/src/examples/wide_fibonacci/component.rs index cff5f2d1..cc1971bf 100644 --- a/crates/prover/src/examples/wide_fibonacci/component.rs +++ b/crates/prover/src/examples/wide_fibonacci/component.rs @@ -14,6 +14,7 @@ use crate::core::fields::FieldExpOps; use crate::core::pcs::TreeVec; use crate::core::poly::circle::{CanonicCoset, CircleEvaluation}; use crate::core::poly::BitReversedOrder; +use crate::core::prover::VerificationError; use crate::core::utils::shifted_secure_combination; use crate::core::{ColumnVec, InteractionElements, LookupValues}; use crate::examples::wide_fibonacci::trace_gen::write_lookup_column; @@ -182,6 +183,10 @@ impl Air for WideFibAir { fn components(&self) -> Vec<&dyn Component> { vec![&self.component] } + + fn verify_lookups(&self, _lookup_values: &LookupValues) -> Result<(), VerificationError> { + Ok(()) + } } impl Component for WideFibComponent { diff --git a/crates/prover/src/examples/wide_fibonacci/simd.rs b/crates/prover/src/examples/wide_fibonacci/simd.rs index 1479f5f8..e4faf11a 100644 --- a/crates/prover/src/examples/wide_fibonacci/simd.rs +++ b/crates/prover/src/examples/wide_fibonacci/simd.rs @@ -20,7 +20,7 @@ use crate::core::fields::{FieldExpOps, FieldOps}; use crate::core::pcs::TreeVec; use crate::core::poly::circle::{CanonicCoset, CircleEvaluation}; use crate::core::poly::BitReversedOrder; -use crate::core::prover::BASE_TRACE; +use crate::core::prover::{VerificationError, BASE_TRACE}; use crate::core::{ColumnVec, InteractionElements, LookupValues}; use crate::examples::wide_fibonacci::component::N_COLUMNS; use crate::trace_generation::registry::ComponentGenerationRegistry; @@ -59,6 +59,10 @@ impl Air for SimdWideFibAir { fn components(&self) -> Vec<&dyn Component> { vec![&self.component] } + + fn verify_lookups(&self, _lookup_values: &LookupValues) -> Result<(), VerificationError> { + Ok(()) + } } impl AirTraceVerifier for SimdWideFibAir {