mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-04 23:03:08 +00:00
Add some FRI params & clean up FFT a bit
This commit is contained in:
parent
13cc76316c
commit
1480876c9a
@ -50,7 +50,7 @@ impl Field for CrandallField {
|
||||
*self * *self * *self
|
||||
}
|
||||
|
||||
fn inverse(&self) -> Self {
|
||||
fn try_inverse(&self) -> Option<Self> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
|
||||
@ -34,10 +34,10 @@ impl<F: Field> FftPrecomputation<F> {
|
||||
}
|
||||
}
|
||||
|
||||
// pub fn fft<F: Field>(coefficients: &[F]) -> Vec<F> {
|
||||
// let precomputation = fft_precompute(coefficients.len());
|
||||
// fft_with_precomputation(coefficients, &precomputation)
|
||||
// }
|
||||
pub fn fft<F: Field>(coefficients: Vec<F>) -> Vec<F> {
|
||||
let precomputation = fft_precompute(coefficients.len());
|
||||
fft_with_precomputation_power_of_2(coefficients, &precomputation)
|
||||
}
|
||||
|
||||
pub fn fft_precompute<F: Field>(degree: usize) -> FftPrecomputation<F> {
|
||||
let degree_pow = log2_ceil(degree);
|
||||
@ -54,11 +54,11 @@ pub fn fft_precompute<F: Field>(degree: usize) -> FftPrecomputation<F> {
|
||||
}
|
||||
|
||||
pub fn ifft_with_precomputation_power_of_2<F: Field>(
|
||||
points: &[F],
|
||||
points: Vec<F>,
|
||||
precomputation: &FftPrecomputation<F>,
|
||||
) -> Vec<F> {
|
||||
let n = points.len();
|
||||
let n_inv = Field(n as u64).multiplicative_inverse().unwrap();
|
||||
let n_inv = F::from_canonical_usize(n).try_inverse().unwrap();
|
||||
let mut result = fft_with_precomputation_power_of_2(points, precomputation);
|
||||
|
||||
// We reverse all values except the first, and divide each by n.
|
||||
|
||||
@ -25,7 +25,11 @@ pub trait Field: 'static
|
||||
fn cube(&self) -> Self;
|
||||
|
||||
/// Compute the multiplicative inverse of this field element.
|
||||
fn inverse(&self) -> Self;
|
||||
fn try_inverse(&self) -> Option<Self>;
|
||||
|
||||
fn inverse(&self) -> Self {
|
||||
self.try_inverse().expect("Tried to invert zero")
|
||||
}
|
||||
|
||||
fn primitive_root_of_unity(n_power: usize) -> Self;
|
||||
|
||||
|
||||
21
src/fri.rs
Normal file
21
src/fri.rs
Normal file
@ -0,0 +1,21 @@
|
||||
/// Somewhat arbitrary. Smaller values will increase delta, but with diminishing returns,
|
||||
/// while increasing L, potentially requiring more challenge points.
|
||||
const EPSILON: f64 = 0.01;
|
||||
|
||||
fn fri_delta(rate_log: usize, conjecture: bool) -> f64 {
|
||||
let rate = (1 << rate_log) as f64;
|
||||
if conjecture {
|
||||
todo!()
|
||||
} else {
|
||||
return 1.0 - rate.sqrt() - EPSILON;
|
||||
}
|
||||
}
|
||||
|
||||
fn fri_l(rate_log: usize, conjecture: bool) -> f64 {
|
||||
let rate = (1 << rate_log) as f64;
|
||||
if conjecture {
|
||||
todo!()
|
||||
} else {
|
||||
return 1.0 / (2.0 * EPSILON * rate.sqrt());
|
||||
}
|
||||
}
|
||||
@ -13,6 +13,7 @@ use crate::util::log2_ceil;
|
||||
mod circuit_data;
|
||||
mod constraint_polynomial;
|
||||
mod field;
|
||||
mod fri;
|
||||
mod gates;
|
||||
mod generator;
|
||||
mod gmimc;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user