mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-02-25 16:23:07 +00:00
No longer need to store number of PP polynomials (#424)
* No longer need to store number of PP polynomials It's unused after the refactoring we did. * PR feedback
This commit is contained in:
parent
bde6114428
commit
3ab0a37af3
@ -629,7 +629,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
let min_quotient_degree_factor = max_filtered_constraint_degree - 1;
|
||||
let max_quotient_degree_factor = self.config.max_quotient_degree_factor.min(1 << rate_bits);
|
||||
let quotient_degree_factor = (min_quotient_degree_factor..=max_quotient_degree_factor)
|
||||
.min_by_key(|&q| num_partial_products(self.config.num_routed_wires, q).0 + q)
|
||||
.min_by_key(|&q| num_partial_products(self.config.num_routed_wires, q) + q)
|
||||
.unwrap();
|
||||
debug!("Quotient degree factor set to: {}.", quotient_degree_factor);
|
||||
|
||||
|
||||
@ -237,9 +237,8 @@ pub struct CommonCircuitData<
|
||||
/// The `{k_i}` valued used in `S_ID_i` in Plonk's permutation argument.
|
||||
pub(crate) k_is: Vec<F>,
|
||||
|
||||
/// The number of partial products needed to compute the `Z` polynomials and
|
||||
/// the number of original elements consumed in `partial_products()`.
|
||||
pub(crate) num_partial_products: (usize, usize),
|
||||
/// The number of partial products needed to compute the `Z` polynomials.
|
||||
pub(crate) num_partial_products: usize,
|
||||
|
||||
/// A digest of the "circuit" (i.e. the instance, minus public inputs), which can be used to
|
||||
/// seed Fiat-Shamir.
|
||||
@ -356,7 +355,7 @@ impl<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
|
||||
|
||||
fn fri_zs_partial_products_polys(&self) -> Vec<FriPolynomialInfo> {
|
||||
let num_zs_partial_products_polys =
|
||||
self.config.num_challenges * (1 + self.num_partial_products.0);
|
||||
self.config.num_challenges * (1 + self.num_partial_products);
|
||||
FriPolynomialInfo::from_range(
|
||||
PlonkOracle::ZS_PARTIAL_PRODUCTS.index,
|
||||
0..num_zs_partial_products_polys,
|
||||
|
||||
@ -269,7 +269,7 @@ fn wires_permutation_partial_products_and_zs<
|
||||
let degree = common_data.quotient_degree_factor;
|
||||
let subgroup = &prover_data.subgroup;
|
||||
let k_is = &common_data.k_is;
|
||||
let (num_prods, _final_num_prod) = common_data.num_partial_products;
|
||||
let num_prods = common_data.num_partial_products;
|
||||
let all_quotient_chunk_products = subgroup
|
||||
.par_iter()
|
||||
.enumerate()
|
||||
|
||||
@ -37,7 +37,7 @@ pub(crate) fn eval_vanishing_poly<
|
||||
alphas: &[F],
|
||||
) -> Vec<F::Extension> {
|
||||
let max_degree = common_data.quotient_degree_factor;
|
||||
let (num_prods, _final_num_prod) = common_data.num_partial_products;
|
||||
let num_prods = common_data.num_partial_products;
|
||||
|
||||
let constraint_terms =
|
||||
evaluate_gate_constraints(&common_data.gates, common_data.num_gate_constraints, vars);
|
||||
@ -123,7 +123,7 @@ pub(crate) fn eval_vanishing_poly_base_batch<
|
||||
assert_eq!(s_sigmas_batch.len(), n);
|
||||
|
||||
let max_degree = common_data.quotient_degree_factor;
|
||||
let (num_prods, _final_num_prod) = common_data.num_partial_products;
|
||||
let num_prods = common_data.num_partial_products;
|
||||
|
||||
let num_gate_constraints = common_data.num_gate_constraints;
|
||||
|
||||
@ -302,7 +302,7 @@ pub(crate) fn eval_vanishing_poly_recursively<
|
||||
alphas: &[Target],
|
||||
) -> Vec<ExtensionTarget<D>> {
|
||||
let max_degree = common_data.quotient_degree_factor;
|
||||
let (num_prods, _final_num_prod) = common_data.num_partial_products;
|
||||
let num_prods = common_data.num_partial_products;
|
||||
|
||||
let constraint_terms = with_context!(
|
||||
builder,
|
||||
|
||||
@ -35,16 +35,14 @@ pub(crate) fn partial_products_and_z_gx<F: Field>(z_x: F, quotient_chunk_product
|
||||
res
|
||||
}
|
||||
|
||||
/// Returns a tuple `(a,b)`, where `a` is the length of the output of `partial_products()` on a
|
||||
/// vector of length `n`, and `b` is the number of original elements consumed in `partial_products()`.
|
||||
pub(crate) fn num_partial_products(n: usize, max_degree: usize) -> (usize, usize) {
|
||||
/// Returns the length of the output of `partial_products()` on a vector of length `n`.
|
||||
pub(crate) fn num_partial_products(n: usize, max_degree: usize) -> usize {
|
||||
debug_assert!(max_degree > 1);
|
||||
let chunk_size = max_degree;
|
||||
// We'll split the product into `ceil_div_usize(n, chunk_size)` chunks, but the last chunk will
|
||||
// be associated with Z(gx) itself. Thus we subtract one to get the chunks associated with
|
||||
// partial products.
|
||||
let num_chunks = ceil_div_usize(n, chunk_size) - 1;
|
||||
(num_chunks, num_chunks * chunk_size)
|
||||
ceil_div_usize(n, chunk_size) - 1
|
||||
}
|
||||
|
||||
/// Checks the relationship between each pair of partial product accumulators. In particular, this
|
||||
@ -127,7 +125,7 @@ mod tests {
|
||||
assert_eq!(pps_and_z_gx, field_vec(&[2, 24, 720]));
|
||||
|
||||
let nums = num_partial_products(v.len(), 2);
|
||||
assert_eq!(pps.len(), nums.0);
|
||||
assert_eq!(pps.len(), nums);
|
||||
assert!(check_partial_products(&v, &denominators, pps, z_x, z_gx, 2)
|
||||
.iter()
|
||||
.all(|x| x.is_zero()));
|
||||
@ -138,7 +136,7 @@ mod tests {
|
||||
let pps = &pps_and_z_gx[..pps_and_z_gx.len() - 1];
|
||||
assert_eq!(pps_and_z_gx, field_vec(&[6, 720]));
|
||||
let nums = num_partial_products(v.len(), 3);
|
||||
assert_eq!(pps.len(), nums.0);
|
||||
assert_eq!(pps.len(), nums);
|
||||
assert!(check_partial_products(&v, &denominators, pps, z_x, z_gx, 3)
|
||||
.iter()
|
||||
.all(|x| x.is_zero()));
|
||||
|
||||
@ -172,9 +172,8 @@ impl Buffer {
|
||||
let wires = self.read_field_ext_vec::<F, D>(config.num_wires)?;
|
||||
let plonk_zs = self.read_field_ext_vec::<F, D>(config.num_challenges)?;
|
||||
let plonk_zs_right = self.read_field_ext_vec::<F, D>(config.num_challenges)?;
|
||||
let partial_products = self.read_field_ext_vec::<F, D>(
|
||||
common_data.num_partial_products.0 * config.num_challenges,
|
||||
)?;
|
||||
let partial_products = self
|
||||
.read_field_ext_vec::<F, D>(common_data.num_partial_products * config.num_challenges)?;
|
||||
let quotient_polys = self.read_field_ext_vec::<F, D>(
|
||||
common_data.quotient_degree_factor * config.num_challenges,
|
||||
)?;
|
||||
@ -248,7 +247,7 @@ impl Buffer {
|
||||
evals_proofs.push((wires_v, wires_p));
|
||||
|
||||
let zs_partial_v =
|
||||
self.read_field_vec(config.num_challenges * (1 + common_data.num_partial_products.0))?;
|
||||
self.read_field_vec(config.num_challenges * (1 + common_data.num_partial_products))?;
|
||||
let zs_partial_p = self.read_merkle_proof()?;
|
||||
evals_proofs.push((zs_partial_v, zs_partial_p));
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user