Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
zethtool::commands::split_keypair_cmd Class Reference
Inheritance diagram for zethtool::commands::split_keypair_cmd:
Inheritance graph
[legend]
Collaboration diagram for zethtool::commands::split_keypair_cmd:
Collaboration graph
[legend]

Public Types

using base_class = generic_subcommand< split_keypair_cmd >
 

Public Member Functions

 split_keypair_cmd (const std::string &subcommand_name, const std::string &description)
 
template<typename ppT , typename snarkT >
int execute_generic (const global_options &)
 
- Public Member Functions inherited from zethtool::generic_subcommand< split_keypair_cmd >
 generic_subcommand (const std::string &subcommand_name, const std::string &description)
 
- Public Member Functions inherited from libtool::subcommand< GlobalOptionsT >
 subcommand (const std::string &subcommand_name, const std::string &description)
 
virtual ~subcommand ()
 
const std::string & description () const
 
int execute (const char *argv0, const std::vector< std::string > command_args, const GlobalOptionsT &global)
 Common code to parse options and invoke the virtual execute entrypoint. More...
 

Protected Member Functions

void initialize_suboptions (boost::program_options::options_description &options, boost::program_options::options_description &all_options, boost::program_options::positional_options_description &pos) override
 Instantiation can now set up the boost program_options structures. More...
 
void parse_suboptions (const boost::program_options::variables_map &vm) override
 
void subcommand_usage (const char *argv0) override
 Any command-specific output for usage. More...
 
- Protected Member Functions inherited from zethtool::generic_subcommand< split_keypair_cmd >
void initialize_suboptions (boost::program_options::options_description &options, boost::program_options::options_description &, boost::program_options::positional_options_description &) override
 Instantiation can now set up the boost program_options structures. More...
 
void parse_suboptions (const boost::program_options::variables_map &vm) override
 
int execute_subcommand (const global_options &options) override
 
- Protected Member Functions inherited from libtool::subcommand< GlobalOptionsT >
void usage (const char *argv0, const boost::program_options::options_description &options)
 
virtual int execute_subcommand (const GlobalOptionsT &global)=0
 Execute the command using global options defined by the caller. More...
 

Protected Attributes

std::string keypair_file
 
std::string vk_file
 
std::string pk_file
 
- Protected Attributes inherited from zethtool::generic_subcommand< split_keypair_cmd >
std::string curve
 
std::string snark
 
- Protected Attributes inherited from libtool::subcommand< GlobalOptionsT >
std::string subcommand_name
 
std::string subcommand_description
 

Detailed Description

Definition at line 15 of file split_keypair_cmd.cpp.

Member Typedef Documentation

◆ base_class

Definition at line 18 of file split_keypair_cmd.cpp.

Constructor & Destructor Documentation

◆ split_keypair_cmd()

zethtool::commands::split_keypair_cmd::split_keypair_cmd ( const std::string &  subcommand_name,
const std::string &  description 
)
inline

Definition at line 20 of file split_keypair_cmd.cpp.

23  {
24  }

Member Function Documentation

◆ execute_generic()

template<typename ppT , typename snarkT >
int zethtool::commands::split_keypair_cmd::execute_generic ( const global_options )
inline

Definition at line 27 of file split_keypair_cmd.cpp.

28  {
29  ppT::init_public_params();
30  libff::inhibit_profiling_info = true;
31  libff::inhibit_profiling_counters = true;
32 
33  typename snarkT::keypair keypair;
34  {
35  std::ifstream in_s = libtool::open_binary_input_file(keypair_file);
36  snarkT::keypair_read_bytes(keypair, in_s);
37  }
38 
39  if (!vk_file.empty()) {
40  std::ofstream out_s = libtool::open_binary_output_file(vk_file);
41  snarkT::verification_key_write_bytes(keypair.vk, out_s);
42  }
43 
44  if (!pk_file.empty()) {
45  std::ofstream out_s = libtool::open_binary_output_file(pk_file);
46  snarkT::proving_key_write_bytes(keypair.pk, out_s);
47  }
48 
49  return 0;
50  }
Here is the call graph for this function:

◆ initialize_suboptions()

