Skip to content

Commit 3067960

Browse files
committed
feat: add provable params
1 parent 7d1eb7f commit 3067960

File tree

1 file changed

+56
-4
lines changed

1 file changed

+56
-4
lines changed

crates/stark-sdk/src/config/fri_params.rs

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,19 @@ impl FriParameters {
2424
}
2525

2626
pub fn standard_fast() -> Self {
27-
standard_fri_params_with_100_bits_conjectured_security(1)
27+
standard_fri_params_with_100_bits_security(1)
2828
}
2929

30+
#[deprecated(note = "use standard_with_100_bits_security instead")]
3031
pub fn standard_with_100_bits_conjectured_security(log_blowup: usize) -> Self {
32+
#[allow(deprecated)]
3133
standard_fri_params_with_100_bits_conjectured_security(log_blowup)
3234
}
3335

36+
pub fn standard_with_100_bits_security(log_blowup: usize) -> Self {
37+
standard_fri_params_with_100_bits_security(log_blowup)
38+
}
39+
3440
pub fn max_constraint_degree(&self) -> usize {
3541
(1 << self.log_blowup) + 1
3642
}
@@ -39,7 +45,7 @@ impl FriParameters {
3945
/// If the environment variable `OPENVM_FAST_TEST` is set to "1", then the parameters are **not
4046
/// secure** and meant for fast testing only.
4147
///
42-
/// In production, use `Self::standard_with_100_bits_conjectured_security` instead.
48+
/// In production, use `Self::standard_with_100_bits_security` instead.
4349
pub fn new_for_testing(log_blowup: usize) -> Self {
4450
if let Ok("1") = std::env::var("OPENVM_FAST_TEST").as_deref() {
4551
Self {
@@ -49,15 +55,61 @@ impl FriParameters {
4955
proof_of_work_bits: 0,
5056
}
5157
} else {
52-
Self::standard_with_100_bits_conjectured_security(log_blowup)
58+
Self::standard_with_100_bits_security(log_blowup)
5359
}
5460
}
5561
}
5662

63+
/// Pre-defined FRI parameters with 100 bits of provable security, meaning we do
64+
/// not rely on any conjectures about Reed–Solomon codes (e.g., about proximity
65+
/// gaps) or the ethSTARK Toy Problem Conjecture.
66+
///
67+
/// The value `num_queries` is chosen so that the verifier accepts a δ-far
68+
/// codeword for δ = (1 - 2**(-log_blowup)) with probability at most 2^{-80}.
69+
/// I.e., we target the unique-decoding radius. We require 20 PoW bits
70+
/// just before the query phase begins to boost the soundness to 100 bits.
71+
///
72+
/// Assumes that:
73+
/// - the challenge field has size at least 2^123
74+
/// - for `log_blowup = 1`, multi-FRI will be run with at most width 30000 at any level
75+
/// - for `log_blowup > 1`, multi-FRI will be run with at most width 2000 at any level
76+
pub fn standard_fri_params_with_100_bits_security(log_blowup: usize) -> FriParameters {
77+
let fri_params = match log_blowup {
78+
1 => FriParameters {
79+
log_blowup,
80+
log_final_poly_len: 0,
81+
num_queries: 193,
82+
proof_of_work_bits: 20,
83+
},
84+
2 => FriParameters {
85+
log_blowup,
86+
log_final_poly_len: 0,
87+
num_queries: 118,
88+
proof_of_work_bits: 20,
89+
},
90+
3 => FriParameters {
91+
log_blowup,
92+
log_final_poly_len: 0,
93+
num_queries: 97,
94+
proof_of_work_bits: 20,
95+
},
96+
4 => FriParameters {
97+
log_blowup,
98+
log_final_poly_len: 0,
99+
num_queries: 88,
100+
proof_of_work_bits: 20,
101+
},
102+
_ => todo!("No standard FRI params defined for log blowup {log_blowup}",),
103+
};
104+
tracing::debug!("FRI parameters | log_blowup: {log_blowup:<2} | num_queries: {:<2} | proof_of_work_bits: {:<2}", fri_params.num_queries, fri_params.proof_of_work_bits);
105+
fri_params
106+
}
107+
57108
/// Pre-defined FRI parameters with 100 bits of conjectured security.
58109
/// Security bits calculated following ethSTARK (<https://eprint.iacr.org/2021/582.pdf>) 5.10.1 eq (19)
59110
///
60111
/// Assumes that the challenge field used as more than 100 bits.
112+
#[deprecated(note = "use standard_fri_params_with_100_bits_security instead")]
61113
pub fn standard_fri_params_with_100_bits_conjectured_security(log_blowup: usize) -> FriParameters {
62114
let fri_params = match log_blowup {
63115
// plonky2 standard fast config uses num_queries=84: https://github.com/0xPolygonZero/plonky2/blob/41dc325e61ab8d4c0491e68e667c35a4e8173ffa/starky/src/config.rs#L49
@@ -109,7 +161,7 @@ impl SecurityParameters {
109161
}
110162
pub fn standard_100_bits_with_fri_log_blowup(log_blowup: usize) -> Self {
111163
Self {
112-
fri_params: FriParameters::standard_with_100_bits_conjectured_security(log_blowup),
164+
fri_params: FriParameters::standard_with_100_bits_security(log_blowup),
113165
log_up_params: log_up_security_params_baby_bear_100_bits(),
114166
}
115167
}

0 commit comments

Comments
 (0)