15 namespace po = boost::program_options;
33 std::string powersoftau_file;
34 std::string lin_comb_file;
35 std::string phase2_challenge_file;
36 std::string keypair_out_file;
37 size_t powersoftau_degree;
42 "create-keypair",
"Create a full keypair from MPC output")
45 , phase2_challenge_file()
47 , powersoftau_degree(0)
52 void initialize_suboptions(
53 po::options_description &options,
54 po::options_description &all_options,
55 po::positional_options_description &pos)
override
57 options.add_options()(
60 "powersoftau degree (assumed to match linear comb)");
61 all_options.add(options).add_options()(
62 "powersoftau_file", po::value<std::string>(),
"powersoftau file")(
63 "linear_combination_file",
64 po::value<std::string>(),
65 "linear combination file")(
66 "phase2_challenge_file",
67 po::value<std::string>(),
68 "phase2 final challenge file")(
70 po::value<std::string>(),
71 "keypair output file");
72 pos.add(
"powersoftau_file", 1)
73 .add(
"linear_combination_file", 1)
74 .add(
"phase2_challenge_file", 1)
75 .add(
"keypair_out_file", 1);
78 void parse_suboptions(
const po::variables_map &vm)
override
80 if (0 == vm.count(
"powersoftau_file")) {
81 throw po::error(
"powersoftau_file not specified");
83 if (0 == vm.count(
"linear_combination_file")) {
84 throw po::error(
"linear_combination_file not specified");
86 if (0 == vm.count(
"phase2_challenge_file")) {
87 throw po::error(
"phase2_challenge_file not specified");
89 if (0 == vm.count(
"keypair_out_file")) {
90 throw po::error(
"keypair_out_file not specified");
93 powersoftau_file = vm[
"powersoftau_file"].as<std::string>();
94 lin_comb_file = vm[
"linear_combination_file"].as<std::string>();
95 phase2_challenge_file = vm[
"phase2_challenge_file"].as<std::string>();
96 keypair_out_file = vm[
"keypair_out_file"].as<std::string>();
98 vm.count(
"pot-degree") ? vm[
"pot-degree"].as<
size_t>() : 0;
101 void subcommand_usage(
const char *argv0)
override
103 std::cout <<
"Usage:\n"
104 <<
" " << argv0 <<
" " << subcommand_name
105 <<
" [<options>] \\\n"
106 <<
" <powersoftau_file> <linear_combination_file> \\\n"
107 <<
" <phase2_challenge_file> <keypair_out_file>\n\n";
113 std::cout <<
"powersoftau_file: " << powersoftau_file <<
"\n"
114 <<
"lin_comb_file: " << lin_comb_file <<
"\n"
115 <<
"phase2_challenge_file: " << phase2_challenge_file
117 <<
"powersoftau_degree: " << powersoftau_degree <<
"\n"
118 <<
"out_file: " << keypair_out_file << std::endl;
124 libff::enter_block(
"Load linear combination data");
125 libff::print_indent();
126 std::cout << lin_comb_file << std::endl;
128 read_from_file<srs_mpc_layer_L1<pp>>(lin_comb_file);
129 libff::leave_block(
"Load linear combination data");
131 libff::enter_block(
"Load powers of tau");
132 libff::print_indent();
133 std::cout << powersoftau_file << std::endl;
136 powersoftau_file, std::ios_base::binary | std::ios_base::in);
137 const size_t pot_degree =
138 powersoftau_degree ? powersoftau_degree : lin_comb.
degree();
139 return powersoftau_load<pp>(in, pot_degree);
141 libff::leave_block(
"Load powers of tau");
143 libff::enter_block(
"Load phase2 data");
144 libff::print_indent();
145 std::cout << phase2_challenge_file << std::endl;
147 read_from_file<srs_mpc_phase2_challenge<pp>>(phase2_challenge_file);
148 libff::leave_block(
"Load phase2 data");
151 libff::enter_block(
"Generate QAP");
152 libsnark::protoboard<Field> pb;
154 libsnark::r1cs_constraint_system<Field> cs = pb.get_constraint_system();
155 const libsnark::qap_instance<Field> qap =
156 libsnark::r1cs_to_qap_instance_map(cs,
true);
157 libff::leave_block(
"Generate QAP");
159 libsnark::r1cs_gg_ppzksnark_keypair<pp> keypair =
160 mpc_create_key_pair<pp>(
168 libff::enter_block(
"Writing keypair file");
169 if (!libff::inhibit_profiling_info) {
170 libff::print_indent();
171 std::cout << keypair_out_file << std::endl;
175 keypair_out_file, std::ios_base::binary | std::ios_base::out);
178 libff::leave_block(
"Writing keypair file");