rct: add serialization machinery to rct types
This commit is contained in:
parent
0ff8305426
commit
d02f9995a8
2 changed files with 61 additions and 10 deletions
|
@ -47,6 +47,9 @@ extern "C" {
|
|||
}
|
||||
#include "crypto/crypto.h"
|
||||
|
||||
#include "serialization/serialization.h"
|
||||
|
||||
|
||||
//Define this flag when debugging to get additional info on the console
|
||||
#ifdef DBG
|
||||
#define DP(x) dp(x)
|
||||
|
@ -106,6 +109,12 @@ namespace rct {
|
|||
key mask;
|
||||
key amount;
|
||||
key senderPk;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(mask)
|
||||
FIELD(amount)
|
||||
FIELD(senderPk)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
//containers for representing amounts
|
||||
|
@ -132,6 +141,12 @@ namespace rct {
|
|||
keyM ss;
|
||||
key cc;
|
||||
keyV II;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(ss)
|
||||
FIELD(cc)
|
||||
FIELD(II)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
//contains the data for an asnl sig
|
||||
// also contains the "Ci" values such that
|
||||
|
@ -142,6 +157,11 @@ namespace rct {
|
|||
struct rangeSig {
|
||||
asnlSig asig;
|
||||
key64 Ci;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(asig)
|
||||
FIELD(Ci)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
//A container to hold all signatures necessary for RingCT
|
||||
// rangeSigs holds all the rangeproof data of a transaction
|
||||
|
@ -157,15 +177,14 @@ namespace rct {
|
|||
//pairs that you mix with
|
||||
vector<ecdhTuple> ecdhInfo;
|
||||
ctkeyV outPk;
|
||||
};
|
||||
|
||||
struct rmsSig {
|
||||
vector<rangeSig> rangeSigs;
|
||||
mgSig MG;
|
||||
ctkeyM mixRing;
|
||||
vector<ecdhTuple> destinationEcdhInfo;
|
||||
vector<ecdhTuple> participantEcdhInfo;
|
||||
ctkeyV outPk;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(rangeSigs)
|
||||
FIELD(MG)
|
||||
FIELD(mixRing)
|
||||
FIELD(ecdhInfo)
|
||||
FIELD(outPk)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
//other basepoint H = toPoint(cn_fast_hash(G)), G the basepoint
|
||||
|
@ -173,7 +192,7 @@ namespace rct {
|
|||
|
||||
//H2 contains 2^i H in each index, i.e. H, 2H, 4H, 8H, ...
|
||||
//This is used for the range proofG
|
||||
//You can regenerate this by running python2 Test.py HPow2 in the MiniNero repo
|
||||
//You can regenerate this by running python2 Test.py HPow2 in the MiniNero repo
|
||||
static const key64 H2 = {{0x8b, 0x65, 0x59, 0x70, 0x15, 0x37, 0x99, 0xaf, 0x2a, 0xea, 0xdc, 0x9f, 0xf1, 0xad, 0xd0, 0xea, 0x6c, 0x72, 0x51, 0xd5, 0x41, 0x54, 0xcf, 0xa9, 0x2c, 0x17, 0x3a, 0x0d, 0xd3, 0x9c, 0x1f, 0x94},
|
||||
{0x8f, 0xaa, 0x44, 0x8a, 0xe4, 0xb3, 0xe2, 0xbb, 0x3d, 0x4d, 0x13, 0x09, 0x09, 0xf5, 0x5f, 0xcd, 0x79, 0x71, 0x1c, 0x1c, 0x83, 0xcd, 0xbc, 0xca, 0xdd, 0x42, 0xcb, 0xe1, 0x51, 0x5e, 0x87, 0x12},
|
||||
{0x12, 0xa7, 0xd6, 0x2c, 0x77, 0x91, 0x65, 0x4a, 0x57, 0xf3, 0xe6, 0x76, 0x94, 0xed, 0x50, 0xb4, 0x9a, 0x7d, 0x9e, 0x3f, 0xc1, 0xe4, 0xc7, 0xa0, 0xbd, 0xe2, 0x9d, 0x18, 0x7e, 0x9c, 0xc7, 0x1d},
|
||||
|
@ -270,4 +289,7 @@ namespace rct {
|
|||
xmr_amount b2d(bits amountb);
|
||||
}
|
||||
|
||||
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); }
|
||||
|
||||
#endif /* RCTTYPES_H */
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "crypto/chacha8.h"
|
||||
#include "crypto/crypto.h"
|
||||
#include "crypto/hash.h"
|
||||
#include "ringct/rctTypes.h"
|
||||
|
||||
// read
|
||||
template <template <bool> class Archive>
|
||||
|
@ -92,3 +93,31 @@ VARIANT_TAG(debug_archive, crypto::secret_key, "secret_key");
|
|||
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");
|
||||
|
||||
|
|
Loading…
Reference in a new issue