diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-07-26 11:09:48 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-09-11 13:38:19 +0000 |
commit | d0a0565f7d2aa658b0632acd11b61ac705bd2294 (patch) | |
tree | 453ceb69b400fce99d870be9a73dae5f8d38e051 | |
parent | core_tests: add a test for a tx with empty bulletproof (diff) | |
download | monero-d0a0565f7d2aa658b0632acd11b61ac705bd2294.tar.xz |
unit_tests: add a few more multiexp unit tests
-rw-r--r-- | tests/unit_tests/multiexp.cpp | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/tests/unit_tests/multiexp.cpp b/tests/unit_tests/multiexp.cpp index 10303c392..d8d79a7a2 100644 --- a/tests/unit_tests/multiexp.cpp +++ b/tests/unit_tests/multiexp.cpp @@ -32,8 +32,10 @@ #include "ringct/rctOps.h" #include "ringct/multiexp.h" -static const rct::key TESTSCALAR = rct::H; -static const rct::key TESTPOINT = rct::scalarmultBase(rct::H); +static const rct::key TESTSCALAR = rct::skGen(); +static const rct::key TESTPOW2SCALAR = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; +static const rct::key TESTSMALLSCALAR = {{5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; +static const rct::key TESTPOINT = rct::scalarmultBase(rct::skGen()); static rct::key basic(const std::vector<rct::MultiexpData> &data) { @@ -81,6 +83,54 @@ TEST(multiexp, pippenger_empty) ASSERT_TRUE(basic(data) == pippenger(data)); } +TEST(multiexp, bos_coster_zero_and_non_zero) +{ + std::vector<rct::MultiexpData> data; + data.push_back({rct::zero(), get_p3(TESTPOINT)}); + data.push_back({TESTSCALAR, get_p3(TESTPOINT)}); + ASSERT_TRUE(basic(data) == bos_coster_heap_conv_robust(data)); +} + +TEST(multiexp, straus_zero_and_non_zero) +{ + std::vector<rct::MultiexpData> data; + data.push_back({rct::zero(), get_p3(TESTPOINT)}); + data.push_back({TESTSCALAR, get_p3(TESTPOINT)}); + ASSERT_TRUE(basic(data) == straus(data)); +} + +TEST(multiexp, pippenger_zero_and_non_zero) +{ + std::vector<rct::MultiexpData> data; + data.push_back({rct::zero(), get_p3(TESTPOINT)}); + data.push_back({TESTSCALAR, get_p3(TESTPOINT)}); + ASSERT_TRUE(basic(data) == pippenger(data)); +} + +TEST(multiexp, bos_coster_pow2_scalar) +{ + std::vector<rct::MultiexpData> data; + data.push_back({TESTPOW2SCALAR, get_p3(TESTPOINT)}); + data.push_back({TESTSMALLSCALAR, get_p3(TESTPOINT)}); + ASSERT_TRUE(basic(data) == bos_coster_heap_conv_robust(data)); +} + +TEST(multiexp, straus_pow2_scalar) +{ + std::vector<rct::MultiexpData> data; + data.push_back({TESTPOW2SCALAR, get_p3(TESTPOINT)}); + data.push_back({TESTSMALLSCALAR, get_p3(TESTPOINT)}); + ASSERT_TRUE(basic(data) == straus(data)); +} + +TEST(multiexp, pippenger_pow2_scalar) +{ + std::vector<rct::MultiexpData> data; + data.push_back({TESTPOW2SCALAR, get_p3(TESTPOINT)}); + data.push_back({TESTSMALLSCALAR, get_p3(TESTPOINT)}); + ASSERT_TRUE(basic(data) == pippenger(data)); +} + TEST(multiexp, bos_coster_only_zeroes) { std::vector<rct::MultiexpData> data; |