-
Notifications
You must be signed in to change notification settings - Fork 333
/
Copy pathcomposer.hpp.hbs
68 lines (51 loc) · 2.73 KB
/
composer.hpp.hbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// AUTOGENERATED FILE
#pragma once
#include "barretenberg/srs/global_crs.hpp"
#include "barretenberg/vm/{{snakeCase name}}/generated/circuit_builder.hpp"
#include "barretenberg/vm/{{snakeCase name}}/generated/prover.hpp"
#include "barretenberg/vm/{{snakeCase name}}/generated/verifier.hpp"
namespace bb {
class {{name}}Composer {
public:
using Flavor = {{name}}Flavor;
using CircuitConstructor = {{name}}CircuitBuilder;
using ProvingKey = Flavor::ProvingKey;
using VerificationKey = Flavor::VerificationKey;
using PCS = Flavor::PCS;
using CommitmentKey = Flavor::CommitmentKey;
using VerifierCommitmentKey = Flavor::VerifierCommitmentKey;
// TODO: which of these will we really need
static constexpr std::string_view NAME_STRING = "{{name}}";
static constexpr size_t NUM_RESERVED_GATES = 0;
static constexpr size_t NUM_WIRES = Flavor::NUM_WIRES;
std::shared_ptr<ProvingKey> proving_key;
std::shared_ptr<VerificationKey> verification_key;
// The crs_factory holds the path to the srs and exposes methods to extract the srs elements
std::shared_ptr<bb::srs::factories::CrsFactory<Flavor::Curve>> crs_factory_;
// The commitment key is passed to the prover but also used herein to compute the verfication key commitments
std::shared_ptr<CommitmentKey> commitment_key;
AggregationObjectPubInputIndices recursive_proof_public_input_indices;
bool contains_recursive_proof = false;
bool computed_witness = false;
{{name}}Composer() { crs_factory_ = bb::srs::get_bn254_crs_factory(); }
{{name}}Composer(std::shared_ptr<ProvingKey> p_key, std::shared_ptr<VerificationKey> v_key)
: proving_key(std::move(p_key))
, verification_key(std::move(v_key))
{}
{{name}}Composer({{name}}Composer&& other) noexcept = default;
{{name}}Composer({{name}}Composer const& other) noexcept = default;
{{name}}Composer& operator=({{name}}Composer&& other) noexcept = default;
{{name}}Composer& operator=({{name}}Composer const& other) noexcept = default;
~{{name}}Composer() = default;
std::shared_ptr<ProvingKey> compute_proving_key(CircuitConstructor& circuit_constructor);
std::shared_ptr<VerificationKey> compute_verification_key(CircuitConstructor& circuit_constructor);
void compute_witness(CircuitConstructor& circuit_constructor);
{{name}}Prover create_prover(CircuitConstructor& circuit_constructor);
{{name}}Verifier create_verifier(CircuitConstructor& circuit_constructor);
void add_table_column_selector_poly_to_proving_key(bb::polynomial& small, const std::string& tag);
void compute_commitment_key(size_t circuit_size)
{
proving_key->commitment_key = std::make_shared<CommitmentKey>(circuit_size);
};
};
} // namespace bb