From 96daa70216b5ba3a395d482182da117e4b5b83ed Mon Sep 17 00:00:00 2001 From: Robin Salen Date: Mon, 13 Jan 2025 10:52:07 -0500 Subject: [PATCH] perf: Unify FRI configs at 100 bits --- crates/recursion/core/src/stark/config.rs | 6 ++++-- crates/stark/src/bb31_poseidon2.rs | 15 ++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/crates/recursion/core/src/stark/config.rs b/crates/recursion/core/src/stark/config.rs index 48e812146b..dabe913e17 100644 --- a/crates/recursion/core/src/stark/config.rs +++ b/crates/recursion/core/src/stark/config.rs @@ -71,6 +71,7 @@ pub fn outer_perm() -> OuterPerm { } /// The FRI config for outer recursion. +/// This targets by default 100 bits of security. pub fn outer_fri_config() -> FriConfig { let perm = outer_perm(); let hash = OuterHash::new(perm.clone()).unwrap(); @@ -81,13 +82,14 @@ pub fn outer_fri_config() -> FriConfig { } else { match std::env::var("FRI_QUERIES") { Ok(value) => value.parse().unwrap(), - Err(_) => 25, + Err(_) => 21, } }; FriConfig { log_blowup: 4, num_queries, proof_of_work_bits: 16, mmcs: challenge_mmcs } } /// The FRI config for outer recursion. +/// This targets by default 100 bits of security. pub fn outer_fri_config_with_blowup(log_blowup: usize) -> FriConfig { let perm = outer_perm(); let hash = OuterHash::new(perm.clone()).unwrap(); @@ -98,7 +100,7 @@ pub fn outer_fri_config_with_blowup(log_blowup: usize) -> FriConfig value.parse().unwrap(), - Err(_) => 100 / log_blowup, + Err(_) => 84 / log_blowup, } }; FriConfig { log_blowup, num_queries, proof_of_work_bits: 16, mmcs: challenge_mmcs } diff --git a/crates/stark/src/bb31_poseidon2.rs b/crates/stark/src/bb31_poseidon2.rs index 8c610f54e8..d6b11303cf 100644 --- a/crates/stark/src/bb31_poseidon2.rs +++ b/crates/stark/src/bb31_poseidon2.rs @@ -52,6 +52,7 @@ pub fn inner_perm() -> InnerPerm { } /// The FRI config for sp1 proofs. +/// This targets by default 100 bits of security. #[must_use] pub fn sp1_fri_config() -> FriConfig { let perm = inner_perm(); @@ -60,12 +61,13 @@ pub fn sp1_fri_config() -> FriConfig { let challenge_mmcs = InnerChallengeMmcs::new(InnerValMmcs::new(hash, compress)); let num_queries = match std::env::var("FRI_QUERIES") { Ok(value) => value.parse().unwrap(), - Err(_) => 100, + Err(_) => 84, }; FriConfig { log_blowup: 1, num_queries, proof_of_work_bits: 16, mmcs: challenge_mmcs } } /// The FRI config for inner recursion. +/// This targets by default 100 bits of security. #[must_use] pub fn inner_fri_config() -> FriConfig { let perm = inner_perm(); @@ -74,7 +76,7 @@ pub fn inner_fri_config() -> FriConfig { let challenge_mmcs = InnerChallengeMmcs::new(InnerValMmcs::new(hash, compress)); let num_queries = match std::env::var("FRI_QUERIES") { Ok(value) => value.parse().unwrap(), - Err(_) => 100, + Err(_) => 84, }; FriConfig { log_blowup: 1, num_queries, proof_of_work_bits: 16, mmcs: challenge_mmcs } } @@ -208,6 +210,7 @@ pub mod baby_bear_poseidon2 { } #[must_use] + /// This targets by default 100 bits of security. pub fn default_fri_config() -> FriConfig { let perm = my_perm(); let hash = MyHash::new(perm.clone()); @@ -215,12 +218,13 @@ pub mod baby_bear_poseidon2 { let challenge_mmcs = ChallengeMmcs::new(ValMmcs::new(hash, compress)); let num_queries = match std::env::var("FRI_QUERIES") { Ok(value) => value.parse().unwrap(), - Err(_) => 100, + Err(_) => 84, }; FriConfig { log_blowup: 1, num_queries, proof_of_work_bits: 16, mmcs: challenge_mmcs } } #[must_use] + /// This targets by default 100 bits of security. pub fn compressed_fri_config() -> FriConfig { let perm = my_perm(); let hash = MyHash::new(perm.clone()); @@ -228,12 +232,13 @@ pub mod baby_bear_poseidon2 { let challenge_mmcs = ChallengeMmcs::new(ValMmcs::new(hash, compress)); let num_queries = match std::env::var("FRI_QUERIES") { Ok(value) => value.parse().unwrap(), - Err(_) => 50, + Err(_) => 42, }; FriConfig { log_blowup: 2, num_queries, proof_of_work_bits: 16, mmcs: challenge_mmcs } } #[must_use] + /// This targets by default 100 bits of security. pub fn ultra_compressed_fri_config() -> FriConfig { let perm = my_perm(); let hash = MyHash::new(perm.clone()); @@ -241,7 +246,7 @@ pub mod baby_bear_poseidon2 { let challenge_mmcs = ChallengeMmcs::new(ValMmcs::new(hash, compress)); let num_queries = match std::env::var("FRI_QUERIES") { Ok(value) => value.parse().unwrap(), - Err(_) => 33, + Err(_) => 28, }; FriConfig { log_blowup: 3, num_queries, proof_of_work_bits: 16, mmcs: challenge_mmcs } }