Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
mpc_common.cpp
Go to the documentation of this file.
1 // Copyright (c) 2015-2022 Clearmatics Technologies Ltd
2 //
3 // SPDX-License-Identifier: LGPL-3.0+
4 
5 #include "mpc_common.hpp"
6 
7 #include "libtool/run.hpp"
8 
9 #include <iostream>
10 
11 namespace
12 {
13 
16 class mpc_command : public libtool::command<global_options>
17 {
18 public:
20  boost::program_options::options_description &global,
21  boost::program_options::options_description &all_options) override
22  {
23  global.add_options()("verbose,v", "Verbose output");
24  all_options.add(global);
25  }
26 
28  global_options &out_options,
29  const boost::program_options::variables_map &vm) override
30  {
31  const bool verbose = (bool)vm.count("verbose");
32  if (!verbose) {
33  libff::inhibit_profiling_info = true;
34  libff::inhibit_profiling_counters = true;
35  }
36 
37  out_options.verbose = verbose;
38  }
39 };
40 
41 } // namespace
42 
44  const std::map<std::string, mpc_subcommand *> &subcommands,
45  const ProtoboardInitFn &pb_init,
46  int argc,
47  char **argv)
48 {
49  libzeth::defaults::pp::init_public_params();
50 
51  global_options options{pb_init, false};
52  mpc_command cmd;
53  return libtool::run_command(cmd, options, subcommands, argc, argv);
54 }
mpc_common.hpp
libtool::command::initialize_global_options
virtual void initialize_global_options(boost::program_options::options_description &global, boost::program_options::options_description &all_options)=0
Set up global options which are valid for all subcommands.
global_options::verbose
bool verbose
Definition: mpc_subcommand.hpp:19
global_options
Definition: mpc_subcommand.hpp:15
libtool::command::parse_global_options
virtual void parse_global_options(GlobalOptionsT &out_options, const boost::program_options::variables_map &vm)=0
Parse the variables map to update the GlobalOptionsT object.
libtool::command
Represents a top-level command, implementing parsing of global options.
Definition: command.hpp:14
run.hpp
mpc_main
int mpc_main(const std::map< std::string, mpc_subcommand * > &subcommands, const ProtoboardInitFn &pb_init, int argc, char **argv)
Main entry point into the mpc command for a given circuit.
Definition: mpc_common.cpp:43
libtool::run_command
int run_command(command< GlobalOptionsT > &command, GlobalOptionsT &options, const std::map< std::string, subcommand< GlobalOptionsT > * > &subcommands, int argc, char **argv)
ProtoboardInitFn
std::function< void(libsnark::protoboard< Field > &)> ProtoboardInitFn
Definition: mpc_subcommand.hpp:13