SerialNumberSignatureOfKnowledge.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // ECOin - Copyright (c) - 2014/2022 - GPLv3 - epsylon@riseup.net (https://03c8.net)
  2. #ifndef SERIALNUMBERPROOF_H_
  3. #define SERIALNUMBERPROOF_H_
  4. #include <list>
  5. #include <vector>
  6. #include <bitset>
  7. #include "Params.h"
  8. #include "Coin.h"
  9. #include "Commitment.h"
  10. #include "../bignum.h"
  11. #include "../serialize.h"
  12. #include "Accumulator.h"
  13. #include "../util.h"
  14. using namespace std;
  15. namespace libzerocoin {
  16. /**A Signature of knowledge on the hash of metadata attesting that the signer knows the values
  17. * necessary to open a commitment which contains a coin(which it self is of course a commitment)
  18. * with a given serial number.
  19. */
  20. class SerialNumberSignatureOfKnowledge {
  21. public:
  22. SerialNumberSignatureOfKnowledge(const Params* p);
  23. /** Creates a Signature of knowledge object that a commitment to a coin contains a coin with serial number x
  24. *
  25. * @param p params
  26. * @param coin the coin we are going to prove the serial number of.
  27. * @param commitmentToCoin the commitment to the coin
  28. * @param msghash hash of meta data to create a signature of knowledge on.
  29. */
  30. SerialNumberSignatureOfKnowledge(const Params* p, const PrivateCoin& coin, const Commitment& commitmentToCoin, uint256 msghash);
  31. /** Verifies the Signature of knowledge.
  32. *
  33. * @param msghash hash of meta data to create a signature of knowledge on.
  34. * @return
  35. */
  36. bool Verify(const CBigNum& coinSerialNumber, const CBigNum& valueOfCommitmentToCoin,const uint256 msghash) const;
  37. IMPLEMENT_SERIALIZE
  38. (
  39. READWRITE(s_notprime);
  40. READWRITE(sprime);
  41. READWRITE(hash);
  42. )
  43. private:
  44. const Params* params;
  45. // challenge hash
  46. uint256 hash; //TODO For efficiency, should this be a bitset where Templates define params?
  47. // challenge response values
  48. // this is s_notprime instead of s
  49. // because the serialization macros
  50. // define something named s and it conflicts
  51. vector<CBigNum> s_notprime;
  52. vector<CBigNum> sprime;
  53. inline CBigNum challengeCalculation(const CBigNum& a_exp, const CBigNum& b_exp,
  54. const CBigNum& h_exp) const;
  55. };
  56. } /* namespace libzerocoin */
  57. #endif /* SERIALNUMBERPROOF_H_ */