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
| 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); |
nothing calls this directly
no test coverage detected