2021-04-06 13:14:59 -07:00
|
|
|
use std::time::Instant;
|
|
|
|
|
|
|
|
|
|
use plonky2::field::crandall_field::CrandallField;
|
2021-07-29 22:00:29 -07:00
|
|
|
use plonky2::field::field_types::Field;
|
2021-04-23 12:35:19 -07:00
|
|
|
use plonky2::polynomial::polynomial::PolynomialValues;
|
2021-06-10 14:10:35 -07:00
|
|
|
use rayon::prelude::*;
|
2021-04-06 13:14:59 -07:00
|
|
|
|
|
|
|
|
type F = CrandallField;
|
|
|
|
|
|
2021-05-22 09:38:07 -07:00
|
|
|
// This is an estimate of how many LDEs the prover will compute. The biggest component, 86, comes
|
|
|
|
|
// from wire polynomials which "store" the outputs of S-boxes in our Poseidon gate.
|
|
|
|
|
const NUM_LDES: usize = 8 + 8 + 3 + 86 + 3 + 8;
|
|
|
|
|
|
2021-05-22 09:46:02 -07:00
|
|
|
const DEGREE: usize = 1 << 14;
|
2021-05-22 09:38:07 -07:00
|
|
|
|
|
|
|
|
const RATE_BITS: usize = 3;
|
2021-04-06 13:14:59 -07:00
|
|
|
|
|
|
|
|
fn main() {
|
2021-05-22 09:38:07 -07:00
|
|
|
// We start with random polynomials.
|
|
|
|
|
let all_poly_values = (0..NUM_LDES)
|
|
|
|
|
.map(|_| PolynomialValues::new(F::rand_vec(DEGREE)))
|
|
|
|
|
.collect::<Vec<_>>();
|
2021-04-06 13:14:59 -07:00
|
|
|
|
|
|
|
|
let start = Instant::now();
|
2021-05-22 09:38:07 -07:00
|
|
|
|
|
|
|
|
all_poly_values.into_par_iter().for_each(|poly_values| {
|
2021-04-06 13:14:59 -07:00
|
|
|
let start = Instant::now();
|
2021-05-22 09:38:07 -07:00
|
|
|
let lde = poly_values.lde(RATE_BITS);
|
2021-04-06 13:14:59 -07:00
|
|
|
let duration = start.elapsed();
|
|
|
|
|
println!("LDE took {:?}", duration);
|
2021-05-22 09:38:07 -07:00
|
|
|
println!("LDE result: {:?}", lde.values[0]);
|
2021-04-06 13:14:59 -07:00
|
|
|
});
|
2021-05-22 09:44:34 -07:00
|
|
|
println!("All LDEs took {:?}", start.elapsed());
|
2021-04-06 13:14:59 -07:00
|
|
|
}
|