Electroneum
Loading...
Searching...
No Matches
crypto::serialization::detail Namespace Reference

Functions

template<typename T>
void prepare_custom_vector_serialization (size_t size, std::vector< T > &vec, const boost::mpl::bool_< true > &)
template<typename T>
void prepare_custom_vector_serialization (size_t size, std::vector< T > &vec, const boost::mpl::bool_< false > &)
template<typename T>
void prepare_custom_deque_serialization (size_t size, std::deque< T > &vec, const boost::mpl::bool_< true > &)
template<typename T>
void prepare_custom_deque_serialization (size_t size, std::deque< T > &vec, const boost::mpl::bool_< false > &)
template<class Stream>
bool do_check_stream_state (Stream &s, boost::mpl::bool_< true >, bool noeof)
template<class Stream>
bool do_check_stream_state (Stream &s, boost::mpl::bool_< false >, bool noeof)

Function Documentation

◆ do_check_stream_state() [1/2]

template<class Stream>
bool crypto::serialization::detail::do_check_stream_state ( Stream & s,
boost::mpl::bool_< false > ,
bool noeof )

Definition at line 333 of file hash.h.

375 {
376
377 extern "C" {
378#include "hash-ops.h"
379 }
380
381#pragma pack(push, 1)
383 char data[HASH_SIZE];
384 };
386 char data[8];
387 };
389 char data[64];
390 };
391#pragma pack(pop)
392
393 static_assert(sizeof(hash) == HASH_SIZE, "Invalid structure size");
394 static_assert(sizeof(hash8) == 8, "Invalid structure size");
395 static_assert(sizeof(hash64) == 64, "Invalid structure size");
396
397 /*
398 Cryptonight hash functions
399 */
400
401 inline void cn_fast_hash(const void *data, std::size_t length, hash &hash) {
402 cn_fast_hash(data, length, reinterpret_cast<char *>(&hash));
403 }
404
405 inline hash cn_fast_hash(const void *data, std::size_t length) {
406 hash h;
407 cn_fast_hash(data, length, reinterpret_cast<char *>(&h));
408 return h;
409 }
410
411 inline void cn_slow_hash(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
412 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 0/*prehashed*/, height);
413 }
414
415 inline void cn_slow_hash_prehashed(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
416 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 1/*prehashed*/, height);
417 }
418
419 inline void tree_hash(const hash *hashes, std::size_t count, hash &root_hash) {
420 tree_hash(reinterpret_cast<const char (*)[HASH_SIZE]>(hashes), count, reinterpret_cast<char *>(&root_hash));
421 }
422
423 inline std::ostream &operator <<(std::ostream &o, const crypto::hash &v) {
425 }
426 inline std::ostream &operator <<(std::ostream &o, const crypto::hash8 &v) {
428 }
429 inline std::ostream &operator <<(std::ostream &o, const crypto::hash64 &v) {
431 }
432
433 const static crypto::hash null_hash = boost::value_initialized<crypto::hash>();
434 const static crypto::hash8 null_hash8 = boost::value_initialized<crypto::hash8>();
435 const static crypto::hash64 null_hash64 = boost::value_initialized<crypto::hash64>();
436}
437
uint64_t height
#define CRYPTO_MAKE_COMPARABLE(type)
Definition generic-ops.h:39
#define CRYPTO_MAKE_HASHABLE(type)
Definition generic-ops.h:76
void cn_slow_hash_prehashed(const void *data, std::size_t length, hash &hash, int variant=0, uint64_t height=0)
Definition hash.h:83
void cn_fast_hash(const void *data, size_t length, char *hash)
POD_CLASS hash8
Definition hash.h:53
void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed, uint64_t height)
unsigned __int64 uint64_t
Definition hash.h:137
void tree_hash(const char(*hashes)[HASH_SIZE], size_t count, char *root_hash)
std::ostream & operator<<(std::ostream &o, const crypto::public_key &v)
Definition crypto.h:357
POD_CLASS hash64
Definition hash.h:56
POD_CLASS hash
Definition hash.h:50
@ HASH_SIZE
Definition hash.h:78
span< const std::uint8_t > as_byte_span(const T &src) noexcept
Definition span.h:153
#define POD_CLASS
Definition pod-class.h:44
static void formatted(std::ostream &out, const span< const std::uint8_t > src)
Append < + src + > as hex to out.
Definition hex.cpp:76
struct hash_func hashes[]

