Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
pghr13_snark.hpp
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 #ifndef __ZETH_SNARKS_PGHR13_PGHR13_SNARK_HPP__
6 #define __ZETH_SNARKS_PGHR13_PGHR13_SNARK_HPP__
7 
8 #include <boost/filesystem.hpp>
9 #include <libsnark/gadgetlib1/protoboard.hpp>
10 #include <libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.hpp>
11 
12 namespace libzeth
13 {
14 
15 template<typename ppT> class pghr13_snark
16 {
17 public:
18  using proving_key = libsnark::r1cs_ppzksnark_proving_key<ppT>;
19  using verification_key = libsnark::r1cs_ppzksnark_verification_key<ppT>;
20  using keypair = libsnark::r1cs_ppzksnark_keypair<ppT>;
21  using proof = libsnark::r1cs_ppzksnark_proof<ppT>;
22 
25  static const std::string name;
26 
28  static keypair generate_setup(
29  const libsnark::protoboard<libff::Fr<ppT>> &pb);
30 
32  static proof generate_proof(
33  const proving_key &proving_key,
34  const libsnark::protoboard<libff::Fr<ppT>> &pb);
35 
37  static proof generate_proof(
38  const proving_key &proving_key,
39  const libsnark::r1cs_primary_input<libff::Fr<ppT>> &primary_input,
40  const libsnark::r1cs_auxiliary_input<libff::Fr<ppT>> auxiliary_input);
41 
43  static bool verify(
44  const libsnark::r1cs_primary_input<libff::Fr<ppT>> &primary_inputs,
45  const proof &proof,
47 
49  static void verification_key_write_json(
50  const verification_key &, std::ostream &);
51 
53  static void verification_key_write_bytes(
54  const verification_key &, std::ostream &);
55 
57  static void verification_key_read_bytes(verification_key &, std::istream &);
58 
60  static void proving_key_write_bytes(const proving_key &, std::ostream &);
61 
63  static void proving_key_read_bytes(proving_key &, std::istream &);
64 
66  static void proof_write_json(const proof &, std::ostream &);
67 
69  static void proof_write_bytes(const proof &, std::ostream &);
70 
72  static void proof_read_bytes(proof &, std::istream &);
73 
75  static void keypair_write_bytes(const keypair &, std::ostream &);
76 
78  static void keypair_read_bytes(keypair &, std::istream &);
79 };
80 
81 } // namespace libzeth
82 
84 
85 #endif // __ZETH_SNARKS_PGHR13_PGHR13_SNARK_HPP__
libzeth::pghr13_snark::verification_key_write_json
static void verification_key_write_json(const verification_key &, std::ostream &)
Write verification as json.
pghr13_snark.tcc
libzeth::pghr13_snark::keypair
libsnark::r1cs_ppzksnark_keypair< ppT > keypair
Definition: pghr13_snark.hpp:20
libzeth::pghr13_snark::proof_read_bytes
static void proof_read_bytes(proof &, std::istream &)
Read proof as bytes.
libzeth::pghr13_snark::proving_key_read_bytes
static void proving_key_read_bytes(proving_key &, std::istream &)
Read proving key as bytes.
libzeth
Definition: binary_operation.hpp:15
libzeth::pghr13_snark::verify
static bool verify(const libsnark::r1cs_primary_input< libff::Fr< ppT >> &primary_inputs, const proof &proof, const verification_key &verification_key)
Verify proof.
libzeth::pghr13_snark::verification_key_write_bytes
static void verification_key_write_bytes(const verification_key &, std::ostream &)
Write verification key as bytes.
libzeth::pghr13_snark::proof
libsnark::r1cs_ppzksnark_proof< ppT > proof
Definition: pghr13_snark.hpp:21
libzeth::pghr13_snark::verification_key_read_bytes
static void verification_key_read_bytes(verification_key &, std::istream &)
Read a verification key as bytes.
libzeth::pghr13_snark
Definition: pghr13_snark.hpp:15
libzeth::pghr13_snark::keypair_write_bytes
static void keypair_write_bytes(const keypair &, std::ostream &)
Write a keypair as bytes.
libzeth::pghr13_snark::generate_setup
static keypair generate_setup(const libsnark::protoboard< libff::Fr< ppT >> &pb)
Run the trusted setup and return the keypair for the circuit.
libzeth::pghr13_snark::proving_key
libsnark::r1cs_ppzksnark_proving_key< ppT > proving_key
Definition: pghr13_snark.hpp:18
libzeth::pghr13_snark::proof_write_bytes
static void proof_write_bytes(const proof &, std::ostream &)
Write proof as bytes.
libzeth::pghr13_snark::name
static const std::string name
Definition: pghr13_snark.hpp:25
libzeth::pghr13_snark::generate_proof
static proof generate_proof(const proving_key &proving_key, const libsnark::protoboard< libff::Fr< ppT >> &pb)
Generate the proof (from the values set to the protoboard)
libzeth::pghr13_snark::proof_write_json
static void proof_write_json(const proof &, std::ostream &)
Write proof as json.
libzeth::pghr13_snark::keypair_read_bytes
static void keypair_read_bytes(keypair &, std::istream &)
Read a keypair from a stream.
libzeth::pghr13_snark::proving_key_write_bytes
static void proving_key_write_bytes(const proving_key &, std::ostream &)
Write proving key as bytes.
libzeth::pghr13_snark::verification_key
libsnark::r1cs_ppzksnark_verification_key< ppT > verification_key
Definition: pghr13_snark.hpp:19