| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "ringct/rctSigs.h" |
| 34 |
#include "ringct/bulletproofs_plus.h" |
| 35 |
|
| 36 |
template<bool a_verify, size_t n_amounts> |
| 37 |
class test_bulletproof_plus |
| 38 |
{ |
| 39 |
public: |
| 40 |
static const size_t approx_loop_count = 100 / n_amounts; |
| 41 |
static const size_t loop_count = (approx_loop_count >= 10 ? approx_loop_count : 10) / (a_verify ? 1 : 5); |
| 42 |
static const bool verify = a_verify; |
| 43 |
|
| 44 |
bool init() |
| 45 |
{ |
| 46 |
proof = rct::bulletproof_plus_PROVE(std::vector<uint64_t>(n_amounts, 749327532984), rct::skvGen(n_amounts)); |
| 47 |
return true; |
| 48 |
} |
| 49 |
|
| 50 |
bool test() |
| 51 |
{ |
| 52 |
bool ret = true; |
| 53 |
if (verify) |
| 54 |
ret = rct::bulletproof_plus_VERIFY(proof); |
| 55 |
else |
| 56 |
rct::bulletproof_plus_PROVE(std::vector<uint64_t>(n_amounts, 749327532984), rct::skvGen(n_amounts)); |
| 57 |
return ret; |
| 58 |
} |
| 59 |
|
| 60 |
private: |
| 61 |
rct::BulletproofPlus proof; |
| 62 |
}; |
| 63 |
|
| 64 |
template<bool batch, size_t start, size_t repeat, size_t mul, size_t add, size_t N> |
| 65 |
class test_aggregated_bulletproof_plus |
| 66 |
{ |
| 67 |
public: |
| 68 |
static const size_t loop_count = 500 / (N * repeat); |
| 69 |
|
| 70 |
bool init() |
| 71 |
{ |
| 72 |
size_t o = start; |
| 73 |
for (size_t n = 0; n < N; ++n) |
| 74 |
{ |
| 75 |
for (size_t i = 0; i < repeat; ++i) |
| 76 |
proofs.push_back(rct::bulletproof_plus_PROVE(std::vector<uint64_t>(o, 749327532984), rct::skvGen(o))); |
| 77 |
o = o * mul + add; |
| 78 |
} |
| 79 |
return true; |
| 80 |
} |
| 81 |
|
| 82 |
bool test() |
| 83 |
{ |
| 84 |
if (batch) |
| 85 |
{ |
| 86 |
return rct::bulletproof_plus_VERIFY(proofs); |
| 87 |
} |
| 88 |
else |
| 89 |
{ |
| 90 |
for (const rct::BulletproofPlus &proof: proofs) |
| 91 |
if (!rct::bulletproof_plus_VERIFY(proof)) |
| 92 |
return false; |
| 93 |
return true; |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
private: |
| 98 |
std::vector<rct::BulletproofPlus> proofs; |
| 99 |
}; |