|
@ -26,8 +26,7 @@ |
|
|
#include <array> |
|
|
#include <array> |
|
|
#include <cstdint> |
|
|
#include <cstdint> |
|
|
#include <algorithm> |
|
|
#include <algorithm> |
|
|
#include <boost/random/random_device.hpp> |
|
|
#include <random> |
|
|
#include <boost/random/uniform_int_distribution.hpp> |
|
|
|
|
|
#include "CommonData.h" |
|
|
#include "CommonData.h" |
|
|
|
|
|
|
|
|
namespace dev |
|
|
namespace dev |
|
@ -37,7 +36,7 @@ namespace dev |
|
|
template <unsigned N> struct StaticLog2 { enum { result = 1 + StaticLog2<N/2>::result }; }; |
|
|
template <unsigned N> struct StaticLog2 { enum { result = 1 + StaticLog2<N/2>::result }; }; |
|
|
template <> struct StaticLog2<1> { enum { result = 0 }; }; |
|
|
template <> struct StaticLog2<1> { enum { result = 0 }; }; |
|
|
|
|
|
|
|
|
extern boost::random_device s_fixedHashEngine; |
|
|
extern std::random_device s_fixedHashEngine; |
|
|
|
|
|
|
|
|
/// Fixed-size raw-byte array container type, with an API optimised for storing hashes.
|
|
|
/// Fixed-size raw-byte array container type, with an API optimised for storing hashes.
|
|
|
/// Transparently converts to/from the corresponding arithmetic type; this will
|
|
|
/// Transparently converts to/from the corresponding arithmetic type; this will
|
|
@ -154,7 +153,7 @@ public: |
|
|
void randomize(Engine& _eng) |
|
|
void randomize(Engine& _eng) |
|
|
{ |
|
|
{ |
|
|
for (auto& i: m_data) |
|
|
for (auto& i: m_data) |
|
|
i = (uint8_t)boost::random::uniform_int_distribution<uint16_t>(0, 255)(_eng); |
|
|
i = (uint8_t)std::uniform_int_distribution<uint16_t>(0, 255)(_eng); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// @returns a random valued object.
|
|
|
/// @returns a random valued object.
|
|
@ -291,7 +290,6 @@ public: |
|
|
bytesConstRef ref() const { return FixedHash<T>::ref(); } |
|
|
bytesConstRef ref() const { return FixedHash<T>::ref(); } |
|
|
byte const* data() const { return FixedHash<T>::data(); } |
|
|
byte const* data() const { return FixedHash<T>::data(); } |
|
|
|
|
|
|
|
|
static SecureFixedHash<T> random() { SecureFixedHash<T> ret; ret.randomize(s_fixedHashEngine); return ret; } |
|
|
|
|
|
using FixedHash<T>::firstBitSet; |
|
|
using FixedHash<T>::firstBitSet; |
|
|
|
|
|
|
|
|
void clear() { ref().cleanse(); } |
|
|
void clear() { ref().cleanse(); } |
|
|