File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ bench_bench_bitcoin_SOURCES = \
22
22
bench/data.h \
23
23
bench/data.cpp \
24
24
bench/duplicate_inputs.cpp \
25
+ bench/ellsq.cpp \
25
26
bench/examples.cpp \
26
27
bench/rollingbloom.cpp \
27
28
bench/chacha20.cpp \
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2016-2020 The Bitcoin Core developers
2
+ // Distributed under the MIT software license, see the accompanying
3
+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
+
5
+ #include < bench/bench.h>
6
+
7
+ #include < pubkey.h>
8
+ #include < random.h>
9
+
10
+ #include < array>
11
+
12
+ EllSqPubKey GetRandomEllSq () {
13
+ EllSqPubKey encoded_pubkey;
14
+
15
+ // GetRandBytes can only give us up to 32 bytes at a time
16
+ GetRandBytes (encoded_pubkey.data (), 32 );
17
+ GetRandBytes (encoded_pubkey.data () + 32 , 32 );
18
+
19
+ return encoded_pubkey;
20
+ }
21
+
22
+ static void EllSqEncode (benchmark::Bench& bench)
23
+ {
24
+ std::array<uint8_t , 32 > rnd32;
25
+ GetRandBytes (rnd32.data (), 32 );
26
+
27
+ // Any 64 bytes are a valid encoding for a public key.
28
+ EllSqPubKey encoded_pubkey = GetRandomEllSq ();
29
+ CPubKey pubkey{encoded_pubkey};
30
+ bench.batch (1 ).unit (" pubkey" ).run ([&] {
31
+ pubkey.EllSqEncode (rnd32);
32
+ });
33
+ }
34
+
35
+ static void EllSqDecode (benchmark::Bench& bench)
36
+ {
37
+ // Any 64 bytes are a valid encoding for a public key.
38
+ EllSqPubKey encoded_pubkey = GetRandomEllSq ();
39
+ bench.batch (1 ).unit (" pubkey" ).run ([&] {
40
+ CPubKey pubkey{encoded_pubkey};
41
+ });
42
+ }
43
+
44
+ BENCHMARK (EllSqEncode);
45
+ BENCHMARK (EllSqDecode);
You can’t perform that action at this time.
0 commit comments