From 9feb687f08ea59d825c9f0af553e975decc56632 Mon Sep 17 00:00:00 2001 From: Alon Frydberg Date: Thu, 23 Jan 2025 10:39:15 +0200 Subject: [PATCH] Add security_bites function to PcsConfig --- crates/prover/src/core/fri.rs | 4 ++++ crates/prover/src/core/pcs/mod.rs | 19 +++++++++++++++++++ crates/prover/src/examples/blake/air.rs | 4 +++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/crates/prover/src/core/fri.rs b/crates/prover/src/core/fri.rs index 30ad38aac..a80fcf234 100644 --- a/crates/prover/src/core/fri.rs +++ b/crates/prover/src/core/fri.rs @@ -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 + PolyOps + Sized + ColumnOps { diff --git a/crates/prover/src/core/pcs/mod.rs b/crates/prover/src/core/pcs/mod.rs index ab415dbae..1b7167ba8 100644 --- a/crates/prover/src/core/pcs/mod.rs +++ b/crates/prover/src/core/pcs/mod.rs @@ -33,6 +33,7 @@ pub struct PcsConfig { pub pow_bits: u32, pub fri_config: FriConfig, } + impl Default for PcsConfig { fn default() -> Self { Self { @@ -41,3 +42,21 @@ impl Default for PcsConfig { } } } + +impl PcsConfig { + pub const fn security_bits(&self) -> u32 { + self.pow_bits + self.fri_config.security_bits() + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_security_bits() { + let config = super::PcsConfig { + pow_bits: 26, + fri_config: super::FriConfig::new(1, 1, 70), + }; + assert!(config.security_bits() == 96); + } +} diff --git a/crates/prover/src/examples/blake/air.rs b/crates/prover/src/examples/blake/air.rs index e7be746b8..6f58bc615 100644 --- a/crates/prover/src/examples/blake/air.rs +++ b/crates/prover/src/examples/blake/air.rs @@ -509,8 +509,10 @@ pub fn verify_blake( stark_proof, }: BlakeProof, ) -> 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::::new(stark_proof.config); let log_sizes = stmt0.log_sizes();