Comment and test for coset_ifft

This commit is contained in:
wborgeaud 2021-06-25 10:20:20 +02:00
parent 2e9d3f768e
commit 727919b14f
2 changed files with 30 additions and 2 deletions

View File

@ -30,7 +30,10 @@ impl<F: Field> ListPolynomialCommitment<F> {
/// Creates a list polynomial commitment for the polynomials interpolating the values in `values`.
pub fn new(values: Vec<PolynomialValues<F>>, rate_bits: usize, blinding: bool) -> Self {
let degree = values[0].len();
let polynomials = values.iter().map(|v| v.clone().ifft()).collect::<Vec<_>>();
let polynomials = values
.par_iter()
.map(|v| v.clone().ifft())
.collect::<Vec<_>>();
let lde_values = timed!(
Self::lde_values(&polynomials, rate_bits, blinding),
"to compute LDE"

View File

@ -36,6 +36,7 @@ impl<F: Field> PolynomialValues<F> {
ifft(self)
}
/// Returns the polynomial whose evaluation on the coset `shift*H` is `self`.
pub fn coset_ifft(self, shift: F) -> PolynomialCoeffs<F> {
let mut shifted_coeffs = self.ifft();
shifted_coeffs
@ -195,6 +196,7 @@ impl<F: Field> PolynomialCoeffs<F> {
fft(self)
}
/// Returns the evaluation of the polynomial on the coset `shift*H`.
pub fn coset_fft(self, shift: F) -> PolynomialValues<F> {
let modified_poly: Self = shift
.powers()
@ -393,8 +395,31 @@ mod tests {
.into_iter()
.map(|x| poly.eval(x))
.collect::<Vec<_>>();
assert_eq!(coset_evals, naive_coset_evals);
let ifft_coeffs = PolynomialValues::new(coset_evals).coset_ifft(shift);
assert_eq!(poly, ifft_coeffs.into());
}
#[test]
fn test_coset_ifft() {
type F = CrandallField;
let k = 8;
let n = 1 << k;
let evals = PolynomialValues::new(F::rand_vec(n));
let shift = F::rand();
let coeffs = evals.clone().coset_ifft(shift);
let generator = F::primitive_root_of_unity(k);
let naive_coset_evals = F::cyclic_subgroup_coset_known_order(generator, shift, n)
.into_iter()
.map(|x| coeffs.eval(x))
.collect::<Vec<_>>();
assert_eq!(evals, naive_coset_evals.into());
let fft_evals = coeffs.coset_fft(shift);
assert_eq!(evals, fft_evals);
}
#[test]