shockwave-plus/tensor_pcs/src/rs_config/ecfft.rs
tensor_pcs/src/rs_config/ecfft.rsRaw
1use crate::FieldExt;
2use ecfft::{prepare_domain, prepare_matrices, GoodCurve, Matrix2x2};
3
4#[derive(Clone, Debug)]
5pub struct ECFFTConfig<F: FieldExt> {
6 pub domain: Vec<Vec<F>>,
7 pub matrices: Vec<Vec<Matrix2x2<F>>>,
8 pub inverse_matrices: Vec<Vec<Matrix2x2<F>>>,
9}
10
11pub fn gen_config<F: FieldExt>(num_cols: usize) -> ECFFTConfig<F> {
12 assert!(num_cols.is_power_of_two());
13 let expansion_factor = 2;
14 let codeword_len = num_cols * expansion_factor;
15
16 let k = (codeword_len as f64).log2() as usize;
17
18 let good_curve = GoodCurve::find_k(k);
19 let domain = prepare_domain(good_curve);
20 let (matrices, inverse_matrices) = prepare_matrices(&domain);
21
22 ECFFTConfig {
23 domain,
24 matrices,
25 inverse_matrices,
26 }
27}