22 #define DEFAULT_MODULUS_SIZE 3072
23 #define MIN_MODULUS_SIZE 1026
30 cout <<
"Zerocoin parameter generation utility" << endl;
31 cout <<
"-------------------------------------" << endl << endl;
32 cout <<
"This utility generates an l-bit modulus N as the product of" << endl;
33 cout <<
"two safe primes p, q. The values p and q are not stored." << endl;
34 cout <<
"Call this program with no arguments to see usage options." << endl;
36 cout <<
"SECURITY WARNING: ZEROCOIN PARAMETERS MUST BE GENERATED BY" << endl;
37 cout <<
"A TRUSTED PARTY WHO DOES NOT STORE THE FACTORS. WHILE WE MAKE" << endl;
38 cout <<
"A BEST EFFORT TO DESTROY THIS INFORMATION WE DO NOT TAKE" << endl;
39 cout <<
"SPECIAL PRECAUTIONS TO ENSURE THAT THEY ARE DESTROYED." << endl;
41 cout <<
"USE THIS UTILITY AT YOUR OWN RISK" << endl << endl;
47 printf(
" -b <numbits>\n");
48 printf(
" -o <output file>\n");
53 int main(
int argc,
char **argv)
55 static Bignum resultModulus(0);
59 bool writeToFile =
false;
61 while ((argc > 1) && (argv[1][0] ==
'-'))
66 numBits =
atoi(argv[2]);
72 outfileName = argv[2];
81 printf(
"Wrong Argument: %s\n", argv[1]);
91 cout <<
"Modulus is below minimum length (" <<
MIN_MODULUS_SIZE <<
") bits" << endl;
97 cout <<
"Modulus size set to " << numBits <<
" bits." << endl;
98 cout <<
"Generating parameters. This may take a few minutes..." << endl;
104 *p = Bignum::generatePrime(numBits / 2,
true);
105 *q = Bignum::generatePrime(numBits / 2,
true);
108 resultModulus = (*p) * (*q);
115 std::string resultHex = resultModulus.ToString(16);
117 cout << endl <<
"N = " << endl << resultHex << endl;
121 outfile.open (outfileName);
122 outfile << resultHex;
124 cout << endl <<
"Result has been written to file '" << outfileName <<
"'." << endl;
125 }
catch (std::runtime_error &e) {
126 cout <<
"Unable to write to file:" << e.what() << endl;
int main(int argc, char **argv)
Exceptions and constants for Zerocoin.
#define DEFAULT_MODULUS_SIZE
int atoi(const std::string &str)