MCPcopy Create free account
hub / github.com/arkworks-rs/poly-commit / commit

Method commit

poly-commit/src/sonic_pc/mod.rs:274–338  ·  view source on GitHub ↗

Outputs a commitment to `polynomial`.

(
        ck: &Self::CommitterKey,
        polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<E::ScalarField, P>>,
        rng: Option<&mut dyn RngCore>,
    )

Source from the content-addressed store, hash-verified

272
273 /// Outputs a commitment to `polynomial`.
274 fn commit<'a>(
275 ck: &Self::CommitterKey,
276 polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<E::ScalarField, P>>,
277 rng: Option<&mut dyn RngCore>,
278 ) -> Result<
279 (
280 Vec<LabeledCommitment<Self::Commitment>>,
281 Vec<Self::CommitmentState>,
282 ),
283 Self::Error,
284 >
285 where
286 P: 'a,
287 {
288 let rng = &mut crate::optional_rng::OptionalRng(rng);
289 let commit_time = start_timer!(|| "Committing to polynomials");
290 let mut labeled_comms: Vec<LabeledCommitment<Self::Commitment>> = Vec::new();
291 let mut randomness: Vec<Self::CommitmentState> = Vec::new();
292
293 for labeled_polynomial in polynomials {
294 let enforced_degree_bounds: Option<&[usize]> = ck
295 .enforced_degree_bounds
296 .as_ref()
297 .map(|bounds| bounds.as_slice());
298
299 kzg10::KZG10::<E, P>::check_degrees_and_bounds(
300 ck.supported_degree(),
301 ck.max_degree,
302 enforced_degree_bounds,
303 &labeled_polynomial,
304 )?;
305
306 let polynomial: &P = labeled_polynomial.polynomial();
307 let degree_bound = labeled_polynomial.degree_bound();
308 let hiding_bound = labeled_polynomial.hiding_bound();
309 let label = labeled_polynomial.label();
310
311 let commit_time = start_timer!(|| format!(
312 "Polynomial {} of degree {}, degree bound {:?}, and hiding bound {:?}",
313 label,
314 polynomial.degree(),
315 degree_bound,
316 hiding_bound,
317 ));
318
319 let powers = if let Some(degree_bound) = degree_bound {
320 ck.shifted_powers(degree_bound).unwrap()
321 } else {
322 ck.powers()
323 };
324
325 let (comm, rand) = kzg10::KZG10::commit(&powers, polynomial, hiding_bound, Some(rng))?;
326
327 labeled_comms.push(LabeledCommitment::new(
328 label.to_string(),
329 comm,
330 degree_bound,
331 ));

Callers

nothing calls this directly

Calls 10

OptionalRngClass · 0.85
commitFunction · 0.85
polynomialMethod · 0.80
degree_boundMethod · 0.80
hiding_boundMethod · 0.80
labelMethod · 0.80
pushMethod · 0.80
supported_degreeMethod · 0.45
shifted_powersMethod · 0.45
powersMethod · 0.45

Tested by

no test coverage detected