From b5ed27e624322b368b282c1ab7c847d6c617508c Mon Sep 17 00:00:00 2001 From: John Guibas Date: Thu, 23 May 2024 17:49:39 -0700 Subject: [PATCH] hm --- core/src/stark/verifier.rs | 14 +++++++++++++- recursion/program/src/stark.rs | 19 +++++++------------ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/core/src/stark/verifier.rs b/core/src/stark/verifier.rs index 6f5bad846d..17e3753336 100644 --- a/core/src/stark/verifier.rs +++ b/core/src/stark/verifier.rs @@ -176,7 +176,6 @@ impl>> Verifier { .map_err(|e| VerificationError::InvalidopeningArgument(e))?; // Verify the constrtaint evaluations. - for (chip, trace_domain, qc_domains, values) in izip!( chips.iter(), trace_domains, @@ -199,6 +198,12 @@ impl>> Verifier { ) .map_err(|_| VerificationError::OodEvaluationMismatch(chip.name()))?; } + + let nb_cpu_chips = chips.iter().filter(|chip| chip.name() == "CPU").count(); + if nb_cpu_chips != 1 { + return Err(VerificationError::MissingCpuChip); + } + Ok(()) } @@ -411,6 +416,7 @@ pub enum VerificationError { OodEvaluationMismatch(String), /// The shape of the opening arguments is invalid. OpeningShapeError(String, OpeningShapeError), + MissingCpuChip, } impl Debug for OpeningShapeError { @@ -474,6 +480,9 @@ impl Debug for VerificationError { VerificationError::OpeningShapeError(chip, e) => { write!(f, "Invalid opening shape for chip {}: {:?}", chip, e) } + VerificationError::MissingCpuChip => { + write!(f, "Missing CPU chip") + } } } } @@ -490,6 +499,9 @@ impl Display for VerificationError { VerificationError::OpeningShapeError(chip, e) => { write!(f, "Invalid opening shape for chip {}: {}", chip, e) } + VerificationError::MissingCpuChip => { + write!(f, "Missing CPU chip in shard") + } } } } diff --git a/recursion/program/src/stark.rs b/recursion/program/src/stark.rs index a7cdd1fb53..ebff884623 100644 --- a/recursion/program/src/stark.rs +++ b/recursion/program/src/stark.rs @@ -97,11 +97,7 @@ impl<'a, SC: StarkGenericConfig, A: MachineAir> VerifyingKeyHint<'a, SC impl StarkRecursiveVerifier for StarkMachine where C::F: TwoAdicField, - SC: StarkGenericConfig< - Val = C::F, - Challenge = C::EF, - Domain = TwoAdicMultiplicativeCoset, - >, + SC: StarkGenericConfig>, A: MachineAir + for<'a> Air>, C::F: TwoAdicField, C::EF: TwoAdicField, @@ -148,11 +144,7 @@ pub type RecursiveVerifierConstraintFolder<'a, C> = GenericVerifierConstraintFol impl StarkVerifier where C::F: TwoAdicField, - SC: StarkGenericConfig< - Val = C::F, - Challenge = C::EF, - Domain = TwoAdicMultiplicativeCoset, - >, + SC: StarkGenericConfig>, { pub fn verify_shard( builder: &mut Builder, @@ -346,14 +338,17 @@ where // TODO CONSTRAIN: that the preprocessed chips get called with verify_constraints. builder.cycle_tracker("stage-e-verify-constraints"); for (i, chip) in machine.chips().iter().enumerate() { - let chip_name = chip.name(); - tracing::debug!("verifying constraints for chip: {}", chip_name); + tracing::debug!("verifying constraints for chip: {}", chip.name()); let index = builder.get(&proof.sorted_idxs, i); if chip.preprocessed_width() > 0 { builder.assert_var_ne(index, C::N::from_canonical_usize(EMPTY)); } + if chip.name() == "CPU" { + builder.assert_var_ne(index, C::N::from_canonical_usize(EMPTY)); + } + builder .if_ne(index, C::N::from_canonical_usize(EMPTY)) .then(|builder| {