Skip to content

Commit

Permalink
Remove degree_bound and Commitment::bound
Browse files Browse the repository at this point in the history
  • Loading branch information
volhovm committed Dec 4, 2023
1 parent 09f9b54 commit 31b93fa
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 144 deletions.
63 changes: 15 additions & 48 deletions kimchi/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ where

let mut polynomials = polys
.iter()
.map(|(p, d1_size)| (coefficients_form(p), None, non_hiding(*d1_size)))
.map(|(p, d1_size)| (coefficients_form(p), non_hiding(*d1_size)))
.collect::<Vec<_>>();

let fixed_hiding = |d1_size: usize| PolyComm {
Expand All @@ -1245,62 +1245,52 @@ where
//~~ * the poseidon selector
//~~ * the 15 registers/witness columns
//~~ * the 6 sigmas
polynomials.push((
coefficients_form(&public_poly),
None,
fixed_hiding(num_chunks),
));
polynomials.push((coefficients_form(&ft), None, blinding_ft));
polynomials.push((coefficients_form(&z_poly), None, z_comm.blinders));
polynomials.push((coefficients_form(&public_poly), fixed_hiding(num_chunks)));
polynomials.push((coefficients_form(&ft), blinding_ft));
polynomials.push((coefficients_form(&z_poly), z_comm.blinders));
polynomials.push((
evaluations_form(&index.column_evaluations.generic_selector4),
None,
fixed_hiding(num_chunks),
));
polynomials.push((
evaluations_form(&index.column_evaluations.poseidon_selector8),
None,
fixed_hiding(num_chunks),
));
polynomials.push((
evaluations_form(&index.column_evaluations.complete_add_selector4),
None,
fixed_hiding(num_chunks),
));
polynomials.push((
evaluations_form(&index.column_evaluations.mul_selector8),
None,
fixed_hiding(num_chunks),
));
polynomials.push((
evaluations_form(&index.column_evaluations.emul_selector8),
None,
fixed_hiding(num_chunks),
));
polynomials.push((
evaluations_form(&index.column_evaluations.endomul_scalar_selector8),
None,
fixed_hiding(num_chunks),
));
polynomials.extend(
witness_poly
.iter()
.zip(w_comm.iter())
.map(|(w, c)| (coefficients_form(w), None, c.blinders.clone()))
.map(|(w, c)| (coefficients_form(w), c.blinders.clone()))
.collect::<Vec<_>>(),
);
polynomials.extend(
index
.column_evaluations
.coefficients8
.iter()
.map(|coefficientm| (evaluations_form(coefficientm), None, non_hiding(num_chunks)))
.map(|coefficientm| (evaluations_form(coefficientm), non_hiding(num_chunks)))
.collect::<Vec<_>>(),
);
polynomials.extend(
index.column_evaluations.permutation_coefficients8[0..PERMUTS - 1]
.iter()
.map(|w| (evaluations_form(w), None, non_hiding(num_chunks)))
.map(|w| (evaluations_form(w), non_hiding(num_chunks)))
.collect::<Vec<_>>(),
);

Expand All @@ -1310,7 +1300,6 @@ where
{
polynomials.push((
evaluations_form(range_check0_selector8),
None,
non_hiding(num_chunks),
));
}
Expand All @@ -1319,7 +1308,6 @@ where
{
polynomials.push((
evaluations_form(range_check1_selector8),
None,
non_hiding(num_chunks),
));
}
Expand All @@ -1330,7 +1318,6 @@ where
{
polynomials.push((
evaluations_form(foreign_field_add_selector8),
None,
non_hiding(num_chunks),
));
}
Expand All @@ -1341,23 +1328,14 @@ where
{
polynomials.push((
evaluations_form(foreign_field_mul_selector8),
None,
non_hiding(num_chunks),
));
}
if let Some(xor_selector8) = index.column_evaluations.xor_selector8.as_ref() {
polynomials.push((
evaluations_form(xor_selector8),
None,
non_hiding(num_chunks),
));
polynomials.push((evaluations_form(xor_selector8), non_hiding(num_chunks)));
}
if let Some(rot_selector8) = index.column_evaluations.rot_selector8.as_ref() {
polynomials.push((
evaluations_form(rot_selector8),
None,
non_hiding(num_chunks),
));
polynomials.push((evaluations_form(rot_selector8), non_hiding(num_chunks)));
}

//~~ * optionally, the runtime table
Expand All @@ -1368,17 +1346,13 @@ where
let sorted_comms = lookup_context.sorted_comms.as_ref().unwrap();

for (poly, comm) in sorted_poly.iter().zip(sorted_comms) {
polynomials.push((coefficients_form(poly), None, comm.blinders.clone()));
polynomials.push((coefficients_form(poly), comm.blinders.clone()));
}

//~~ * add the lookup aggreg polynomial
let aggreg_poly = lookup_context.aggreg_coeffs.as_ref().unwrap();
let aggreg_comm = lookup_context.aggreg_comm.as_ref().unwrap();
polynomials.push((
coefficients_form(aggreg_poly),
None,
aggreg_comm.blinders.clone(),
));
polynomials.push((coefficients_form(aggreg_poly), aggreg_comm.blinders.clone()));

//~~ * add the combined table polynomial
let table_blinding = if lcs.runtime_selector.is_some() {
Expand All @@ -1399,7 +1373,7 @@ where

let joint_lookup_table = lookup_context.joint_lookup_table.as_ref().unwrap();

polynomials.push((coefficients_form(joint_lookup_table), None, table_blinding));
polynomials.push((coefficients_form(joint_lookup_table), table_blinding));

//~~ * if present, add the runtime table polynomial
if lcs.runtime_selector.is_some() {
Expand All @@ -1408,7 +1382,6 @@ where

polynomials.push((
coefficients_form(runtime_table),
None,
runtime_table_comm.blinders.clone(),
));
}
Expand All @@ -1418,27 +1391,21 @@ where
if let Some(runtime_lookup_table_selector) = lcs.runtime_selector.as_ref() {
polynomials.push((
evaluations_form(runtime_lookup_table_selector),
None,
non_hiding(1),
))
}
if let Some(xor_lookup_selector) = lcs.lookup_selectors.xor.as_ref() {
polynomials.push((evaluations_form(xor_lookup_selector), None, non_hiding(1)))
polynomials.push((evaluations_form(xor_lookup_selector), non_hiding(1)))
}
if let Some(lookup_gate_selector) = lcs.lookup_selectors.lookup.as_ref() {
polynomials.push((evaluations_form(lookup_gate_selector), None, non_hiding(1)))
polynomials.push((evaluations_form(lookup_gate_selector), non_hiding(1)))
}
if let Some(range_check_lookup_selector) = lcs.lookup_selectors.range_check.as_ref() {
polynomials.push((
evaluations_form(range_check_lookup_selector),
None,
non_hiding(1),
))
polynomials.push((evaluations_form(range_check_lookup_selector), non_hiding(1)))
}
if let Some(foreign_field_mul_lookup_selector) = lcs.lookup_selectors.ffmul.as_ref() {
polynomials.push((
evaluations_form(foreign_field_mul_lookup_selector),
None,
non_hiding(1),
))
}
Expand Down
7 changes: 0 additions & 7 deletions kimchi/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,21 +911,18 @@ where
evaluations.extend(polys.into_iter().map(|(c, e)| Evaluation {
commitment: c,
evaluations: e,
degree_bound: None,
}));

//~~ * public input commitment
evaluations.push(Evaluation {
commitment: public_comm,
evaluations: public_evals.to_vec(),
degree_bound: None,
});

//~~ * ft commitment (chunks of it)
evaluations.push(Evaluation {
commitment: ft_comm,
evaluations: vec![vec![ft_eval0], vec![proof.ft_eval1]],
degree_bound: None,
});

for col in [
Expand Down Expand Up @@ -1009,7 +1006,6 @@ where
.ok_or(VerifyError::MissingCommitment(col))?
.clone(),
evaluations: vec![evals.zeta.clone(), evals.zeta_omega.clone()],
degree_bound: None,
});
}

Expand Down Expand Up @@ -1051,7 +1047,6 @@ where
evaluations.push(Evaluation {
commitment: table_comm,
evaluations: vec![lookup_table.zeta.clone(), lookup_table.zeta_omega.clone()],
degree_bound: None,
});

// add evaluation of the runtime table polynomial
Expand All @@ -1068,7 +1063,6 @@ where
evaluations.push(Evaluation {
commitment: runtime.clone(),
evaluations: vec![runtime_eval.zeta, runtime_eval.zeta_omega],
degree_bound: None,
});
}
}
Expand Down Expand Up @@ -1119,7 +1113,6 @@ where
.ok_or(VerifyError::MissingCommitment(col))?
.clone(),
evaluations: vec![evals.zeta.clone(), evals.zeta_omega.clone()],
degree_bound: None,
});
}

Expand Down
33 changes: 8 additions & 25 deletions poly-commitment/src/commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,6 @@ where

/// Contains an evaluation table
pub evaluations: Vec<Vec<G::ScalarField>>,

/// optional degree bound
pub degree_bound: Option<usize>,
}

/// Contains the batch evaluation
Expand Down Expand Up @@ -502,11 +499,7 @@ pub fn combine_evaluations<G: CommitmentCurve>(
vec![G::ScalarField::zero(); num_evals]
};

for Evaluation {
evaluations,
degree_bound,
..
} in evaluations
for Evaluation { evaluations, .. } in evaluations
.iter()
.filter(|x| !x.commitment.elems.is_empty())
{
Expand All @@ -517,10 +510,6 @@ pub fn combine_evaluations<G: CommitmentCurve>(
}
xi_i *= polyscale;
}

if let Some(_m) = degree_bound {
todo!("Misaligned chunked commitments are not supported")
}
}

acc
Expand Down Expand Up @@ -951,10 +940,9 @@ mod tests {
let srs = SRS::<VestaG>::create(20);
let rng = &mut StdRng::from_seed([0u8; 32]);

// commit the two polynomials (and upperbound the second one)
let commitment = srs.commit(&poly1, 1, rng);
let upperbound = poly2.degree() + 1;
let bounded_commitment = srs.commit(&poly2, 1, rng);
// commit the two polynomials
let commitment1 = srs.commit(&poly1, 1, rng);
let commitment2 = srs.commit(&poly2, 1, rng);

// create an aggregated opening proof
let (u, v) = (Fp::rand(rng), Fp::rand(rng));
Expand All @@ -964,18 +952,15 @@ mod tests {

let polys: Vec<(
DensePolynomialOrEvaluations<_, Radix2EvaluationDomain<_>>,
Option<usize>,
PolyComm<_>,
)> = vec![
(
DensePolynomialOrEvaluations::DensePolynomial(&poly1),
None,
commitment.blinders,
commitment1.blinders,
),
(
DensePolynomialOrEvaluations::DensePolynomial(&poly2),
Some(upperbound),
bounded_commitment.blinders,
commitment2.blinders,
),
];
let elm = vec![Fp::rand(rng), Fp::rand(rng)];
Expand Down Expand Up @@ -1013,14 +998,12 @@ mod tests {

let evaluations = vec![
Evaluation {
commitment: commitment.commitment,
commitment: commitment1.commitment,
evaluations: poly1_chunked_evals,
degree_bound: None,
},
Evaluation {
commitment: bounded_commitment.commitment,
commitment: commitment2.commitment,
evaluations: poly2_chunked_evals,
degree_bound: Some(upperbound),
},
];

Expand Down
Loading

0 comments on commit 31b93fa

Please sign in to comment.