Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
goblin.cpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: Planned, auditors: [], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#include "goblin.hpp"
8
20#include <utility>
21
22namespace bb {
23
24Goblin::Goblin(CommitmentKey<curve::BN254> bn254_commitment_key, const std::shared_ptr<Transcript>& transcript)
25 : commitment_key(std::move(bn254_commitment_key))
26 , transcript(transcript)
27{}
28
29void Goblin::prove_merge(const std::shared_ptr<Transcript>& transcript, const MergeSettings merge_settings)
30{
31 BB_BENCH_NAME("Goblin::prove_merge");
32 MergeProver merge_prover{ op_queue, merge_settings, commitment_key, transcript };
33 merge_verification_queue.push_back(merge_prover.construct_proof());
34}
35
37{
38 BB_BENCH_NAME("Goblin::prove_eccvm");
39 ECCVMBuilder eccvm_builder(op_queue);
40 ECCVMProver eccvm_prover(eccvm_builder, transcript);
41 auto [eccvm_proof, opening_claim] = eccvm_prover.construct_proof();
42 goblin_proof.eccvm_proof = std::move(eccvm_proof);
43
44 // Compute IPA proof for the opening claim
45 auto ipa_transcript = std::make_shared<NativeTranscript>();
46 IPA_PCS::compute_opening_proof(eccvm_prover.key->commitment_key, opening_claim, ipa_transcript);
47 goblin_proof.ipa_proof = ipa_transcript->export_proof();
48
51}
52
54{
55 BB_BENCH_NAME("Goblin::prove_translator");
57 auto translator_key = std::make_shared<TranslatorProvingKey>(translator_builder, commitment_key);
58 TranslatorProver translator_prover(translator_key, transcript);
59 goblin_proof.translator_proof = translator_prover.construct_proof();
60}
61
63{
64 BB_BENCH_NAME("Goblin::prove");
65
66 prove_merge(transcript, merge_settings); // Use shared transcript for merge proving
67 info("Goblin: num ultra ops = ", op_queue->get_ultra_ops_count());
68
70 1U,
71 "Goblin::prove: merge_verification_queue should contain only a single proof at this stage.");
73
74 vinfo("prove eccvm...");
76 vinfo("finished eccvm proving.");
77 vinfo("prove translator...");
79 vinfo("finished translator proving.");
80 return goblin_proof;
81}
82
93 const RecursiveMergeCommitments& merge_commitments,
95 const MergeSettings merge_settings)
96{
98 const MergeProof& merge_proof = merge_verification_queue.front();
99 const stdlib::Proof<MegaBuilder> stdlib_merge_proof(builder, merge_proof);
100
101 MergeRecursiveVerifier merge_verifier{ merge_settings, transcript };
102 auto merge_result = merge_verifier.reduce_to_pairing_check(stdlib_merge_proof, merge_commitments);
103
104 merge_verification_queue.pop_front(); // remove the processed proof from the queue
105
106 return { merge_result.pairing_points, merge_result.merged_commitments };
107}
108
110{
111 BB_ASSERT_EQ(avm_mode, true, "ensure_well_formed_op_queue should only be called for avm");
112 // Add Ultra ops for the Translator (no-op + 3 random ops as prefix for translator accumulation)
113 builder.queue_ecc_no_op();
114 builder.queue_ecc_random_op();
115 builder.queue_ecc_random_op();
116 builder.queue_ecc_random_op();
117 // In the AVM Recursive Verifier case, we don't need ZK; so we place a deterministic non-op as a "hiding_op", it
118 // does not contribute to the actual MSM circuit.
120 builder.queue_ecc_hiding_op(Fq(0), Fq(0));
121}
122
123} // namespace bb
#define BB_ASSERT(expression,...)
Definition assert.hpp:80
#define BB_ASSERT_EQ(actual, expected,...)
Definition assert.hpp:93
#define BB_BENCH_NAME(name)
Definition bb_bench.hpp:219
CommitmentKey object over a pairing group 𝔾₁.
std::pair< Proof, OpeningClaim > construct_proof()
std::shared_ptr< ProvingKey > key
fq evaluation_challenge_x
Definition goblin.hpp:54
void ensure_well_formed_op_queue_for_avm(MegaBuilder &builder) const
Add required initial ops to the op queue for AVM mode.
Definition goblin.cpp:109
Goblin(CommitmentKey< curve::BN254 > bn254_commitment_key=CommitmentKey< curve::BN254 >(), const std::shared_ptr< Transcript > &transcript=std::make_shared< Transcript >())
Definition goblin.cpp:24
GoblinProof goblin_proof
Definition goblin.hpp:51
std::pair< PairingPoints, RecursiveTableCommitments > recursively_verify_merge(MegaBuilder &builder, const RecursiveMergeCommitments &merge_commitments, const std::shared_ptr< RecursiveTranscript > &transcript, const MergeSettings merge_settings=MergeSettings::PREPEND)
Recursively verify the next merge proof in the merge verification queue.
Definition goblin.cpp:91
void prove_eccvm()
Construct an ECCVM proof and IPA opening proof.
Definition goblin.cpp:36
fq translation_batching_challenge_v
Definition goblin.hpp:53
void prove_merge(const std::shared_ptr< Transcript > &transcript=std::make_shared< Transcript >(), const MergeSettings merge_settings=MergeSettings::PREPEND)
Construct a merge proof for the goblin ECC ops in the provided circuit; append the proof to the merge...
Definition goblin.cpp:29
std::shared_ptr< OpQueue > op_queue
Definition goblin.hpp:48
void prove_translator()
Construct a translator proof.
Definition goblin.cpp:53
GoblinProof prove(const MergeSettings merge_settings=MergeSettings::PREPEND)
Constuct a full Goblin proof (ECCVM, Translator, merge)
Definition goblin.cpp:62
MergeProver::MergeProof MergeProof
Definition goblin.hpp:34
CommitmentKey< curve::BN254 > commitment_key
Definition goblin.hpp:49
bool avm_mode
Definition goblin.hpp:62
std::deque< MergeProof > merge_verification_queue
Definition goblin.hpp:57
std::shared_ptr< Transcript > transcript
Definition goblin.hpp:55
Prover class for the Goblin ECC op queue transcript merge protocol.
Unified verifier class for the Goblin ECC op queue transcript merge protocol.
ReductionResult reduce_to_pairing_check(const Proof &proof, const InputCommitments &input_commitments)
Reduce the merge proof to a pairing check.
TranslatorCircuitBuilder creates a circuit that evaluates the correctness of the evaluation of EccOpQ...
A simple wrapper around a vector of stdlib field elements representing a proof.
Definition proof.hpp:19
#define vinfo(...)
Definition log.hpp:94
void info(Args... args)
Definition log.hpp:89
AluTraceBuilder builder
Definition alu.test.cpp:124
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
MergeSettings
The MergeSettings define whether an current subtable will be added at the beginning (PREPEND) or at t...
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
HonkProof eccvm_proof
Definition types.hpp:23
HonkProof ipa_proof
Definition types.hpp:24
HonkProof merge_proof
Definition types.hpp:22
HonkProof translator_proof
Definition types.hpp:25
curve::BN254::BaseField Fq