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 security_bits function to PcsConfig #998

Merged
merged 1 commit into from
Jan 28, 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
4 changes: 4 additions & 0 deletions crates/prover/src/core/fri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ impl FriConfig {
const fn last_layer_domain_size(&self) -> usize {
1 << (self.log_last_layer_degree_bound + self.log_blowup_factor)
}

pub const fn security_bits(&self) -> u32 {
self.log_blowup_factor * self.n_queries as u32
}
}

pub trait FriOps: ColumnOps<BaseField> + PolyOps + Sized + ColumnOps<SecureField> {
Expand Down
19 changes: 19 additions & 0 deletions crates/prover/src/core/pcs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ pub struct PcsConfig {
pub pow_bits: u32,
pub fri_config: FriConfig,
}
impl PcsConfig {
pub const fn security_bits(&self) -> u32 {
self.pow_bits + self.fri_config.security_bits()
}
}

impl Default for PcsConfig {
fn default() -> Self {
Self {
Expand All @@ -41,3 +47,16 @@ impl Default for PcsConfig {
}
}
}

#[cfg(test)]
mod tests {
#[test]
fn test_security_bits() {
let config = super::PcsConfig {
pow_bits: 42,
fri_config: super::FriConfig::new(10, 10, 70),
};
// 10 * 70 + 42 = 742
assert!(config.security_bits() == 742);
}
}
4 changes: 3 additions & 1 deletion crates/prover/src/examples/blake/air.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,10 @@ pub fn verify_blake<MC: MerkleChannel>(
stark_proof,
}: BlakeProof<MC::H>,
) -> Result<(), VerificationError> {
let channel = &mut MC::C::default();
// TODO(alonf): Consider mixing the config into the channel.
let channel = &mut MC::C::default();
const REQUIRED_SECURITY_BITS: u32 = 5;
assert!(stark_proof.config.security_bits() >= REQUIRED_SECURITY_BITS);
let commitment_scheme = &mut CommitmentSchemeVerifier::<MC>::new(stark_proof.config);

let log_sizes = stmt0.log_sizes();
Expand Down
Loading