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

Method check

poly-commit/src/hyrax/mod.rs:418–511  ·  view source on GitHub ↗

Verifies a list of opening proofs and confirms the evaluation of the committed polynomials at the desired point. # Panics - If the point doesn't have an even number of variables. - If the length of a commitment does not correspond to the length of the point (specifically, commitment length should be 2^(point-length/2)). # Disregarded arguments - `rng`

(
        vk: &Self::VerifierKey,
        commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
        point: &'a P::Point,
        _values: impl IntoIterator<Item = G::Scal

Source from the content-addressed store, hash-verified

416 /// # Disregarded arguments
417 /// - `rng`
418 fn check<'a>(
419 vk: &Self::VerifierKey,
420 commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
421 point: &'a P::Point,
422 _values: impl IntoIterator<Item = G::ScalarField>,
423 proof: &Self::Proof,
424 sponge: &mut impl CryptographicSponge,
425 _rng: Option<&mut dyn RngCore>,
426 ) -> Result<bool, Self::Error>
427 where
428 Self::Commitment: 'a,
429 {
430 let n = point.len();
431
432 if n % 2 == 1 {
433 // Only polynomials with an even number of variables are
434 // supported in this implementation
435 return Err(Error::InvalidNumberOfVariables);
436 }
437
438 // Reversing the point is necessary because the MLE interface returns
439 // evaluations in little-endian order
440 let point_rev: Vec<G::ScalarField> = point.iter().rev().cloned().collect();
441
442 let point_lower = &point_rev[n / 2..];
443 let point_upper = &point_rev[..n / 2];
444
445 // Deriving the tensors which result in the evaluation of the polynomial
446 // when they are multiplied by the coefficient matrix.
447 let l = tensor_prime(point_lower);
448 let r = tensor_prime(point_upper);
449
450 for (com, h_proof) in commitments.into_iter().zip(proof.iter()) {
451 let row_coms = &com.commitment().row_coms;
452
453 // extract each field from h_proof
454 let HyraxProof {
455 com_eval,
456 com_d,
457 com_b,
458 z,
459 z_d,
460 z_b,
461 } = h_proof;
462
463 if row_coms.len() != 1 << n / 2 {
464 return Err(Error::IncorrectCommitmentSize {
465 encountered: row_coms.len(),
466 expected: 1 << n / 2,
467 });
468 }
469
470 // Absorbing public parameters
471 sponge.absorb(&serialize_to_vec!(*vk).map_err(|_| Error::TranscriptError)?);
472
473 // Absorbing the commitment to the polynomial
474 sponge.absorb(&serialize_to_vec!(*row_coms).map_err(|_| Error::TranscriptError)?);
475

Callers

nothing calls this directly

Calls 5

tensor_primeFunction · 0.85
inner_productFunction · 0.85
lenMethod · 0.80
iterMethod · 0.80
commitmentMethod · 0.80

Tested by

no test coverage detected