◆ do_check_stream_state() [2/2]

template<class Stream>
bool crypto::serialization::detail::do_check_stream_state ( Stream & s,
boost::mpl::bool_< true > ,
bool noeof )

Definition at line 322 of file hash.h.

364 {
365
366 extern "C" {
367#include "hash-ops.h"
368 }
369
370#pragma pack(push, 1)
372 char data[HASH_SIZE];
373 };
375 char data[8];
376 };
378 char data[64];
379 };
380#pragma pack(pop)
381
382 static_assert(sizeof(hash) == HASH_SIZE, "Invalid structure size");
383 static_assert(sizeof(hash8) == 8, "Invalid structure size");
384 static_assert(sizeof(hash64) == 64, "Invalid structure size");
385
386 /*
387 Cryptonight hash functions
388 */
389
390 inline void cn_fast_hash(const void *data, std::size_t length, hash &hash) {
391 cn_fast_hash(data, length, reinterpret_cast<char *>(&hash));
392 }
393
394 inline hash cn_fast_hash(const void *data, std::size_t length) {
395 hash h;
396 cn_fast_hash(data, length, reinterpret_cast<char *>(&h));
397 return h;
398 }
399
400 inline void cn_slow_hash(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
401 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 0/*prehashed*/, height);
402 }
403
404 inline void cn_slow_hash_prehashed(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
405 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 1/*prehashed*/, height);
406 }
407
408 inline void tree_hash(const hash *hashes, std::size_t count, hash &root_hash) {
409 tree_hash(reinterpret_cast<const char (*)[HASH_SIZE]>(hashes), count, reinterpret_cast<char *>(&root_hash));
410 }
411
412 inline std::ostream &operator <<(std::ostream &o, const crypto::hash &v) {
414 }
415 inline std::ostream &operator <<(std::ostream &o, const crypto::hash8 &v) {
417 }
418 inline std::ostream &operator <<(std::ostream &o, const crypto::hash64 &v) {
420 }
421
422 const static crypto::hash null_hash = boost::value_initialized<crypto::hash>();
423 const static crypto::hash8 null_hash8 = boost::value_initialized<crypto::hash8>();
424 const static crypto::hash64 null_hash64 = boost::value_initialized<crypto::hash64>();
425}
426

◆ prepare_custom_deque_serialization() [1/2]

template<typename T>
void crypto::serialization::detail::prepare_custom_deque_serialization ( size_t size,
std::deque< T > & vec,
const boost::mpl::bool_< false > &  )

Definition at line 312 of file hash.h.

354 {
355
356 extern "C" {
357#include "hash-ops.h"
358 }
359
360#pragma pack(push, 1)
362 char data[HASH_SIZE];
363 };
365 char data[8];
366 };
368 char data[64];
369 };
370#pragma pack(pop)
371
372 static_assert(sizeof(hash) == HASH_SIZE, "Invalid structure size");
373 static_assert(sizeof(hash8) == 8, "Invalid structure size");
374 static_assert(sizeof(hash64) == 64, "Invalid structure size");
375
376 /*
377 Cryptonight hash functions
378 */
379
380 inline void cn_fast_hash(const void *data, std::size_t length, hash &hash) {
381 cn_fast_hash(data, length, reinterpret_cast<char *>(&hash));
382 }
383
384 inline hash cn_fast_hash(const void *data, std::size_t length) {
385 hash h;
386 cn_fast_hash(data, length, reinterpret_cast<char *>(&h));
387 return h;
388 }
389
390 inline void cn_slow_hash(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
391 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 0/*prehashed*/, height);
392 }
393
394 inline void cn_slow_hash_prehashed(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
395 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 1/*prehashed*/, height);
396 }
397
398 inline void tree_hash(const hash *hashes, std::size_t count, hash &root_hash) {
399 tree_hash(reinterpret_cast<const char (*)[HASH_SIZE]>(hashes), count, reinterpret_cast<char *>(&root_hash));
400 }
401
402 inline std::ostream &operator <<(std::ostream &o, const crypto::hash &v) {
404 }
405 inline std::ostream &operator <<(std::ostream &o, const crypto::hash8 &v) {
407 }
408 inline std::ostream &operator <<(std::ostream &o, const crypto::hash64 &v) {
410 }
411
412 const static crypto::hash null_hash = boost::value_initialized<crypto::hash>();
413 const static crypto::hash8 null_hash8 = boost::value_initialized<crypto::hash8>();
414 const static crypto::hash64 null_hash64 = boost::value_initialized<crypto::hash64>();
415}
416

◆ prepare_custom_deque_serialization() [2/2]

template<typename T>
void crypto::serialization::detail::prepare_custom_deque_serialization ( size_t size,
std::deque< T > & vec,
const boost::mpl::bool_< true > &  )

Definition at line 307 of file hash.h.

349 {
350
351 extern "C" {
352#include "hash-ops.h"
353 }
354
355#pragma pack(push, 1)
357 char data[HASH_SIZE];
358 };
360 char data[8];
361 };
363 char data[64];
364 };
365#pragma pack(pop)
366
367 static_assert(sizeof(hash) == HASH_SIZE, "Invalid structure size");
368 static_assert(sizeof(hash8) == 8, "Invalid structure size");
369 static_assert(sizeof(hash64) == 64, "Invalid structure size");
370
371 /*
372 Cryptonight hash functions
373 */
374
375 inline void cn_fast_hash(const void *data, std::size_t length, hash &hash) {
376 cn_fast_hash(data, length, reinterpret_cast<char *>(&hash));
377 }
378
379 inline hash cn_fast_hash(const void *data, std::size_t length) {
380 hash h;
381 cn_fast_hash(data, length, reinterpret_cast<char *>(&h));
382 return h;
383 }
384
385 inline void cn_slow_hash(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
386 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 0/*prehashed*/, height);
387 }
388
389 inline void cn_slow_hash_prehashed(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
390 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 1/*prehashed*/, height);
391 }
392
393 inline void tree_hash(const hash *hashes, std::size_t count, hash &root_hash) {
394 tree_hash(reinterpret_cast<const char (*)[HASH_SIZE]>(hashes), count, reinterpret_cast<char *>(&root_hash));
395 }
396
397 inline std::ostream &operator <<(std::ostream &o, const crypto::hash &v) {
399 }
400 inline std::ostream &operator <<(std::ostream &o, const crypto::hash8 &v) {
402 }
403 inline std::ostream &operator <<(std::ostream &o, const crypto::hash64 &v) {
405 }
406
407 const static crypto::hash null_hash = boost::value_initialized<crypto::hash>();
408 const static crypto::hash8 null_hash8 = boost::value_initialized<crypto::hash8>();
409 const static crypto::hash64 null_hash64 = boost::value_initialized<crypto::hash64>();
410}
411

◆ prepare_custom_vector_serialization() [1/2]

template<typename T>
void crypto::serialization::detail::prepare_custom_vector_serialization ( size_t size,
std::vector< T > & vec,
const boost::mpl::bool_< false > &  )

Definition at line 301 of file hash.h.

