Fix LLVM compilation issues
[novacoin.git] / src / zerocoin / SerialNumberSignatureOfKnowledge.h
1 /**
2 * @file       SerialNumberSignatureOfKnowledge.h
3 *
4 * @brief      SerialNumberSignatureOfKnowledge class for the Zerocoin library.
5 *
6 * @author     Ian Miers, Christina Garman and Matthew Green
7 * @date       June 2013
8 *
9 * @copyright  Copyright 2013 Ian Miers, Christina Garman and Matthew Green
10 * @license    This project is released under the MIT license.
11 **/
12
13 #ifndef SERIALNUMBERPROOF_H_
14 #define SERIALNUMBERPROOF_H_
15
16 #include <list>
17 #include <vector>
18 #include <bitset>
19 #include "Params.h"
20 #include "Coin.h"
21 #include "Commitment.h"
22 #include "../bignum.h"
23 #include "../serialize.h"
24 #include "Accumulator.h"
25 #include "../util.h"
26
27 using namespace std;
28 namespace libzerocoin {
29
30 /**A Signature of knowledge on the hash of metadata attesting that the signer knows the values
31  *  necessary to open a commitment which contains a coin(which it self is of course a commitment)
32  * with a given serial number.
33  */
34 class SerialNumberSignatureOfKnowledge {
35 public:
36         SerialNumberSignatureOfKnowledge(const Params* p);
37         /** Creates a Signature of knowledge object that a commitment to a coin contains a coin with serial number x
38          *
39          * @param p params
40          * @param coin the coin we are going to prove the serial number of.
41          * @param commitmentToCoin the commitment to the coin
42          * @param msghash hash of meta data to create a signature of knowledge on.
43          */
44         SerialNumberSignatureOfKnowledge(const Params* p, const PrivateCoin& coin, const Commitment& commitmentToCoin, uint256 msghash);
45
46         /** Verifies the Signature of knowledge.
47          *
48          * @param msghash hash of meta data to create a signature of knowledge on.
49          * @return
50          */
51         bool Verify(const Bignum& coinSerialNumber, const Bignum& valueOfCommitmentToCoin,const uint256 msghash) const;
52
53         IMPLEMENT_SERIALIZE
54         (
55             READWRITE(s_notprime);
56             READWRITE(sprime);
57             READWRITE(hash);
58         )
59 private:
60         const Params* params;
61         // challenge hash
62         uint256 hash; //TODO For efficiency, should this be a bitset where Templates define params?
63
64         // challenge response values
65         // this is s_notprime instead of s
66         // because the serialization macros
67         // define something named s and it conflicts
68         vector<Bignum> s_notprime;
69         vector<Bignum> sprime;
70         inline Bignum challengeCalculation(const Bignum& a_exp, const Bignum& b_exp,
71                                            const Bignum& h_exp) const;
72 };
73
74 } /* namespace libzerocoin */
75 #endif /* SERIALNUMBERPROOF_H_ */