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

Method check_combinations

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

Checks that `values` are the true evaluations at `query_set` of the polynomials committed in `labeled_commitments`.

(
        vk: &Self::VerifierKey,
        linear_combinations: impl IntoIterator<Item = &'a LinearCombination<E::ScalarField>>,
        commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self

Source from the content-addressed store, hash-verified

588 /// Checks that `values` are the true evaluations at `query_set` of the polynomials
589 /// committed in `labeled_commitments`.
590 fn check_combinations<'a, R: RngCore>(
591 vk: &Self::VerifierKey,
592 linear_combinations: impl IntoIterator<Item = &'a LinearCombination<E::ScalarField>>,
593 commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
594 eqn_query_set: &QuerySet<P::Point>,
595 eqn_evaluations: &Evaluations<P::Point, E::ScalarField>,
596 proof: &BatchLCProof<E::ScalarField, Self::BatchProof>,
597 sponge: &mut impl CryptographicSponge,
598 rng: &mut R,
599 ) -> Result<bool, Self::Error>
600 where
601 Self::Commitment: 'a,
602 {
603 let BatchLCProof { proof, .. } = proof;
604 let label_comm_map = commitments
605 .into_iter()
606 .map(|c| (c.label(), c))
607 .collect::<BTreeMap<_, _>>();
608
609 let mut lc_commitments = Vec::new();
610 let mut lc_info = Vec::new();
611 let mut evaluations = eqn_evaluations.clone();
612 for lc in linear_combinations {
613 let lc_label = lc.label().clone();
614 let num_polys = lc.len();
615
616 let mut degree_bound = None;
617 let mut combined_comm = E::G1::zero();
618
619 for (coeff, label) in lc.iter() {
620 if label.is_one() {
621 for (&(ref label, _), ref mut eval) in evaluations.iter_mut() {
622 if label == &lc_label {
623 **eval -= coeff;
624 }
625 }
626 } else {
627 let label: &String = label.try_into().unwrap();
628 let &cur_comm = label_comm_map.get(label).ok_or(Error::MissingPolynomial {
629 label: label.to_string(),
630 })?;
631
632 if num_polys == 1 && cur_comm.degree_bound().is_some() {
633 assert!(
634 coeff.is_one(),
635 "Coefficient must be one for degree-bounded equations"
636 );
637 degree_bound = cur_comm.degree_bound();
638 } else if cur_comm.degree_bound().is_some() {
639 return Err(Self::Error::EquationHasDegreeBounds(lc_label));
640 }
641 combined_comm += &cur_comm.commitment().0.mul(*coeff);
642 }
643 }
644
645 lc_commitments.push(combined_comm);
646 lc_info.push((lc_label, degree_bound));
647 }

Callers

nothing calls this directly

Calls 9

labelMethod · 0.80
lenMethod · 0.80
iterMethod · 0.80
is_oneMethod · 0.80
try_intoMethod · 0.80
degree_boundMethod · 0.80
commitmentMethod · 0.80
pushMethod · 0.80
CommitmentClass · 0.50

Tested by

no test coverage detected