Skip to content

Commit

Permalink
fix: read scope from chip (#1642)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamirhemo authored Oct 15, 2024
1 parent 752cf46 commit 87d5de2
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 31 deletions.
2 changes: 0 additions & 2 deletions crates/recursion/circuit/src/machine/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ where
shard_proof.public_values[0..machine.num_pv_elts()].iter().copied(),
);

assert!(!shard_proof.contains_global_main_commitment());

let zero_ext: Ext<C::F, C::EF> = builder.eval(C::F::zero());
StarkVerifier::verify_shard(
builder,
Expand Down
2 changes: 0 additions & 2 deletions crates/recursion/circuit/src/machine/deferred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ where
shard_proof.public_values[0..machine.num_pv_elts()].iter().copied(),
);

assert!(!shard_proof.contains_global_main_commitment());

let zero_ext: Ext<C::F, C::EF> = builder.eval(C::F::zero());
StarkVerifier::verify_shard(
builder,
Expand Down
2 changes: 0 additions & 2 deletions crates/recursion/circuit/src/machine/wrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ where
challenger
.observe_slice(builder, proof.public_values[0..machine.num_pv_elts()].iter().copied());

assert!(!proof.contains_global_main_commitment());

let zero_ext: Ext<C::F, C::EF> = builder.eval(C::F::zero());
StarkVerifier::verify_shard(
builder,
Expand Down
19 changes: 4 additions & 15 deletions crates/recursion/circuit/src/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ pub struct ShardProofVariable<C: CircuitConfig<F = SC::Val>, SC: BabyBearFriConf
pub opened_values: ShardOpenedValues<Ext<C::F, C::EF>>,
pub opening_proof: TwoAdicPcsProofVariable<C, SC>,
pub chip_ordering: HashMap<String, usize>,
pub chip_scopes: Vec<InteractionScope>,
pub public_values: Vec<Felt<C::F>>,
}

Expand Down Expand Up @@ -180,14 +179,8 @@ pub fn dummy_vk_and_shard_proof<A: MachineAir<BabyBear>>(
chip_ordering: preprocessed_chip_ordering,
};

let shard_proof = ShardProof {
commitment,
opened_values,
opening_proof,
chip_ordering,
chip_scopes,
public_values,
};
let shard_proof =
ShardProof { commitment, opened_values, opening_proof, chip_ordering, public_values };

(vk, shard_proof)
}
Expand Down Expand Up @@ -277,15 +270,15 @@ where
A: for<'a> Air<RecursiveVerifierConstraintFolder<'a, C>>,
{
let chips = machine.shard_chips_ordered(&proof.chip_ordering).collect::<Vec<_>>();
let chip_scopes = chips.iter().map(|chip| chip.commit_scope()).collect::<Vec<_>>();

let has_global_main_commit = proof.contains_global_main_commitment();
let has_global_main_commit = chip_scopes.contains(&InteractionScope::Global);

let ShardProofVariable {
commitment,
opened_values,
opening_proof,
chip_ordering,
chip_scopes,
public_values,
} = proof;

Expand Down Expand Up @@ -527,10 +520,6 @@ impl<C: CircuitConfig<F = SC::Val>, SC: BabyBearFriConfigVariable<C>> ShardProof
pub fn contains_memory_finalize(&self) -> bool {
self.chip_ordering.contains_key("MemoryGlobalFinalize")
}

pub fn contains_global_main_commitment(&self) -> bool {
self.chip_scopes.contains(&InteractionScope::Global)
}
}

#[allow(unused_imports)]
Expand Down
2 changes: 0 additions & 2 deletions crates/recursion/circuit/src/witness/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,13 @@ where
let opening_proof = self.opening_proof.read(builder);
let public_values = self.public_values.read(builder);
let chip_ordering = self.chip_ordering.clone();
let chip_scopes = self.chip_scopes.clone();

ShardProofVariable {
commitment,
opened_values,
opening_proof,
public_values,
chip_ordering,
chip_scopes,
}
}

Expand Down
1 change: 0 additions & 1 deletion crates/sdk/src/provers/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ impl Prover<DefaultProverComponents> for MockProver {
query_openings: vec![],
},
chip_ordering: HashMap::new(),
chip_scopes: vec![],
public_values: vec![],
};

Expand Down
1 change: 0 additions & 1 deletion crates/stark/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,6 @@ where
opened_values: ShardOpenedValues { chips: opened_values },
opening_proof,
chip_ordering: all_chips_ordering,
chip_scopes: all_chip_scopes,
public_values: local_public_values,
})
}
Expand Down
5 changes: 0 additions & 5 deletions crates/stark/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ pub struct ShardProof<SC: StarkGenericConfig> {
pub opened_values: ShardOpenedValues<Challenge<SC>>,
pub opening_proof: OpeningProof<SC>,
pub chip_ordering: HashMap<String, usize>,
pub chip_scopes: Vec<InteractionScope>,
pub public_values: Vec<Val<SC>>,
}

Expand Down Expand Up @@ -151,10 +150,6 @@ impl<SC: StarkGenericConfig> ShardProof<SC> {
pub fn contains_global_memory_finalize(&self) -> bool {
self.chip_ordering.contains_key("MemoryGlobalFinalize")
}

pub fn contains_global_main_commitment(&self) -> bool {
self.chip_scopes.contains(&InteractionScope::Global)
}
}

#[derive(Serialize, Deserialize, Clone)]
Expand Down
3 changes: 2 additions & 1 deletion crates/stark/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ impl<SC: StarkGenericConfig, A: MachineAir<Val<SC>>> Verifier<SC, A> {
opened_values,
opening_proof,
chip_ordering,
chip_scopes,
public_values,
..
} = proof;
Expand All @@ -56,6 +55,8 @@ impl<SC: StarkGenericConfig, A: MachineAir<Val<SC>>> Verifier<SC, A> {
return Err(VerificationError::ChipOpeningLengthMismatch);
}

let chip_scopes = chips.iter().map(|chip| chip.commit_scope()).collect::<Vec<_>>();

// Assert that the byte multiplicities don't overflow.
let mut max_byte_lookup_mult = 0u64;
chips.iter().zip(opened_values.chips.iter()).for_each(|(chip, val)| {
Expand Down

0 comments on commit 87d5de2

Please sign in to comment.