Zecale - Reconciling Privacy and Scalability on Smart-Contract Chains  0.5
Reference implementation of the Zecale protocol by Clearmatics
aggregator_circuit.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 __ZECALE_CORE_AGGREGATOR_CIRCUIT_HPP__
6 #define __ZECALE_CORE_AGGREGATOR_CIRCUIT_HPP__
7 
10 
11 #include <libzeth/core/extended_proof.hpp>
12 
13 using namespace libzeth;
14 
15 namespace libzecale
16 {
17 
32 template<typename wppT, typename wsnarkT, typename nverifierT, size_t NumProofs>
34 {
35 private:
36  using npp = libsnark::other_curve<wppT>;
37  using nsnark = typename nverifierT::snark;
38  using verification_key_variable_gadget =
39  typename nverifierT::verification_key_variable_gadget;
40  using proof_variable_gadget = typename nverifierT::proof_variable_gadget;
41 
42  const size_t _num_inputs_per_nested_proof;
43 
44  libsnark::protoboard<libff::Fr<wppT>> _pb;
45 
49  libsnark::pb_variable<libff::Fr<wppT>> _nested_vk_hash;
50 
54  libsnark::pb_variable<libff::Fr<wppT>> _nested_proof_results;
55 
59  std::array<libsnark::pb_variable_array<libff::Fr<wppT>>, NumProofs>
60  _nested_primary_inputs;
61 
63  std::array<libsnark::pb_variable<libff::Fr<wppT>>, NumProofs>
64  _nested_proof_results_unpacked;
65 
69  std::shared_ptr<verification_key_variable_gadget> _nested_vk;
70 
77  std::array<std::shared_ptr<proof_variable_gadget>, NumProofs>
78  _nested_proofs;
79 
81  std::shared_ptr<verification_key_hash_gadget<wppT, nverifierT>>
82  _nested_vk_hash_gadget;
83 
85  std::shared_ptr<aggregator_gadget<wppT, nverifierT, NumProofs>>
86  _aggregator_gadget;
87 
89  std::shared_ptr<libsnark::packing_gadget<libff::Fr<wppT>>>
90  _nested_proof_results_packer;
91 
92 public:
93  explicit aggregator_circuit(const size_t inputs_per_nested_proof);
94 
95  aggregator_circuit(const aggregator_circuit &other) = delete;
96  const aggregator_circuit &operator=(const aggregator_circuit &other) =
97  delete;
98 
99  typename wsnarkT::keypair generate_trusted_setup() const;
100 
101  // Number of primary inputs to the wrapping circuit
102  size_t num_primary_inputs() const;
103 
104  const libsnark::r1cs_constraint_system<libff::Fr<wppT>>
105  &get_constraint_system() const;
106 
108  extended_proof<wppT, wsnarkT> prove(
109  const typename nsnark::verification_key &nested_vk,
110  const std::array<
111  const libzeth::extended_proof<npp, nsnark> *,
112  NumProofs> &extended_proofs,
113  const typename wsnarkT::proving_key &aggregator_proving_key);
114 };
115 
116 } // namespace libzecale
117 
119 
120 #endif // __ZECALE_CORE_AGGREGATOR_CIRCUIT_HPP__
aggregator_gadget.hpp
libzecale::aggregator_circuit
Definition: aggregator_circuit.hpp:33
aggregator_circuit
libzecale::aggregator_circuit< wpp, wsnark, nverifier, batch_size > aggregator_circuit
Definition: aggregator_server.cpp:76
libzecale
Definition: aggregator_circuit.hpp:15
verification_key_hash_gadget.hpp
aggregator_circuit.tcc