diff options
author | Riccardo Spagni <ric@spagni.net> | 2018-11-16 11:11:10 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2018-11-16 11:11:10 +0200 |
commit | 46f989bc49eddf067a95bc95c3086f68b98a2708 (patch) | |
tree | fde607546a6a8db3aa1e1f9ad60fa3485a01f807 /tests | |
parent | Merge pull request #4794 (diff) | |
parent | rct: add a zeroCommit cache for common pre-rct case (diff) | |
download | monero-46f989bc49eddf067a95bc95c3086f68b98a2708.tar.xz |
Merge pull request #4795
5d7c2316 rct: add a zeroCommit cache for common pre-rct case (moneromooo-monero)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/performance_tests/crypto_ops.h | 4 | ||||
-rw-r--r-- | tests/performance_tests/main.cpp | 2 | ||||
-rw-r--r-- | tests/unit_tests/ringct.cpp | 19 |
3 files changed, 25 insertions, 0 deletions
diff --git a/tests/performance_tests/crypto_ops.h b/tests/performance_tests/crypto_ops.h index 4766a1205..3ebb6f470 100644 --- a/tests/performance_tests/crypto_ops.h +++ b/tests/performance_tests/crypto_ops.h @@ -40,6 +40,7 @@ enum test_op op_sc_mul, op_ge_add_raw, op_ge_add_p3_p3, + op_zeroCommitCached, ops_fast, op_addKeys, @@ -55,6 +56,7 @@ enum test_op op_addKeys3, op_addKeys3_2, op_isInMainSubgroup, + op_zeroCommitUncached, }; template<test_op op> @@ -111,6 +113,8 @@ public: case op_addKeys3: rct::addKeys3(key, scalar0, point0, scalar1, precomp1); break; case op_addKeys3_2: rct::addKeys3(key, scalar0, precomp0, scalar1, precomp1); break; case op_isInMainSubgroup: rct::isInMainSubgroup(point0); break; + case op_zeroCommitUncached: rct::zeroCommit(9001); break; + case op_zeroCommitCached: rct::zeroCommit(9000); break; default: return false; } return true; diff --git a/tests/performance_tests/main.cpp b/tests/performance_tests/main.cpp index 58daf6220..6749b71e4 100644 --- a/tests/performance_tests/main.cpp +++ b/tests/performance_tests/main.cpp @@ -261,6 +261,8 @@ int main(int argc, char** argv) TEST_PERFORMANCE1(filter, p, test_crypto_ops, op_addKeys3); TEST_PERFORMANCE1(filter, p, test_crypto_ops, op_addKeys3_2); TEST_PERFORMANCE1(filter, p, test_crypto_ops, op_isInMainSubgroup); + TEST_PERFORMANCE1(filter, p, test_crypto_ops, op_zeroCommitUncached); + TEST_PERFORMANCE1(filter, p, test_crypto_ops, op_zeroCommitCached); TEST_PERFORMANCE2(filter, p, test_multiexp, multiexp_bos_coster, 2); TEST_PERFORMANCE2(filter, p, test_multiexp, multiexp_bos_coster, 4); 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; |