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

Method check_combinations

poly-commit/src/ipa_pc/mod.rs:965–1048  ·  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<G::ScalarField>>,
        commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self

Source from the content-addressed store, hash-verified

963 /// Checks that `values` are the true evaluations at `query_set` of the polynomials
964 /// committed in `labeled_commitments`.
965 fn check_combinations<'a, R: RngCore>(
966 vk: &Self::VerifierKey,
967 linear_combinations: impl IntoIterator<Item = &'a LinearCombination<G::ScalarField>>,
968 commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
969 eqn_query_set: &QuerySet<P::Point>,
970 eqn_evaluations: &Evaluations<P::Point, G::ScalarField>,
971 proof: &BatchLCProof<G::ScalarField, Self::BatchProof>,
972 sponge: &mut impl CryptographicSponge,
973 rng: &mut R,
974 ) -> Result<bool, Self::Error>
975 where
976 Self::Commitment: 'a,
977 {
978 let BatchLCProof { proof, .. } = proof;
979 let label_comm_map = commitments
980 .into_iter()
981 .map(|c| (c.label(), c))
982 .collect::<BTreeMap<_, _>>();
983
984 let mut lc_commitments = Vec::new();
985 let mut lc_info = Vec::new();
986 let mut evaluations = eqn_evaluations.clone();
987 for lc in linear_combinations {
988 let lc_label = lc.label().clone();
989 let num_polys = lc.len();
990
991 let mut degree_bound = None;
992 let mut combined_comm = G::Group::zero();
993 let mut combined_shifted_comm: Option<G::Group> = None;
994
995 for (coeff, label) in lc.iter() {
996 if label.is_one() {
997 for (&(ref label, _), ref mut eval) in evaluations.iter_mut() {
998 if label == &lc_label {
999 **eval -= coeff;
1000 }
1001 }
1002 } else {
1003 let label: &String = label.try_into().unwrap();
1004 let &cur_comm = label_comm_map.get(label).ok_or(Error::MissingPolynomial {
1005 label: label.to_string(),
1006 })?;
1007
1008 if num_polys == 1 && cur_comm.degree_bound().is_some() {
1009 assert!(
1010 coeff.is_one(),
1011 "Coefficient must be one for degree-bounded equations"
1012 );
1013 degree_bound = cur_comm.degree_bound();
1014 } else if cur_comm.degree_bound().is_some() {
1015 return Err(Self::Error::EquationHasDegreeBounds(lc_label));
1016 }
1017
1018 let commitment = cur_comm.commitment();
1019 combined_comm += &commitment.comm.mul(*coeff);
1020 combined_shifted_comm = Self::combine_shifted_comm(
1021 combined_shifted_comm,
1022 commitment.shifted_comm,

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected