From 722b0117d01f75f88442ccfc27685435ab28ac8f Mon Sep 17 00:00:00 2001 From: Taylor Hornby Date: Mon, 11 Apr 2016 11:51:12 -0600 Subject: [PATCH] Benchmark a random equihash input. --- src/zcbenchmarks.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/zcbenchmarks.cpp b/src/zcbenchmarks.cpp index 649297d31..6a6bf6ae2 100644 --- a/src/zcbenchmarks.cpp +++ b/src/zcbenchmarks.cpp @@ -8,6 +8,8 @@ #include "crypto/equihash.h" #include "chainparams.h" #include "pow.h" +#include "sodium.h" +#include "streams.h" #include "zcbenchmarks.h" @@ -101,11 +103,22 @@ double benchmark_verify_joinsplit(const CPourTx &joinsplit) double benchmark_solve_equihash() { - const char *testing = "testing"; + CBlock pblock; + CEquihashInput I{pblock}; + CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); + ss << I; + Equihash eh {Params(CBaseChainParams::MAIN).EquihashN(), Params(CBaseChainParams::MAIN).EquihashK()}; crypto_generichash_blake2b_state eh_state; eh.InitialiseState(eh_state); - crypto_generichash_blake2b_update(&eh_state, (const unsigned char*)testing, strlen(testing)); + crypto_generichash_blake2b_update(&eh_state, (unsigned char*)&ss[0], ss.size()); + + uint256 nonce; + randombytes_buf(nonce.begin(), 32); + crypto_generichash_blake2b_update(&eh_state, + nonce.begin(), + nonce.size()); + timer_start(); eh.BasicSolve(eh_state); return timer_stop();