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::verify_cmd Class Reference
Inheritance diagram for zethtool::commands::verify_cmd:
Inheritance graph
[legend]
Collaboration diagram for zethtool::commands::verify_cmd:
Collaboration graph
[legend]

Public Types

using base_class = generic_subcommand< verify_cmd >
 

Public Member Functions

 verify_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< verify_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< verify_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 vk_file
 
std::string proof_file
 
std::string primary_input_file
 
- Protected Attributes inherited from zethtool::generic_subcommand< verify_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 16 of file verify_cmd.cpp.

Member Typedef Documentation

◆ base_class

Definition at line 19 of file verify_cmd.cpp.

Constructor & Destructor Documentation

◆ verify_cmd()

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

Definition at line 21 of file verify_cmd.cpp.

24  {
25  }

Member Function Documentation

◆ execute_generic()

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

Definition at line 28 of file verify_cmd.cpp.

29  {
30  ppT::init_public_params();
31  libff::inhibit_profiling_info = true;
32  libff::inhibit_profiling_counters = true;
33 
34  typename snarkT::verification_key verification_key;
35  {
36  std::ifstream in_s = libtool::open_binary_input_file(vk_file);
37  snarkT::verification_key_read_bytes(verification_key, in_s);
38  }
39 
40  libsnark::r1cs_primary_input<libff::Fr<ppT>> primary_input;
41  {
42  std::ifstream in_s =
45  }
46 
47  typename snarkT::proof proof;
48  {
49  std::ifstream in_s = libtool::open_binary_input_file(proof_file);
50  snarkT::proof_read_bytes(proof, in_s);
51  }
52 
53  if (!snarkT::verify(primary_input, proof, verification_key)) {
54  std::cout << "verification failed.\n";
55  return 1;
56  }
57 
58  return 0;
59  }
Here is the call graph for this function:

◆ initialize_suboptions()

void zethtool::commands::verify_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 62 of file verify_cmd.cpp.

66  {
67  base_class::initialize_suboptions(options, all_options, pos);
68 
69  all_options.add(options).add_options()(
70  "vk_file", po::value<std::string>(), "Verification key file");
71  all_options.add_options()(
72  "primary_input_file",
73  po::value<std::string>(),
74  "Primary input file");
75  all_options.add_options()(
76  "proof_file", po::value<std::string>(), "Proof file");
77 
78  pos.add("vk_file", 1);
79  pos.add("primary_input_file", 1);
80  pos.add("proof_file", 1);
81  }
Here is the call graph for this function:

◆ parse_suboptions()

void zethtool::commands::verify_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 83 of file verify_cmd.cpp.

85  {
87 
88  if (vm.count("vk_file") == 0) {
89  throw po::error("vk_file not specified");
90  }
91  if (vm.count("primary_input_file") == 0) {
92  throw po::error("primary_input_file not specified");
93  }
94  if (vm.count("proof_file") == 0) {
95  throw po::error("proof_file not specified");
96  }
97 
98  vk_file = vm["vk_file"].as<std::string>();
99  proof_file = vm["proof_file"].as<std::string>();
100  primary_input_file = vm["primary_input_file"].as<std::string>();
101  }
Here is the call graph for this function:

◆ subcommand_usage()

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

Any command-specific output for usage.

Implements libtool::subcommand< GlobalOptionsT >.

Definition at line 103 of file verify_cmd.cpp.

104  {
105  std::cout << "Usage:\n"
106  " "
107  << argv0
108  << " verify [vk_file] [primary_input_file] [proof_file]\n";
109  }

Member Data Documentation

◆ primary_input_file

std::string zethtool::commands::verify_cmd::primary_input_file
protected

Definition at line 113 of file verify_cmd.cpp.

◆ proof_file

std::string zethtool::commands::verify_cmd::proof_file
protected

Definition at line 112 of file verify_cmd.cpp.

◆ vk_file

std::string zethtool::commands::verify_cmd::vk_file
protected

Definition at line 111 of file verify_cmd.cpp.


The documentation for this class was generated from the following file:
zethtool::generic_subcommand< verify_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< verify_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::verify_cmd::base_class
generic_subcommand< verify_cmd > base_class
Definition: verify_cmd.cpp:19
zeth.core.signing.verify
bool verify(SigningVerificationKey vk, bytes m, int sigma)
Definition: signing.py:145
libtool::subcommand::subcommand_name
std::string subcommand_name
Definition: subcommand.hpp:54
zethtool::commands::verify_cmd::vk_file
std::string vk_file
Definition: verify_cmd.cpp:111
zethtool::commands::verify_cmd::primary_input_file
std::string primary_input_file
Definition: verify_cmd.cpp:113
libtool::open_binary_input_file
std::ifstream open_binary_input_file(const std::string &filename)
Definition: tool_util.cpp:10
zethtool::commands::verify_cmd::proof_file
std::string proof_file
Definition: verify_cmd.cpp:112
libzeth::r1cs_variable_assignment_read_bytes
void r1cs_variable_assignment_read_bytes(libsnark::r1cs_variable_assignment< FieldT > &assignment, std::istream &in_s)