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

Method batch_check

poly-commit/src/lib.rs:373–441  ·  view source on GitHub ↗

Verify opening proofs for several polynomials at one or more points each (possibly different for each polynomial). Each entry in the query set of points contains the label of the polynomial which was queried at that point. Behaviour is undefined if `query_set` contains the entries with the same point label but different points. Behaviour is also undefined if proofs are not ordered the same way a

(
        vk: &Self::VerifierKey,
        commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
        query_set: &QuerySet<P::Point>,
        evaluations: &Evaluations<P::P

Source from the content-addressed store, hash-verified

371 ///
372 /// The opening challenges are independent for each batch of polynomials.
373 fn batch_check<'a, R: RngCore>(
374 vk: &Self::VerifierKey,
375 commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
376 query_set: &QuerySet<P::Point>,
377 evaluations: &Evaluations<P::Point, F>,
378 proof: &Self::BatchProof,
379 sponge: &mut impl CryptographicSponge,
380 rng: &mut R,
381 ) -> Result<bool, Self::Error>
382 where
383 Self::Commitment: 'a,
384 {
385 // The default implementation proceeds by rearranging the queries in
386 // order to gather (i.e. batch) the proofs of all polynomials that should
387 // have been opened at the same point, then verifying those proofs
388 // simultaneously with a single call to `check` (per point).
389 let commitments: BTreeMap<_, _> = commitments.into_iter().map(|c| (c.label(), c)).collect();
390 let mut query_to_labels_map = BTreeMap::new();
391
392 // `label` is the label of the polynomial the query refers to
393 // `point_label` is the label of the point being queried
394 // `point` is the actual point
395 for (label, (point_label, point)) in query_set.iter() {
396 // For each point label in `query_set`, we define an entry in
397 // `query_to_labels_map` containing a pair whose first element is
398 // the actual point and the second one is the set of labels of the
399 // polynomials being queried at that point
400 let labels = query_to_labels_map
401 .entry(point_label)
402 .or_insert((point, BTreeSet::new()));
403 labels.1.insert(label);
404 }
405
406 // Implicit assumption: proofs are ordered in same manner as queries in
407 // `query_to_labels_map`.
408 let proofs: Vec<_> = proof.clone().into();
409 assert_eq!(proofs.len(), query_to_labels_map.len());
410
411 let mut result = true;
412 for ((_point_label, (point, labels)), proof) in query_to_labels_map.into_iter().zip(proofs)
413 {
414 // Constructing matching vectors with the commitment and claimed
415 // value of each polynomial being queried at `point`
416 let mut comms: Vec<&'_ LabeledCommitment<_>> = Vec::new();
417 let mut values = Vec::new();
418 for label in labels.into_iter() {
419 let commitment = commitments.get(label).ok_or(Error::MissingPolynomial {
420 label: label.to_string(),
421 })?;
422
423 let v_i = evaluations.get(&(label.clone(), point.clone())).ok_or(
424 Error::MissingEvaluation {
425 label: label.to_string(),
426 },
427 )?;
428
429 comms.push(commitment);
430 values.push(*v_i);

Callers

nothing calls this directly

Implementers 6

mod.rspoly-commit/src/marlin/marlin_pst13_pc
mod.rspoly-commit/src/marlin/marlin_pc/mod.r
mod.rspoly-commit/src/linear_codes/mod.rs
mod.rspoly-commit/src/ipa_pc/mod.rs
mod.rspoly-commit/src/sonic_pc/mod.rs
mod.rspoly-commit/src/hyrax/mod.rs

Calls 5

labelMethod · 0.80
iterMethod · 0.80
entryMethod · 0.80
insertMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected