chore: from_values takes ref

This commit is contained in:
David Palm 2023-11-29 09:09:36 +01:00
parent 64cc1000e7
commit 7cc123e0a4
No known key found for this signature in database
GPG Key ID: AC8A213E894DB26D
6 changed files with 14 additions and 23 deletions

View File

@ -722,15 +722,11 @@ mod tests {
stark.generate_trace(input, 8, &mut timing)
);
// TODO: Cloning this isn't great; consider having `from_values` accept a reference,
// or having `compute_permutation_z_polys` read trace values from the `PolynomialBatch`.
let cloned_trace_poly_values = timed!(timing, "clone", trace_poly_values.clone());
let trace_commitments = timed!(
timing,
"compute trace commitment",
PolynomialBatch::<F, C, D>::from_values(
cloned_trace_poly_values,
&trace_poly_values,
config.fri_config.rate_bits,
false,
config.fri_config.cap_height,

View File

@ -102,14 +102,7 @@ where
timing,
&format!("compute trace commitment for {:?}", table),
PolynomialBatch::<F, C, D>::from_values(
// TODO: Cloning this isn't great; consider having `from_values` accept a reference,
// or having `compute_permutation_z_polys` read trace values from the `PolynomialBatch`.
trace.clone(),
rate_bits,
false,
cap_height,
timing,
None,
trace, rate_bits, false, cap_height, timing, None,
)
)
})
@ -380,7 +373,7 @@ where
timing,
"compute auxiliary polynomials commitment",
PolynomialBatch::from_values(
auxiliary_polys,
&auxiliary_polys,
rate_bits,
false,
config.fri_config.cap_height,

View File

@ -55,7 +55,7 @@ impl<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
{
/// Creates a list polynomial commitment for the polynomials interpolating the values in `values`.
pub fn from_values(
values: Vec<PolynomialValues<F>>,
values: &[PolynomialValues<F>],
rate_bits: usize,
blinding: bool,
cap_height: usize,
@ -65,7 +65,11 @@ impl<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
let coeffs = timed!(
timing,
"IFFT",
values.into_par_iter().map(|v| v.ifft()).collect::<Vec<_>>()
values
.into_par_iter()
.cloned()
.map(|v| v.ifft())
.collect::<Vec<_>>()
);
Self::from_coeffs(

View File

@ -1029,7 +1029,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
let constants_sigmas_commitment = if commit_to_sigma {
let constants_sigmas_vecs = [constant_vecs, sigma_vecs.clone()].concat();
PolynomialBatch::<F, C, D>::from_values(
constants_sigmas_vecs,
&constants_sigmas_vecs,
rate_bits,
PlonkOracle::CONSTANTS_SIGMAS.blinding,
cap_height,

View File

@ -171,7 +171,7 @@ where
timing,
"compute wires commitment",
PolynomialBatch::<F, C, D>::from_values(
wires_values,
&wires_values,
config.fri_config.rate_bits,
config.zero_knowledge && PlonkOracle::WIRES.blinding,
config.fri_config.cap_height,
@ -238,7 +238,7 @@ where
timing,
"commit to partial products, Z's and, if any, lookup polynomials",
PolynomialBatch::from_values(
zs_partial_products_lookups,
&zs_partial_products_lookups,
config.fri_config.rate_bits,
config.zero_knowledge && PlonkOracle::ZS_PARTIAL_PRODUCTS.blinding,
config.fri_config.cap_height,

View File

@ -55,9 +55,7 @@ where
timing,
"compute trace commitment",
PolynomialBatch::<F, C, D>::from_values(
// TODO: Cloning this isn't great; consider having `from_values` accept a reference,
// or having `compute_permutation_z_polys` read trace values from the `PolynomialBatch`.
trace_poly_values.clone(),
&trace_poly_values,
rate_bits,
false,
cap_height,
@ -88,7 +86,7 @@ where
timing,
"compute permutation Z commitments",
PolynomialBatch::from_values(
permutation_z_polys,
&permutation_z_polys,
rate_bits,
false,
config.fri_config.cap_height,