diff --git a/src/plonk_common.rs b/src/plonk_common.rs index 99ba585e..2ae5ec01 100644 --- a/src/plonk_common.rs +++ b/src/plonk_common.rs @@ -112,18 +112,20 @@ pub(crate) fn eval_vanishing_poly, const D: usize>( // The partial products considered for this iteration of `i`. let current_partial_products = &partial_products[i * num_prods..(i + 1) * num_prods]; - // Check the numerator partial products. + // Check the quotient partial products. let mut partial_product_check = check_partial_products("ient_values, current_partial_products, max_degree); + // The first checks are of the form `q - n/d` which is a rational function not a polynomial. + // We multiply them by `d` to get checks of the form `q*d - n` which low-degree polynomials. denominator_values - .chunks(max_degree - 1) + .chunks(max_degree) .zip(partial_product_check.iter_mut()) .for_each(|(d, q)| { *q *= d.iter().copied().product(); }); vanishing_partial_products_terms.extend(partial_product_check); - // The numerator final product is the product of the last `final_num_prod` elements. + // The quotient final product is the product of the last `final_num_prod` elements. let quotient: F::Extension = current_partial_products[num_prods - final_num_prod..] .iter() .copied() @@ -200,6 +202,8 @@ pub(crate) fn eval_vanishing_poly_base, const D: usize>( // Check the numerator partial products. let mut partial_product_check = check_partial_products("ient_values, current_partial_products, max_degree); + // The first checks are of the form `q - n/d` which is a rational function not a polynomial. + // We multiply them by `d` to get checks of the form `q*d - n` which low-degree polynomials. denominator_values .chunks(max_degree) .zip(partial_product_check.iter_mut()) @@ -208,7 +212,7 @@ pub(crate) fn eval_vanishing_poly_base, const D: usize>( }); vanishing_partial_products_terms.extend(partial_product_check); - // The numerator final product is the product of the last `final_num_prod` elements. + // The quotient final product is the product of the last `final_num_prod` elements. let quotient: F = current_partial_products[num_prods - final_num_prod..] .iter() .copied() @@ -218,7 +222,7 @@ pub(crate) fn eval_vanishing_poly_base, const D: usize>( let vanishing_terms = [ vanishing_z_1_terms, vanishing_partial_products_terms, - // vanishing_v_shift_terms, + vanishing_v_shift_terms, constraint_terms, ] .concat(); diff --git a/src/prover.rs b/src/prover.rs index 88cd2b4b..a6f2ce4d 100644 --- a/src/prover.rs +++ b/src/prover.rs @@ -90,8 +90,8 @@ pub(crate) fn prove, const D: usize>( let plonk_z_vecs = timed!(compute_zs(&partial_products, common_data), "to compute Z's"); - // The first two polynomials in `partial_products` represent the final products used in the - // computation of `Z`. They aren't needed anymore so we discard them. + // The first polynomial in `partial_products` represent the final product used in the + // computation of `Z`. It isn't needed anymore so we discard it. partial_products.iter_mut().for_each(|part| { part.remove(0); }); @@ -313,8 +313,7 @@ fn compute_quotient_polys<'a, F: Extendable, const D: usize>( ZeroPolyOnCoset::new(common_data.degree_bits, max_filtered_constraint_degree_bits); let quotient_values: Vec> = points - // .into_par_iter() - .into_iter() + .into_par_iter() .enumerate() .map(|(i, x)| { let shifted_x = F::coset_shift() * x; diff --git a/src/util/partial_products.rs b/src/util/partial_products.rs index c3e5c2cd..1d169b8d 100644 --- a/src/util/partial_products.rs +++ b/src/util/partial_products.rs @@ -5,14 +5,13 @@ use crate::util::ceil_div_usize; /// Compute partial products of the original vector `v` such that all products consist of `max_degree` /// or less elements. This is done until we've computed the product `P` of all elements in the vector. -/// The final product resulting in `P` consists of at most `max_degree-1` elements since `P` is multiplied -/// by the `Z` polynomial in the Plonk check. pub fn partial_products(v: &[T], max_degree: usize) -> Vec { let mut res = Vec::new(); let mut remainder = v.to_vec(); while remainder.len() > max_degree { let new_partials = remainder .chunks(max_degree) + // TODO: can filter out chunks of length 1. .map(|chunk| chunk.iter().copied().product()) .collect::>(); res.extend_from_slice(&new_partials);