Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PcsConfig to CommitmentSchemeProof #996

Merged
merged 1 commit into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 87 additions & 83 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/prover/src/core/fri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use crate::core::vcs::verifier::{MerkleVerificationError, MerkleVerifier};

/// FRI proof config
// TODO(andrew): Support different step sizes.
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct FriConfig {
pub log_blowup_factor: u32,
pub log_last_layer_degree_bound: u32,
Expand Down
4 changes: 3 additions & 1 deletion crates/prover/src/core/pcs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pub mod quotients;
mod utils;
mod verifier;

use serde::{Deserialize, Serialize};

pub use self::prover::{
CommitmentSchemeProof, CommitmentSchemeProver, CommitmentTreeProver, TreeBuilder,
};
Expand All @@ -26,7 +28,7 @@ pub struct TreeSubspan {
pub col_end: usize,
}

#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct PcsConfig {
pub pow_bits: u32,
pub fri_config: FriConfig,
Expand Down
2 changes: 2 additions & 0 deletions crates/prover/src/core/pcs/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ impl<'a, B: BackendForChannel<MC>, MC: MerkleChannel> CommitmentSchemeProver<'a,
queried_values,
proof_of_work,
fri_proof,
config: self.config,
}
}
}
Expand All @@ -155,6 +156,7 @@ pub struct CommitmentSchemeProof<H: MerkleHasher> {
pub queried_values: TreeVec<Vec<BaseField>>,
pub proof_of_work: u64,
pub fri_proof: FriProof<H>,
pub config: PcsConfig,
}

pub struct TreeBuilder<'a, 'b, B: BackendForChannel<MC>, MC: MerkleChannel> {
Expand Down
3 changes: 3 additions & 0 deletions crates/prover/src/core/prover/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ impl<H: MerkleHasher> StarkProof<H> {
queried_values,
proof_of_work: _,
fri_proof,
config: _,
} = commitment_scheme_proof;

let FriProof {
Expand Down Expand Up @@ -326,13 +327,15 @@ impl<H: MerkleHasher> SizeEstimate for CommitmentSchemeProof<H> {
queried_values,
proof_of_work,
fri_proof,
config,
} = self;
commitments.size_estimate()
+ sampled_values.size_estimate()
+ decommitments.size_estimate()
+ queried_values.size_estimate()
+ mem::size_of_val(proof_of_work)
+ fri_proof.size_estimate()
+ mem::size_of_val(config)
}
}

Expand Down
6 changes: 3 additions & 3 deletions crates/prover/src/examples/blake/air.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,10 +508,10 @@ pub fn verify_blake<MC: MerkleChannel>(
stmt1,
stark_proof,
}: BlakeProof<MC::H>,
config: PcsConfig,
) -> Result<(), VerificationError> {
let channel = &mut MC::C::default();
let commitment_scheme = &mut CommitmentSchemeVerifier::<MC>::new(config);
// TODO(alonf): Consider mixing the config into the channel.
let commitment_scheme = &mut CommitmentSchemeVerifier::<MC>::new(stark_proof.config);

let log_sizes = stmt0.log_sizes();

Expand Down Expand Up @@ -579,6 +579,6 @@ mod tests {
let proof = prove_blake::<Blake2sMerkleChannel>(log_n_instances, config);

// Verify.
verify_blake::<Blake2sMerkleChannel>(proof, config).unwrap();
verify_blake::<Blake2sMerkleChannel>(proof).unwrap();
}
}
3 changes: 2 additions & 1 deletion crates/prover/src/examples/poseidon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,8 @@ mod tests {
// Verify.
// TODO: Create Air instance independently.
let channel = &mut Blake2sChannel::default();
let commitment_scheme = &mut CommitmentSchemeVerifier::<Blake2sMerkleChannel>::new(config);
let commitment_scheme =
&mut CommitmentSchemeVerifier::<Blake2sMerkleChannel>::new(proof.config);

// Decommit.
// Retrieve the expected column sizes in each commitment interaction, from the AIR.
Expand Down
6 changes: 3 additions & 3 deletions crates/prover/src/examples/state_machine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ pub fn prove_state_machine(
}

pub fn verify_state_machine(
config: PcsConfig,
channel: &mut Blake2sChannel,
components: StateMachineComponents,
proof: StateMachineProof<Blake2sMerkleHasher>,
) -> Result<(), VerificationError> {
let commitment_scheme = &mut CommitmentSchemeVerifier::<Blake2sMerkleChannel>::new(config);
let commitment_scheme =
&mut CommitmentSchemeVerifier::<Blake2sMerkleChannel>::new(proof.stark_proof.config);
// Decommit.
// Retrieve the expected column sizes in each commitment interaction, from the AIR.
let sizes = proof.stmt0.log_sizes();
Expand Down Expand Up @@ -308,7 +308,7 @@ mod tests {
let (components, proof, _) =
prove_state_machine(log_n_rows, initial_state, config, prover_channel, false);

verify_state_machine(config, verifier_channel, components, proof).unwrap();
verify_state_machine(verifier_channel, components, proof).unwrap();
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/prover/src/examples/wide_fibonacci/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ mod tests {
// Verify.
let verifier_channel = &mut Poseidon252Channel::default();
let commitment_scheme =
&mut CommitmentSchemeVerifier::<Poseidon252MerkleChannel>::new(config);
&mut CommitmentSchemeVerifier::<Poseidon252MerkleChannel>::new(proof.config);

// Retrieve the expected column sizes in each commitment interaction, from the AIR.
let sizes = component.trace_log_degree_bounds();
Expand Down
6 changes: 4 additions & 2 deletions crates/prover/src/examples/xor/gkr_lookups/mle_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,8 @@ mod tests {

let log_sizes = components.column_log_sizes();
let channel = &mut Blake2sChannel::default();
let commitment_scheme = &mut CommitmentSchemeVerifier::<Blake2sMerkleChannel>::new(config);
let commitment_scheme =
&mut CommitmentSchemeVerifier::<Blake2sMerkleChannel>::new(proof.config);
commitment_scheme.commit(proof.commitments[0], &[], channel);
commitment_scheme.commit(proof.commitments[1], &log_sizes[1], channel);
commitment_scheme.commit(proof.commitments[2], &log_sizes[2], channel);
Expand Down Expand Up @@ -924,7 +925,8 @@ mod tests {

let log_sizes = components.column_log_sizes();
let channel = &mut Blake2sChannel::default();
let commitment_scheme = &mut CommitmentSchemeVerifier::<Blake2sMerkleChannel>::new(config);
let commitment_scheme =
&mut CommitmentSchemeVerifier::<Blake2sMerkleChannel>::new(proof.config);
commitment_scheme.commit(proof.commitments[0], &[], channel);
commitment_scheme.commit(proof.commitments[1], &log_sizes[1], channel);
commitment_scheme.commit(proof.commitments[2], &log_sizes[2], channel);
Expand Down
Loading