barretenberg
Loading...
Searching...
No Matches
goblin_translator_composer.hpp
1#pragma once
2
3#include "barretenberg/flavor/goblin_translator.hpp"
4#include "barretenberg/proof_system/composer/composer_lib.hpp"
5#include "barretenberg/srs/factories/file_crs_factory.hpp"
6#include "barretenberg/srs/global_crs.hpp"
7#include "barretenberg/translator_vm/goblin_translator_prover.hpp"
8#include "barretenberg/translator_vm/goblin_translator_verifier.hpp"
9
10namespace proof_system::honk {
12 public:
14 using Curve = typename Flavor::Curve;
15 using CircuitBuilder = typename Flavor::CircuitBuilder;
16 using ProvingKey = typename Flavor::ProvingKey;
17 using VerificationKey = typename Flavor::VerificationKey;
18 using PCS = typename Flavor::PCS;
19 using CommitmentKey = typename Flavor::CommitmentKey;
20 using VerifierCommitmentKey = typename Flavor::VerifierCommitmentKey;
21 using Polynomial = typename Flavor::Polynomial;
23 static constexpr size_t MINI_CIRCUIT_SIZE = Flavor::MINI_CIRCUIT_SIZE;
24
25 static constexpr std::string_view NAME_STRING = "GoblinTranslator";
26 static constexpr size_t NUM_WIRES = CircuitBuilder::NUM_WIRES;
27 std::shared_ptr<ProvingKey> proving_key;
28 std::shared_ptr<VerificationKey> verification_key;
29
30 // The crs_factory holds the path to the srs and exposes methods to extract the srs elements
31 std::shared_ptr<barretenberg::srs::factories::CrsFactory<Curve>> crs_factory_;
32
33 // The commitment key is passed to the prover but also used herein to compute the verfication key commitments
34 std::shared_ptr<CommitmentKey> commitment_key;
35
36 bool computed_witness = false;
37 size_t total_num_gates = 0; // num_gates (already include zero row offset) (used to compute dyadic size)
38 size_t dyadic_circuit_size = 0; // final power-of-2 circuit size
39 size_t mini_circuit_dyadic_size = 0; // The size of the small circuit that contains non-range constraint relations
40
41 // We only need the standard crs factory. GoblinTranslator is not supposed to be used with Grumpkin
42 GoblinTranslatorComposer() { crs_factory_ = barretenberg::srs::get_crs_factory(); }
43
44 GoblinTranslatorComposer(std::shared_ptr<ProvingKey> p_key, std::shared_ptr<VerificationKey> v_key)
45 : proving_key(std::move(p_key))
46 , verification_key(std::move(v_key))
47 {}
48
49 std::shared_ptr<ProvingKey> compute_proving_key(const CircuitBuilder& circuit_builder);
50 std::shared_ptr<VerificationKey> compute_verification_key(const CircuitBuilder& circuit_builder);
51
52 void compute_circuit_size_parameters(CircuitBuilder& circuit_builder);
53
54 void compute_witness(CircuitBuilder& circuit_builder);
55
57 CircuitBuilder& circuit_builder,
58 const std::shared_ptr<Transcript>& transcript = std::make_shared<Transcript>());
60 const CircuitBuilder& circuit_builder,
61 const std::shared_ptr<Transcript>& transcript = std::make_shared<Transcript>());
62
63 std::shared_ptr<CommitmentKey> compute_commitment_key(size_t circuit_size)
64 {
65 if (commitment_key) {
66 return commitment_key;
67 }
68
69 commitment_key = std::make_shared<CommitmentKey>(circuit_size, crs_factory_);
70 return commitment_key;
71 };
72};
73} // namespace proof_system::honk
Definition: polynomial.hpp:12
Definition: bn254.hpp:10
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
Definition: goblin_translator_composer.hpp:11
void compute_circuit_size_parameters(CircuitBuilder &circuit_builder)
Helper method to compute quantities like total number of gates and dyadic circuit size.
Definition: goblin_translator_composer.cpp:34
GoblinTranslatorProver create_prover(CircuitBuilder &circuit_builder, const std::shared_ptr< Transcript > &transcript=std::make_shared< Transcript >())
Create a prover object (used to create the proof)
Definition: goblin_translator_composer.cpp:205
void compute_witness(CircuitBuilder &circuit_builder)
Compute witness polynomials.
Definition: goblin_translator_composer.cpp:93
std::shared_ptr< VerificationKey > compute_verification_key(const CircuitBuilder &circuit_builder)
Definition: goblin_translator_composer.cpp:292
GoblinTranslatorVerifier create_verifier(const CircuitBuilder &circuit_builder, const std::shared_ptr< Transcript > &transcript=std::make_shared< Transcript >())
Create verifier: compute verification key, initialize verifier with it and an initial manifest and in...
Definition: goblin_translator_composer.cpp:233
std::shared_ptr< ProvingKey > compute_proving_key(const CircuitBuilder &circuit_builder)
Move goblin translator specific inputs from circuit builder and compute all the constant polynomials ...
Definition: goblin_translator_composer.cpp:256
Definition: goblin_translator_prover.hpp:11
Definition: goblin_translator_verifier.hpp:7
The proving key is responsible for storing the polynomials used by the prover.
Definition: goblin_translator.hpp:902
Definition: goblin_translator.hpp:21
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
Defines particular circuit builder types expected to be used for circuit construction in stdlib and c...
Definition: claim.hpp:6