343 {
344
345 extern "C" {
346#include "hash-ops.h"
347 }
348
349#pragma pack(push, 1)
351 char data[HASH_SIZE];
352 };
354 char data[8];
355 };
357 char data[64];
358 };
359#pragma pack(pop)
360
361 static_assert(sizeof(hash) == HASH_SIZE, "Invalid structure size");
362 static_assert(sizeof(hash8) == 8, "Invalid structure size");
363 static_assert(sizeof(hash64) == 64, "Invalid structure size");
364
365 /*
366 Cryptonight hash functions
367 */
368
369 inline void cn_fast_hash(const void *data, std::size_t length, hash &hash) {
370 cn_fast_hash(data, length, reinterpret_cast<char *>(&hash));
371 }
372
373 inline hash cn_fast_hash(const void *data, std::size_t length) {
374 hash h;
375 cn_fast_hash(data, length, reinterpret_cast<char *>(&h));
376 return h;
377 }
378
379 inline void cn_slow_hash(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
380 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 0/*prehashed*/, height);
381 }
382
383 inline void cn_slow_hash_prehashed(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
384 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 1/*prehashed*/, height);
385 }
386
387 inline void tree_hash(const hash *hashes, std::size_t count, hash &root_hash) {
388 tree_hash(reinterpret_cast<const char (*)[HASH_SIZE]>(hashes), count, reinterpret_cast<char *>(&root_hash));
389 }
390
391 inline std::ostream &operator <<(std::ostream &o, const crypto::hash &v) {
393 }
394 inline std::ostream &operator <<(std::ostream &o, const crypto::hash8 &v) {
396 }
397 inline std::ostream &operator <<(std::ostream &o, const crypto::hash64 &v) {
399 }
400
401 const static crypto::hash null_hash = boost::value_initialized<crypto::hash>();
402 const static crypto::hash8 null_hash8 = boost::value_initialized<crypto::hash8>();
403 const static crypto::hash64 null_hash64 = boost::value_initialized<crypto::hash64>();
404}
405

◆ prepare_custom_vector_serialization() [2/2]

template<typename T>
void crypto::serialization::detail::prepare_custom_vector_serialization ( size_t size,
std::vector< T > & vec,
const boost::mpl::bool_< true > &  )

Definition at line 296 of file hash.h.

338 {
339
340 extern "C" {
341#include "hash-ops.h"
342 }
343
344#pragma pack(push, 1)
346 char data[HASH_SIZE];
347 };
349 char data[8];
350 };
352 char data[64];
353 };
354#pragma pack(pop)
355
356 static_assert(sizeof(hash) == HASH_SIZE, "Invalid structure size");
357 static_assert(sizeof(hash8) == 8, "Invalid structure size");
358 static_assert(sizeof(hash64) == 64, "Invalid structure size");
359
360 /*
361 Cryptonight hash functions
362 */
363
364 inline void cn_fast_hash(const void *data, std::size_t length, hash &hash) {
365 cn_fast_hash(data, length, reinterpret_cast<char *>(&hash));
366 }
367
368 inline hash cn_fast_hash(const void *data, std::size_t length) {
369 hash h;
370 cn_fast_hash(data, length, reinterpret_cast<char *>(&h));
371 return h;
372 }
373
374 inline void cn_slow_hash(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
375 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 0/*prehashed*/, height);
376 }
377
378 inline void cn_slow_hash_prehashed(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
379 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 1/*prehashed*/, height);
380 }
381
382 inline void tree_hash(const hash *hashes, std::size_t count, hash &root_hash) {
383 tree_hash(reinterpret_cast<const char (*)[HASH_SIZE]>(hashes), count, reinterpret_cast<char *>(&root_hash));
384 }
385
386 inline std::ostream &operator <<(std::ostream &o, const crypto::hash &v) {
388 }
389 inline std::ostream &operator <<(std::ostream &o, const crypto::hash8 &v) {
391 }
392 inline std::ostream &operator <<(std::ostream &o, const crypto::hash64 &v) {
394 }
395
396 const static crypto::hash null_hash = boost::value_initialized<crypto::hash>();
397 const static crypto::hash8 null_hash8 = boost::value_initialized<crypto::hash8>();
398 const static crypto::hash64 null_hash64 = boost::value_initialized<crypto::hash64>();
399}
400