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

Method commit

poly-commit/src/ipa_pc/mod.rs:403–473  ·  view source on GitHub ↗

Outputs a commitment to `polynomial`.

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

Source from the content-addressed store, hash-verified

401
402 /// Outputs a commitment to `polynomial`.
403 fn commit<'a>(
404 ck: &Self::CommitterKey,
405 polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<G::ScalarField, P>>,
406 rng: Option<&mut dyn RngCore>,
407 ) -> Result<
408 (
409 Vec<LabeledCommitment<Self::Commitment>>,
410 Vec<Self::CommitmentState>,
411 ),
412 Self::Error,
413 >
414 where
415 P: 'a,
416 {
417 let rng = &mut crate::optional_rng::OptionalRng(rng);
418 let mut comms = Vec::new();
419 let mut states = Vec::new();
420
421 let commit_time = start_timer!(|| "Committing to polynomials");
422 for labeled_polynomial in polynomials {
423 Self::check_degrees_and_bounds(ck.supported_degree(), labeled_polynomial)?;
424
425 let polynomial: &P = labeled_polynomial.polynomial();
426 let label = labeled_polynomial.label();
427 let hiding_bound = labeled_polynomial.hiding_bound();
428 let degree_bound = labeled_polynomial.degree_bound();
429
430 let commit_time = start_timer!(|| format!(
431 "Polynomial {} of degree {}, degree bound {:?}, and hiding bound {:?}",
432 label,
433 polynomial.degree(),
434 degree_bound,
435 hiding_bound,
436 ));
437
438 let state = if let Some(h) = hiding_bound {
439 Randomness::rand(h, degree_bound.is_some(), None, rng)
440 } else {
441 Randomness::empty()
442 };
443
444 let comm = Self::cm_commit(
445 &ck.comm_key[..(polynomial.degree() + 1)],
446 &polynomial.coeffs(),
447 Some(ck.s),
448 Some(state.rand),
449 )
450 .into();
451
452 let shifted_comm = degree_bound.map(|d| {
453 Self::cm_commit(
454 &ck.comm_key[(ck.supported_degree() - d)..],
455 &polynomial.coeffs(),
456 Some(ck.s),
457 state.shifted_rand,
458 )
459 .into()
460 });

Callers

nothing calls this directly

Calls 8

OptionalRngClass · 0.85
polynomialMethod · 0.80
labelMethod · 0.80
hiding_boundMethod · 0.80
degree_boundMethod · 0.80
degreeMethod · 0.80
pushMethod · 0.80
supported_degreeMethod · 0.45

Tested by

no test coverage detected