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

Function batch_check_test_template

poly-commit/src/kzg10/mod.rs:605–642  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

603 }
604
605 fn batch_check_test_template<E, P>() -> Result<(), Error>
606 where
607 E: Pairing,
608 P: DenseUVPolynomial<E::ScalarField, Point = E::ScalarField>,
609 for<'a, 'b> &'a P: Div<&'b P, Output = P>,
610 {
611 let rng = &mut test_rng();
612 for _ in 0..10 {
613 let mut degree = 0;
614 while degree <= 1 {
615 degree = usize::rand(rng) % 20;
616 }
617 let pp = KZG10::<E, P>::setup(degree, false, rng)?;
618 let (ck, vk) = KZG10::<E, P>::trim(&pp, degree)?;
619 let mut comms = Vec::new();
620 let mut values = Vec::new();
621 let mut points = Vec::new();
622 let mut proofs = Vec::new();
623 for _ in 0..10 {
624 let p = P::rand(degree, rng);
625 let hiding_bound = Some(1);
626 let (comm, rand) = KZG10::<E, P>::commit(&ck, &p, hiding_bound, Some(rng))?;
627 let point = E::ScalarField::rand(rng);
628 let value = p.evaluate(&point);
629 let proof = KZG10::<E, P>::open(&ck, &p, point, &rand)?;
630
631 assert!(KZG10::<E, P>::check(&vk, &comm, point, value, &proof)?);
632 comms.push(comm);
633 values.push(value);
634 points.push(point);
635 proofs.push(proof);
636 }
637 assert!(KZG10::<E, P>::batch_check(
638 &vk, &comms, &points, &values, &proofs, rng
639 )?);
640 }
641 Ok(())
642 }
643
644 #[test]
645 fn end_to_end_test() {

Callers

nothing calls this directly

Calls 4

commitFunction · 0.85
openFunction · 0.85
pushMethod · 0.80
evaluateMethod · 0.45

Tested by

no test coverage detected