void zethtool::commands::split_keypair_cmd::initialize_suboptions ( boost::program_options::options_description &  options,
boost::program_options::options_description &  all_options,
boost::program_options::positional_options_description &  pos 
)
inlineoverrideprotectedvirtual

Instantiation can now set up the boost program_options structures.

Implements libtool::subcommand< GlobalOptionsT >.

Definition at line 53 of file split_keypair_cmd.cpp.

57  {
58  base_class::initialize_suboptions(options, all_options, pos);
59 
60  options.add_options()(
61  "vk-file,v",
62  po::value<std::string>(),
63  "Verification key file (optional)")(
64  "pk-file,p",
65  po::value<std::string>(),
66  "Proving key file (optional)");
67 
68  all_options.add(options).add_options()(
69  "keypair-file,k", po::value<std::string>(), "Keypair file");
70  pos.add("keypair-file", 1);
71  }
Here is the call graph for this function:

◆ parse_suboptions()

void zethtool::commands::split_keypair_cmd::parse_suboptions ( const boost::program_options::variables_map &  vm)
inlineoverrideprotectedvirtual

Instantiation can record any command-specific information from the parsed variables_map.

Implements libtool::subcommand< GlobalOptionsT >.

Definition at line 73 of file split_keypair_cmd.cpp.

75  {
77 
78  if (vm.count("keypair-file") == 0) {
79  throw po::error("keypair file not specified");
80  }
81 
82  keypair_file = vm["keypair-file"].as<std::string>();
83  vk_file = vm.count("vk-file") ? vm["vk-file"].as<std::string>() : "";
84  pk_file = vm.count("pk-file") ? vm["pk-file"].as<std::string>() : "";
85 
86  if (vk_file.empty() && pk_file.empty()) {
87  throw po::error("no VK or PK file specified");
88  }
89  }
Here is the call graph for this function:

◆ subcommand_usage()

void zethtool::commands::split_keypair_cmd::subcommand_usage ( const char *  argv0)
inlineoverrideprotectedvirtual

Any command-specific output for usage.

Implements libtool::subcommand< GlobalOptionsT >.

Definition at line 91 of file split_keypair_cmd.cpp.

92  {
93  std::cout << "Usage:\n"
94  " "
95  << argv0 << " split-keypair <options> [keypair_file]\n";
96  }

Member Data Documentation

◆ keypair_file

std::string zethtool::commands::split_keypair_cmd::keypair_file
protected

Definition at line 98 of file split_keypair_cmd.cpp.

◆ pk_file

std::string zethtool::commands::split_keypair_cmd::pk_file
protected

Definition at line 100 of file split_keypair_cmd.cpp.

◆ vk_file

std::string zethtool::commands::split_keypair_cmd::vk_file
protected

Definition at line 99 of file split_keypair_cmd.cpp.


The documentation for this class was generated from the following file:
zethtool::generic_subcommand< split_keypair_cmd >::parse_suboptions
void parse_suboptions(const boost::program_options::variables_map &vm) override
Definition: tool_common.hpp:111
libtool::subcommand::description
const std::string & description() const
zethtool::generic_subcommand< split_keypair_cmd >::initialize_suboptions
void initialize_suboptions(boost::program_options::options_description &options, boost::program_options::options_description &, boost::program_options::positional_options_description &) override
Definition: tool_common.hpp:97
zethtool::commands::split_keypair_cmd::pk_file
std::string pk_file
Definition: split_keypair_cmd.cpp:100
libtool::open_binary_output_file
std::ofstream open_binary_output_file(const std::string &filename)
Utility function to open a binary file for writing, with appropriate flags.
Definition: tool_util.cpp:19
libtool::subcommand::subcommand_name
std::string subcommand_name
Definition: subcommand.hpp:54
zethtool::commands::split_keypair_cmd::base_class
generic_subcommand< split_keypair_cmd > base_class
Definition: split_keypair_cmd.cpp:18
libtool::open_binary_input_file
std::ifstream open_binary_input_file(const std::string &filename)
Definition: tool_util.cpp:10
zethtool::commands::split_keypair_cmd::vk_file
std::string vk_file
Definition: split_keypair_cmd.cpp:99
zethtool::commands::split_keypair_cmd::keypair_file
std::string keypair_file
Definition: split_keypair_cmd.cpp:98