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

Method check

poly-commit/src/linear_codes/mod.rs:375–502  ·  view source on GitHub ↗
(
        vk: &Self::VerifierKey,
        commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
        point: &'a P::Point,
        values: impl IntoIterator<Item = F>,
    

Source from the content-addressed store, hash-verified

373 }
374
375 fn check<'a>(
376 vk: &Self::VerifierKey,
377 commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
378 point: &'a P::Point,
379 values: impl IntoIterator<Item = F>,
380 proof_array: &Self::Proof,
381 sponge: &mut impl CryptographicSponge,
382 _rng: Option<&mut dyn RngCore>,
383 ) -> Result<bool, Self::Error>
384 where
385 Self::Commitment: 'a,
386 {
387 let leaf_hash_param: &<<C as Config>::LeafHash as CRHScheme>::Parameters =
388 vk.leaf_hash_param();
389 let two_to_one_hash_param: &<<C as Config>::TwoToOneHash as TwoToOneCRHScheme>::Parameters =
390 vk.two_to_one_hash_param();
391
392 for (i, (labeled_commitment, value)) in commitments.into_iter().zip(values).enumerate() {
393 let proof = &proof_array[i];
394 let commitment = labeled_commitment.commitment();
395 let n_rows = commitment.metadata.n_rows;
396 let n_cols = commitment.metadata.n_cols;
397 let n_ext_cols = commitment.metadata.n_ext_cols;
398 let root = &commitment.root;
399 let t = calculate_t::<F>(vk.sec_param(), vk.distance(), n_ext_cols)?;
400
401 sponge.absorb(&to_bytes!(&commitment.root).map_err(|_| Error::TranscriptError)?);
402
403 let out = if vk.check_well_formedness() {
404 if proof.well_formedness.is_none() {
405 return Err(Error::InvalidCommitment);
406 }
407 let tmp = &proof.well_formedness.as_ref();
408 let v = tmp.unwrap();
409 let r = sponge.squeeze_field_elements::<F>(n_rows);
410 // Upon sending `v` to the Verifier, add it to the sponge. The claim is that v = r.M.
411 sponge.absorb(&v);
412
413 (Some(v), Some(r))
414 } else {
415 (None, None)
416 };
417
418 // 1. Seed the transcript with the point and the recieved vector
419 // TODO Consider removing the evaluation point from the transcript.
420 let point_vec = L::point_to_vec(point.clone());
421 sponge.absorb(&point_vec);
422 sponge.absorb(&proof.opening.v);
423
424 // 2. Ask random oracle for the `t` indices where the checks happen.
425 let indices = get_indices_from_sponge(n_ext_cols, t, sponge)?;
426
427 // 3. Hash the received columns into leaf hashes.
428 let col_hashes: Vec<C::Leaf> = proof
429 .opening
430 .columns
431 .iter()
432 .map(|c| {

Callers

nothing calls this directly

Calls 11

get_indices_from_spongeFunction · 0.85
inner_productFunction · 0.85
commitmentMethod · 0.80
iterMethod · 0.80
verifyMethod · 0.80
leaf_hash_paramMethod · 0.45
two_to_one_hash_paramMethod · 0.45
sec_paramMethod · 0.45
distanceMethod · 0.45
check_well_formednessMethod · 0.45
col_hash_paramsMethod · 0.45

Tested by

no test coverage detected