|
@@ -10,11 +10,25 @@ using namespace std;
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
{
|
|
|
- // Should the Ptable be private or public (arg of "1" = public, "0" = private)
|
|
|
- bool Ptable_is_private = true;
|
|
|
-
|
|
|
- if (argc > 1 && atoi(argv[1]) > 0) {
|
|
|
- Ptable_is_private = false;
|
|
|
+ enum {
|
|
|
+ MODE_NONE,
|
|
|
+ MODE_PRIV,
|
|
|
+ MODE_PUB
|
|
|
+ } mode = MODE_NONE;
|
|
|
+
|
|
|
+ if (argc == 2) {
|
|
|
+ if (!strcmp(argv[1], "priv")) {
|
|
|
+ mode = MODE_PRIV;
|
|
|
+ } else if (!strcmp(argv[1], "pub")) {
|
|
|
+ mode = MODE_PUB;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (mode == MODE_NONE) {
|
|
|
+ cerr << "Usage: " << argv[0] << " mode" << endl << endl;
|
|
|
+ cerr << "Where mode is one of:" << endl;
|
|
|
+ cerr << " priv: use private Ptable" << endl;
|
|
|
+ cerr << " pub: use public Ptable" << endl;
|
|
|
+ exit(1);
|
|
|
}
|
|
|
|
|
|
// Initialize the curve parameters
|
|
@@ -49,14 +63,14 @@ int main(int argc, char **argv)
|
|
|
// This sets up the protoboard variables so that the first n of them
|
|
|
// represent the public input and the rest is private input
|
|
|
|
|
|
- if (Ptable_is_private) {
|
|
|
+ if (mode == MODE_PRIV) {
|
|
|
pb.set_input_sizes(4);
|
|
|
} else {
|
|
|
pb.set_input_sizes(4+2*numbits);
|
|
|
}
|
|
|
|
|
|
// Initialize the gadget
|
|
|
- ec_scalarmul_gadget<FieldT> sm(pb, outx, outy, s, Px, Py, Ptable, Ptable_is_private, true);
|
|
|
+ ec_scalarmul_gadget<FieldT> sm(pb, outx, outy, s, Px, Py, Ptable, mode == MODE_PRIV, true);
|
|
|
sm.generate_r1cs_constraints();
|
|
|
|
|
|
const r1cs_constraint_system<FieldT> constraint_system = pb.get_constraint_system();
|
|
@@ -88,13 +102,13 @@ int main(int argc, char **argv)
|
|
|
// cout << "Auxiliary (private) input: " << pb.auxiliary_input() << endl;
|
|
|
cout << "Verification status: " << verified << endl;
|
|
|
|
|
|
- ofstream pkfile("pk_varscalarmul");
|
|
|
+ ofstream pkfile(string("pk_varscalarmul_") + argv[1]);
|
|
|
pkfile << keypair.pk;
|
|
|
pkfile.close();
|
|
|
- ofstream vkfile("vk_varscalarmul");
|
|
|
+ ofstream vkfile(string("vk_varscalarmul_") + argv[1]);
|
|
|
vkfile << keypair.vk;
|
|
|
vkfile.close();
|
|
|
- ofstream pffile("proof_varscalarmul");
|
|
|
+ ofstream pffile(string("proof_varscalarmul_") + argv[1]);
|
|
|
pffile << proof;
|
|
|
pffile.close();
|
|
|
|