Skip to content

Commit

Permalink
Reworked tests for marshalling #319
Browse files Browse the repository at this point in the history
  • Loading branch information
vo-nil committed Aug 29, 2024
1 parent 884198f commit 9cd0eae
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions libs/marshalling/algebra/test/curve_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,29 +128,42 @@ void test_curve(std::string curve_name)
std::cout << "Marshaling of G1 group elements" << std::endl;
test_group_element<typename curve_type::template g1_type<>>();

if constexpr(nil::crypto3::algebra::has_template_g2_type<curve_type>::value) {
std::cout << "Marshaling of G2 group elements" << std::endl;
test_group_element<typename curve_type::template g2_type<>>();
std::cout << "Marshaling of GT group elements" << std::endl;
test_group_element<typename curve_type::template g2_type<>>();
}

std::cout << "Testing of " << curve_name << " finished" << std::endl;

}

template<typename curve_type>
void test_pairing_curve(std::string curve_name)
{
std::cout << "Testing curve: " << curve_name << std::endl;

std::cout << "Marshaling of G1 group elements" << std::endl;
test_group_element<typename curve_type::template g1_type<>>();

std::cout << "Marshaling of G2 group elements" << std::endl;
test_group_element<typename curve_type::template g2_type<>>();

/* TODO: do we really need to marshal GT elements?
std::cout << "Marshaling of GT group elements" << std::endl;
test_group_element<typename curve_type::gt_type>();
*/

std::cout << "Testing of " << curve_name << " finished" << std::endl;
}


BOOST_AUTO_TEST_SUITE(curve_element_test_suite)

BOOST_AUTO_TEST_CASE(curve_element_mnt4) {
test_curve<nil::crypto3::algebra::curves::mnt4_298>("mnt4_298");
test_pairing_curve<nil::crypto3::algebra::curves::mnt4_298>("mnt4_298");
}

BOOST_AUTO_TEST_CASE(curve_element_mnt6) {
test_curve<nil::crypto3::algebra::curves::mnt6_298>("mnt6_298");
test_pairing_curve<nil::crypto3::algebra::curves::mnt6_298>("mnt6_298");
}

BOOST_AUTO_TEST_CASE(curve_element_bls12_381) {
test_curve<nil::crypto3::algebra::curves::bls12_381>("bls12_381");
test_pairing_curve<nil::crypto3::algebra::curves::bls12_381>("bls12_381");
}

// TODO: implement marshalling for bls12<377>
Expand All @@ -161,7 +174,7 @@ BOOST_AUTO_TEST_CASE(curve_element_bls12_377) {
#endif

BOOST_AUTO_TEST_CASE(curve_element_bn254) {
test_curve<nil::crypto3::algebra::curves::alt_bn128_254>("alt_bn128_254");
test_pairing_curve<nil::crypto3::algebra::curves::alt_bn128_254>("alt_bn128_254");
}

// TODO: implement marshalling for pasta curves
Expand Down

0 comments on commit 9cd0eae

Please sign in to comment.