diff options
Diffstat (limited to '')
-rw-r--r-- | src/cryptonote_core/cryptonote_boost_serialization.h | 56 | ||||
-rw-r--r-- | src/ringct/rctTypes.h | 48 | ||||
-rw-r--r-- | src/serialization/crypto.h | 28 |
3 files changed, 104 insertions, 28 deletions
diff --git a/src/cryptonote_core/cryptonote_boost_serialization.h b/src/cryptonote_core/cryptonote_boost_serialization.h index 79ceec5bc..6a6ff5a7d 100644 --- a/src/cryptonote_core/cryptonote_boost_serialization.h +++ b/src/cryptonote_core/cryptonote_boost_serialization.h @@ -40,6 +40,7 @@ #include "cryptonote_basic.h" #include "common/unordered_containers_boost_serialization.h" #include "crypto/crypto.h" +#include "ringct/rctTypes.h" //namespace cryptonote { namespace boost @@ -163,6 +164,61 @@ namespace boost a & b.miner_tx; a & b.tx_hashes; } + + template <class Archive> + inline void serialize(Archive &a, rct::key &x, const boost::serialization::version_type ver) + { + a & reinterpret_cast<char (&)[sizeof(rct::key)]>(x); + } + + template <class Archive> + inline void serialize(Archive &a, rct::ctkey &x, const boost::serialization::version_type ver) + { + a & x.dest; + a & x.mask; + } + + template <class Archive> + inline void serialize(Archive &a, rct::rangeSig &x, const boost::serialization::version_type ver) + { + a & x.asig; + a & x.Ci; + } + + template <class Archive> + inline void serialize(Archive &a, rct::asnlSig &x, const boost::serialization::version_type ver) + { + a & x.L1; + a & x.s2; + a & x.s; + } + + template <class Archive> + inline void serialize(Archive &a, rct::mgSig &x, const boost::serialization::version_type ver) + { + a & x.ss; + a & x.cc; + a & x.II; + } + + template <class Archive> + inline void serialize(Archive &a, rct::ecdhTuple &x, const boost::serialization::version_type ver) + { + a & x.mask; + a & x.amount; + a & x.senderPk; + } + + template <class Archive> + inline void serialize(Archive &a, rct::rctSig &x, const boost::serialization::version_type ver) + { + a & x.rangeSigs; + a & x.MG; + a & x.mixRing; + a & x.ecdhInfo; + a & x.outPk; + a & x.txnFee; + } } } diff --git a/src/ringct/rctTypes.h b/src/ringct/rctTypes.h index 01585235f..13e9fb6f2 100644 --- a/src/ringct/rctTypes.h +++ b/src/ringct/rctTypes.h @@ -48,6 +48,9 @@ extern "C" { #include "crypto/crypto.h" #include "serialization/serialization.h" +#include "serialization/debug_archive.h" +#include "serialization/binary_archive.h" +#include "serialization/json_archive.h" //Define this flag when debugging to get additional info on the console @@ -309,4 +312,49 @@ namespace cryptonote { template<typename T> std::ostream &print256(std::ostream &o, const T &v); inline std::ostream &operator <<(std::ostream &o, const rct::key &v) { return print256(o, v); } + +BLOB_SERIALIZER(rct::key); +BLOB_SERIALIZER(rct::key64); +BLOB_SERIALIZER(rct::ctkey); +BLOB_SERIALIZER(rct::asnlSig); + +VARIANT_TAG(debug_archive, rct::key, "rct::key"); +VARIANT_TAG(debug_archive, rct::key64, "rct::key64"); +VARIANT_TAG(debug_archive, rct::keyV, "rct::keyV"); +VARIANT_TAG(debug_archive, rct::keyM, "rct::keyM"); +VARIANT_TAG(debug_archive, rct::ctkey, "rct::ctkey"); +VARIANT_TAG(debug_archive, rct::ctkeyV, "rct::ctkeyV"); +VARIANT_TAG(debug_archive, rct::ctkeyM, "rct::ctkeyM"); +VARIANT_TAG(debug_archive, rct::ecdhTuple, "rct::ecdhTuple"); +VARIANT_TAG(debug_archive, rct::mgSig, "rct::mgSig"); +VARIANT_TAG(debug_archive, rct::rangeSig, "rct::rangeSig"); +VARIANT_TAG(debug_archive, rct::asnlSig, "rct::asnlSig"); +VARIANT_TAG(debug_archive, rct::rctSig, "rct::rctSig"); + +VARIANT_TAG(binary_archive, rct::key, 0x90); +VARIANT_TAG(binary_archive, rct::key64, 0x91); +VARIANT_TAG(binary_archive, rct::keyV, 0x92); +VARIANT_TAG(binary_archive, rct::keyM, 0x93); +VARIANT_TAG(binary_archive, rct::ctkey, 0x94); +VARIANT_TAG(binary_archive, rct::ctkeyV, 0x95); +VARIANT_TAG(binary_archive, rct::ctkeyM, 0x96); +VARIANT_TAG(binary_archive, rct::ecdhTuple, 0x97); +VARIANT_TAG(binary_archive, rct::mgSig, 0x98); +VARIANT_TAG(binary_archive, rct::rangeSig, 0x99); +VARIANT_TAG(binary_archive, rct::asnlSig, 0x9a); +VARIANT_TAG(binary_archive, rct::rctSig, 0x9b); + +VARIANT_TAG(json_archive, rct::key, "rct_key"); +VARIANT_TAG(json_archive, rct::key64, "rct_key64"); +VARIANT_TAG(json_archive, rct::keyV, "rct_keyV"); +VARIANT_TAG(json_archive, rct::keyM, "rct_keyM"); +VARIANT_TAG(json_archive, rct::ctkey, "rct_ctkey"); +VARIANT_TAG(json_archive, rct::ctkeyV, "rct_ctkeyV"); +VARIANT_TAG(json_archive, rct::ctkeyM, "rct_ctkeyM"); +VARIANT_TAG(json_archive, rct::ecdhTuple, "rct_ecdhTuple"); +VARIANT_TAG(json_archive, rct::mgSig, "rct_mgSig"); +VARIANT_TAG(json_archive, rct::rangeSig, "rct_rangeSig"); +VARIANT_TAG(json_archive, rct::asnlSig, "rct_asnlSig"); +VARIANT_TAG(json_archive, rct::rctSig, "rct_rctSig"); + #endif /* RCTTYPES_H */ diff --git a/src/serialization/crypto.h b/src/serialization/crypto.h index 9babe698d..9a7e89c49 100644 --- a/src/serialization/crypto.h +++ b/src/serialization/crypto.h @@ -37,7 +37,6 @@ #include "crypto/chacha8.h" #include "crypto/crypto.h" #include "crypto/hash.h" -#include "ringct/rctTypes.h" // read template <template <bool> class Archive> @@ -94,30 +93,3 @@ VARIANT_TAG(debug_archive, crypto::key_derivation, "key_derivation"); VARIANT_TAG(debug_archive, crypto::key_image, "key_image"); VARIANT_TAG(debug_archive, crypto::signature, "signature"); -BLOB_SERIALIZER(rct::key); -BLOB_SERIALIZER(rct::key64); -BLOB_SERIALIZER(rct::ctkey); -BLOB_SERIALIZER(rct::ecdhTuple); -BLOB_SERIALIZER(rct::asnlSig); - -VARIANT_TAG(debug_archive, rct::key, "rct::key"); -VARIANT_TAG(debug_archive, rct::key64, "rct::key64"); -VARIANT_TAG(debug_archive, rct::ctkey, "rct::ctkey"); -VARIANT_TAG(debug_archive, rct::ecdhTuple, "rct::ecdhTuple"); -VARIANT_TAG(debug_archive, rct::asnlSig, "rct::asnlSig"); -VARIANT_TAG(debug_archive, rct::rctSig, "rct::rctSig"); - -VARIANT_TAG(binary_archive, rct::key, 0x90); -VARIANT_TAG(binary_archive, rct::key64, 0x91); -VARIANT_TAG(binary_archive, rct::ctkey, 0x92); -VARIANT_TAG(binary_archive, rct::ecdhTuple, 0x93); -VARIANT_TAG(binary_archive, rct::asnlSig, 0x94); -VARIANT_TAG(binary_archive, rct::rctSig, 0x95); - -VARIANT_TAG(json_archive, rct::key, "rct_key"); -VARIANT_TAG(json_archive, rct::key64, "rct_key64"); -VARIANT_TAG(json_archive, rct::ctkey, "rct_ctkey"); -VARIANT_TAG(json_archive, rct::ecdhTuple, "rct_ecdhTuple"); -VARIANT_TAG(json_archive, rct::asnlSig, "rct_asnlSig"); -VARIANT_TAG(json_archive, rct::rctSig, "rct_rctSig"); - |