aboutsummaryrefslogtreecommitdiff
path: root/tests/unit_tests
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2018-11-16 11:11:10 +0200
committerRiccardo Spagni <ric@spagni.net>2018-11-16 11:11:10 +0200
commit46f989bc49eddf067a95bc95c3086f68b98a2708 (patch)
treefde607546a6a8db3aa1e1f9ad60fa3485a01f807 /tests/unit_tests
parentMerge pull request #4794 (diff)
parentrct: add a zeroCommit cache for common pre-rct case (diff)
downloadmonero-46f989bc49eddf067a95bc95c3086f68b98a2708.tar.xz
Merge pull request #4795
5d7c2316 rct: add a zeroCommit cache for common pre-rct case (moneromooo-monero)
Diffstat (limited to 'tests/unit_tests')
-rw-r--r--tests/unit_tests/ringct.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/unit_tests/ringct.cpp b/tests/unit_tests/ringct.cpp
index 3877ef785..52bdb00cf 100644
--- a/tests/unit_tests/ringct.cpp
+++ b/tests/unit_tests/ringct.cpp
@@ -1086,6 +1086,25 @@ TEST(ringct, zeroCommmit)
ASSERT_EQ(z, manual);
}
+static rct::key uncachedZeroCommit(uint64_t amount)
+{
+ const rct::key am = rct::d2h(amount);
+ const rct::key bH = rct::scalarmultH(am);
+ return rct::addKeys(rct::G, bH);
+}
+
+TEST(ringct, zeroCommitCache)
+{
+ ASSERT_EQ(rct::zeroCommit(0), uncachedZeroCommit(0));
+ ASSERT_EQ(rct::zeroCommit(1), uncachedZeroCommit(1));
+ ASSERT_EQ(rct::zeroCommit(2), uncachedZeroCommit(2));
+ ASSERT_EQ(rct::zeroCommit(10), uncachedZeroCommit(10));
+ ASSERT_EQ(rct::zeroCommit(200), uncachedZeroCommit(200));
+ ASSERT_EQ(rct::zeroCommit(1000000000), uncachedZeroCommit(1000000000));
+ ASSERT_EQ(rct::zeroCommit(3000000000000), uncachedZeroCommit(3000000000000));
+ ASSERT_EQ(rct::zeroCommit(900000000000000), uncachedZeroCommit(900000000000000));
+}
+
TEST(ringct, H)
{
ge_p3 p3;