Increase degree

This commit is contained in:
wborgeaud 2021-11-09 14:24:04 +01:00
parent bd1672cbf2
commit 9617c22173
4 changed files with 9 additions and 58 deletions

View File

@ -777,7 +777,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
.expect("No gates?");
let num_partial_products =
num_partial_products(self.config.num_routed_wires, quotient_degree_factor - 1);
num_partial_products(self.config.num_routed_wires, quotient_degree_factor);
// TODO: This should also include an encoding of gate constraints.
let circuit_digest_parts = [

View File

@ -63,7 +63,6 @@ pub(crate) fn prove<F: RichField + Extendable<D>, const D: usize>(
.map(|column| PolynomialValues::new(column.clone()))
.collect()
);
let wires = wires_values.iter().map(|v| v.values[0]).collect::<Vec<_>>();
let wires_commitment = timed!(
timing,
@ -109,33 +108,6 @@ pub(crate) fn prove<F: RichField + Extendable<D>, const D: usize>(
partial_products.iter_mut().for_each(|part| {
part.remove(0);
});
// let part = partial_products[0].clone();
// let v = part.iter().map(|v| v.values[0]).collect::<Vec<_>>();
// dbg!();
// let numerator_values = (0..common_data.config.num_routed_wires)
// .map(|j| {
// let wire_value = wires[j];
// let k_i = common_data.k_is[j];
// let s_id = k_i;
// wire_value + s_id * betas[0] + gammas[0]
// })
// .collect::<Vec<_>>();
// let denominator_values = (0..common_data.config.num_routed_wires)
// .map(|j| {
// let wire_value = wires[j];
// let s_sigma = s_sigmas[j];
// wire_value + s_sigma * betas[0] + gammas[0]
// })
// .collect::<Vec<_>>();
// let quotient_values = (0..common_data.config.num_routed_wires)
// .map(|j| numerator_values[j] / denominator_values[j])
// .collect::<Vec<_>>();
//
// // // The partial products considered for this iteration of `i`.
// // let current_partial_products = &partial_products[i * num_prods..(i + 1) * num_prods];
// // Check the quotient partial products.
// let mut partial_product_check = check_partial_products(&quotient_values, &v, quotient_degree);
// dbg!(partial_product_check);
let zs_partial_products = [plonk_z_vecs, partial_products.concat()].concat();
let zs_partial_products_commitment = timed!(
@ -266,7 +238,7 @@ fn wires_permutation_partial_products<F: RichField + Extendable<D>, const D: usi
prover_data: &ProverOnlyCircuitData<F, D>,
common_data: &CommonCircuitData<F, D>,
) -> Vec<PolynomialValues<F>> {
let degree = common_data.quotient_degree_factor - 1;
let degree = common_data.quotient_degree_factor;
let subgroup = &prover_data.subgroup;
let k_is = &common_data.k_is;
let values = subgroup
@ -294,11 +266,6 @@ fn wires_permutation_partial_products<F: RichField + Extendable<D>, const D: usi
.collect::<Vec<_>>();
let quotient_partials = partial_products(&quotient_values, degree);
dbg!(check_partial_products(
&quotient_values,
&quotient_partials,
degree
));
// This is the final product for the quotient.
let quotient = *quotient_partials.last().unwrap()

View File

@ -27,7 +27,7 @@ pub(crate) fn eval_vanishing_poly<F: RichField + Extendable<D>, const D: usize>(
gammas: &[F],
alphas: &[F],
) -> Vec<F::Extension> {
let max_degree = common_data.quotient_degree_factor - 1;
let max_degree = common_data.quotient_degree_factor;
let (num_prods, final_num_prod) = common_data.num_partial_products;
let constraint_terms =
@ -74,15 +74,9 @@ pub(crate) fn eval_vanishing_poly<F: RichField + Extendable<D>, const D: usize>(
// 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.
for (j, q) in partial_product_check.iter_mut().enumerate() {
let range = j * (max_degree - 1)..(j + 1) * (max_degree - 1);
let range = j * max_degree..(j + 1) * max_degree;
*q *= denominator_values[range].iter().copied().product();
}
// denominator_values
// .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 quotient final product is the product of the last `final_num_prod` elements.
@ -131,7 +125,7 @@ pub(crate) fn eval_vanishing_poly_base_batch<F: RichField + Extendable<D>, const
assert_eq!(partial_products_batch.len(), n);
assert_eq!(s_sigmas_batch.len(), n);
let max_degree = common_data.quotient_degree_factor - 1;
let max_degree = common_data.quotient_degree_factor;
let (num_prods, final_num_prod) = common_data.num_partial_products;
let num_gate_constraints = common_data.num_gate_constraints;
@ -197,24 +191,14 @@ pub(crate) fn eval_vanishing_poly_base_batch<F: RichField + Extendable<D>, const
// 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.
for (j, q) in partial_product_check.iter_mut().enumerate() {
let range = j * (max_degree - 1)..(j + 1) * (max_degree - 1);
let range = j * max_degree..(j + 1) * max_degree;
*q *= denominator_values[range].iter().copied().product();
}
// denominator_values
// .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 quotient final product is the product of the last `final_num_prod` elements.
let quotient: F = *current_partial_products.last().unwrap()
* quotient_values[final_num_prod..].iter().copied().product();
// let quotient: F = current_partial_products[num_prods - final_num_prod..]
// .iter()
// .copied()
// .product();
let mut wanted = quotient * z_x - z_gz;
wanted *= denominator_values[final_num_prod..]
.iter()

View File

@ -13,7 +13,7 @@ pub fn partial_products<F: Field>(v: &[F], max_degree: usize) -> Vec<F> {
debug_assert!(max_degree > 1);
let mut res = Vec::new();
let mut acc = F::ONE;
let chunk_size = max_degree - 1;
let chunk_size = max_degree;
let num_chunks = ceil_div_usize(v.len(), chunk_size) - 1;
for i in 0..num_chunks {
acc *= v[i * chunk_size..(i + 1) * chunk_size]
@ -30,7 +30,7 @@ pub fn partial_products<F: Field>(v: &[F], max_degree: usize) -> Vec<F> {
/// vector of length `n`, and `b` is the number of elements needed to compute the final product.
pub fn num_partial_products(n: usize, max_degree: usize) -> (usize, usize) {
debug_assert!(max_degree > 1);
let chunk_size = max_degree - 1;
let chunk_size = max_degree;
let num_chunks = ceil_div_usize(n, chunk_size) - 1;
(num_chunks, num_chunks * chunk_size)
@ -43,7 +43,7 @@ pub fn check_partial_products<F: Field>(v: &[F], mut partials: &[F], max_degree:
let mut partials = partials.iter();
let mut res = Vec::new();
let mut acc = F::ONE;
let chunk_size = max_degree - 1;
let chunk_size = max_degree;
let num_chunks = ceil_div_usize(v.len(), chunk_size) - 1;
for i in 0..num_chunks {
acc *= v[i * chunk_size..(i + 1) * chunk_size]