File tree 2 files changed +47
-0
lines changed
2 files changed +47
-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
+ {
14
+ EllSqPubKey encoded_pubkey;
15
+
16
+ // GetRandBytes can only give us up to 32 bytes at a time
17
+ GetRandBytes (encoded_pubkey.data (), 32 );
18
+ GetRandBytes (encoded_pubkey.data () + 32 , 32 );
19
+
20
+ return encoded_pubkey;
21
+ }
22
+
23
+ static void EllSqEncode (benchmark::Bench& bench)
24
+ {
25
+ std::array<uint8_t , 32 > rnd32;
26
+ GetRandBytes (rnd32.data (), 32 );
27
+
28
+ // Any 64 bytes are a valid encoding for a public key.
29
+ EllSqPubKey encoded_pubkey = GetRandomEllSq ();
30
+ CPubKey pubkey{encoded_pubkey};
31
+ bench.batch (1 ).unit (" pubkey" ).run ([&] {
32
+ pubkey.EllSqEncode (rnd32);
33
+ });
34
+ }
35
+
36
+ static void EllSqDecode (benchmark::Bench& bench)
37
+ {
38
+ // Any 64 bytes are a valid encoding for a public key.
39
+ EllSqPubKey encoded_pubkey = GetRandomEllSq ();
40
+ bench.batch (1 ).unit (" pubkey" ).run ([&] {
41
+ CPubKey pubkey{encoded_pubkey};
42
+ });
43
+ }
44
+
45
+ BENCHMARK (EllSqEncode);
46
+ BENCHMARK (EllSqDecode);
You can’t perform that action at this time.
0 commit comments