diff options
author | Neozaru <neozaru@mailoo.org> | 2014-06-01 18:21:30 +0200 |
---|---|---|
committer | Neozaru <neozaru@mailoo.org> | 2014-06-01 18:21:30 +0200 |
commit | 8530629e22d88de4c2fd4d7d231b00c65d30100d (patch) | |
tree | 0890c9ee74331cd1f27093833718d3cf7eb20d26 /tests/performance_tests/cn_slow_hash.h | |
parent | simplewallet returns 0 when no error (diff) | |
parent | Merge branch '0.8.8update' (diff) | |
download | monero-8530629e22d88de4c2fd4d7d231b00c65d30100d.tar.xz |
Merge bitmonero@monero-project
Diffstat (limited to 'tests/performance_tests/cn_slow_hash.h')
-rw-r--r-- | tests/performance_tests/cn_slow_hash.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/performance_tests/cn_slow_hash.h b/tests/performance_tests/cn_slow_hash.h new file mode 100644 index 000000000..ec001326e --- /dev/null +++ b/tests/performance_tests/cn_slow_hash.h @@ -0,0 +1,45 @@ +// Copyright (c) 2012-2013 The Cryptonote developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#pragma once + +#include "crypto/crypto.h" +#include "cryptonote_core/cryptonote_basic.h" + +class test_cn_slow_hash +{ +public: + static const size_t loop_count = 10; + +#pragma pack(push, 1) + struct data_t + { + char data[13]; + }; +#pragma pack(pop) + + static_assert(13 == sizeof(data_t), "Invalid structure size"); + + bool init() + { + if (!epee::string_tools::hex_to_pod("63617665617420656d70746f72", m_data)) + return false; + + if (!epee::string_tools::hex_to_pod("bbec2cacf69866a8e740380fe7b818fc78f8571221742d729d9d02d7f8989b87", m_expected_hash)) + return false; + + return true; + } + + bool test() + { + crypto::hash hash; + crypto::cn_slow_hash(&m_data, sizeof(m_data), hash); + return hash == m_expected_hash; + } + +private: + data_t m_data; + crypto::hash m_expected_hash; +}; |