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(const std::shared_ptr<Transcript>& transcript)
25 : transcript(transcript)
26{}
27
28Goblin::MergeProof Goblin::prove_merge(const std::shared_ptr<Transcript>& transcript) const
29{
30 BB_BENCH_NAME("Goblin::prove_merge");
31 MergeProver merge_prover{ op_queue, transcript };
32 return merge_prover.construct_proof();
33}
34
36{
37 BB_BENCH_NAME("Goblin::prove_eccvm");
38 // Scope the builder so it (and any circuit data) is freed before proving
39 ECCVMProver eccvm_prover = [&]() {
40 ECCVMBuilder eccvm_builder(op_queue);
41 return ECCVMProver(eccvm_builder, transcript);
42 }();
43 auto [eccvm_proof, opening_claim] = eccvm_prover.construct_proof();
44 goblin_proof.eccvm_proof = std::move(eccvm_proof);
45
46 // Extract what we need before freeing the prover
47 auto commitment_key = eccvm_prover.key->commitment_key;
50
51 // Free ECCVM polynomials (~118 MiB) before IPA proving; only the commitment key is needed for IPA
52 eccvm_prover.key.reset();
53
54 // Compute IPA proof for the opening claim
55 auto ipa_transcript = std::make_shared<NativeTranscript>();
56 IPA_PCS::compute_opening_proof(commitment_key, opening_claim, ipa_transcript);
57 goblin_proof.ipa_proof = ipa_transcript->export_proof();
58}
59
61{
62 BB_BENCH_NAME("Goblin::prove_translator");
64 auto translator_key = std::make_shared<TranslatorProvingKey>(translator_builder);
65 TranslatorProver translator_prover(translator_key, transcript);
66 goblin_proof.translator_proof = translator_prover.construct_proof();
67}
68
70{
71 BB_BENCH_NAME("Goblin::prove");
72
73 goblin_proof.merge_proof = prove_merge(transcript); // Use shared transcript for merge proving
74 info("Goblin: num ultra ops = ", op_queue->get_ultra_ops_count());
75
76 vinfo("prove eccvm...");
78 vinfo("finished eccvm proving.");
79 vinfo("prove translator...");
81 vinfo("finished translator proving.");
82 return goblin_proof;
83}
84
99{
100 BB_BENCH_NAME("Goblin::prove_batch_merge");
101 BatchMergeProver prover{ op_queue, CHONK_MAX_NUM_CIRCUITS };
103}
104
117{
118 BB_ASSERT(!batch_merge_proof.empty(), "Goblin::recursively_verify_batch_merge: no batch merge proof available");
120
122 auto result = verifier.reduce_to_pairing_check(stdlib_proof, hash);
123
124 return { result.pairing_points, result.merged_commitments };
125}
126
127} // namespace bb
#define BB_ASSERT(expression,...)
Definition assert.hpp:70
#define BB_BENCH_NAME(name)
Definition bb_bench.hpp:264
Batch merge prover.
MergeProof construct_proof()
Construct the batch merge proof.
Unified batch verifier for the batch Goblin ECC op queue merge protocol.
typename Curve::ScalarField FF
ReductionResult reduce_to_pairing_check(const Proof &proof, const FF hash)
Reduce the batch merge proof to a pairing check.
std::pair< Proof, OpeningClaim > construct_proof()
std::shared_ptr< ProvingKey > key
fq evaluation_challenge_x
Definition goblin.hpp:64
GoblinProof goblin_proof
Definition goblin.hpp:61
MergeProof prove_merge(const std::shared_ptr< Transcript > &transcript=std::make_shared< Transcript >()) const
Construct a single-step merge proof for the most recently merged subtable.
Definition goblin.cpp:28
void prove_eccvm()
Construct an ECCVM proof and IPA opening proof.
Definition goblin.cpp:35
fq translation_batching_challenge_v
Definition goblin.hpp:63
GoblinProof prove()
Constuct a full Goblin proof (ECCVM, Translator, merge)
Definition goblin.cpp:69
void prove_batch_merge()
Construct a batched merge proof for all subtables accumulated during the IVC.
Definition goblin.cpp:98
BatchMergeProof batch_merge_proof
Definition goblin.hpp:67
Goblin(const std::shared_ptr< Transcript > &transcript=std::make_shared< Transcript >())
Definition goblin.cpp:24
std::shared_ptr< OpQueue > op_queue
Definition goblin.hpp:59
void prove_translator()
Construct a translator proof.
Definition goblin.cpp:60
MergeProver::MergeProof MergeProof
Definition goblin.hpp:42
bool avm_mode
Definition goblin.hpp:32
std::shared_ptr< Transcript > transcript
Definition goblin.hpp:65
std::pair< PairingPoints, BatchRecursiveTableCommitments > recursively_verify_batch_merge(MegaBuilder &builder, const BatchMergeRecursiveVerifier::FF &hash) const
Recursively verify the batched merge proof inside the hiding kernel.
Definition goblin.cpp:115
Prover for the single-step Goblin ECC op queue merge protocol.
BB_PROFILE MergeProof construct_proof()
Prove proper construction of the aggregate Goblin ECC op queue polynomials T_j.
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 info(...)
Definition log.hpp:93
#define vinfo(...)
Definition log.hpp:94
AluTraceBuilder builder
Definition alu.test.cpp:124
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
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