Monero
rctTypes.h
Go to the documentation of this file.
1 // Copyright (c) 2016, Monero Research Labs
2 //
3 // Author: Shen Noether <shen.noether@gmx.com>
4 //
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without modification, are
8 // permitted provided that the following conditions are met:
9 //
10 // 1. Redistributions of source code must retain the above copyright notice, this list of
11 // conditions and the following disclaimer.
12 //
13 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
14 // of conditions and the following disclaimer in the documentation and/or other
15 // materials provided with the distribution.
16 //
17 // 3. Neither the name of the copyright holder nor the names of its contributors may be
18 // used to endorse or promote products derived from this software without specific
19 // prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
22 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
24 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
29 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 #pragma once
32 #ifndef RCT_TYPES_H
33 #define RCT_TYPES_H
34 
35 #include <cstddef>
36 #include <vector>
37 #include <iostream>
38 #include <cinttypes>
40 
41 extern "C" {
42 #include "crypto/crypto-ops.h"
43 #include "crypto/random.h"
44 #include "crypto/keccak.h"
45 }
46 #include "crypto/generic-ops.h"
47 #include "crypto/crypto.h"
48 
49 #include "hex.h"
50 #include "span.h"
51 #include "serialization/vector.h"
55 
56 
57 //Define this flag when debugging to get additional info on the console
58 #ifdef DBG
59 #define DP(x) dp(x)
60 #else
61 #define DP(x)
62 #endif
63 
64 //atomic units of moneros
65 #define ATOMS 64
66 
67 //for printing large ints
68 
69 //Namespace specifically for ring ct code
70 namespace rct {
71  //basic ops containers
72  typedef unsigned char * Bytes;
73 
74  // Can contain a secret or public key
75  // similar to secret_key / public_key of crypto-ops,
76  // but uses unsigned chars,
77  // also includes an operator for accessing the i'th byte.
78  struct key {
79  unsigned char & operator[](int i) {
80  return bytes[i];
81  }
82  unsigned char operator[](int i) const {
83  return bytes[i];
84  }
85  bool operator==(const key &k) const { return !crypto_verify_32(bytes, k.bytes); }
86  unsigned char bytes[32];
87  };
88  typedef std::vector<key> keyV; //vector of keys
89  typedef std::vector<keyV> keyM; //matrix of keys (indexed by column first)
90 
91  //containers For CT operations
92  //if it's representing a private ctkey then "dest" contains the secret key of the address
93  // while "mask" contains a where C = aG + bH is CT pedersen commitment and b is the amount
94  // (store b, the amount, separately
95  //if it's representing a public ctkey, then "dest" = P the address, mask = C the commitment
96  struct ctkey {
98  key mask; //C here if public
99  };
100  typedef std::vector<ctkey> ctkeyV;
101  typedef std::vector<ctkeyV> ctkeyM;
102 
103  //used for multisig data
104  struct multisig_kLRki {
109  };
110 
111  struct multisig_out {
112  std::vector<key> c; // for all inputs
113 
115  FIELD(c)
116  END_SERIALIZE()
117  };
118 
119  //data for passing the amount to the receiver secretly
120  // If the pedersen commitment to an amount is C = aG + bH,
121  // "mask" contains a 32 byte key a
122  // "amount" contains a hex representation (in 32 bytes) of a 64 bit number
123  // "senderPk" is not the senders actual public key, but a one-time public key generated for
124  // the purpose of the ECDH exchange
125  struct ecdhTuple {
129 
131  FIELD(mask)
132  FIELD(amount)
133  // FIELD(senderPk) // not serialized, as we do not use it in monero currently
134  END_SERIALIZE()
135  };
136 
137  //containers for representing amounts
138  typedef uint64_t xmr_amount;
139  typedef unsigned int bits[ATOMS];
140  typedef key key64[64];
141 
142  struct boroSig {
146  };
147 
148  //Container for precomp
149  struct geDsmp {
151  };
152 
153  //just contains the necessary keys to represent MLSAG sigs
154  //c.f. https://eprint.iacr.org/2015/1098
155  struct mgSig {
159 
161  FIELD(ss)
162  FIELD(cc)
163  // FIELD(II) - not serialized, it can be reconstructed
164  END_SERIALIZE()
165  };
166  //contains the data for an Borromean sig
167  // also contains the "Ci" values such that
168  // \sum Ci = C
169  // and the signature proves that each Ci is either
170  // a Pedersen commitment to 0 or to 2^i
171  //thus proving that C is in the range of [0, 2^64]
172  struct rangeSig {
175 
177  FIELD(asig)
178  FIELD(Ci)
179  END_SERIALIZE()
180  };
181 
182  struct Bulletproof
183  {
185  rct::key A, S, T1, T2;
189 
191  Bulletproof(const rct::key &V, const rct::key &A, const rct::key &S, const rct::key &T1, const rct::key &T2, const rct::key &taux, const rct::key &mu, const rct::keyV &L, const rct::keyV &R, const rct::key &a, const rct::key &b, const rct::key &t):
192  V({V}), A(A), S(S), T1(T1), T2(T2), taux(taux), mu(mu), L(L), R(R), a(a), b(b), t(t) {}
193  Bulletproof(const rct::keyV &V, const rct::key &A, const rct::key &S, const rct::key &T1, const rct::key &T2, const rct::key &taux, const rct::key &mu, const rct::keyV &L, const rct::keyV &R, const rct::key &a, const rct::key &b, const rct::key &t):
194  V(V), A(A), S(S), T1(T1), T2(T2), taux(taux), mu(mu), L(L), R(R), a(a), b(b), t(t) {}
195 
197  // Commitments aren't saved, they're restored via outPk
198  // FIELD(V)
199  FIELD(A)
200  FIELD(S)
201  FIELD(T1)
202  FIELD(T2)
203  FIELD(taux)
204  FIELD(mu)
205  FIELD(L)
206  FIELD(R)
207  FIELD(a)
208  FIELD(b)
209  FIELD(t)
210 
211  if (L.empty() || L.size() != R.size())
212  return false;
213  END_SERIALIZE()
214  };
215 
216  size_t n_bulletproof_amounts(const Bulletproof &proof);
217  size_t n_bulletproof_max_amounts(const Bulletproof &proof);
218  size_t n_bulletproof_amounts(const std::vector<Bulletproof> &proofs);
219  size_t n_bulletproof_max_amounts(const std::vector<Bulletproof> &proofs);
220 
221  //A container to hold all signatures necessary for RingCT
222  // rangeSigs holds all the rangeproof data of a transaction
223  // MG holds the MLSAG signature of a transaction
224  // mixRing holds all the public keypairs (P, C) for a transaction
225  // ecdhInfo holds an encoded mask / amount to be passed to each receiver
226  // outPk contains public keypairs which are destinations (P, C),
227  // P = address, C = commitment to amount
228  enum {
233  };
235  struct rctSigBase {
236  uint8_t type;
238  ctkeyM mixRing; //the set of all pubkeys / copy
239  //pairs that you mix with
240  keyV pseudoOuts; //C - for simple rct
241  std::vector<ecdhTuple> ecdhInfo;
243  xmr_amount txnFee; // contains b
244 
245  template<bool W, template <bool> class Archive>
246  bool serialize_rctsig_base(Archive<W> &ar, size_t inputs, size_t outputs)
247  {
248  FIELD(type)
249  if (type == RCTTypeNull)
250  return true;
251  if (type != RCTTypeFull && type != RCTTypeSimple && type != RCTTypeBulletproof)
252  return false;
253  VARINT_FIELD(txnFee)
254  // inputs/outputs not saved, only here for serialization help
255  // FIELD(message) - not serialized, it can be reconstructed
256  // FIELD(mixRing) - not serialized, it can be reconstructed
257  if (type == RCTTypeSimple) // moved to prunable with bulletproofs
258  {
259  ar.tag("pseudoOuts");
260  ar.begin_array();
261  PREPARE_CUSTOM_VECTOR_SERIALIZATION(inputs, pseudoOuts);
262  if (pseudoOuts.size() != inputs)
263  return false;
264  for (size_t i = 0; i < inputs; ++i)
265  {
266  FIELDS(pseudoOuts[i])
267  if (inputs - i > 1)
268  ar.delimit_array();
269  }
270  ar.end_array();
271  }
272 
273  ar.tag("ecdhInfo");
274  ar.begin_array();
275  PREPARE_CUSTOM_VECTOR_SERIALIZATION(outputs, ecdhInfo);
276  if (ecdhInfo.size() != outputs)
277  return false;
278  for (size_t i = 0; i < outputs; ++i)
279  {
280  FIELDS(ecdhInfo[i])
281  if (outputs - i > 1)
282  ar.delimit_array();
283  }
284  ar.end_array();
285 
286  ar.tag("outPk");
287  ar.begin_array();
288  PREPARE_CUSTOM_VECTOR_SERIALIZATION(outputs, outPk);
289  if (outPk.size() != outputs)
290  return false;
291  for (size_t i = 0; i < outputs; ++i)
292  {
293  FIELDS(outPk[i].mask)
294  if (outputs - i > 1)
295  ar.delimit_array();
296  }
297  ar.end_array();
298  return true;
299  }
300  };
301  struct rctSigPrunable {
302  std::vector<rangeSig> rangeSigs;
303  std::vector<Bulletproof> bulletproofs;
304  std::vector<mgSig> MGs; // simple rct has N, full has 1
305  keyV pseudoOuts; //C - for simple rct
306 
307  template<bool W, template <bool> class Archive>
308  bool serialize_rctsig_prunable(Archive<W> &ar, uint8_t type, size_t inputs, size_t outputs, size_t mixin)
309  {
310  if (type == RCTTypeNull)
311  return true;
312  if (type != RCTTypeFull && type != RCTTypeSimple && type != RCTTypeBulletproof)
313  return false;
314  if (type == RCTTypeBulletproof)
315  {
316  uint32_t nbp = bulletproofs.size();
317  FIELD(nbp)
318  ar.tag("bp");
319  ar.begin_array();
320  if (nbp > outputs)
321  return false;
322  PREPARE_CUSTOM_VECTOR_SERIALIZATION(nbp, bulletproofs);
323  for (size_t i = 0; i < nbp; ++i)
324  {
325  FIELDS(bulletproofs[i])
326  if (nbp - i > 1)
327  ar.delimit_array();
328  }
329  if (n_bulletproof_max_amounts(bulletproofs) < outputs)
330  return false;
331  ar.end_array();
332  }
333  else
334  {
335  ar.tag("rangeSigs");
336  ar.begin_array();
337  PREPARE_CUSTOM_VECTOR_SERIALIZATION(outputs, rangeSigs);
338  if (rangeSigs.size() != outputs)
339  return false;
340  for (size_t i = 0; i < outputs; ++i)
341  {
342  FIELDS(rangeSigs[i])
343  if (outputs - i > 1)
344  ar.delimit_array();
345  }
346  ar.end_array();
347  }
348 
349  ar.tag("MGs");
350  ar.begin_array();
351  // we keep a byte for size of MGs, because we don't know whether this is
352  // a simple or full rct signature, and it's starting to annoy the hell out of me
353  size_t mg_elements = (type == RCTTypeSimple || type == RCTTypeBulletproof) ? inputs : 1;
354  PREPARE_CUSTOM_VECTOR_SERIALIZATION(mg_elements, MGs);
355  if (MGs.size() != mg_elements)
356  return false;
357  for (size_t i = 0; i < mg_elements; ++i)
358  {
359  // we save the MGs contents directly, because we want it to save its
360  // arrays and matrices without the size prefixes, and the load can't
361  // know what size to expect if it's not in the data
362  ar.begin_object();
363  ar.tag("ss");
364  ar.begin_array();
365  PREPARE_CUSTOM_VECTOR_SERIALIZATION(mixin + 1, MGs[i].ss);
366  if (MGs[i].ss.size() != mixin + 1)
367  return false;
368  for (size_t j = 0; j < mixin + 1; ++j)
369  {
370  ar.begin_array();
371  size_t mg_ss2_elements = ((type == RCTTypeSimple || type == RCTTypeBulletproof) ? 1 : inputs) + 1;
372  PREPARE_CUSTOM_VECTOR_SERIALIZATION(mg_ss2_elements, MGs[i].ss[j]);
373  if (MGs[i].ss[j].size() != mg_ss2_elements)
374  return false;
375  for (size_t k = 0; k < mg_ss2_elements; ++k)
376  {
377  FIELDS(MGs[i].ss[j][k])
378  if (mg_ss2_elements - k > 1)
379  ar.delimit_array();
380  }
381  ar.end_array();
382 
383  if (mixin + 1 - j > 1)
384  ar.delimit_array();
385  }
386  ar.end_array();
387 
388  ar.tag("cc");
389  FIELDS(MGs[i].cc)
390  // MGs[i].II not saved, it can be reconstructed
391  ar.end_object();
392 
393  if (mg_elements - i > 1)
394  ar.delimit_array();
395  }
396  ar.end_array();
397  if (type == RCTTypeBulletproof)
398  {
399  ar.tag("pseudoOuts");
400  ar.begin_array();
401  PREPARE_CUSTOM_VECTOR_SERIALIZATION(inputs, pseudoOuts);
402  if (pseudoOuts.size() != inputs)
403  return false;
404  for (size_t i = 0; i < inputs; ++i)
405  {
406  FIELDS(pseudoOuts[i])
407  if (inputs - i > 1)
408  ar.delimit_array();
409  }
410  ar.end_array();
411  }
412  return true;
413  }
414 
415  };
416  struct rctSig: public rctSigBase {
418 
420  {
421  return type == RCTTypeBulletproof ? p.pseudoOuts : pseudoOuts;
422  }
423 
424  keyV const& get_pseudo_outs() const
425  {
426  return type == RCTTypeBulletproof ? p.pseudoOuts : pseudoOuts;
427  }
428  };
429 
430  //other basepoint H = toPoint(cn_fast_hash(G)), G the basepoint
431  static const key H = { {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} };
432 
433  //H2 contains 2^i H in each index, i.e. H, 2H, 4H, 8H, ...
434  //This is used for the range proofG
435  //You can regenerate this by running python2 Test.py HPow2 in the MiniNero repo
436  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}},
437  {{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}},
438  {{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}},
439  {{0x78, 0x9a, 0xb9, 0x93, 0x4b, 0x49, 0xc4, 0xf9, 0xe6, 0x78, 0x5c, 0x6d, 0x57, 0xa4, 0x98, 0xb3, 0xea, 0xd4, 0x43, 0xf0, 0x4f, 0x13, 0xdf, 0x11, 0x0c, 0x54, 0x27, 0xb4, 0xf2, 0x14, 0xc7, 0x39}},
440  {{0x77, 0x1e, 0x92, 0x99, 0xd9, 0x4f, 0x02, 0xac, 0x72, 0xe3, 0x8e, 0x44, 0xde, 0x56, 0x8a, 0xc1, 0xdc, 0xb2, 0xed, 0xc6, 0xed, 0xb6, 0x1f, 0x83, 0xca, 0x41, 0x8e, 0x10, 0x77, 0xce, 0x3d, 0xe8}},
441  {{0x73, 0xb9, 0x6d, 0xb4, 0x30, 0x39, 0x81, 0x9b, 0xda, 0xf5, 0x68, 0x0e, 0x5c, 0x32, 0xd7, 0x41, 0x48, 0x88, 0x84, 0xd1, 0x8d, 0x93, 0x86, 0x6d, 0x40, 0x74, 0xa8, 0x49, 0x18, 0x2a, 0x8a, 0x64}},
442  {{0x8d, 0x45, 0x8e, 0x1c, 0x2f, 0x68, 0xeb, 0xeb, 0xcc, 0xd2, 0xfd, 0x5d, 0x37, 0x9f, 0x5e, 0x58, 0xf8, 0x13, 0x4d, 0xf3, 0xe0, 0xe8, 0x8c, 0xad, 0x3d, 0x46, 0x70, 0x10, 0x63, 0xa8, 0xd4, 0x12}},
443  {{0x09, 0x55, 0x1e, 0xdb, 0xe4, 0x94, 0x41, 0x8e, 0x81, 0x28, 0x44, 0x55, 0xd6, 0x4b, 0x35, 0xee, 0x8a, 0xc0, 0x93, 0x06, 0x8a, 0x5f, 0x16, 0x1f, 0xa6, 0x63, 0x75, 0x59, 0x17, 0x7e, 0xf4, 0x04}},
444  {{0xd0, 0x5a, 0x88, 0x66, 0xf4, 0xdf, 0x8c, 0xee, 0x1e, 0x26, 0x8b, 0x1d, 0x23, 0xa4, 0xc5, 0x8c, 0x92, 0xe7, 0x60, 0x30, 0x97, 0x86, 0xcd, 0xac, 0x0f, 0xed, 0xa1, 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 0x89, 0xd6, 0xbe, 0x9e, 0x7e, 0xbc, 0x19, 0xc4, 0x09, 0xb5, 0x10, 0x35, 0x68, 0xf2, 0x77, 0x61, 0x1d, 0x7e, 0xa8, 0x48, 0x94}},
451  {{0x56, 0xb1, 0xf5, 0x12, 0x65, 0xb9, 0x55, 0x98, 0x76, 0xd5, 0x8d, 0x24, 0x9d, 0x0c, 0x14, 0x6d, 0x69, 0xa1, 0x03, 0x63, 0x66, 0x99, 0x87, 0x4d, 0x3f, 0x90, 0x47, 0x35, 0x50, 0xfe, 0x3f, 0x2c}},
452  {{0x1d, 0x7a, 0x36, 0x57, 0x5e, 0x22, 0xf5, 0xd1, 0x39, 0xff, 0x9c, 0xc5, 0x10, 0xfa, 0x13, 0x85, 0x05, 0x57, 0x6b, 0x63, 0x81, 0x5a, 0x94, 0xe4, 0xb0, 0x12, 0xbf, 0xd4, 0x57, 0xca, 0xaa, 0xda}},
453  {{0xd0, 0xac, 0x50, 0x7a, 0x86, 0x4e, 0xcd, 0x05, 0x93, 0xfa, 0x67, 0xbe, 0x7d, 0x23, 0x13, 0x43, 0x92, 0xd0, 0x0e, 0x40, 0x07, 0xe2, 0x53, 0x48, 0x78, 0xd9, 0xb2, 0x42, 0xe1, 0x0d, 0x76, 0x20}},
454  {{0xf6, 0xc6, 0x84, 0x0b, 0x9c, 0xf1, 0x45, 0xbb, 0x2d, 0xcc, 0xf8, 0x6e, 0x94, 0x0b, 0xe0, 0xfc, 0x09, 0x8e, 0x32, 0xe3, 0x10, 0x99, 0xd5, 0x6f, 0x7f, 0xe0, 0x87, 0xbd, 0x5d, 0xeb, 0x50, 0x94}},
455  {{0x28, 0x83, 0x1a, 0x33, 0x40, 0x07, 0x0e, 0xb1, 0xdb, 0x87, 0xc1, 0x2e, 0x05, 0x98, 0x0d, 0x5f, 0x33, 0xe9, 0xef, 0x90, 0xf8, 0x3a, 0x48, 0x17, 0xc9, 0xf4, 0xa0, 0xa3, 0x32, 0x27, 0xe1, 0x97}},
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xcb, 0x6b, 0x50, 0x0b, 0x94, 0x41, 0x8c, 0x0b, 0x89, 0x25, 0xf9, 0x86, 0x55, 0x30, 0x30, 0x3a, 0xe4, 0xe4, 0xb2, 0x62, 0x59, 0x18, 0x65, 0x66, 0x6a, 0x45, 0x90}},
468  {{0xb3, 0xdb, 0x6b, 0xd3, 0x89, 0x7a, 0xfb, 0xd1, 0xdf, 0x3f, 0x96, 0x44, 0xab, 0x21, 0xc8, 0x05, 0x0e, 0x1f, 0x00, 0x38, 0xa5, 0x2f, 0x7c, 0xa9, 0x5a, 0xc0, 0xc3, 0xde, 0x75, 0x58, 0xcb, 0x7a}},
469  {{0x81, 0x19, 0xb3, 0xa0, 0x59, 0xff, 0x2c, 0xac, 0x48, 0x3e, 0x69, 0xbc, 0xd4, 0x1d, 0x6d, 0x27, 0x14, 0x94, 0x47, 0x91, 0x42, 0x88, 0xbb, 0xea, 0xee, 0x34, 0x13, 0xe6, 0xdc, 0xc6, 0xd1, 0xeb}},
470  {{0x10, 0xfc, 0x58, 0xf3, 0x5f, 0xc7, 0xfe, 0x7a, 0xe8, 0x75, 0x52, 0x4b, 0xb5, 0x85, 0x00, 0x03, 0x00, 0x5b, 0x7f, 0x97, 0x8c, 0x0c, 0x65, 0xe2, 0xa9, 0x65, 0x46, 0x4b, 0x6d, 0x00, 0x81, 0x9c}},
471  {{0x5a, 0xcd, 0x94, 0xeb, 0x3c, 0x57, 0x83, 0x79, 0xc1, 0xea, 0x58, 0xa3, 0x43, 0xec, 0x4f, 0xcf, 0xf9, 0x62, 0x77, 0x6f, 0xe3, 0x55, 0x21, 0xe4, 0x75, 0xa0, 0xe0, 0x6d, 0x88, 0x7b, 0x2d, 0xb9}},
472  {{0x33, 0xda, 0xf3, 0xa2, 0x14, 0xd6, 0xe0, 0xd4, 0x2d, 0x23, 0x00, 0xa7, 0xb4, 0x4b, 0x39, 0x29, 0x0d, 0xb8, 0x98, 0x9b, 0x42, 0x79, 0x74, 0xcd, 0x86, 0x5d,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, 0x1b, 0x41, 0x37, 0xca, 0x61, 0x7e, 0x21, 0x29, 0x7f, 0x2f, 0x0d, 0xed, 0x8e, 0x31, 0xb7, 0xd2, 0xea, 0xd8, 0x71, 0x46, 0x60}},
479  {{0x7b, 0x12, 0x45, 0x83, 0x09, 0x7f, 0x10, 0x29, 0xa0, 0xc7, 0x41, 0x91, 0xfe, 0x73, 0x78, 0xc9, 0x10, 0x5a, 0xcc, 0x70, 0x66, 0x95, 0xed, 0x14, 0x93, 0xbb, 0x76, 0x03, 0x42, 0x26, 0xa5, 0x7b}},
480  {{0xec, 0x40, 0x05, 0x7b, 0x99, 0x54, 0x76, 0x65, 0x0b, 0x3d, 0xb9, 0x8e, 0x9d, 0xb7, 0x57, 0x38, 0xa8, 0xcd, 0x2f, 0x94, 0xd8, 0x63, 0xb9, 0x06, 0x15, 0x0c, 0x56, 0xaa, 0xc1, 0x9c, 0xaa, 0x6b}},
481  {{0x01, 0xd9, 0xff, 0x72, 0x9e, 0xfd, 0x39, 0xd8, 0x37, 0x84, 0xc0, 0xfe, 0x59, 0xc4, 0xae, 0x81, 0xa6, 0x70, 0x34, 0xcb, 0x53, 0xc9, 0x43, 0xfb, 0x81, 0x8b, 0x9d, 0x8a, 0xe7, 0xfc, 0x33, 0xe5}},
482  {{0x00, 0xdf, 0xb3, 0xc6, 0x96, 0x32, 0x8c, 0x76, 0x42, 0x45, 0x19, 0xa7, 0xbe, 0xfe, 0x8e, 0x0f, 0x6c, 0x76, 0xf9, 0x47, 0xb5, 0x27, 0x67, 0x91, 0x6d, 0x24, 0x82, 0x3f, 0x73, 0x5b, 0xaf, 0x2e}},
483  {{0x46, 0x1b, 0x79, 0x9b, 0x4d, 0x9c, 0xee, 0xa8, 0xd5, 0x80, 0xdc, 0xb7, 0x6d, 0x11, 0x15, 0x0d, 0x53, 0x5e, 0x16, 0x39, 0xd1, 0x60, 0x03, 0xc3, 0xfb, 0x7e, 0x9d, 0x1f, 0xd1, 0x30, 0x83, 0xa8}},
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x6b, 0xb9, 0x7d, 0x22, 0xfe, 0xad, 0xbc, 0x6c, 0x0d, 0x89, 0x30, 0xc5, 0xf8, 0xfc, 0x50, 0x8b, 0x2f, 0xc5, 0xb3, 0x53, 0x28, 0xd2, 0x6b, 0x88, 0xdb, 0x19, 0xae}},
496  {{0x60, 0xb6, 0x26, 0xa0, 0x33, 0xb5, 0x5f, 0x27, 0xd7, 0x67, 0x6c, 0x40, 0x95, 0xea, 0xba, 0xbc, 0x7a, 0x2c, 0x7e, 0xde, 0x26, 0x24, 0xb4, 0x72, 0xe9, 0x7f, 0x64, 0xf9, 0x6b, 0x8c, 0xfc, 0x0e}},
497  {{0xe5, 0xb5, 0x2b, 0xc9, 0x27, 0x46, 0x8d, 0xf7, 0x18, 0x93, 0xeb, 0x81, 0x97, 0xef, 0x82, 0x0c, 0xf7, 0x6c, 0xb0, 0xaa, 0xf6, 0xe8, 0xe4, 0xfe, 0x93, 0xad, 0x62, 0xd8, 0x03, 0x98, 0x31, 0x04}},
498  {{0x05, 0x65, 0x41, 0xae, 0x5d, 0xa9, 0x96, 0x1b, 0xe2, 0xb0, 0xa5, 0xe8, 0x95, 0xe5, 0xc5, 0xba, 0x15, 0x3c, 0xbb, 0x62, 0xdd, 0x56, 0x1a, 0x42, 0x7b, 0xad, 0x0f, 0xfd, 0x41, 0x92, 0x31, 0x99}},
499  {{0xf8, 0xfe, 0xf0, 0x5a, 0x3f, 0xa5, 0xc9, 0xf3, 0xeb, 0xa4, 0x16, 0x38, 0xb2, 0x47, 0xb7, 0x11, 0xa9, 0x9f, 0x96, 0x0f, 0xe7, 0x3a, 0xa2, 0xf9, 0x01, 0x36, 0xae, 0xb2, 0x03, 0x29, 0xb8, 0x88}}};
500 
501  //Debug printing for the above types
502  //Actually use DP(value) and #define DBG
503  void dp(key a);
504  void dp(bool a);
505  void dp(const char * a, int l);
506  void dp(keyV a);
507  void dp(keyM a);
508  void dp(xmr_amount vali);
509  void dp(int vali);
510  void dp(bits amountb);
511  void dp(const char * st);
512 
513  //various conversions
514 
515  //uint long long to 32 byte key
516  void d2h(key & amounth, xmr_amount val);
517  key d2h(xmr_amount val);
518  //uint long long to int[64]
519  void d2b(bits amountb, xmr_amount val);
520  //32 byte key to uint long long
521  // if the key holds a value > 2^64
522  // then the value in the first 8 bytes is returned
523  xmr_amount h2d(const key &test);
524  //32 byte key to int[64]
525  void h2b(bits amountb2, const key & test);
526  //int[64] to 32 byte key
527  void b2h(key & amountdh, bits amountb2);
528  //int[64] to uint long long
529  xmr_amount b2d(bits amountb);
530 
531  bool is_rct_simple(int type);
532  bool is_rct_bulletproof(int type);
533  bool is_rct_borromean(int type);
534 
535  static inline const rct::key &pk2rct(const crypto::public_key &pk) { return (const rct::key&)pk; }
536  static inline const rct::key &sk2rct(const crypto::secret_key &sk) { return (const rct::key&)sk; }
537  static inline const rct::key &ki2rct(const crypto::key_image &ki) { return (const rct::key&)ki; }
538  static inline const rct::key &hash2rct(const crypto::hash &h) { return (const rct::key&)h; }
539  static inline const crypto::public_key &rct2pk(const rct::key &k) { return (const crypto::public_key&)k; }
540  static inline const crypto::secret_key &rct2sk(const rct::key &k) { return (const crypto::secret_key&)k; }
541  static inline const crypto::key_image &rct2ki(const rct::key &k) { return (const crypto::key_image&)k; }
542  static inline const crypto::hash &rct2hash(const rct::key &k) { return (const crypto::hash&)k; }
543  static inline bool operator==(const rct::key &k0, const crypto::public_key &k1) { return !crypto_verify_32(k0.bytes, (const unsigned char*)&k1); }
544  static inline bool operator!=(const rct::key &k0, const crypto::public_key &k1) { return crypto_verify_32(k0.bytes, (const unsigned char*)&k1); }
545 }
546 
547 
548 namespace cryptonote {
549  static inline bool operator==(const crypto::public_key &k0, const rct::key &k1) { return !crypto_verify_32((const unsigned char*)&k0, k1.bytes); }
550  static inline bool operator!=(const crypto::public_key &k0, const rct::key &k1) { return crypto_verify_32((const unsigned char*)&k0, k1.bytes); }
551  static inline bool operator==(const crypto::secret_key &k0, const rct::key &k1) { return !crypto_verify_32((const unsigned char*)&k0, k1.bytes); }
552  static inline bool operator!=(const crypto::secret_key &k0, const rct::key &k1) { return crypto_verify_32((const unsigned char*)&k0, k1.bytes); }
553 }
554 
555 namespace rct {
556 inline std::ostream &operator <<(std::ostream &o, const rct::key &v) {
557  epee::to_hex::formatted(o, epee::as_byte_span(v)); return o;
558 }
559 }
560 
561 
562 namespace std
563 {
564  template<> struct hash<rct::key> { std::size_t operator()(const rct::key &k) const { return reinterpret_cast<const std::size_t&>(k); } };
565 }
566 
572 
573 VARIANT_TAG(debug_archive, rct::key, "rct::key");
574 VARIANT_TAG(debug_archive, rct::key64, "rct::key64");
575 VARIANT_TAG(debug_archive, rct::keyV, "rct::keyV");
576 VARIANT_TAG(debug_archive, rct::keyM, "rct::keyM");
577 VARIANT_TAG(debug_archive, rct::ctkey, "rct::ctkey");
578 VARIANT_TAG(debug_archive, rct::ctkeyV, "rct::ctkeyV");
579 VARIANT_TAG(debug_archive, rct::ctkeyM, "rct::ctkeyM");
580 VARIANT_TAG(debug_archive, rct::ecdhTuple, "rct::ecdhTuple");
581 VARIANT_TAG(debug_archive, rct::mgSig, "rct::mgSig");
582 VARIANT_TAG(debug_archive, rct::rangeSig, "rct::rangeSig");
583 VARIANT_TAG(debug_archive, rct::boroSig, "rct::boroSig");
584 VARIANT_TAG(debug_archive, rct::rctSig, "rct::rctSig");
585 VARIANT_TAG(debug_archive, rct::Bulletproof, "rct::bulletproof");
586 VARIANT_TAG(debug_archive, rct::multisig_kLRki, "rct::multisig_kLRki");
587 VARIANT_TAG(debug_archive, rct::multisig_out, "rct::multisig_out");
588 
604 
605 VARIANT_TAG(json_archive, rct::key, "rct_key");
606 VARIANT_TAG(json_archive, rct::key64, "rct_key64");
607 VARIANT_TAG(json_archive, rct::keyV, "rct_keyV");
608 VARIANT_TAG(json_archive, rct::keyM, "rct_keyM");
609 VARIANT_TAG(json_archive, rct::ctkey, "rct_ctkey");
610 VARIANT_TAG(json_archive, rct::ctkeyV, "rct_ctkeyV");
611 VARIANT_TAG(json_archive, rct::ctkeyM, "rct_ctkeyM");
612 VARIANT_TAG(json_archive, rct::ecdhTuple, "rct_ecdhTuple");
613 VARIANT_TAG(json_archive, rct::mgSig, "rct_mgSig");
614 VARIANT_TAG(json_archive, rct::rangeSig, "rct_rangeSig");
615 VARIANT_TAG(json_archive, rct::boroSig, "rct_boroSig");
616 VARIANT_TAG(json_archive, rct::rctSig, "rct_rctSig");
617 VARIANT_TAG(json_archive, rct::Bulletproof, "rct_bulletproof");
618 VARIANT_TAG(json_archive, rct::multisig_kLRki, "rct_multisig_kLR");
619 VARIANT_TAG(json_archive, rct::multisig_out, "rct_multisig_out");
620 
621 #endif /* RCTTYPES_H */
key ee
Definition: rctTypes.h:145
static bool operator!=(const rct::key &k0, const crypto::public_key &k1)
Definition: rctTypes.h:544
size_t n_bulletproof_max_amounts(const Bulletproof &proof)
Definition: rctTypes.cpp:276
std::vector< rangeSig > rangeSigs
Definition: rctTypes.h:302
xmr_amount txnFee
Definition: rctTypes.h:243
key64 Ci
Definition: rctTypes.h:174
ctkeyM mixRing
Definition: rctTypes.h:238
int crypto_verify_32(const unsigned char *, const unsigned char *)
Definition: verify.c:3
static const key H
Definition: rctTypes.h:431
bool is_rct_borromean(int type)
Definition: rctTypes.cpp:237
Definition: rctTypes.h:111
Definition: rctTypes.h:301
static const rct::key & pk2rct(const crypto::public_key &pk)
Definition: rctTypes.h:535
key k
Definition: rctTypes.h:105
void dp(key a)
Definition: rctTypes.cpp:46
Definition: rctTypes.h:232
std::vector< ecdhTuple > ecdhInfo
Definition: rctTypes.h:241
std::vector< mgSig > MGs
Definition: rctTypes.h:304
key message
Definition: rctTypes.h:237
key ki
Definition: rctTypes.h:108
bool serialize_rctsig_prunable(Archive< W > &ar, uint8_t type, size_t inputs, size_t outputs, size_t mixin)
Definition: rctTypes.h:308
uint64_t xmr_amount
Definition: rctTypes.h:138
Definition: rctTypes.h:96
keyV const & get_pseudo_outs() const
Definition: rctTypes.h:424
key mask
Definition: rctTypes.h:126
key amount
Definition: rctTypes.h:127
Definition: test.py:1
bool operator==(const key &k) const
Definition: rctTypes.h:85
Definition: rctTypes.h:230
bool is_rct_simple(int type)
Definition: rctTypes.cpp:214
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition: crypto.h:69
Definition: blockchain_ancestry.cpp:70
Definition: bulletproofs.cc:56
static bool operator==(const rct::key &k0, const crypto::public_key &k1)
Definition: rctTypes.h:543
Definition: rctTypes.h:125
key dest
Definition: rctTypes.h:97
Definition: rctTypes.h:149
key64 s0
Definition: rctTypes.h:143
std::vector< Bulletproof > bulletproofs
Definition: rctTypes.h:303
Definition: rctTypes.h:104
BLOB_SERIALIZER(rct::key)
#define END_SERIALIZE()
self-explanatory
Definition: serialization.h:214
void d2h(key &amounth, const xmr_amount in)
Definition: rctTypes.cpp:119
std::vector< key > keyV
Definition: rctTypes.h:88
bool is_rct_bulletproof(int type)
Definition: rctTypes.cpp:226
Holds cryptonote related classes and helpers.
Definition: db_bdb.cpp:224
VARIANT_TAG(debug_archive, rct::key, "rct::key")
Bulletproof()
Definition: rctTypes.h:190
keyV & get_pseudo_outs()
Definition: rctTypes.h:419
rct::keyV R
Definition: rctTypes.h:187
static const crypto::secret_key & rct2sk(const rct::key &k)
Definition: rctTypes.h:540
unsigned char operator[](int i) const
Definition: rctTypes.h:82
key key64[64]
Definition: rctTypes.h:140
static const rct::key & hash2rct(const crypto::hash &h)
Definition: rctTypes.h:538
#define FIELDS(f)
does not add a tag to the serialized value
Definition: serialization.h:254
Definition: rctTypes.h:142
rctSigPrunable p
Definition: rctTypes.h:417
std::vector< ctkey > ctkeyV
Definition: rctTypes.h:100
key L
Definition: rctTypes.h:106
Definition: rctTypes.h:78
int b
Definition: base.py:1
#define BEGIN_SERIALIZE_OBJECT()
begins the environment of the DSL for described the serialization of an object
Definition: serialization.h:190
Definition: rctTypes.h:416
key R
Definition: rctTypes.h:107
static const key L
Definition: rctOps.h:64
static const rct::key & ki2rct(const crypto::key_image &ki)
Definition: rctTypes.h:537
Definition: rctTypes.h:234
#define false
Definition: stdbool.h:37
void d2b(bits amountb, xmr_amount val)
Definition: rctTypes.cpp:145
keyV pseudoOuts
Definition: rctTypes.h:305
int l
Definition: base.py:3
Definition: rctTypes.h:172
static const rct::key & sk2rct(const crypto::secret_key &sk)
Definition: rctTypes.h:536
POD_CLASS public_key
Definition: crypto.h:63
Definition: rctTypes.h:155
Definition: rctTypes.h:234
Bulletproof(const rct::key &V, const rct::key &A, const rct::key &S, const rct::key &T1, const rct::key &T2, const rct::key &taux, const rct::key &mu, const rct::keyV &L, const rct::keyV &R, const rct::key &a, const rct::key &b, const rct::key &t)
Definition: rctTypes.h:191
rct::key T2
Definition: rctTypes.h:185
Definition: rctTypes.h:182
std::vector< key > c
Definition: rctTypes.h:112
boroSig asig
Definition: rctTypes.h:173
xmr_amount b2d(bits amountb)
Definition: rctTypes.cpp:205
std::vector< keyV > keyM
Definition: rctTypes.h:89
Definition: rctTypes.h:231
std::ostream & operator<<(std::ostream &o, const rct::key &v)
Definition: rctTypes.h:556
ge_cached ge_dsmp[8]
Definition: crypto-ops.h:78
xmr_amount h2d(const key &test)
Definition: rctTypes.cpp:161
#define ATOMS
Definition: rctTypes.h:65
unsigned char bytes[32]
Definition: rctTypes.h:86
POD_CLASS key_image
Definition: crypto.h:89
#define VARINT_FIELD(f)
tags and serializes the varint f
Definition: serialization.h:263
uint8_t type
Definition: rctTypes.h:236
key cc
Definition: rctTypes.h:157
string a
Definition: MakeCryptoOps.py:15
key mask
Definition: rctTypes.h:98
ge_dsmp k
Definition: rctTypes.h:150
keyM ss
Definition: rctTypes.h:156
static const crypto::hash & rct2hash(const rct::key &k)
Definition: rctTypes.h:542
std::size_t operator()(const rct::key &k) const
Definition: rctTypes.h:564
static const crypto::public_key & rct2pk(const rct::key &k)
Definition: rctTypes.h:539
keyV II
Definition: rctTypes.h:158
Definition: rctTypes.h:234
void b2h(key &amountdh, const bits amountb2)
Definition: rctTypes.cpp:189
POD_CLASS hash
Definition: hash.h:49
Definition: rctTypes.h:229
JSON archive.
#define PREPARE_CUSTOM_VECTOR_SERIALIZATION(size, vec)
Definition: serialization.h:203
RangeProofType
Definition: rctTypes.h:234
std::vector< ctkeyV > ctkeyM
Definition: rctTypes.h:101
static const key64 H2
Definition: rctTypes.h:436
bool serialize_rctsig_base(Archive< W > &ar, size_t inputs, size_t outputs)
Definition: rctTypes.h:246
#define FIELD(f)
tags the field with the variable name and then serializes it
Definition: serialization.h:243
unsigned char & operator[](int i)
Definition: rctTypes.h:79
unsigned char * Bytes
Definition: rctTypes.h:72
rct::key taux
Definition: rctTypes.h:186
key senderPk
Definition: rctTypes.h:128
rct::keyV V
Definition: rctTypes.h:184
Definition: rctTypes.h:234
keyV pseudoOuts
Definition: rctTypes.h:240
Definition: binary_archive.h:94
Definition: debug_archive.h:37
Bulletproof(const rct::keyV &V, const rct::key &A, const rct::key &S, const rct::key &T1, const rct::key &T2, const rct::key &taux, const rct::key &mu, const rct::keyV &L, const rct::keyV &R, const rct::key &a, const rct::key &b, const rct::key &t)
Definition: rctTypes.h:193
void h2b(bits amountb2, const key &test)
Definition: rctTypes.cpp:171
unsigned int bits[ATOMS]
Definition: rctTypes.h:139
Definition: rctTypes.h:235
ctkeyV outPk
Definition: rctTypes.h:242
rct::key t
Definition: rctTypes.h:188
key64 s1
Definition: rctTypes.h:144
a archive using the JSON standard
Definition: json_archive.h:111
size_t n_bulletproof_amounts(const Bulletproof &proof)
Definition: rctTypes.cpp:249
static const crypto::key_image & rct2ki(const rct::key &k)
Definition: rctTypes.h:541