From bacf0a1e2ff54ef1fc77e3f6ec92e87946084c1a Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 3 Feb 2018 14:36:29 +0000 Subject: bulletproofs: add aggregated verification Ported from sarang's java code --- tests/performance_tests/bulletproof.h | 38 +++++++++++++++++++++++++++++ tests/performance_tests/main.cpp | 11 +++++++++ tests/performance_tests/performance_tests.h | 2 ++ 3 files changed, 51 insertions(+) (limited to 'tests/performance_tests') diff --git a/tests/performance_tests/bulletproof.h b/tests/performance_tests/bulletproof.h index b11c9fe97..7bb702c3d 100644 --- a/tests/performance_tests/bulletproof.h +++ b/tests/performance_tests/bulletproof.h @@ -60,3 +60,41 @@ public: private: rct::Bulletproof proof; }; + +template +class test_aggregated_bulletproof +{ +public: + static const size_t loop_count = 500 / (N * repeat); + + bool init() + { + size_t o = start; + for (size_t n = 0; n < N; ++n) + { + //printf("adding %zu times %zu\n", repeat, o); + for (size_t i = 0; i < repeat; ++i) + proofs.push_back(rct::bulletproof_PROVE(std::vector(o, 749327532984), rct::skvGen(o))); + o = o * mul + add; + } + return true; + } + + bool test() + { + if (batch) + { + return rct::bulletproof_VERIFY(proofs); + } + else + { + for (const rct::Bulletproof &proof: proofs) + if (!rct::bulletproof_VERIFY(proof)) + return false; + return true; + } + } + +private: + std::vector proofs; +}; diff --git a/tests/performance_tests/main.cpp b/tests/performance_tests/main.cpp index a00f05ce7..c125f9042 100644 --- a/tests/performance_tests/main.cpp +++ b/tests/performance_tests/main.cpp @@ -183,6 +183,17 @@ int main(int argc, char** argv) TEST_PERFORMANCE2(filter, verbose, test_bulletproof, true, 15); TEST_PERFORMANCE2(filter, verbose, test_bulletproof, false, 15); + TEST_PERFORMANCE6(filter, verbose, test_aggregated_bulletproof, false, 2, 1, 1, 0, 4); + TEST_PERFORMANCE6(filter, verbose, test_aggregated_bulletproof, true, 2, 1, 1, 0, 4); + TEST_PERFORMANCE6(filter, verbose, test_aggregated_bulletproof, false, 8, 1, 1, 0, 4); + TEST_PERFORMANCE6(filter, verbose, test_aggregated_bulletproof, true, 8, 1, 1, 0, 4); + TEST_PERFORMANCE6(filter, verbose, test_aggregated_bulletproof, false, 1, 1, 2, 0, 4); + TEST_PERFORMANCE6(filter, verbose, test_aggregated_bulletproof, true, 1, 1, 2, 0, 4); + TEST_PERFORMANCE6(filter, verbose, test_aggregated_bulletproof, false, 1, 8, 1, 1, 4); + TEST_PERFORMANCE6(filter, verbose, test_aggregated_bulletproof, true, 1, 8, 1, 1, 4); + TEST_PERFORMANCE6(filter, verbose, test_aggregated_bulletproof, false, 2, 1, 1, 0, 64); + TEST_PERFORMANCE6(filter, verbose, test_aggregated_bulletproof, true, 2, 1, 1, 0, 64); + TEST_PERFORMANCE3(filter, verbose, test_ringct_mlsag, 1, 3, false); TEST_PERFORMANCE3(filter, verbose, test_ringct_mlsag, 1, 5, false); TEST_PERFORMANCE3(filter, verbose, test_ringct_mlsag, 1, 10, false); diff --git a/tests/performance_tests/performance_tests.h b/tests/performance_tests/performance_tests.h index 6f613e0a5..ce9baf61f 100644 --- a/tests/performance_tests/performance_tests.h +++ b/tests/performance_tests/performance_tests.h @@ -169,3 +169,5 @@ void run_test(const std::string &filter, bool verbose, const char* test_name) #define TEST_PERFORMANCE2(filter, verbose, test_class, a0, a1) run_test< test_class >(filter, verbose, QUOTEME(test_class) "<" QUOTEME(a0) ", " QUOTEME(a1) ">") #define TEST_PERFORMANCE3(filter, verbose, test_class, a0, a1, a2) run_test< test_class >(filter, verbose, QUOTEME(test_class) "<" QUOTEME(a0) ", " QUOTEME(a1) ", " QUOTEME(a2) ">") #define TEST_PERFORMANCE4(filter, verbose, test_class, a0, a1, a2, a3) run_test< test_class >(filter, verbose, QUOTEME(test_class) "<" QUOTEME(a0) ", " QUOTEME(a1) ", " QUOTEME(a2) ", " QUOTEME(a3) ">") +#define TEST_PERFORMANCE5(filter, verbose, test_class, a0, a1, a2, a3, a4) run_test< test_class >(filter, verbose, QUOTEME(test_class) "<" QUOTEME(a0) ", " QUOTEME(a1) ", " QUOTEME(a2) ", " QUOTEME(a3) ", " QUOTEME(a4) ">") +#define TEST_PERFORMANCE6(filter, verbose, test_class, a0, a1, a2, a3, a4, a5) run_test< test_class >(filter, verbose, QUOTEME(test_class) "<" QUOTEME(a0) ", " QUOTEME(a1) ", " QUOTEME(a2) ", " QUOTEME(a3) ", " QUOTEME(a4) ", " QUOTEME(a5) ">") -- cgit v1.2.3