|
12 | 12 | #include <script/script.h>
|
13 | 13 | #include <script/sign.h>
|
14 | 14 | #include <uint256.h>
|
| 15 | +#include <test/util/random.h> |
15 | 16 | #include <util/translation.h>
|
16 | 17 |
|
17 | 18 | enum class InputType {
|
@@ -66,5 +67,33 @@ static void SignTransactionSingleInput(benchmark::Bench& bench, InputType input_
|
66 | 67 | static void SignTransactionECDSA(benchmark::Bench& bench) { SignTransactionSingleInput(bench, InputType::P2WPKH); }
|
67 | 68 | static void SignTransactionSchnorr(benchmark::Bench& bench) { SignTransactionSingleInput(bench, InputType::P2TR); }
|
68 | 69 |
|
| 70 | +static void SignSchnorrTapTweakBenchmark(benchmark::Bench& bench, bool use_null_merkle_root) |
| 71 | +{ |
| 72 | + ECC_Context ecc_context{}; |
| 73 | + |
| 74 | + auto key = GenerateRandomKey(); |
| 75 | + auto msg = InsecureRand256(); |
| 76 | + auto merkle_root = use_null_merkle_root ? uint256() : InsecureRand256(); |
| 77 | + auto aux = InsecureRand256(); |
| 78 | + std::vector<unsigned char> sig(64); |
| 79 | + |
| 80 | + bench.minEpochIterations(100).run([&] { |
| 81 | + bool success = key.SignSchnorr(msg, sig, &merkle_root, aux); |
| 82 | + assert(success); |
| 83 | + }); |
| 84 | +} |
| 85 | + |
| 86 | +static void SignSchnorrWithMerkleRoot(benchmark::Bench& bench) |
| 87 | +{ |
| 88 | + SignSchnorrTapTweakBenchmark(bench, /*use_null_merkle_root=*/false); |
| 89 | +} |
| 90 | + |
| 91 | +static void SignSchnorrWithNullMerkleRoot(benchmark::Bench& bench) |
| 92 | +{ |
| 93 | + SignSchnorrTapTweakBenchmark(bench, /*use_null_merkle_root=*/true); |
| 94 | +} |
| 95 | + |
69 | 96 | BENCHMARK(SignTransactionECDSA, benchmark::PriorityLevel::HIGH);
|
70 | 97 | BENCHMARK(SignTransactionSchnorr, benchmark::PriorityLevel::HIGH);
|
| 98 | +BENCHMARK(SignSchnorrWithMerkleRoot, benchmark::PriorityLevel::HIGH); |
| 99 | +BENCHMARK(SignSchnorrWithNullMerkleRoot, benchmark::PriorityLevel::HIGH); |
0 commit comments