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

Method open_combinations

poly-commit/src/sonic_pc/mod.rs:496–586  ·  view source on GitHub ↗
(
        ck: &Self::CommitterKey,
        linear_combinations: impl IntoIterator<Item = &'a LinearCombination<E::ScalarField>>,
        polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<E::

Source from the content-addressed store, hash-verified

494 }
495
496 fn open_combinations<'a>(
497 ck: &Self::CommitterKey,
498 linear_combinations: impl IntoIterator<Item = &'a LinearCombination<E::ScalarField>>,
499 polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<E::ScalarField, P>>,
500 commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
501 query_set: &QuerySet<P::Point>,
502 sponge: &mut impl CryptographicSponge,
503 states: impl IntoIterator<Item = &'a Self::CommitmentState>,
504 rng: Option<&mut dyn RngCore>,
505 ) -> Result<BatchLCProof<E::ScalarField, Self::BatchProof>, Self::Error>
506 where
507 Self::CommitmentState: 'a,
508 Self::Commitment: 'a,
509 P: 'a,
510 {
511 let label_map = polynomials
512 .into_iter()
513 .zip(states)
514 .zip(commitments)
515 .map(|((p, s), c)| (p.label(), (p, s, c)))
516 .collect::<BTreeMap<_, _>>();
517
518 let mut lc_polynomials = Vec::new();
519 let mut lc_states = Vec::new();
520 let mut lc_commitments = Vec::new();
521 let mut lc_info = Vec::new();
522
523 for lc in linear_combinations {
524 let lc_label = lc.label().clone();
525 let mut poly = P::zero();
526 let mut degree_bound = None;
527 let mut hiding_bound = None;
528 let mut state = Self::CommitmentState::empty();
529 let mut comm = E::G1::zero();
530
531 let num_polys = lc.len();
532 for (coeff, label) in lc.iter().filter(|(_, l)| !l.is_one()) {
533 let label: &String = label.try_into().expect("cannot be one!");
534 let &(cur_poly, cur_state, curr_comm) =
535 label_map.get(label).ok_or(Error::MissingPolynomial {
536 label: label.to_string(),
537 })?;
538
539 if num_polys == 1 && cur_poly.degree_bound().is_some() {
540 assert!(
541 coeff.is_one(),
542 "Coefficient must be one for degree-bounded equations"
543 );
544 degree_bound = cur_poly.degree_bound();
545 } else if cur_poly.degree_bound().is_some() {
546 eprintln!("Degree bound when number of equations is non-zero");
547 return Err(Self::Error::EquationHasDegreeBounds(lc_label));
548 }
549
550 // Some(_) > None, always.
551 hiding_bound = core::cmp::max(hiding_bound, cur_poly.hiding_bound());
552 poly += (*coeff, cur_poly.polynomial());
553 state += (*coeff, cur_state);

Callers

nothing calls this directly

Calls 10

labelMethod · 0.80
lenMethod · 0.80
iterMethod · 0.80
is_oneMethod · 0.80
try_intoMethod · 0.80
degree_boundMethod · 0.80
hiding_boundMethod · 0.80
polynomialMethod · 0.80
commitmentMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected