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

Namespaces

namespace  detail

Functions

template<class Archive>
bool check_stream_state (Archive &ar, bool noeof=false)
template<class Archive, class T>
bool serialize (Archive &ar, T &v)
template<class Archive, class T>
bool serialize_noeof (Archive &ar, T &v)

Function Documentation

◆ check_stream_state()

template<class Archive>
bool crypto::serialization::check_stream_state ( Archive & ar,
bool noeof = false )

Definition at line 351 of file hash.h.

393 {
394
395 extern "C" {
396#include "hash-ops.h"
397 }
398
399#pragma pack(push, 1)
401 char data[HASH_SIZE];
402 };
404 char data[8];
405 };
407 char data[64];
408 };
409#pragma pack(pop)
410
411 static_assert(sizeof(hash) == HASH_SIZE, "Invalid structure size");
412 static_assert(sizeof(hash8) == 8, "Invalid structure size");
413 static_assert(sizeof(hash64) == 64, "Invalid structure size");
414
415 /*
416 Cryptonight hash functions
417 */
418
419 inline void cn_fast_hash(const void *data, std::size_t length, hash &hash) {
420 cn_fast_hash(data, length, reinterpret_cast<char *>(&hash));
421 }
422
423 inline hash cn_fast_hash(const void *data, std::size_t length) {
424 hash h;
425 cn_fast_hash(data, length, reinterpret_cast<char *>(&h));
426 return h;
427 }
428
429 inline void cn_slow_hash(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
430 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 0/*prehashed*/, height);
431 }
432
433 inline void cn_slow_hash_prehashed(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
434 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 1/*prehashed*/, height);
435 }
436
437 inline void tree_hash(const hash *hashes, std::size_t count, hash &root_hash) {
438 tree_hash(reinterpret_cast<const char (*)[HASH_SIZE]>(hashes), count, reinterpret_cast<char *>(&root_hash));
439 }
440
441 inline std::ostream &operator <<(std::ostream &o, const crypto::hash &v) {
443 }
444 inline std::ostream &operator <<(std::ostream &o, const crypto::hash8 &v) {
446 }
447 inline std::ostream &operator <<(std::ostream &o, const crypto::hash64 &v) {
449 }
450
451 const static crypto::hash null_hash = boost::value_initialized<crypto::hash>();
452 const static crypto::hash8 null_hash8 = boost::value_initialized<crypto::hash8>();
453 const static crypto::hash64 null_hash64 = boost::value_initialized<crypto::hash64>();
454}
455
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[]

◆ serialize()

template<class Archive, class T>
bool crypto::serialization::serialize ( Archive & ar,
T & v )
inline

Definition at line 361 of file hash.h.

403 {
404
405 extern "C" {
406#include "hash-ops.h"
407 }
408
409#pragma pack(push, 1)
411 char data[HASH_SIZE];
412 };
414 char data[8];
415 };
417 char data[64];
418 };
419#pragma pack(pop)
420
421 static_assert(sizeof(hash) == HASH_SIZE, "Invalid structure size");
422 static_assert(sizeof(hash8) == 8, "Invalid structure size");
423 static_assert(sizeof(hash64) == 64, "Invalid structure size");
424
425 /*
426 Cryptonight hash functions
427 */
428
429 inline void cn_fast_hash(const void *data, std::size_t length, hash &hash) {
430 cn_fast_hash(data, length, reinterpret_cast<char *>(&hash));
431 }
432
433 inline hash cn_fast_hash(const void *data, std::size_t length) {
434 hash h;
435 cn_fast_hash(data, length, reinterpret_cast<char *>(&h));
436 return h;
437 }
438
439 inline void cn_slow_hash(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
440 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 0/*prehashed*/, height);
441 }
442
443 inline void cn_slow_hash_prehashed(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
444 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 1/*prehashed*/, height);
445 }
446
447 inline void tree_hash(const hash *hashes, std::size_t count, hash &root_hash) {
448 tree_hash(reinterpret_cast<const char (*)[HASH_SIZE]>(hashes), count, reinterpret_cast<char *>(&root_hash));
449 }
450
451 inline std::ostream &operator <<(std::ostream &o, const crypto::hash &v) {
453 }
454 inline std::ostream &operator <<(std::ostream &o, const crypto::hash8 &v) {
456 }
457 inline std::ostream &operator <<(std::ostream &o, const crypto::hash64 &v) {
459 }
460
461 const static crypto::hash null_hash = boost::value_initialized<crypto::hash>();
462 const static crypto::hash8 null_hash8 = boost::value_initialized<crypto::hash8>();
463 const static crypto::hash64 null_hash64 = boost::value_initialized<crypto::hash64>();
464}
465

◆ serialize_noeof()

template<class Archive, class T>
bool crypto::serialization::serialize_noeof ( Archive & ar,
T & v )
inline

Definition at line 372 of file hash.h.

414 {
415
416 extern "C" {
417#include "hash-ops.h"
418 }
419
420#pragma pack(push, 1)
422 char data[HASH_SIZE];
423 };
425 char data[8];
426 };
428 char data[64];
429 };
430#pragma pack(pop)
431
432 static_assert(sizeof(hash) == HASH_SIZE, "Invalid structure size");
433 static_assert(sizeof(hash8) == 8, "Invalid structure size");
434 static_assert(sizeof(hash64) == 64, "Invalid structure size");
435
436 /*
437 Cryptonight hash functions
438 */
439
440 inline void cn_fast_hash(const void *data, std::size_t length, hash &hash) {
441 cn_fast_hash(data, length, reinterpret_cast<char *>(&hash));
442 }
443
444 inline hash cn_fast_hash(const void *data, std::size_t length) {
445 hash h;
446 cn_fast_hash(data, length, reinterpret_cast<char *>(&h));
447 return h;
448 }
449
450 inline void cn_slow_hash(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
451 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 0/*prehashed*/, height);
452 }
453
454 inline void cn_slow_hash_prehashed(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
455 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 1/*prehashed*/, height);
456 }
457
458 inline void tree_hash(const hash *hashes, std::size_t count, hash &root_hash) {
459 tree_hash(reinterpret_cast<const char (*)[HASH_SIZE]>(hashes), count, reinterpret_cast<char *>(&root_hash));
460 }
461
462 inline std::ostream &operator <<(std::ostream &o, const crypto::hash &v) {
464 }
465 inline std::ostream &operator <<(std::ostream &o, const crypto::hash8 &v) {
467 }
468 inline std::ostream &operator <<(std::ostream &o, const crypto::hash64 &v) {
470 }
471
472 const static crypto::hash null_hash = boost::value_initialized<crypto::hash>();
473 const static crypto::hash8 null_hash8 = boost::value_initialized<crypto::hash8>();
474 const static crypto::hash64 null_hash64 = boost::value_initialized<crypto::hash64>();
475}
476