Skip to content

Commit

Permalink
hm
Browse files Browse the repository at this point in the history
  • Loading branch information
jtguibas committed May 24, 2024
1 parent 8af2e2f commit b5ed27e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
14 changes: 13 additions & 1 deletion core/src/stark/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ impl<SC: StarkGenericConfig, A: MachineAir<Val<SC>>> Verifier<SC, A> {
.map_err(|e| VerificationError::InvalidopeningArgument(e))?;

// Verify the constrtaint evaluations.

for (chip, trace_domain, qc_domains, values) in izip!(
chips.iter(),
trace_domains,
Expand All @@ -199,6 +198,12 @@ impl<SC: StarkGenericConfig, A: MachineAir<Val<SC>>> Verifier<SC, A> {
)
.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(())
}

Expand Down Expand Up @@ -411,6 +416,7 @@ pub enum VerificationError<SC: StarkGenericConfig> {
OodEvaluationMismatch(String),
/// The shape of the opening arguments is invalid.
OpeningShapeError(String, OpeningShapeError),
MissingCpuChip,
}

impl Debug for OpeningShapeError {
Expand Down Expand Up @@ -474,6 +480,9 @@ impl<SC: StarkGenericConfig> Debug for VerificationError<SC> {
VerificationError::OpeningShapeError(chip, e) => {
write!(f, "Invalid opening shape for chip {}: {:?}", chip, e)
}
VerificationError::MissingCpuChip => {
write!(f, "Missing CPU chip")
}
}
}
}
Expand All @@ -490,6 +499,9 @@ impl<SC: StarkGenericConfig> Display for VerificationError<SC> {
VerificationError::OpeningShapeError(chip, e) => {
write!(f, "Invalid opening shape for chip {}: {}", chip, e)
}
VerificationError::MissingCpuChip => {
write!(f, "Missing CPU chip in shard")
}
}
}
}
Expand Down
19 changes: 7 additions & 12 deletions recursion/program/src/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,7 @@ impl<'a, SC: StarkGenericConfig, A: MachineAir<SC::Val>> VerifyingKeyHint<'a, SC
impl<C: Config, SC: StarkGenericConfig, A> StarkRecursiveVerifier<C> for StarkMachine<SC, A>
where
C::F: TwoAdicField,
SC: StarkGenericConfig<
Val = C::F,
Challenge = C::EF,
Domain = TwoAdicMultiplicativeCoset<C::F>,
>,
SC: StarkGenericConfig<Val = C::F, Challenge = C::EF, Domain = TwoAdicMultiplicativeCoset<C::F>>,
A: MachineAir<C::F> + for<'a> Air<RecursiveVerifierConstraintFolder<'a, C>>,
C::F: TwoAdicField,
C::EF: TwoAdicField,
Expand Down Expand Up @@ -148,11 +144,7 @@ pub type RecursiveVerifierConstraintFolder<'a, C> = GenericVerifierConstraintFol
impl<C: Config, SC: StarkGenericConfig> StarkVerifier<C, SC>
where
C::F: TwoAdicField,
SC: StarkGenericConfig<
Val = C::F,
Challenge = C::EF,
Domain = TwoAdicMultiplicativeCoset<C::F>,
>,
SC: StarkGenericConfig<Val = C::F, Challenge = C::EF, Domain = TwoAdicMultiplicativeCoset<C::F>>,
{
pub fn verify_shard<A>(
builder: &mut Builder<C>,
Expand Down Expand Up @@ -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| {
Expand Down

0 comments on commit b5ed27e

Please sign in to comment.