-
Notifications
You must be signed in to change notification settings - Fork 53
/
Params.h
216 lines (186 loc) · 5.42 KB
/
Params.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/**
* @file Params.h
*
* @brief Parameter classes for Zerocoin.
*
* @author Ian Miers, Christina Garman and Matthew Green
* @date June 2013
*
* @copyright Copyright 2013 Ian Miers, Christina Garman and Matthew Green
* @license This project is released under the MIT license.
**/
#ifndef PARAMS_H_
#define PARAMS_H_
namespace libzerocoin {
class IntegerGroupParams {
public:
/** @brief Integer group class, default constructor
*
* Allocates an empty (uninitialized) set of parameters.
**/
IntegerGroupParams();
/**
* Generates a random group element
* @return a random element in the group.
*/
Bignum randomElement() const;
bool initialized;
/**
* A generator for the group.
*/
Bignum g;
/**
* A second generator for the group.
* Note log_g(h) and log_h(g) must
* be unknown.
*/
Bignum h;
/**
* The modulus for the group.
*/
Bignum modulus;
/**
* The order of the group
*/
Bignum groupOrder;
IMPLEMENT_SERIALIZE
(
READWRITE(initialized);
READWRITE(g);
READWRITE(h);
READWRITE(modulus);
READWRITE(groupOrder);
)
};
class AccumulatorAndProofParams {
public:
/** @brief Construct a set of Zerocoin parameters from a modulus "N".
* @param N A trusted RSA modulus
* @param securityLevel A security level expressed in symmetric bits (default 80)
*
* Allocates and derives a set of Zerocoin parameters from
* a trustworthy RSA modulus "N". This routine calculates all
* of the remaining parameters (group descriptions etc.) from N
* using a verifiable, deterministic procedure.
*
* Note: this constructor makes the fundamental assumption that "N"
* encodes a valid RSA-style modulus of the form "e1 * e2" where
* "e1" and "e2" are safe primes. The factors "e1", "e2" MUST NOT
* be known to any party, or the security of Zerocoin is
* compromised. The integer "N" must be a MINIMUM of 1024
* in length. 3072 bits is strongly recommended.
**/
AccumulatorAndProofParams();
//AccumulatorAndProofParams(Bignum accumulatorModulus);
bool initialized;
/**
* Modulus used for the accumulator.
* Product of two safe primes who's factorization is unknown.
*/
Bignum accumulatorModulus;
/**
* The initial value for the accumulator
* A random Quadratic residue mod n thats not 1
*/
Bignum accumulatorBase;
/**
* Lower bound on the value for committed coin.
* Required by the accumulator proof.
*/
Bignum minCoinValue;
/**
* Upper bound on the value for a comitted coin.
* Required by the accumulator proof.
*/
Bignum maxCoinValue;
/**
* The second of two groups used to form a commitment to
* a coin (which it self is a commitment to a serial number).
* This one differs from serialNumberSokCommitment due to
* restrictions from Camenisch and Lysyanskaya's paper.
*/
IntegerGroupParams accumulatorPoKCommitmentGroup;
/**
* Hidden order quadratic residue group mod N.
* Used in the accumulator proof.
*/
IntegerGroupParams accumulatorQRNCommitmentGroup;
/**
* Security parameter.
* Bit length of the challenges used in the accumulator proof.
*/
uint32_t k_prime;
/**
* Security parameter.
* The statistical zero-knowledgeness of the accumulator proof.
*/
uint32_t k_dprime;
IMPLEMENT_SERIALIZE
(
READWRITE(initialized);
READWRITE(accumulatorModulus);
READWRITE(accumulatorBase);
READWRITE(accumulatorPoKCommitmentGroup);
READWRITE(accumulatorQRNCommitmentGroup);
READWRITE(minCoinValue);
READWRITE(maxCoinValue);
READWRITE(k_prime);
READWRITE(k_dprime);
)
};
class Params {
public:
/** @brief Construct a set of Zerocoin parameters from a modulus "N".
* @param N A trusted RSA modulus
* @param securityLevel A security level expressed in symmetric bits (default 80)
*
* Allocates and derives a set of Zerocoin parameters from
* a trustworthy RSA modulus "N". This routine calculates all
* of the remaining parameters (group descriptions etc.) from N
* using a verifiable, deterministic procedure.
*
* Note: this constructor makes the fundamental assumption that "N"
* encodes a valid RSA-style modulus of the form "e1 * e2" where
* "e1" and "e2" are safe primes. The factors "e1", "e2" MUST NOT
* be known to any party, or the security of Zerocoin is
* compromised. The integer "N" must be a MINIMUM of 1024
* in length. 3072 bits is strongly recommended.
**/
Params(Bignum accumulatorModulus,
uint32_t securityLevel = ZEROCOIN_DEFAULT_SECURITYLEVEL);
bool initialized;
AccumulatorAndProofParams accumulatorParams;
/**
* The Quadratic Residue group from which we form
* a coin as a commitment to a serial number.
*/
IntegerGroupParams coinCommitmentGroup;
/**
* One of two groups used to form a commitment to
* a coin (which it self is a commitment to a serial number).
* This is the one used in the serial number poof.
* It's order must be equal to the modulus of coinCommitmentGroup.
*/
IntegerGroupParams serialNumberSoKCommitmentGroup;
/**
* The number of iterations to use in the serial
* number proof.
*/
uint32_t zkp_iterations;
/**
* The amount of the hash function we use for
* proofs.
*/
uint32_t zkp_hash_len;
IMPLEMENT_SERIALIZE
(
READWRITE(initialized);
READWRITE(accumulatorParams);
READWRITE(coinCommitmentGroup);
READWRITE(serialNumberSoKCommitmentGroup);
READWRITE(zkp_iterations);
READWRITE(zkp_hash_len);
)
};
} /* namespace libzerocoin */
#endif /* PARAMS_H_ */