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

perf: Unify FRI configs at 100 bits #1929

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions crates/recursion/core/src/stark/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<OuterChallengeMmcs> {
let perm = outer_perm();
let hash = OuterHash::new(perm.clone()).unwrap();
Expand All @@ -81,13 +82,14 @@ pub fn outer_fri_config() -> FriConfig<OuterChallengeMmcs> {
} 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<OuterChallengeMmcs> {
let perm = outer_perm();
let hash = OuterHash::new(perm.clone()).unwrap();
Expand All @@ -98,7 +100,7 @@ pub fn outer_fri_config_with_blowup(log_blowup: usize) -> FriConfig<OuterChallen
} else {
match std::env::var("FRI_QUERIES") {
Ok(value) => value.parse().unwrap(),
Err(_) => 100 / log_blowup,
Err(_) => 84 / log_blowup,
}
};
FriConfig { log_blowup, num_queries, proof_of_work_bits: 16, mmcs: challenge_mmcs }
Expand Down
15 changes: 10 additions & 5 deletions crates/stark/src/bb31_poseidon2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<InnerChallengeMmcs> {
let perm = inner_perm();
Expand All @@ -60,12 +61,13 @@ pub fn sp1_fri_config() -> FriConfig<InnerChallengeMmcs> {
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<InnerChallengeMmcs> {
let perm = inner_perm();
Expand All @@ -74,7 +76,7 @@ pub fn inner_fri_config() -> FriConfig<InnerChallengeMmcs> {
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 }
}
Expand Down Expand Up @@ -208,40 +210,43 @@ pub mod baby_bear_poseidon2 {
}

#[must_use]
/// This targets by default 100 bits of security.
pub fn default_fri_config() -> FriConfig<ChallengeMmcs> {
let perm = my_perm();
let hash = MyHash::new(perm.clone());
let compress = MyCompress::new(perm.clone());
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<ChallengeMmcs> {
let perm = my_perm();
let hash = MyHash::new(perm.clone());
let compress = MyCompress::new(perm.clone());
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<ChallengeMmcs> {
let perm = my_perm();
let hash = MyHash::new(perm.clone());
let compress = MyCompress::new(perm.clone());
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 }
}
Expand Down