Ethereum  PoC-8
The C++ Implementation of Ethereum
FixedHash.h
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
24 #pragma once
25 
26 #include <array>
27 #include <cstdint>
28 #include <algorithm>
29 #include <random>
30 #include <boost/functional/hash.hpp>
31 #include "CommonData.h"
32 
33 namespace dev
34 {
35 
37 template <unsigned N> struct StaticLog2 { enum { result = 1 + StaticLog2<N/2>::result }; };
38 template <> struct StaticLog2<1> { enum { result = 0 }; };
39 
40 extern std::random_device s_fixedHashEngine;
41 
45 template <unsigned N>
46 class FixedHash
47 {
48 public:
50  using Arith = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N * 8, N * 8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>;
51 
53  enum { size = N };
54 
57 
60 
63 
65  FixedHash() { m_data.fill(0); }
66 
68  template <unsigned M> explicit FixedHash(FixedHash<M> const& _h, ConstructFromHashType _t = AlignLeft) { m_data.fill(0); unsigned c = std::min(M, N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _h[_t == AlignRight ? M - 1 - i : i]; }
69 
71  FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); }
72 
74  explicit FixedHash(unsigned _u) { toBigEndian(_u, m_data); }
75 
77  explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min<unsigned>(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min<unsigned>(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } }
78 
80  explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min<unsigned>(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min<unsigned>(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } }
81 
83  explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); }
84 
86  explicit FixedHash(std::string const& _s, ConstructFromStringType _t = FromHex, ConstructFromHashType _ht = FailIfDifferent): FixedHash(_t == FromHex ? fromHex(_s, WhenError::Throw) : dev::asBytes(_s), _ht) {}
87 
89  operator Arith() const { return fromBigEndian<Arith>(m_data); }
90 
92  explicit operator bool() const { return std::any_of(m_data.begin(), m_data.end(), [](byte _b) { return _b != 0; }); }
93 
94  // The obvious comparison operators.
95  bool operator==(FixedHash const& _c) const { return m_data == _c.m_data; }
96  bool operator!=(FixedHash const& _c) const { return m_data != _c.m_data; }
97  bool operator<(FixedHash const& _c) const { for (unsigned i = 0; i < N; ++i) if (m_data[i] < _c.m_data[i]) return true; else if (m_data[i] > _c.m_data[i]) return false; return false; }
98  bool operator>=(FixedHash const& _c) const { return !operator<(_c); }
99  bool operator<=(FixedHash const& _c) const { return operator==(_c) || operator<(_c); }
100  bool operator>(FixedHash const& _c) const { return !operator<=(_c); }
101 
102  // The obvious binary operators.
103  FixedHash& operator^=(FixedHash const& _c) { for (unsigned i = 0; i < N; ++i) m_data[i] ^= _c.m_data[i]; return *this; }
104  FixedHash operator^(FixedHash const& _c) const { return FixedHash(*this) ^= _c; }
105  FixedHash& operator|=(FixedHash const& _c) { for (unsigned i = 0; i < N; ++i) m_data[i] |= _c.m_data[i]; return *this; }
106  FixedHash operator|(FixedHash const& _c) const { return FixedHash(*this) |= _c; }
107  FixedHash& operator&=(FixedHash const& _c) { for (unsigned i = 0; i < N; ++i) m_data[i] &= _c.m_data[i]; return *this; }
108  FixedHash operator&(FixedHash const& _c) const { return FixedHash(*this) &= _c; }
109  FixedHash operator~() const { FixedHash ret; for (unsigned i = 0; i < N; ++i) ret[i] = ~m_data[i]; return ret; }
110 
111  // Big-endian increment.
112  FixedHash& operator++() { for (unsigned i = size; i > 0 && !++m_data[--i]; ) {} return *this; }
113 
115  bool contains(FixedHash const& _c) const { return (*this & _c) == _c; }
116 
118  byte& operator[](unsigned _i) { return m_data[_i]; }
120  byte operator[](unsigned _i) const { return m_data[_i]; }
121 
123  std::string abridged() const { return toHex(ref().cropped(0, 4)) + "\342\200\246"; }
124 
126  std::string abridgedMiddle() const { return toHex(ref().cropped(0, 4)) + "\342\200\246" + toHex(ref().cropped(N - 4)); }
127 
129  std::string hex() const { return toHex(ref()); }
130 
132  bytesRef ref() { return bytesRef(m_data.data(), N); }
133 
135  bytesConstRef ref() const { return bytesConstRef(m_data.data(), N); }
136 
138  byte* data() { return m_data.data(); }
139 
141  byte const* data() const { return m_data.data(); }
142 
144  auto begin() const -> typename std::array<byte, N>::const_iterator { return m_data.begin(); }
145 
147  auto end() const -> typename std::array<byte, N>::const_iterator { return m_data.end(); }
148 
150  bytes asBytes() const { return bytes(data(), data() + N); }
151 
153  std::array<byte, N>& asArray() { return m_data; }
154 
156  std::array<byte, N> const& asArray() const { return m_data; }
157 
159  template <class Engine>
160  void randomize(Engine& _eng)
161  {
162  for (auto& i: m_data)
163  i = (uint8_t)std::uniform_int_distribution<uint16_t>(0, 255)(_eng);
164  }
165 
167  static FixedHash random() { FixedHash ret; ret.randomize(s_fixedHashEngine); return ret; }
168 
169  struct hash
170  {
172  size_t operator()(FixedHash const& _value) const { return boost::hash_range(_value.m_data.cbegin(), _value.m_data.cend()); }
173  };
174 
175  template <unsigned P, unsigned M> inline FixedHash& shiftBloom(FixedHash<M> const& _h)
176  {
177  return (*this |= _h.template bloomPart<P, N>());
178  }
179 
180  template <unsigned P, unsigned M> inline bool containsBloom(FixedHash<M> const& _h)
181  {
182  return contains(_h.template bloomPart<P, N>());
183  }
184 
185  template <unsigned P, unsigned M> inline FixedHash<M> bloomPart() const
186  {
187  unsigned const c_bloomBits = M * 8;
188  unsigned const c_mask = c_bloomBits - 1;
189  unsigned const c_bloomBytes = (StaticLog2<c_bloomBits>::result + 7) / 8;
190 
191  static_assert((M & (M - 1)) == 0, "M must be power-of-two");
192  static_assert(P * c_bloomBytes <= N, "out of range");
193 
194  FixedHash<M> ret;
195  byte const* p = data();
196  for (unsigned i = 0; i < P; ++i)
197  {
198  unsigned index = 0;
199  for (unsigned j = 0; j < c_bloomBytes; ++j, ++p)
200  index = (index << 8) | *p;
201  index &= c_mask;
202  ret[M - 1 - index / 8] |= (1 << (index % 8));
203  }
204  return ret;
205  }
206 
208  inline unsigned firstBitSet() const
209  {
210  unsigned ret = 0;
211  for (auto d: m_data)
212  if (d)
213  {
214  for (;; ++ret, d <<= 1)
215  {
216  if (d & 0x80)
217  return ret;
218  }
219  }
220  else
221  ret += 8;
222  return ret;
223  }
224 
225  void clear() { m_data.fill(0); }
226 
227 private:
228  std::array<byte, N> m_data;
229 };
230 
231 template <unsigned T>
232 class SecureFixedHash: private FixedHash<T>
233 {
234 public:
238  SecureFixedHash() = default;
242  template <unsigned M> explicit SecureFixedHash(FixedHash<M> const& _h, ConstructFromHashType _t = FixedHash<T>::AlignLeft): FixedHash<T>(_h, _t) {}
243  template <unsigned M> explicit SecureFixedHash(SecureFixedHash<M> const& _h, ConstructFromHashType _t = FixedHash<T>::AlignLeft): FixedHash<T>(_h.makeInsecure(), _t) {}
245  explicit SecureFixedHash(bytes const* _d, ConstructFromPointerType _t): FixedHash<T>(_d, _t) {}
247 
249  {
250  if (&_c == this)
251  return *this;
252  ref().cleanse();
253  FixedHash<T>::operator=(static_cast<FixedHash<T> const&>(_c));
254  return *this;
255  }
256 
257  using FixedHash<T>::size;
258 
259  bytesSec asBytesSec() const { return bytesSec(ref()); }
260 
261  FixedHash<T> const& makeInsecure() const { return static_cast<FixedHash<T> const&>(*this); }
262  FixedHash<T>& writable() { clear(); return static_cast<FixedHash<T>&>(*this); }
263 
264  using FixedHash<T>::operator bool;
265 
266  // The obvious comparison operators.
267  bool operator==(SecureFixedHash const& _c) const { return static_cast<FixedHash<T> const&>(*this).operator==(static_cast<FixedHash<T> const&>(_c)); }
268  bool operator!=(SecureFixedHash const& _c) const { return static_cast<FixedHash<T> const&>(*this).operator!=(static_cast<FixedHash<T> const&>(_c)); }
269  bool operator<(SecureFixedHash const& _c) const { return static_cast<FixedHash<T> const&>(*this).operator<(static_cast<FixedHash<T> const&>(_c)); }
270  bool operator>=(SecureFixedHash const& _c) const { return static_cast<FixedHash<T> const&>(*this).operator>=(static_cast<FixedHash<T> const&>(_c)); }
271  bool operator<=(SecureFixedHash const& _c) const { return static_cast<FixedHash<T> const&>(*this).operator<=(static_cast<FixedHash<T> const&>(_c)); }
272  bool operator>(SecureFixedHash const& _c) const { return static_cast<FixedHash<T> const&>(*this).operator>(static_cast<FixedHash<T> const&>(_c)); }
273 
274  using FixedHash<T>::operator==;
275  using FixedHash<T>::operator!=;
276  using FixedHash<T>::operator<;
277  using FixedHash<T>::operator>=;
278  using FixedHash<T>::operator<=;
279  using FixedHash<T>::operator>;
280 
281  // The obvious binary operators.
282  SecureFixedHash& operator^=(FixedHash<T> const& _c) { static_cast<FixedHash<T>&>(*this).operator^=(_c); return *this; }
283  SecureFixedHash operator^(FixedHash<T> const& _c) const { return SecureFixedHash(*this) ^= _c; }
284  SecureFixedHash& operator|=(FixedHash<T> const& _c) { static_cast<FixedHash<T>&>(*this).operator^=(_c); return *this; }
285  SecureFixedHash operator|(FixedHash<T> const& _c) const { return SecureFixedHash(*this) |= _c; }
286  SecureFixedHash& operator&=(FixedHash<T> const& _c) { static_cast<FixedHash<T>&>(*this).operator^=(_c); return *this; }
287  SecureFixedHash operator&(FixedHash<T> const& _c) const { return SecureFixedHash(*this) &= _c; }
288 
289  SecureFixedHash& operator^=(SecureFixedHash const& _c) { static_cast<FixedHash<T>&>(*this).operator^=(static_cast<FixedHash<T> const&>(_c)); return *this; }
290  SecureFixedHash operator^(SecureFixedHash const& _c) const { return SecureFixedHash(*this) ^= _c; }
291  SecureFixedHash& operator|=(SecureFixedHash const& _c) { static_cast<FixedHash<T>&>(*this).operator^=(static_cast<FixedHash<T> const&>(_c)); return *this; }
292  SecureFixedHash operator|(SecureFixedHash const& _c) const { return SecureFixedHash(*this) |= _c; }
293  SecureFixedHash& operator&=(SecureFixedHash const& _c) { static_cast<FixedHash<T>&>(*this).operator^=(static_cast<FixedHash<T> const&>(_c)); return *this; }
294  SecureFixedHash operator&(SecureFixedHash const& _c) const { return SecureFixedHash(*this) &= _c; }
295  SecureFixedHash operator~() const { auto r = ~static_cast<FixedHash<T> const&>(*this); return static_cast<SecureFixedHash const&>(r); }
296 
299 
300  bytesConstRef ref() const { return FixedHash<T>::ref(); }
301  byte const* data() const { return FixedHash<T>::data(); }
302 
305 
306  void clear() { ref().cleanse(); }
307 };
308 
310 template<> inline bool FixedHash<32>::operator==(FixedHash<32> const& _other) const
311 {
312  const uint64_t* hash1 = (const uint64_t*)data();
313  const uint64_t* hash2 = (const uint64_t*)_other.data();
314  return (hash1[0] == hash2[0]) && (hash1[1] == hash2[1]) && (hash1[2] == hash2[2]) && (hash1[3] == hash2[3]);
315 }
316 
318 template<> inline size_t FixedHash<32>::hash::operator()(FixedHash<32> const& value) const
319 {
320  uint64_t const* data = reinterpret_cast<uint64_t const*>(value.data());
321  return boost::hash_range(data, data + 4);
322 }
323 
325 template <unsigned N>
326 inline std::ostream& operator<<(std::ostream& _out, FixedHash<N> const& _h)
327 {
328  _out << toHex(_h);
329  return _out;
330 }
331 
332 template <unsigned N>
333 inline std::istream& operator>>(std::istream& _in, FixedHash<N>& o_h)
334 {
335  std::string s;
336  _in >> s;
338  return _in;
339 }
340 
342 template <unsigned N>
343 inline std::ostream& operator<<(std::ostream& _out, SecureFixedHash<N> const& _h)
344 {
345  _out << "SecureFixedHash#" << std::hex << typename FixedHash<N>::hash()(_h.makeInsecure()) << std::dec;
346  return _out;
347 }
348 
349 // Common types of FixedHash.
358 using h512s = std::vector<h512>;
359 using h256s = std::vector<h256>;
360 using h160s = std::vector<h160>;
361 using h256Set = std::set<h256>;
362 using h160Set = std::set<h160>;
363 using h256Hash = std::unordered_set<h256>;
364 using h160Hash = std::unordered_set<h160>;
365 
367 inline h160 right160(h256 const& _t)
368 {
369  h160 ret;
370  memcpy(ret.data(), _t.data() + 12, 20);
371  return ret;
372 }
373 
374 h128 fromUUID(std::string const& _uuid);
375 
376 std::string toUUID(h128 const& _uuid);
377 
378 inline std::string toString(h256s const& _bs)
379 {
380  std::ostringstream out;
381  out << "[ ";
382  for (h256 const& i: _bs)
383  out << i.abridged() << ", ";
384  out << "]";
385  return out.str();
386 }
387 
388 }
389 
390 namespace std
391 {
393  template<> struct hash<dev::h64>: dev::h64::hash {};
394  template<> struct hash<dev::h128>: dev::h128::hash {};
395  template<> struct hash<dev::h160>: dev::h160::hash {};
396  template<> struct hash<dev::h256>: dev::h256::hash {};
397  template<> struct hash<dev::h512>: dev::h512::hash {};
398 }
bool operator!=(SecureFixedHash const &_c) const
Definition: FixedHash.h:268
bytesConstRef ref() const
Definition: FixedHash.h:300
h128 fromUUID(std::string const &_uuid)
Definition: FixedHash.cpp:26
Definition: Address.cpp:20
FixedHash operator &(FixedHash const &_c) const
Definition: FixedHash.h:108
byte operator[](unsigned _i) const
Definition: FixedHash.h:120
std::set< h160 > h160Set
Definition: FixedHash.h:362
uint8_t byte
Definition: Common.h:57
auto end() const -> typename std::array< byte, N >::const_iterator
Definition: FixedHash.h:147
byte * data()
Definition: FixedHash.h:138
FixedHash & operator|=(FixedHash const &_c)
Definition: FixedHash.h:105
bool operator<=(SecureFixedHash const &_c) const
Definition: FixedHash.h:271
FixedHash & operator++()
Definition: FixedHash.h:112
void toBigEndian(T _val, Out &o_out)
Definition: CommonData.h:124
h160 right160(h256 const &_t)
Convert the given value into h160 (160-bit unsigned integer) using the right 20 bytes.
Definition: FixedHash.h:367
std::istream & operator>>(std::istream &_in, FixedHash< N > &o_h)
Definition: FixedHash.h:333
unsigned firstBitSet() const
Returns the index of the first bit set to one, or size() * 8 if no bits are set.
Definition: FixedHash.h:208
std::set< h256 > h256Set
Definition: FixedHash.h:361
FixedHash(FixedHash< M > const &_h, ConstructFromHashType _t=AlignLeft)
Construct from another hash, filling with zeroes or cropping as necessary.
Definition: FixedHash.h:68
secure_vector< byte > bytesSec
Definition: Common.h:115
FixedHash(unsigned _u)
Convert from unsigned.
Definition: FixedHash.h:74
SecureFixedHash & operator|=(FixedHash< T > const &_c)
Definition: FixedHash.h:284
FixedHash< 8 > h64
Definition: FixedHash.h:357
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< N *8, N *8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void > > Arith
The corresponding arithmetic type.
Definition: FixedHash.h:50
Definition: FixedHash.h:390
void cleanse()
Definition: vector_ref.h:72
bool operator>(FixedHash const &_c) const
Definition: FixedHash.h:100
byte & operator[](unsigned _i)
Definition: FixedHash.h:118
bool operator<(SecureFixedHash const &_c) const
Definition: FixedHash.h:269
WhenError
Definition: CommonData.h:39
Compile-time calculation of Log2 of constant values.
Definition: FixedHash.h:37
std::string abridged() const
Definition: FixedHash.h:123
FixedHash & shiftBloom(FixedHash< M > const &_h)
Definition: FixedHash.h:175
byte const * data() const
Definition: FixedHash.h:141
FixedHash< 64 > h512
Definition: FixedHash.h:353
FixedHash()
Construct an empty hash.
Definition: FixedHash.h:65
std::vector< h512 > h512s
Definition: FixedHash.h:358
bool operator>=(SecureFixedHash const &_c) const
Definition: FixedHash.h:270
SecureFixedHash(bytesSec const &_b, ConstructFromHashType _t=FixedHash< T >::FailIfDifferent)
Definition: FixedHash.h:241
SecureFixedHash(std::string const &_s, ConstructFromStringType _t=FixedHash< T >::FromHex, ConstructFromHashType _ht=FixedHash< T >::FailIfDifferent)
Definition: FixedHash.h:244
std::random_device s_fixedHashEngine
Definition: FixedHash.cpp:24
FixedHash operator^(FixedHash const &_c) const
Definition: FixedHash.h:104
void randomize(Engine &_eng)
Populate with random data.
Definition: FixedHash.h:160
FixedHash operator~() const
Definition: FixedHash.h:109
bool contains(FixedHash const &_c) const
Definition: FixedHash.h:115
SecureFixedHash(bytes const &_b, ConstructFromHashType _t=FixedHash< T >::FailIfDifferent)
Definition: FixedHash.h:239
SecureFixedHash & operator &=(FixedHash< T > const &_c)
Definition: FixedHash.h:286
bool containsBloom(FixedHash< M > const &_h)
Definition: FixedHash.h:180
FixedHash(bytes const &_b, ConstructFromHashType _t=FailIfDifferent)
Explicitly construct, copying from a byte array.
Definition: FixedHash.h:77
FixedHash operator|(FixedHash const &_c) const
Definition: FixedHash.h:106
bytes fromHex(std::string const &_s, WhenError _throw=WhenError::DontThrow)
Definition: CommonData.cpp:81
FixedHash(std::string const &_s, ConstructFromStringType _t=FromHex, ConstructFromHashType _ht=FailIfDifferent)
Explicitly construct, copying from a string.
Definition: FixedHash.h:86
FixedHash(byte const *_bs, ConstructFromPointerType)
Explicitly construct, copying from a bytes in memory with given pointer.
Definition: FixedHash.h:83
byte const * data() const
Definition: FixedHash.h:301
SecureFixedHash()=default
FixedHash(Arith const &_arith)
Convert from the corresponding arithmetic type.
Definition: FixedHash.h:71
static SecureFixedHash< T > random()
Definition: FixedHash.h:303
vector_ref< byte > bytesRef
Definition: Common.h:73
bytesRef ref()
Definition: FixedHash.h:132
std::string abridgedMiddle() const
Definition: FixedHash.h:126
SecureFixedHash & operator|=(SecureFixedHash const &_c)
Definition: FixedHash.h:291
SecureFixedHash operator^(SecureFixedHash const &_c) const
Definition: FixedHash.h:290
FixedHash(bytesConstRef _b, ConstructFromHashType _t=FailIfDifferent)
Explicitly construct, copying from a byte array.
Definition: FixedHash.h:80
SecureFixedHash(bytesConstRef _b, ConstructFromHashType _t=FixedHash< T >::FailIfDifferent)
Definition: FixedHash.h:240
auto begin() const -> typename std::array< byte, N >::const_iterator
Definition: FixedHash.h:144
std::unordered_set< h160 > h160Hash
Definition: FixedHash.h:364
bytesConstRef ref() const
Definition: FixedHash.h:135
SecureFixedHash operator &(FixedHash< T > const &_c) const
Definition: FixedHash.h:287
std::vector< byte > bytes
Definition: Common.h:72
vector_ref< byte const > bytesConstRef
Definition: Common.h:74
std::string hex() const
Definition: FixedHash.h:129
FixedHash< T > & writable()
Definition: FixedHash.h:262
SecureFixedHash operator^(FixedHash< T > const &_c) const
Definition: FixedHash.h:283
bool operator==(FixedHash const &_c) const
Definition: FixedHash.h:95
FixedHash< 32 > h256
Definition: FixedHash.h:354
SecureFixedHash & operator &=(SecureFixedHash const &_c)
Definition: FixedHash.h:293
FixedHash & operator &=(FixedHash const &_c)
Definition: FixedHash.h:107
bool operator<=(FixedHash const &_c) const
Definition: FixedHash.h:99
bool operator!=(FixedHash const &_c) const
Definition: FixedHash.h:96
std::array< byte, N > const & asArray() const
Definition: FixedHash.h:156
SecureFixedHash & operator^=(FixedHash< T > const &_c)
Definition: FixedHash.h:282
static FixedHash random()
Definition: FixedHash.h:167
std::vector< h160 > h160s
Definition: FixedHash.h:360
void clear()
Definition: FixedHash.h:225
bool operator<(FixedHash const &_c) const
Definition: FixedHash.h:97
FixedHash< 16 > h128
Definition: FixedHash.h:356
SecureFixedHash(bytes const *_d, ConstructFromPointerType _t)
Definition: FixedHash.h:245
SecureFixedHash & operator^=(SecureFixedHash const &_c)
Definition: FixedHash.h:289
size_t size() const
Definition: vector_ref.h:53
size_t operator()(FixedHash const &_value) const
Make a hash of the object&#39;s data.
Definition: FixedHash.h:172
SecureFixedHash operator|(SecureFixedHash const &_c) const
Definition: FixedHash.h:292
SecureFixedHash operator|(FixedHash< T > const &_c) const
Definition: FixedHash.h:285
bool operator==(SecureFixedHash const &_c) const
Definition: FixedHash.h:267
std::unordered_set< h256 > h256Hash
Definition: FixedHash.h:363
FixedHash< 20 > h160
Definition: FixedHash.h:355
bool operator>=(FixedHash const &_c) const
Definition: FixedHash.h:98
FixedHash< M > bloomPart() const
Definition: FixedHash.h:185
SecureFixedHash operator &(SecureFixedHash const &_c) const
Definition: FixedHash.h:294
ConstructFromHashType
Method to convert from a string.
Definition: FixedHash.h:62
std::string toHex(Iterator _it, Iterator _end, std::string const &_prefix)
Definition: CommonData.h:46
std::array< byte, N > & asArray()
Definition: FixedHash.h:153
FixedHash< T > const & makeInsecure() const
Definition: FixedHash.h:261
bool operator>(SecureFixedHash const &_c) const
Definition: FixedHash.h:272
std::string toString(h256s const &_bs)
Definition: FixedHash.h:378
std::vector< h256 > h256s
Definition: FixedHash.h:359
bytesSec asBytesSec() const
Definition: FixedHash.h:259
ConstructFromPointerType
A dummy flag to avoid accidental construction from pointer.
Definition: FixedHash.h:56
ConstructFromStringType
Method to convert from a string.
Definition: FixedHash.h:59
bytes asBytes() const
Definition: FixedHash.h:150
FixedHash & operator^=(FixedHash const &_c)
Definition: FixedHash.h:103
SecureFixedHash(SecureFixedHash< M > const &_h, ConstructFromHashType _t=FixedHash< T >::AlignLeft)
Definition: FixedHash.h:243
SecureFixedHash< T > & operator=(SecureFixedHash< T > const &_c)
Definition: FixedHash.h:248
_T * data() const
Definition: vector_ref.h:49
std::string toUUID(h128 const &_uuid)
Definition: FixedHash.cpp:38
SecureFixedHash operator~() const
Definition: FixedHash.h:295
SecureFixedHash(FixedHash< M > const &_h, ConstructFromHashType _t=FixedHash< T >::AlignLeft)
Definition: FixedHash.h:242