Electroneum
Loading...
Searching...
No Matches
crypto::serializer< Archive, T > Struct Template Reference

... wouldn't a class be better? More...

#include <hash.h>

Static Public Member Functions

static bool serialize (Archive &ar, T &v)
template<typename A>
static bool serialize (Archive &ar, T &v, boost::false_type, boost::true_type, A a)
template<typename A>
static bool serialize (Archive &ar, T &v, boost::true_type, boost::false_type, A a)
static bool serialize (Archive &ar, T &v, boost::false_type, boost::false_type, boost::false_type)
static bool serialize (Archive &ar, T &v, boost::false_type, boost::false_type, boost::true_type)
static void serialize_custom (Archive &ar, T &v, boost::true_type)

Detailed Description

template<class Archive, class T>
struct crypto::serializer< Archive, T >

... wouldn't a class be better?

\detailed The logic behind serializing data. Places the archive data into the supplied parameter. This dispatches based on the supplied T template parameter's traits of is_blob_type or it is an integral (as defined by the is_integral trait). Depends on the Archive parameter to have overloaded the serialize_blob(T v, size_t size) and serialize_int(T v) base on which trait it applied. When the class has neither types, it falls to the overloaded method do_serialize(Archive ar) in T to do the work.

Definition at line 93 of file hash.h.

Member Function Documentation

◆ serialize() [1/5]

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

Definition at line 94 of file hash.h.

94 {
96 }
... wouldn't a class be better?
Definition hash.h:93
static void formatted(std::ostream &out, const span< const std::uint8_t > src)
Append < + src + > as hex to out.
Definition hex.cpp:76
Here is the call graph for this function:

◆ serialize() [2/5]

template<class Archive, class T>
bool crypto::serializer< Archive, T >::serialize ( Archive & ar,
T & v,
boost::false_type ,
boost::false_type ,
boost::false_type  )
inlinestatic

Definition at line 107 of file hash.h.

◆ serialize() [3/5]

template<class Archive, class T>
bool crypto::serializer< Archive, T >::serialize ( Archive & ar,
T & v,
boost::false_type ,
boost::false_type ,
boost::true_type  )
inlinestatic

Definition at line 111 of file hash.h.

153 {
154
155 extern "C" {
156#include "hash-ops.h"
157 }
158
159#pragma pack(push, 1)
161 char data[HASH_SIZE];
162 };
164 char data[8];
165 };
167 char data[64];
168 };
169#pragma pack(pop)
170
171 static_assert(sizeof(hash) == HASH_SIZE, "Invalid structure size");
172 static_assert(sizeof(hash8) == 8, "Invalid structure size");
173 static_assert(sizeof(hash64) == 64, "Invalid structure size");
174
175 /*
176 Cryptonight hash functions
177 */
178
179 inline void cn_fast_hash(const void *data, std::size_t length, hash &hash) {
180 cn_fast_hash(data, length, reinterpret_cast<char *>(&hash));
181 }
182
183 inline hash cn_fast_hash(const void *data, std::size_t length) {
184 hash h;
185 cn_fast_hash(data, length, reinterpret_cast<char *>(&h));
186 return h;
187 }
188
189 inline void cn_slow_hash(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
190 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 0/*prehashed*/, height);
191 }
192
193 inline void cn_slow_hash_prehashed(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
194 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 1/*prehashed*/, height);
195 }
196
197 inline void tree_hash(const hash *hashes, std::size_t count, hash &root_hash) {
198 tree_hash(reinterpret_cast<const char (*)[HASH_SIZE]>(hashes), count, reinterpret_cast<char *>(&root_hash));
199 }
200
203 }
206 }
209 }
210
214}
215
#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)
void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed, uint64_t height)
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

◆ serialize() [4/5]

template<class Archive, class T>
template<typename A>
bool crypto::serializer< Archive, T >::serialize ( Archive & ar,
T & v,
boost::false_type ,
boost::true_type ,
A a )
inlinestatic

Definition at line 98 of file hash.h.

Here is the call graph for this function:

◆ serialize() [5/5]

template<class Archive, class T>
template<typename A>
bool crypto::serializer< Archive, T >::serialize ( Archive & ar,
T & v,
boost::true_type ,
boost::false_type ,
A a )
inlinestatic

Definition at line 103 of file hash.h.

◆ serialize_custom()

template<class Archive, class T>
void crypto::serializer< Archive, T >::serialize_custom ( Archive & ar,
T & v,
boost::true_type  )
inlinestatic

Definition at line 115 of file hash.h.

157 {
158
159 extern "C" {
160#include "hash-ops.h"
161 }
162
163#pragma pack(push, 1)
165 char data[HASH_SIZE];
166 };
168 char data[8];
169 };
171 char data[64];
172 };
173#pragma pack(pop)
174
175 static_assert(sizeof(hash) == HASH_SIZE, "Invalid structure size");
176 static_assert(sizeof(hash8) == 8, "Invalid structure size");
177 static_assert(sizeof(hash64) == 64, "Invalid structure size");
178
179 /*
180 Cryptonight hash functions
181 */
182
183 inline void cn_fast_hash(const void *data, std::size_t length, hash &hash) {
184 cn_fast_hash(data, length, reinterpret_cast<char *>(&hash));
185 }
186
187 inline hash cn_fast_hash(const void *data, std::size_t length) {
188 hash h;
189 cn_fast_hash(data, length, reinterpret_cast<char *>(&h));
190 return h;
191 }
192
193 inline void cn_slow_hash(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
194 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 0/*prehashed*/, height);
195 }
196
197 inline void cn_slow_hash_prehashed(const void *data, std::size_t length, hash &hash, int variant = 0, uint64_t height = 0) {
198 cn_slow_hash(data, length, reinterpret_cast<char *>(&hash), variant, 1/*prehashed*/, height);
199 }
200
201 inline void tree_hash(const hash *hashes, std::size_t count, hash &root_hash) {
202 tree_hash(reinterpret_cast<const char (*)[HASH_SIZE]>(hashes), count, reinterpret_cast<char *>(&root_hash));
203 }
204
207 }
210 }
213 }
214
218}
219

The documentation for this struct was generated from the following file:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/src/crypto/hash.h