Outputs a commitment to `polynomial`.
(
ck: &Self::CommitterKey,
polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<G::ScalarField, P>>,
rng: Option<&mut dyn RngCore>,
)
| 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 | }); |
nothing calls this directly
no test coverage detected