Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: Unify FRI configs at 100 bits
Browse files Browse the repository at this point in the history
Nashtare committed Jan 13, 2025

Verified

This commit was signed with the committer’s verified signature.
fritzy Nathan Fritz
1 parent a91f59c commit fa592a8
Showing 2 changed files with 14 additions and 7 deletions.
6 changes: 4 additions & 2 deletions crates/recursion/core/src/stark/config.rs
Original file line number Diff line number Diff line change
@@ -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();
@@ -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();
@@ -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 }
15 changes: 10 additions & 5 deletions crates/stark/src/bb31_poseidon2.rs
Original file line number Diff line number Diff line change
@@ -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();
@@ -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();
@@ -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 }
}
@@ -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 }
}

0 comments on commit fa592a8

Please sign in to comment.