Implement fft_g1
This commit is contained in:
parent
7b9643f17e
commit
44fdd136ac
|
@ -15,6 +15,7 @@ ark-poly = { version = "0.4.2" }
|
|||
ark-poly-commit = { version = "0.4.0" }
|
||||
ark-serialize = { version = "0.4" }
|
||||
blst = "0.3.11"
|
||||
derive_more = "0.99"
|
||||
num-bigint = "0.4.4"
|
||||
thiserror = "1.0.58"
|
||||
num-traits = "0.2.18"
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
use ark_bls12_381::{Fr, G1Affine};
|
||||
use ark_ec::CurveGroup;
|
||||
|
||||
pub fn fft_g1(vals: &[G1Affine], roots_of_unity: &[Fr]) -> Vec<G1Affine> {
|
||||
if vals.len() == 1 {
|
||||
return vals.to_vec();
|
||||
}
|
||||
let half_roots: Vec<_> = roots_of_unity.iter().step_by(2).copied().collect();
|
||||
|
||||
let l = fft_g1(
|
||||
vals.iter()
|
||||
.step_by(2)
|
||||
.copied()
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice(),
|
||||
half_roots.as_slice(),
|
||||
);
|
||||
|
||||
let r = fft_g1(
|
||||
vals.iter()
|
||||
.skip(1)
|
||||
.step_by(2)
|
||||
.copied()
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice(),
|
||||
half_roots.as_slice(),
|
||||
);
|
||||
|
||||
let y_times_root = r
|
||||
.into_iter()
|
||||
.cycle()
|
||||
.enumerate()
|
||||
.map(|(i, y)| (y * roots_of_unity[i % vals.len()]).into_affine());
|
||||
|
||||
l.into_iter()
|
||||
.cycle()
|
||||
.take(vals.len())
|
||||
.zip(y_times_root)
|
||||
.enumerate()
|
||||
.map(|(i, (x, y_times_root))| {
|
||||
if i < vals.len() / 2 {
|
||||
x + y_times_root
|
||||
} else {
|
||||
x - y_times_root
|
||||
}
|
||||
.into_affine()
|
||||
})
|
||||
.collect()
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
use crate::{GlobalParameters, Polynomial, Proof};
|
||||
use ark_bls12_381::{Bls12_381, Fq, Fr, G1Affine, G1Projective};
|
||||
use ark_ec::mnt4::G1Prepared;
|
||||
use ark_ec::{AffineRepr, CurveGroup};
|
||||
|
||||
use ark_poly::univariate::DensePolynomial;
|
||||
use ark_poly::{EvaluationDomain, Radix2EvaluationDomain};
|
||||
use num_traits::Zero;
|
||||
fn toeplitz1(global_parameters: &GlobalParameters, polynomial_degree: usize) -> Vec<G1Projective> {
|
||||
debug_assert_eq!(global_parameters.powers_of_g.len(), polynomial_degree);
|
||||
debug_assert!(polynomial_degree.is_power_of_two());
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn fk20_batch_generate_elements_proofs(
|
||||
polynomial: &DensePolynomial<Fr>,
|
||||
global_parameters: &GlobalParameters,
|
||||
) -> Vec<Proof> {
|
||||
unimplemented!()
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
pub mod common;
|
||||
mod fft;
|
||||
mod fk20;
|
||||
pub mod global_parameters;
|
||||
pub mod kzg;
|
||||
pub mod rs;
|
||||
|
|
Loading…
Reference in New Issue