Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
ultra_prover.cpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], date: YYYY-MM-DD }
3// external_1: { status: not started, auditors: [], date: YYYY-MM-DD }
4// external_2: { status: not started, auditors: [], date: YYYY-MM-DD }
5// =====================
6
7#include "ultra_prover.hpp"
11namespace bb {
12
13template <IsUltraOrMegaHonk Flavor>
14UltraProver_<Flavor>::UltraProver_(const std::shared_ptr<ProverInstance>& prover_instance,
15 const std::shared_ptr<HonkVK>& honk_vk,
16 const CommitmentKey& commitment_key)
17 : prover_instance(std::move(prover_instance))
18 , honk_vk(honk_vk)
19 , transcript(std::make_shared<Transcript>())
20 , commitment_key(commitment_key)
21{}
22
30template <IsUltraOrMegaHonk Flavor>
31UltraProver_<Flavor>::UltraProver_(const std::shared_ptr<ProverInstance>& prover_instance,
32 const std::shared_ptr<HonkVK>& honk_vk,
33 const std::shared_ptr<Transcript>& transcript)
34 : prover_instance(std::move(prover_instance))
35 , honk_vk(honk_vk)
36 , transcript(transcript)
37 , commitment_key(prover_instance->commitment_key)
38{}
39
47template <IsUltraOrMegaHonk Flavor>
49 const std::shared_ptr<HonkVK>& honk_vk,
50 const std::shared_ptr<Transcript>& transcript)
51 : prover_instance(std::make_shared<ProverInstance>(circuit))
52 , honk_vk(honk_vk)
53 , transcript(transcript)
54 , commitment_key(prover_instance->commitment_key)
55{}
56
57template <IsUltraOrMegaHonk Flavor>
58UltraProver_<Flavor>::UltraProver_(Builder&& circuit, const std::shared_ptr<HonkVK>& honk_vk)
59 : prover_instance(std::make_shared<ProverInstance>(circuit))
60 , honk_vk(honk_vk)
61 , transcript(std::make_shared<Transcript>())
62 , commitment_key(prover_instance->commitment_key)
63{}
64
65template <IsUltraOrMegaHonk Flavor> typename UltraProver_<Flavor>::Proof UltraProver_<Flavor>::export_proof()
66{
67 auto proof = transcript->export_proof();
68
69 // Add the IPA proof
70 if constexpr (HasIPAAccumulator<Flavor>) {
71 // The extra calculation is for the IPA proof length.
72 BB_ASSERT_EQ(prover_instance->ipa_proof.size(), static_cast<size_t>(IPA_PROOF_LENGTH));
73 proof.insert(proof.end(), prover_instance->ipa_proof.begin(), prover_instance->ipa_proof.end());
74 }
75
76 return proof;
77}
78
79template <IsUltraOrMegaHonk Flavor> void UltraProver_<Flavor>::generate_gate_challenges()
80{
81 // Determine the number of rounds in the sumcheck based on whether or not padding is employed
82 const size_t virtual_log_n =
83 Flavor::USE_PADDING ? Flavor::VIRTUAL_LOG_N : static_cast<size_t>(prover_instance->log_dyadic_size());
84
85 prover_instance->gate_challenges =
86 transcript->template get_powers_of_challenge<FF>("Sumcheck:gate_challenge", virtual_log_n);
87}
88
89template <IsUltraOrMegaHonk Flavor> typename UltraProver_<Flavor>::Proof UltraProver_<Flavor>::construct_proof()
90{
91 OinkProver<Flavor> oink_prover(prover_instance, honk_vk, transcript);
92 oink_prover.prove();
93 vinfo("created oink proof");
94
95 generate_gate_challenges();
96
97 DeciderProver_<Flavor> decider_prover(prover_instance, transcript);
98 decider_prover.construct_proof();
99 return export_proof();
100}
101
102template class UltraProver_<UltraFlavor>;
103template class UltraProver_<UltraZKFlavor>;
105#ifdef STARKNET_GARAGA_FLAVORS
108#endif
111template class UltraProver_<MegaFlavor>;
112template class UltraProver_<MegaZKFlavor>;
113
114} // namespace bb
#define BB_ASSERT_EQ(actual, expected,...)
Definition assert.hpp:88
static constexpr size_t VIRTUAL_LOG_N
static constexpr bool USE_PADDING
Class for all the oink rounds, which are shared between the folding prover and ultra prover.
void prove()
Oink Prover function that runs all the rounds of the verifier.
A ProverInstance is normally constructed from a finalized circuit and it contains all the information...
BB_PROFILE void generate_gate_challenges()
typename Transcript::Proof Proof
typename Flavor::CommitmentKey CommitmentKey
typename Flavor::Transcript Transcript
UltraProver_(const std::shared_ptr< ProverInstance > &, const std::shared_ptr< HonkVK > &, const CommitmentKey &)
typename Flavor::CircuitBuilder Builder
#define vinfo(...)
Definition log.hpp:79
Entry point for Barretenberg command-line interface.
STL namespace.