aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-05-29 12:38:21 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-09-11 13:37:49 +0000
commit51eb3bdcd6090ae42d4aca24c35772f0d6104c72 (patch)
tree9d3968a9088395259743abc655c7d718ff432ca7 /tests
parentperformance_tests: add stats and loop count multiplier options (diff)
downloadmonero-51eb3bdcd6090ae42d4aca24c35772f0d6104c72.tar.xz
add pippenger unit tests
Diffstat (limited to 'tests')
-rw-r--r--tests/unit_tests/multiexp.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/unit_tests/multiexp.cpp b/tests/unit_tests/multiexp.cpp
index 2dce5bb80..10303c392 100644
--- a/tests/unit_tests/multiexp.cpp
+++ b/tests/unit_tests/multiexp.cpp
@@ -74,6 +74,13 @@ TEST(multiexp, straus_empty)
ASSERT_TRUE(basic(data) == straus(data));
}
+TEST(multiexp, pippenger_empty)
+{
+ std::vector<rct::MultiexpData> data;
+ data.push_back({rct::zero(), get_p3(rct::identity())});
+ ASSERT_TRUE(basic(data) == pippenger(data));
+}
+
TEST(multiexp, bos_coster_only_zeroes)
{
std::vector<rct::MultiexpData> data;
@@ -90,6 +97,14 @@ TEST(multiexp, straus_only_zeroes)
ASSERT_TRUE(basic(data) == straus(data));
}
+TEST(multiexp, pippenger_only_zeroes)
+{
+ std::vector<rct::MultiexpData> data;
+ for (int n = 0; n < 16; ++n)
+ data.push_back({rct::zero(), get_p3(TESTPOINT)});
+ ASSERT_TRUE(basic(data) == pippenger(data));
+}
+
TEST(multiexp, bos_coster_only_identities)
{
std::vector<rct::MultiexpData> data;
@@ -106,6 +121,14 @@ TEST(multiexp, straus_only_identities)
ASSERT_TRUE(basic(data) == straus(data));
}
+TEST(multiexp, pippenger_only_identities)
+{
+ std::vector<rct::MultiexpData> data;
+ for (int n = 0; n < 16; ++n)
+ data.push_back({TESTSCALAR, get_p3(rct::identity())});
+ ASSERT_TRUE(basic(data) == pippenger(data));
+}
+
TEST(multiexp, bos_coster_random)
{
std::vector<rct::MultiexpData> data;
@@ -126,6 +149,16 @@ TEST(multiexp, straus_random)
}
}
+TEST(multiexp, pippenger_random)
+{
+ std::vector<rct::MultiexpData> data;
+ for (int n = 0; n < 32; ++n)
+ {
+ data.push_back({rct::skGen(), get_p3(rct::scalarmultBase(rct::skGen()))});
+ ASSERT_TRUE(basic(data) == pippenger(data));
+ }
+}
+
TEST(multiexp, straus_cached)
{
static constexpr size_t N = 256;
@@ -147,3 +180,25 @@ TEST(multiexp, straus_cached)
ASSERT_TRUE(basic(data) == straus(data, cache));
}
}
+
+TEST(multiexp, pippenger_cached)
+{
+ static constexpr size_t N = 256;
+ std::vector<rct::MultiexpData> P(N);
+ for (size_t n = 0; n < N; ++n)
+ {
+ P[n].scalar = rct::zero();
+ ASSERT_TRUE(ge_frombytes_vartime(&P[n].point, rct::scalarmultBase(rct::skGen()).bytes) == 0);
+ }
+ std::shared_ptr<rct::pippenger_cached_data> cache = rct::pippenger_init_cache(P);
+ for (size_t n = 0; n < N/16; ++n)
+ {
+ std::vector<rct::MultiexpData> data;
+ size_t sz = 1 + crypto::rand<size_t>() % (N-1);
+ for (size_t s = 0; s < sz; ++s)
+ {
+ data.push_back({rct::skGen(), P[s].point});
+ }
+ ASSERT_TRUE(basic(data) == pippenger(data, cache));
+ }
+}