plonky2/src/fri/mod.rs

45 lines
1.4 KiB
Rust
Raw Normal View History

2021-05-05 18:23:59 +02:00
pub mod prover;
2021-06-04 15:40:54 +02:00
mod recursive_verifier;
2021-05-05 18:23:59 +02:00
pub mod verifier;
/// Somewhat arbitrary. Smaller values will increase delta, but with diminishing returns,
/// while increasing L, potentially requiring more challenge points.
const EPSILON: f64 = 0.01;
2021-05-06 17:09:55 +02:00
#[derive(Debug, Clone, Eq, PartialEq)]
2021-05-05 18:23:59 +02:00
pub struct FriConfig {
pub proof_of_work_bits: u32,
/// The arity of each FRI reduction step, expressed (i.e. the log2 of the actual arity).
/// For example, `[3, 2, 1]` would describe a FRI reduction tree with 8-to-1 reduction, then
/// a 4-to-1 reduction, then a 2-to-1 reduction. After these reductions, the reduced polynomial
/// is sent directly.
pub reduction_arity_bits: Vec<usize>,
/// Number of query rounds to perform.
pub num_query_rounds: usize,
2021-06-01 19:13:22 -07:00
}
2021-05-05 18:23:59 +02:00
fn fri_delta(rate_log: usize, conjecture: bool) -> f64 {
let rate = (1 << rate_log) as f64;
if conjecture {
// See Conjecture 2.3 in DEEP-FRI.
1.0 - rate - EPSILON
} else {
// See the Johnson radius.
1.0 - rate.sqrt() - EPSILON
}
}
fn fri_l(codeword_len: usize, rate_log: usize, conjecture: bool) -> f64 {
let rate = (1 << rate_log) as f64;
if conjecture {
// See Conjecture 2.3 in DEEP-FRI.
// We assume the conjecture holds with a constant of 1 (as do other STARK implementations).
(codeword_len as f64) / EPSILON
} else {
// See the Johnson bound.
1.0 / (2.0 * EPSILON * rate.sqrt())
}
}