-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mpc: separate mpc executables for production and test scripts
- Loading branch information
Showing
11 changed files
with
162 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,19 @@ | ||
#include "mpc_common.hpp" | ||
#include "circuit-wrapper.hpp" | ||
#include "mpc_main.hpp" | ||
|
||
#include <boost/program_options.hpp> | ||
|
||
namespace po = boost::program_options; | ||
|
||
extern subcommand *mpc_linear_combination_cmd; | ||
extern subcommand *mpc_dummy_phase2_cmd; | ||
extern subcommand *mpc_create_keypair_cmd; | ||
|
||
int main(int argc, char **argv) | ||
void zeth_protoboard(libsnark::protoboard<FieldT> &pb) | ||
{ | ||
ppT::init_public_params(); | ||
po::options_description global(""); | ||
global.add_options()("help,h", "This help")("verbose,v", "Verbose output")( | ||
"simple-circuit", "Use simple circuit (for testing)"); | ||
|
||
po::options_description all(""); | ||
all.add(global).add_options()( | ||
"command", po::value<std::string>(), "Command to execute")( | ||
"subargs", | ||
po::value<std::vector<std::string>>(), | ||
"Arguments to command"); | ||
|
||
po::positional_options_description pos; | ||
pos.add("command", 1).add("subargs", -1); | ||
|
||
const std::map<std::string, subcommand *> commands{ | ||
{"linear-combination", mpc_linear_combination_cmd}, | ||
{"dummy-phase2", mpc_dummy_phase2_cmd}, | ||
{"create-keypair", mpc_create_keypair_cmd}, | ||
}; | ||
|
||
auto usage = [&argv, &global, &commands]() { | ||
std::cout << "Usage:\n" | ||
<< " " << argv[0] | ||
<< " [<options>] <command> <command-arguments> ...\n\n" | ||
<< global; | ||
|
||
std::cout << "\nCommands:\n"; | ||
for (const auto &cmd : commands) { | ||
std::cout << " " << cmd.first; | ||
} | ||
std::cout << std::endl; | ||
}; | ||
|
||
try { | ||
po::variables_map vm; | ||
po::parsed_options parsed = po::command_line_parser(argc, argv) | ||
.options(all) | ||
.positional(pos) | ||
.allow_unregistered() | ||
.run(); | ||
po::store(parsed, vm); | ||
|
||
if (vm.count("help")) { | ||
usage(); | ||
return 0; | ||
} | ||
|
||
const bool verbose = (bool)vm.count("verbose"); | ||
if (!verbose) { | ||
libff::inhibit_profiling_info = true; | ||
libff::inhibit_profiling_counters = true; | ||
} | ||
|
||
const bool simple_circuit = (bool)vm.count("simple-circuit"); | ||
|
||
if (0 == vm.count("command")) { | ||
std::cerr << "error: no command specified\n"; | ||
usage(); | ||
return 1; | ||
} | ||
|
||
const std::string command(vm["command"].as<std::string>()); | ||
std::vector<std::string> subargs = | ||
po::collect_unrecognized(parsed.options, po::include_positional); | ||
subargs[0] = std::string(argv[0]) + " " + subargs[0]; | ||
|
||
subcommand *sub = commands.find(command)->second; | ||
if (sub == nullptr) { | ||
throw po::error("invalid command"); | ||
} | ||
|
||
sub->set_global_options(verbose, simple_circuit); | ||
return sub->execute(subargs); | ||
} catch (po::error &error) { | ||
std::cerr << " ERROR: " << error.what() << std::endl; | ||
usage(); | ||
} | ||
|
||
return 1; | ||
using HashTreeT = MiMC_mp_gadget<FieldT>; | ||
using HashT = sha256_ethereum<FieldT>; | ||
|
||
joinsplit_gadget< | ||
FieldT, | ||
HashT, | ||
HashTreeT, | ||
ZETH_NUM_JS_INPUTS, | ||
ZETH_NUM_JS_OUTPUTS> | ||
js(pb); | ||
js.generate_r1cs_constraints(); | ||
} | ||
|
||
int main(int argc, char **argv) { mpc_main(argc, argv, zeth_protoboard); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#include "mpc_common.hpp" | ||
|
||
#include <boost/program_options.hpp> | ||
|
||
namespace po = boost::program_options; | ||
|
||
extern subcommand *mpc_linear_combination_cmd; | ||
extern subcommand *mpc_dummy_phase2_cmd; | ||
extern subcommand *mpc_create_keypair_cmd; | ||
|
||
int mpc_main(int argc, char **argv, ProtoboardInitFn pb_init) | ||
{ | ||
ppT::init_public_params(); | ||
po::options_description global(""); | ||
global.add_options()("help,h", "This help")("verbose,v", "Verbose output"); | ||
|
||
po::options_description all(""); | ||
all.add(global).add_options()( | ||
"command", po::value<std::string>(), "Command to execute")( | ||
"subargs", | ||
po::value<std::vector<std::string>>(), | ||
"Arguments to command"); | ||
|
||
po::positional_options_description pos; | ||
pos.add("command", 1).add("subargs", -1); | ||
|
||
const std::map<std::string, subcommand *> commands{ | ||
{"linear-combination", mpc_linear_combination_cmd}, | ||
{"dummy-phase2", mpc_dummy_phase2_cmd}, | ||
{"create-keypair", mpc_create_keypair_cmd}, | ||
}; | ||
|
||
auto usage = [&argv, &global, &commands]() { | ||
std::cout << "Usage:\n" | ||
<< " " << argv[0] | ||
<< " [<options>] <command> <command-arguments> ...\n\n" | ||
<< global; | ||
|
||
std::cout << "\nCommands:\n"; | ||
for (const auto &cmd : commands) { | ||
std::cout << " " << cmd.first; | ||
} | ||
std::cout << std::endl; | ||
}; | ||
|
||
try { | ||
po::variables_map vm; | ||
po::parsed_options parsed = po::command_line_parser(argc, argv) | ||
.options(all) | ||
.positional(pos) | ||
.allow_unregistered() | ||
.run(); | ||
po::store(parsed, vm); | ||
|
||
if (vm.count("help")) { | ||
usage(); | ||
return 0; | ||
} | ||
|
||
const bool verbose = (bool)vm.count("verbose"); | ||
if (!verbose) { | ||
libff::inhibit_profiling_info = true; | ||
libff::inhibit_profiling_counters = true; | ||
} | ||
|
||
if (0 == vm.count("command")) { | ||
std::cerr << "error: no command specified\n"; | ||
usage(); | ||
return 1; | ||
} | ||
|
||
const std::string command(vm["command"].as<std::string>()); | ||
std::vector<std::string> subargs = | ||
po::collect_unrecognized(parsed.options, po::include_positional); | ||
subargs[0] = std::string(argv[0]) + " " + subargs[0]; | ||
|
||
subcommand *sub = commands.find(command)->second; | ||
if (sub == nullptr) { | ||
throw po::error("invalid command"); | ||
} | ||
|
||
sub->set_global_options(verbose, pb_init); | ||
return sub->execute(subargs); | ||
} catch (po::error &error) { | ||
std::cerr << " ERROR: " << error.what() << std::endl; | ||
usage(); | ||
} | ||
|
||
return 1; | ||
} |
Oops, something went wrong.