barretenberg
Loading...
Searching...
No Matches
prover_instance.hpp
1#pragma once
3#include "barretenberg/flavor/goblin_ultra.hpp"
4#include "barretenberg/flavor/ultra.hpp"
5#include "barretenberg/proof_system/composer/composer_lib.hpp"
6#include "barretenberg/relations/relation_parameters.hpp"
7#include "barretenberg/srs/factories/file_crs_factory.hpp"
8
9namespace proof_system::honk {
18// TODO(https://github.com/AztecProtocol/barretenberg/issues/725): create an Instances class that manages several
19// Instance and passes them to ProtoGalaxy prover and verifier so that Instance objects don't need to mantain an index
20template <class Flavor> class ProverInstance_ {
21 using Circuit = typename Flavor::CircuitBuilder;
22 using ProvingKey = typename Flavor::ProvingKey;
23 using VerificationKey = typename Flavor::VerificationKey;
24 using CommitmentKey = typename Flavor::CommitmentKey;
25 using FF = typename Flavor::FF;
26 using FoldingParameters = typename Flavor::FoldingParameters;
27 using ProverPolynomials = typename Flavor::ProverPolynomials;
28 using Polynomial = typename Flavor::Polynomial;
29 using WitnessCommitments = typename Flavor::WitnessCommitments;
30 using CommitmentLabels = typename Flavor::CommitmentLabels;
31
32 public:
33 std::shared_ptr<ProvingKey> proving_key;
34 std::shared_ptr<VerificationKey> verification_key;
35
36 ProverPolynomials prover_polynomials;
37 WitnessCommitments witness_commitments;
38 CommitmentLabels commitment_labels;
39
40 std::array<Polynomial, 4> sorted_polynomials;
41
42 // The number of public inputs has to be the same for all instances because they are
43 // folded element by element.
44 std::vector<FF> public_inputs;
45 // offset due to placing zero wires at the start of execution trace
46 // non-zero for Instances constructed from circuits, this concept doesn't exist for accumulated
47 // instances
48 size_t pub_inputs_offset = 0;
49 FF alpha;
50 proof_system::RelationParameters<FF> relation_parameters;
51 std::vector<uint32_t> recursive_proof_public_input_indices;
52 // non-empty for the accumulated instances
53 FoldingParameters folding_parameters;
54 bool is_accumulator = false;
55 size_t instance_size;
56 size_t log_instance_size;
57
58 ProverInstance_(Circuit& circuit)
59 {
60 compute_circuit_size_parameters(circuit);
61 compute_proving_key(circuit);
62 compute_witness(circuit);
63 }
64
65 ProverInstance_() = default;
66 ~ProverInstance_() = default;
67
68 void initialize_prover_polynomials();
69
70 void compute_sorted_accumulator_polynomials(FF);
71
73
76
77 void compute_grand_product_polynomials(FF, FF);
78
79 private:
80 static constexpr size_t num_zero_rows = Flavor::has_zero_row ? 1 : 0;
81 static constexpr size_t NUM_WIRES = Circuit::NUM_WIRES;
82 bool contains_recursive_proof = false;
83 bool computed_witness = false;
84 size_t total_num_gates = 0; // num_gates + num_pub_inputs + tables + zero_row_offset (used to compute dyadic size)
85 size_t dyadic_circuit_size = 0; // final power-of-2 circuit size
86 size_t lookups_size = 0; // total number of lookup gates
87 size_t tables_size = 0; // total number of table entries
88 size_t num_public_inputs = 0;
89 size_t num_ecc_op_gates = 0;
90
91 std::shared_ptr<ProvingKey> compute_proving_key(Circuit&);
92
93 void compute_circuit_size_parameters(Circuit&);
94
95 void compute_witness(Circuit&);
96
97 void construct_ecc_op_wire_polynomials(auto&);
98
99 void construct_databus_polynomials(Circuit&)
100 requires IsGoblinFlavor<Flavor>;
101
102 void add_table_column_selector_poly_to_proving_key(barretenberg::polynomial& small, const std::string& tag);
103
104 void add_plookup_memory_records_to_wire_4(FF);
105};
106
107extern template class ProverInstance_<honk::flavor::Ultra>;
109
110} // namespace proof_system::honk
Definition: polynomial.hpp:12
GoblinTranslatorCircuitBuilder creates a circuit that evaluates the correctness of the evaluation of ...
Definition: goblin_translator_circuit_builder.hpp:76
An Instance is normally constructed from a finalized circuit and it's role is to compute all the poly...
Definition: prover_instance.hpp:20
void compute_logderivative_inverse(FF, FF)
Compute the inverse polynomial used in the log derivative lookup argument.
Definition: prover_instance.cpp:402
void compute_sorted_list_accumulator(FF)
Construct sorted list accumulator polynomial 's'.
Definition: prover_instance.cpp:336
A container for commitment labels.
Definition: goblin_translator.hpp:1022
A container for the prover polynomials handles.
Definition: goblin_translator.hpp:955
The proving key is responsible for storing the polynomials used by the prover.
Definition: goblin_translator.hpp:902
VerificationKey_< PrecomputedEntities< Commitment > > VerificationKey
The verification key is responsible for storing the the commitments to the precomputed (non-witnessk)...
Definition: goblin_translator.hpp:941
CommitmentKey object over a pairing group 𝔾₁.
Definition: commitment_key.hpp:35
Definition: flavor.hpp:295
Base class templates for structures that contain data parameterized by the fundamental polynomials of...
Defines particular circuit builder types expected to be used for circuit construction in stdlib and c...
Definition: claim.hpp:6
Container for parameters used by the grand product (permutation, lookup) Honk relations.
Definition: relation_parameters.hpp:12