Skip to content

Commit

Permalink
Add security_bites function to PcsConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
alon-f committed Jan 23, 2025
1 parent f4a4f6e commit 687f4ea
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
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,7 @@ pub struct PcsConfig {
pub pow_bits: u32,
pub fri_config: FriConfig,
}

impl Default for PcsConfig {
fn default() -> Self {
Self {
Expand All @@ -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);
}
}
2 changes: 2 additions & 0 deletions crates/prover/src/examples/blake/air.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,8 @@ pub fn verify_blake<MC: MerkleChannel>(
}: BlakeProof<MC::H>,
) -> Result<(), VerificationError> {
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

0 comments on commit 687f4ea

Please sign in to comment.