Skip to content

Commit

Permalink
Further cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
davxy committed Jul 27, 2024
1 parent 79e31c0 commit 6cbc42b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
10 changes: 10 additions & 0 deletions src/ietf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,16 @@ pub mod testing {
assert!(result.is_ok());
}

#[macro_export]
macro_rules! ietf_suite_tests {
($suite:ident) => {
#[test]
fn ietf_prove_verify() {
$crate::ietf::testing::prove_verify::<$suite>();
}
};
}

pub struct TestVector<S: IetfSuite> {
pub base: common::TestVector<S>,
pub c: ScalarField<S>,
Expand Down
12 changes: 11 additions & 1 deletion src/pedersen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub(crate) mod testing {
use super::*;
use crate::testing::{self as common, random_val, TEST_SEED};

pub fn pedersen_prove_verify<S: pedersen::PedersenSuite>() {
pub fn prove_verify<S: pedersen::PedersenSuite>() {
use pedersen::{Prover, Verifier};

let secret = Secret::<S>::from_seed(TEST_SEED);
Expand All @@ -163,6 +163,16 @@ pub(crate) mod testing {
);
}

#[macro_export]
macro_rules! pedersen_suite_tests {
($suite:ident) => {
#[test]
fn pedersen_prove_verify() {
$crate::pedersen::testing::prove_verify::<$suite>();
}
};
}

pub struct TestVector<S: PedersenSuite> {
pub base: common::TestVector<S>,
pub blind: ScalarField<S>,
Expand Down
12 changes: 5 additions & 7 deletions src/ring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,18 +307,16 @@ where
}

#[cfg(test)]
pub(crate) mod test {
pub(crate) mod testing {
use super::*;
use crate::testing::*;

pub fn ring_prove_verify<S: ring::RingSuite>()
pub fn prove_verify<S: RingSuite>()
where
BaseField<S>: ark_ff::PrimeField,
CurveConfig<S>: ark_ec::short_weierstrass::SWCurveConfig + Clone,
AffinePoint<S>: utils::te_sw_map::SWMapping<CurveConfig<S>>,
{
use ring::{Prover, RingContext, Verifier};

let rng = &mut ark_std::test_rng();
let ring_ctx = RingContext::<S>::from_rand(512, rng);

Expand All @@ -343,7 +341,7 @@ pub(crate) mod test {
assert!(result.is_ok());
}

pub fn check_complement_point<S: ring::RingSuite>()
pub fn check_complement_point<S: RingSuite>()
where
BaseField<S>: ark_ff::PrimeField,
CurveConfig<S>: ark_ec::short_weierstrass::SWCurveConfig + Clone,
Expand All @@ -361,13 +359,13 @@ pub(crate) mod test {
#[cfg(feature = "ring")]
#[test]
fn ring_prove_verify() {
$crate::ring::test::ring_prove_verify::<$suite>()
$crate::ring::testing::prove_verify::<$suite>()
}

#[cfg(feature = "ring")]
#[test]
fn check_complement_point() {
$crate::ring::test::check_complement_point::<$suite>()
$crate::ring::testing::check_complement_point::<$suite>()
}
};
($suite:ident, false) => {};
Expand Down
11 changes: 2 additions & 9 deletions src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,8 @@ macro_rules! suite_tests {
ring_suite_tests!($suite, $build_ring);
};
($suite:ident) => {
#[test]
fn ietf_prove_verify() {
$crate::ietf::testing::prove_verify::<$suite>();
}

#[test]
fn pedersen_prove_verify() {
$crate::pedersen::testing::pedersen_prove_verify::<$suite>();
}
ietf_suite_tests!($suite);
pedersen_suite_tests!($suite);
};
}

Expand Down

0 comments on commit 6cbc42b

Please sign in to comment.