barretenberg
Loading...
Searching...
No Matches
ultra_composer.hpp
1#pragma once
3#include "barretenberg/proof_system/composer/composer_lib.hpp"
4#include "barretenberg/protogalaxy/protogalaxy_prover.hpp"
5#include "barretenberg/protogalaxy/protogalaxy_verifier.hpp"
6#include "barretenberg/srs/global_crs.hpp"
7#include "barretenberg/sumcheck/instance/prover_instance.hpp"
8#include "barretenberg/ultra_honk/merge_prover.hpp"
9#include "barretenberg/ultra_honk/merge_verifier.hpp"
10#include "barretenberg/ultra_honk/ultra_prover.hpp"
11#include "barretenberg/ultra_honk/ultra_verifier.hpp"
12
13namespace proof_system::honk {
14template <UltraFlavor Flavor> class UltraComposer_ {
15 public:
16 using CircuitBuilder = typename Flavor::CircuitBuilder;
17 using ProvingKey = typename Flavor::ProvingKey;
18 using VerificationKey = typename Flavor::VerificationKey;
19 using PCS = typename Flavor::PCS;
20 using CommitmentKey = typename Flavor::CommitmentKey;
21 using VerifierCommitmentKey = typename Flavor::VerifierCommitmentKey;
24 using FF = typename Flavor::FF;
25 using Transcript = typename Flavor::Transcript;
27
28 static constexpr size_t NUM_FOLDING = 2;
31
32 // offset due to placing zero wires at the start of execution trace
33 static constexpr size_t num_zero_rows = Flavor::has_zero_row ? 1 : 0;
34 static constexpr std::string_view NAME_STRING = "UltraHonk";
35 static constexpr size_t NUM_WIRES = CircuitBuilder::NUM_WIRES;
36
37 // The crs_factory holds the path to the srs and exposes methods to extract the srs elements
38 std::shared_ptr<CRSFactory> crs_factory_;
39 // The commitment key is passed to the prover but also used herein to compute the verfication key commitments
40 std::shared_ptr<CommitmentKey> commitment_key;
41
42 UltraComposer_() { crs_factory_ = barretenberg::srs::get_crs_factory(); }
43
44 explicit UltraComposer_(std::shared_ptr<CRSFactory> crs_factory)
45 : crs_factory_(std::move(crs_factory))
46 {}
47
48 UltraComposer_(UltraComposer_&& other) noexcept = default;
49 UltraComposer_(UltraComposer_ const& other) noexcept = default;
50 UltraComposer_& operator=(UltraComposer_&& other) noexcept = default;
51 UltraComposer_& operator=(UltraComposer_ const& other) noexcept = default;
52 ~UltraComposer_() = default;
53
54 std::shared_ptr<CommitmentKey> compute_commitment_key(size_t circuit_size)
55 {
56 commitment_key = std::make_shared<CommitmentKey>(circuit_size + 1);
57 return commitment_key;
58 };
59
60 std::shared_ptr<Instance> create_instance(CircuitBuilder& circuit);
61
62 UltraProver_<Flavor> create_prover(const std::shared_ptr<Instance>&,
63 const std::shared_ptr<Transcript>& transcript = std::make_shared<Transcript>());
64
65 UltraVerifier_<Flavor> create_verifier(
66 const std::shared_ptr<Instance>&,
67 const std::shared_ptr<Transcript>& transcript = std::make_shared<Transcript>());
68
69 UltraVerifier_<Flavor> create_verifier(CircuitBuilder& circuit);
70
71 UltraVerifier_<Flavor> create_ultra_with_keccak_verifier(CircuitBuilder& circuit);
72
82 const std::shared_ptr<ECCOpQueue>& op_queue,
83 const std::shared_ptr<Transcript>& transcript = std::make_shared<Transcript>())
84 {
85 // Store the previous aggregate op queue size and update the current one
86 op_queue->set_size_data();
87 // Merge requires a commitment key with size equal to that of the current op queue transcript T_i since the
88 // shift of the current contribution t_i will be of degree equal to deg(T_i)
89 auto commitment_key = compute_commitment_key(op_queue->get_current_size());
90 return MergeProver_<Flavor>(commitment_key, op_queue, transcript);
91 }
92
99
100 ProtoGalaxyProver_<ProverInstances> create_folding_prover(const std::vector<std::shared_ptr<Instance>>& instances,
101 const std::shared_ptr<CommitmentKey>& commitment_key)
102 {
103 ProtoGalaxyProver_<ProverInstances> output_state(instances, commitment_key);
104
105 return output_state;
106 };
107 ProtoGalaxyVerifier_<VerifierInstances> create_folding_verifier()
108 {
109
110 auto insts = VerifierInstances();
111 ProtoGalaxyVerifier_<VerifierInstances> output_state(insts);
112
113 return output_state;
114 };
115
121 void compute_verification_key(const std::shared_ptr<Instance>&);
122};
123
124extern template class UltraComposer_<honk::flavor::Ultra>;
125extern template class UltraComposer_<honk::flavor::GoblinUltra>;
126// TODO(#532): this pattern is weird; is this not instantiating the templates?
127using UltraComposer = UltraComposer_<honk::flavor::Ultra>;
128using GoblinUltraComposer = UltraComposer_<honk::flavor::GoblinUltra>;
129} // namespace proof_system::honk
Definition: crs_factory.hpp:72
GoblinTranslatorCircuitBuilder creates a circuit that evaluates the correctness of the evaluation of ...
Definition: goblin_translator_circuit_builder.hpp:76
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
Definition: transcript.hpp:62
Prover class for the Goblin ECC op queue transcript merge protocol.
Definition: merge_prover.hpp:17
Verifier class for the Goblin ECC op queue transcript merge protocol.
Definition: merge_verifier.hpp:18
Definition: protogalaxy_prover.hpp:15
An Instance is normally constructed from a finalized circuit and it's role is to compute all the poly...
Definition: prover_instance.hpp:20
Definition: ultra_composer.hpp:14
void compute_verification_key(const std::shared_ptr< Instance > &)
Compute the verification key of an Instance, produced from a finalised circuit.
Definition: ultra_composer.cpp:15
MergeVerifier_< Flavor > create_merge_verifier()
Create Verifier for Goblin ECC op queue merge protocol.
Definition: ultra_composer.hpp:98
MergeProver_< Flavor > create_merge_prover(const std::shared_ptr< ECCOpQueue > &op_queue, const std::shared_ptr< Transcript > &transcript=std::make_shared< Transcript >())
Create Prover for Goblin ECC op queue merge protocol.
Definition: ultra_composer.hpp:81
Definition: ultra_prover.hpp:13
Definition: ultra_verifier.hpp:9
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: verification_key.hpp:25
Definition: kzg.hpp:14
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
Definition: instances.hpp:7
Definition: instances.hpp:89