From bfcd00de5e2023e9cb20440af423fc2d4f8fa85c Mon Sep 17 00:00:00 2001 From: Skalman Date: Thu, 26 Sep 2024 15:09:34 -0400 Subject: [PATCH] Add multiple proof and verification test for benchmarking --- ring/src/lib.rs | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/ring/src/lib.rs b/ring/src/lib.rs index 21e5b2d..f610888 100644 --- a/ring/src/lib.rs +++ b/ring/src/lib.rs @@ -83,6 +83,8 @@ mod tests { use common::gadgets::ProverGadget; use common::gadgets::VerifierGadget; + use std::hint::black_box; + use super::*; fn _test_ring_proof< @@ -91,6 +93,7 @@ mod tests { CondAddT: CondAdd + ProverGadget, >( domain_size: usize, + repeat: usize, ) where CondAddT::CondAddValT: VerifierGadget, { @@ -116,12 +119,23 @@ mod tests { Transcript::new(b"ring-vrf-test"), ); let t_prove = start_timer!(|| "Prove"); + let mut proofs: Vec> = vec![]; + for _ in 0..repeat - 1 { + black_box(proofs.push(ring_prover.prove::(secret))); + } + let proof = ring_prover.prove::(secret); end_timer!(t_prove); let ring_verifier = RingVerifier::init(verifier_key, piop_params, Transcript::new(b"ring-vrf-test")); let t_verify = start_timer!(|| "Verify"); + for _ in 0..repeat - 1 { + black_box(ring_verifier.verify_ring_proof::( + proofs.pop().unwrap(), + result.into_affine(), + )); + } let res = ring_verifier.verify_ring_proof::(proof, result.into_affine()); end_timer!(t_verify); @@ -194,13 +208,14 @@ mod tests { #[test] fn test_ring_proof_kzg_sw() { - _test_ring_proof::, SWAffine, SwCondAdd>(2usize.pow(10)); + _test_ring_proof::, SWAffine, SwCondAdd>(2usize.pow(10), 1); } #[test] fn test_ring_proof_kzg_te() { _test_ring_proof::, EdwardsAffine, TeCondAdd>( 2usize.pow(10), + 1, ); } @@ -208,6 +223,7 @@ mod tests { fn test_ring_proof_id_sw() { _test_ring_proof::>( 2usize.pow(10), + 1, ); } @@ -217,6 +233,19 @@ mod tests { fflonk::pcs::IdentityCommitment, EdwardsAffine, TeCondAdd, - >(2usize.pow(10)); + >(2usize.pow(10), 1); + } + + #[test] + fn test_16k_ring_10_proofs_kzg_sw() { + _test_ring_proof::, SWAffine, SwCondAdd>(2usize.pow(14), 10); + } + + #[test] + fn test_16k_ring_10_proofs_kzg_te() { + _test_ring_proof::, EdwardsAffine, TeCondAdd>( + 2usize.pow(14), + 10, + ); } }