Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

poly1305.cpp
Go to the documentation of this file.
1 // Copyright (c) 2019 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 <iostream>
6 #include <vector>
7 
8 #include <bench/bench.h>
9 #include <crypto/poly1305.h>
10 
11 /* Number of bytes to process per iteration */
12 static constexpr uint64_t BUFFER_SIZE_TINY = 64;
13 static constexpr uint64_t BUFFER_SIZE_SMALL = 256;
14 static constexpr uint64_t BUFFER_SIZE_LARGE = 1024*1024;
15 
16 static void POLY1305(benchmark::State& state, size_t buffersize)
17 {
18  std::vector<unsigned char> tag(POLY1305_TAGLEN, 0);
19  std::vector<unsigned char> key(POLY1305_KEYLEN, 0);
20  std::vector<unsigned char> in(buffersize, 0);
21  while (state.KeepRunning())
22  poly1305_auth(tag.data(), in.data(), in.size(), key.data());
23 }
24 
26 {
27  POLY1305(state, BUFFER_SIZE_TINY);
28 }
29 
31 {
33 }
34 
35 static void POLY1305_1MB(benchmark::State& state)
36 {
38 }
39 
40 //TODO add back below once benchmarking backports are done
41 BENCHMARK(POLY1305_64BYTES/*, 500000*/);
42 BENCHMARK(POLY1305_256BYTES/*, 250000*/);
43 BENCHMARK(POLY1305_1MB/*, 340*/);
#define POLY1305_TAGLEN
Definition: poly1305.h:12
static constexpr uint64_t BUFFER_SIZE_SMALL
Definition: poly1305.cpp:13
bool KeepRunning()
Definition: bench.cpp:39
static void POLY1305(benchmark::State &state, size_t buffersize)
Definition: poly1305.cpp:16
static constexpr uint64_t BUFFER_SIZE_LARGE
Definition: poly1305.cpp:14
BENCHMARK(POLY1305_64BYTES)
void poly1305_auth(unsigned char out[POLY1305_TAGLEN], const unsigned char *m, size_t inlen, const unsigned char key[POLY1305_KEYLEN])
Definition: poly1305.cpp:15
static constexpr uint64_t BUFFER_SIZE_TINY
Definition: poly1305.cpp:12
static void POLY1305_64BYTES(benchmark::State &state)
Definition: poly1305.cpp:25
static void POLY1305_256BYTES(benchmark::State &state)
Definition: poly1305.cpp:30
static void POLY1305_1MB(benchmark::State &state)
Definition: poly1305.cpp:35
#define POLY1305_KEYLEN
Definition: poly1305.h:11
Released under the MIT license