Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
ultra_keccak_zk_flavor.hpp
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#pragma once
8
11
12namespace bb {
13
15 public:
16 // This flavor runs with ZK Sumcheck
17 static constexpr bool HasZK = true;
18 // Determine the number of evaluations of Prover and Libra Polynomials that the Prover sends to the Verifier in
19 // the rounds of ZK Sumcheck.
22 "LIBRA_UNIVARIATES_LENGTH must be equal to UltraKeccakZKFlavor::BATCHED_RELATION_PARTIAL_LENGTH");
23
24 // Proof length formula method
25 static constexpr size_t PROOF_LENGTH_WITHOUT_PUB_INPUTS(size_t virtual_log_n = VIRTUAL_LOG_N)
26 {
27 return /* 1. NUM_WITNESS_ENTITIES commitments */ (NUM_WITNESS_ENTITIES * num_elements_comm) +
28 /* 2. Libra concatenation commitment*/ (num_elements_comm) +
29 /* 3. Libra sum */ (num_elements_fr) +
30 /* 4. virtual_log_n sumcheck univariates */
32 /* 5. NUM_ALL_ENTITIES sumcheck evaluations*/ (NUM_ALL_ENTITIES * num_elements_fr) +
33 /* 6. Libra claimed evaluation */ (num_elements_fr) +
34 /* 7. Libra grand sum commitment */ (num_elements_comm) +
35 /* 8. Libra quotient commitment */ (num_elements_comm) +
36 /* 9. Gemini masking commitment */ (num_elements_comm) +
37 /* 10. Gemini masking evaluation */ (num_elements_fr) +
38 /* 11. virtual_log_n - 1 Gemini Fold commitments */
39 ((virtual_log_n - 1) * num_elements_comm) +
40 /* 12. virtual_log_n Gemini a evaluations */
41 (virtual_log_n * num_elements_fr) +
42 /* 13. NUM_SMALL_IPA_EVALUATIONS libra evals */ (NUM_SMALL_IPA_EVALUATIONS * num_elements_fr) +
43 /* 14. Shplonk Q commitment */ (num_elements_comm) +
44 /* 15. KZG W commitment */ (num_elements_comm);
45 }
46
53 public:
55 // Note: we have a different vector of univariates because the degree for ZK flavors differs
68
69 Transcript() = default;
70
71 static std::shared_ptr<Transcript> prover_init_empty()
72 {
73 auto transcript = Base::prover_init_empty();
74 return std::static_pointer_cast<Transcript>(transcript);
75 };
76
77 static std::shared_ptr<Transcript> verifier_init_empty(const std::shared_ptr<Transcript>& transcript)
78 {
79 auto verifier_transcript = Base::verifier_init_empty(transcript);
80 return std::static_pointer_cast<Transcript>(verifier_transcript);
81 };
82
89 void deserialize_full_transcript(size_t public_input_size, size_t virtual_log_n = VIRTUAL_LOG_N)
90 {
91 // take current proof and put them into the struct
92 size_t num_frs_read = 0;
93 auto& proof_data = this->proof_data;
94 for (size_t i = 0; i < public_input_size; ++i) {
95 this->public_inputs.push_back(Base::template deserialize_from_buffer<FF>(proof_data, num_frs_read));
96 }
97 this->w_l_comm = Base::template deserialize_from_buffer<Commitment>(proof_data, num_frs_read);
98 this->w_r_comm = Base::template deserialize_from_buffer<Commitment>(proof_data, num_frs_read);
99 this->w_o_comm = Base::template deserialize_from_buffer<Commitment>(proof_data, num_frs_read);
100 this->lookup_read_counts_comm =
101 Base::template deserialize_from_buffer<Commitment>(proof_data, num_frs_read);
102 this->lookup_read_tags_comm = Base::template deserialize_from_buffer<Commitment>(proof_data, num_frs_read);
103 this->w_4_comm = Base::template deserialize_from_buffer<Commitment>(proof_data, num_frs_read);
104 this->lookup_inverses_comm = Base::template deserialize_from_buffer<Commitment>(proof_data, num_frs_read);
105 this->z_perm_comm = Base::template deserialize_from_buffer<Commitment>(proof_data, num_frs_read);
107 Base::template deserialize_from_buffer<Commitment>(proof_data, num_frs_read);
108 libra_sum = Base::template deserialize_from_buffer<FF>(proof_data, num_frs_read);
109
110 for (size_t i = 0; i < virtual_log_n; ++i) {
111 zk_sumcheck_univariates.push_back(
112 Base::template deserialize_from_buffer<bb::Univariate<FF, BATCHED_RELATION_PARTIAL_LENGTH>>(
113 proof_data, num_frs_read));
114 }
115 libra_claimed_evaluation = Base::template deserialize_from_buffer<FF>(proof_data, num_frs_read);
116 this->sumcheck_evaluations =
117 Base::template deserialize_from_buffer<std::array<FF, NUM_ALL_ENTITIES>>(proof_data, num_frs_read);
118 libra_grand_sum_commitment = Base::template deserialize_from_buffer<Commitment>(proof_data, num_frs_read);
119 libra_quotient_commitment = Base::template deserialize_from_buffer<Commitment>(proof_data, num_frs_read);
120 hiding_polynomial_commitment = Base::template deserialize_from_buffer<Commitment>(proof_data, num_frs_read);
121 hiding_polynomial_eval = Base::template deserialize_from_buffer<FF>(proof_data, num_frs_read);
122 for (size_t i = 0; i < virtual_log_n - 1; ++i) {
123 this->gemini_fold_comms.push_back(
124 Base::template deserialize_from_buffer<Commitment>(proof_data, num_frs_read));
125 }
126 for (size_t i = 0; i < virtual_log_n; ++i) {
127 this->gemini_fold_evals.push_back(Base::template deserialize_from_buffer<FF>(proof_data, num_frs_read));
128 }
129 libra_concatenation_eval = Base::template deserialize_from_buffer<FF>(proof_data, num_frs_read);
130 libra_shifted_grand_sum_eval = Base::template deserialize_from_buffer<FF>(proof_data, num_frs_read);
131 libra_grand_sum_eval = Base::template deserialize_from_buffer<FF>(proof_data, num_frs_read);
132 libra_quotient_eval = Base::template deserialize_from_buffer<FF>(proof_data, num_frs_read);
133 this->shplonk_q_comm = Base::template deserialize_from_buffer<Commitment>(proof_data, num_frs_read);
134
135 this->kzg_w_comm = Base::template deserialize_from_buffer<Commitment>(proof_data, num_frs_read);
136 }
137
144 void serialize_full_transcript(size_t virtual_log_n = VIRTUAL_LOG_N)
145 {
146 auto& proof_data = this->proof_data;
147 size_t old_proof_length = proof_data.size();
148 proof_data.clear(); // clear proof_data so the rest of the function can replace it
149 for (const auto& public_input : this->public_inputs) {
150 Base::serialize_to_buffer(public_input, proof_data);
151 }
152 Base::serialize_to_buffer(this->w_l_comm, proof_data);
153 Base::serialize_to_buffer(this->w_r_comm, proof_data);
154 Base::serialize_to_buffer(this->w_o_comm, proof_data);
155 Base::serialize_to_buffer(this->lookup_read_counts_comm, proof_data);
156 Base::serialize_to_buffer(this->lookup_read_tags_comm, proof_data);
157 Base::serialize_to_buffer(this->w_4_comm, proof_data);
158 Base::serialize_to_buffer(this->lookup_inverses_comm, proof_data);
159 Base::serialize_to_buffer(this->z_perm_comm, proof_data);
162
163 for (size_t i = 0; i < virtual_log_n; ++i) {
165 }
167
168 Base::serialize_to_buffer(this->sumcheck_evaluations, proof_data);
173 for (size_t i = 0; i < virtual_log_n - 1; ++i) {
174 Base::serialize_to_buffer(this->gemini_fold_comms[i], proof_data);
175 }
176 for (size_t i = 0; i < virtual_log_n; ++i) {
177 Base::serialize_to_buffer(this->gemini_fold_evals[i], proof_data);
178 }
183 Base::serialize_to_buffer(this->shplonk_q_comm, proof_data);
184 Base::serialize_to_buffer(this->kzg_w_comm, proof_data);
185
186 BB_ASSERT_EQ(proof_data.size(), old_proof_length);
187 }
188 };
189};
190} // namespace bb
#define BB_ASSERT_EQ(actual, expected,...)
Definition assert.hpp:59
void serialize_to_buffer(const T &element, Proof &proof_data)
Serializes object and appends it to proof_data.
static std::shared_ptr< BaseTranscript > verifier_init_empty(const std::shared_ptr< BaseTranscript > &transcript)
For testing: initializes transcript based on proof data then receives junk data produced by BaseTrans...
static std::shared_ptr< BaseTranscript > prover_init_empty()
For testing: initializes transcript with some arbitrary data so that a challenge can be generated aft...
BaseTranscript< Params > Base
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH
Curve::AffineElement Commitment
static constexpr size_t VIRTUAL_LOG_N
static constexpr size_t NUM_ALL_ENTITIES
static constexpr size_t NUM_WITNESS_ENTITIES
static constexpr size_t num_elements_comm
static constexpr size_t num_elements_fr
UltraKeccakFlavor::Transcript_< KeccakTranscriptParams > Transcript
Derived class that defines proof structure for Ultra zero knowledge proofs, as well as supporting fun...
void deserialize_full_transcript(size_t public_input_size, size_t virtual_log_n=VIRTUAL_LOG_N)
Takes a FULL Ultra proof and deserializes it into the public member variables that compose the struct...
static std::shared_ptr< Transcript > verifier_init_empty(const std::shared_ptr< Transcript > &transcript)
static std::shared_ptr< Transcript > prover_init_empty()
std::vector< bb::Univariate< FF, BATCHED_RELATION_PARTIAL_LENGTH > > zk_sumcheck_univariates
void serialize_full_transcript(size_t virtual_log_n=VIRTUAL_LOG_N)
Serializes the structure variables into a FULL Ultra proof. Should be called only if deserialize_full...
static constexpr size_t PROOF_LENGTH_WITHOUT_PUB_INPUTS(size_t virtual_log_n=VIRTUAL_LOG_N)
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH
A univariate polynomial represented by its values on {domain_start, domain_start + 1,...
static constexpr uint32_t LIBRA_UNIVARIATES_LENGTH
Definition grumpkin.hpp:79
Entry point for Barretenberg command-line interface.
typename Flavor::FF FF
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13