134template <
typename PrecomputedCommitments,
139 using Commitment =
typename PrecomputedCommitments::DataType;
146 template <
size_t NUM_PRECOMPUTED_ENTITIES,
typename StringType>
150 bool is_equal =
true;
167 for (
auto [this_comm, other_comm, label] :
zip_view(this->get_all(), other.get_all(), commitment_labels)) {
168 if (this_comm != other_comm) {
169 info(
"Commitment mismatch: ", label);
192 size_t commitments_size =
193 PrecomputedCommitments::size() * Transcript::Codec::template calc_num_fields<Commitment>();
194 size_t metadata_size = 0;
197 metadata_size = 3 * Transcript::Codec::template calc_num_fields<uint64_t>();
200 return metadata_size + commitments_size;
213 buffer.insert(
buffer.end(), input_fields.begin(), input_fields.end());
219 serialize(this->log_circuit_size, elements);
220 serialize(this->num_public_inputs, elements);
221 serialize(this->pub_inputs_offset, elements);
225 for (
const Commitment& commitment : this->get_all()) {
230 key.from_field_elements(elements);
242 auto deserialize = [&idx, &elements]<
typename T>(T& target) {
243 size_t size = Transcript::Codec::template calc_num_fields<T>();
244 target = Transcript::template deserialize<T>(elements.subspan(idx, size));
249 deserialize(this->log_circuit_size);
250 deserialize(this->num_public_inputs);
251 deserialize(this->pub_inputs_offset);
255 for (
Commitment& commitment : this->get_all()) {
256 deserialize(commitment);
286 std::vector<DataType> vk_elements;
291 auto tag_and_append = [&]<
typename T>(
const T& component) {
292 auto frs = bb::tag_and_serialize<Transcript::in_circuit, Codec>(component,
tag);
293 vk_elements.insert(vk_elements.end(), frs.begin(), frs.end());
297 tag_and_append(this->log_circuit_size);
298 tag_and_append(this->num_public_inputs);
299 tag_and_append(this->pub_inputs_offset);
302 for (
const Commitment& commitment : this->get_all()) {
303 tag_and_append(commitment);
307 bb::unset_free_witness_tags<Transcript::in_circuit, DataType>(vk_elements);
310 return Transcript::HashFunction::hash(vk_elements);
322template <
typename Builder_,
323 typename PrecomputedCommitments,
329 using Commitment =
typename PrecomputedCommitments::DataType;
353 auto serialize_to_field_buffer = []<
typename T>(
const T& input, std::vector<FF>&
buffer) {
354 std::vector<FF> input_fields = Codec::template serialize_to_fields<T>(input);
355 buffer.insert(
buffer.end(), input_fields.begin(), input_fields.end());
358 std::vector<FF> elements;
360 serialize_to_field_buffer(this->log_circuit_size, elements);
361 serialize_to_field_buffer(this->num_public_inputs, elements);
362 serialize_to_field_buffer(this->pub_inputs_offset, elements);
364 for (
const Commitment& commitment : this->get_all()) {
365 serialize_to_field_buffer(commitment, elements);
397 std::vector<FF> vk_elements;
402 auto append_tagged = [&]<
typename T>(
const T& component) {
403 auto frs = bb::tag_and_serialize<Transcript::in_circuit, Codec>(component,
tag);
404 vk_elements.insert(vk_elements.end(), frs.begin(), frs.end());
408 append_tagged(this->log_circuit_size);
409 append_tagged(this->num_public_inputs);
410 append_tagged(this->pub_inputs_offset);
413 for (
const Commitment& commitment : this->get_all()) {
414 append_tagged(commitment);
418 bb::unset_free_witness_tags<Transcript::in_circuit, FF>(vk_elements);
421 return Transcript::HashFunction::hash(vk_elements);
425template <
typename FF,
typename VerificationKey>
class VKAndHash_ {
445 std::shared_ptr<VerificationKey>
vk;
452 return concatenate(all_entities.get_unshifted(), all_entities.get_shifted());
464 return std::max({ std::tuple_element_t<Is, Tuple>::RELATION_LENGTH... });
475 return (0 + ... + std::tuple_element_t<I, Tuple>::SUBRELATION_PARTIAL_LENGTHS.size());
490 typename std::tuple_element_t<I, RelationsTuple>::SumcheckTupleOfUnivariatesOverSubrelations{}...);
513 typename std::tuple_element_t<I, RelationsTuple>::SumcheckArrayOfValuesOverSubrelations{}...);
523class UltraRollupFlavor;
525class UltraKeccakFlavor;
526#ifdef STARKNET_GARAGA_FLAVORS
527class UltraStarknetFlavor;
528class UltraStarknetZKFlavor;
530class UltraKeccakZKFlavor;
533class TranslatorFlavor;
534class ECCVMRecursiveFlavor;
535class TranslatorRecursiveFlavor;
536class AvmRecursiveFlavor;
537class MultilinearBatchingRecursiveFlavor;
539template <
typename BuilderType>
class UltraRecursiveFlavor_;
540template <
typename BuilderType>
class UltraZKRecursiveFlavor_;
541template <
typename BuilderType>
class UltraRollupRecursiveFlavor_;
542template <
typename BuilderType>
class MegaRecursiveFlavor_;
543template <
typename BuilderType>
class MegaZKRecursiveFlavor_;
548template <
typename PrecomputedCommitments,
typename Transcript, VKSerializationMode SerializeMetadata>
559 for (
auto& element : field_elements) {
563 vk.from_field_elements(field_elements);
566template <
typename PrecomputedCommitments,
typename Transcript, VKSerializationMode SerializeMetadata>
571 size_t before =
buf.size();
573 auto field_elements =
vk.to_field_elements();
574 for (
const auto& element : field_elements) {
577 size_t after =
buf.size();
584class AvmRecursiveFlavor;
#define BB_ASSERT_EQ(actual, expected,...)
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
typename Codec::DataType DataType
static std::vector< DataType > serialize(const T &element)
Base Native verification key class.
static size_t calc_num_data_types()
Calculate the number of field elements needed for serialization.
uint64_t num_public_inputs
bool operator==(const NativeVerificationKey_ &) const =default
typename PrecomputedCommitments::DataType Commitment
NativeVerificationKey_(const size_t circuit_size, const size_t num_public_inputs)
size_t from_field_elements(const std::span< const typename Transcript::DataType > &elements)
Populate verification key from field elements.
fr hash() const
Compute VK hash.
uint64_t log_circuit_size
virtual std::vector< typename Transcript::DataType > to_field_elements() const
Serialize verification key to field elements.
bool compare(const NativeVerificationKey_ &other, RefArray< StringType, NUM_PRECOMPUTED_ENTITIES > commitment_labels) const
NativeVerificationKey_()=default
virtual Transcript::DataType hash_with_origin_tagging(const std::string &domain_separator, Transcript &transcript) const
Tag VK components and hash.
virtual ~NativeVerificationKey_()=default
uint64_t pub_inputs_offset
A template class for a reference array. Behaves as if std::array<T&, N> was possible.
Base Stdlib verification key class.
virtual ~StdlibVerificationKey_()=default
StdlibVerificationKey_()=default
virtual std::vector< FF > to_field_elements() const
Serialize verification key to field elements.
StdlibVerificationKey_(const size_t circuit_size, const size_t num_public_inputs)
virtual FF hash_with_origin_tagging(const std::string &domain_separator, Transcript &transcript) const
Tag VK components and hash.
typename PrecomputedCommitments::DataType Commitment
FF hash()
A model function to show how to compute the VK hash (without the Transcript abstracting things away).
bool operator==(const StdlibVerificationKey_ &) const =default
VerificationKey::NativeVerificationKey NativeVerificationKey
VKAndHash_(Builder &builder, const std::shared_ptr< NativeVerificationKey > &native_vk)
std::shared_ptr< VerificationKey > vk
VKAndHash_(const std::shared_ptr< VerificationKey > &vk, const FF &hash)
VerificationKey::Builder Builder
VKAndHash_(const std::shared_ptr< VerificationKey > &vk)
static FF hash(const std::vector< FF > &input)
Hashes a vector of field elements.
ECCVMFlavor::Transcript Transcript
uint8_t buffer[RANDOM_BUFFER_SIZE]
UltraKeccakFlavor::VerificationKey VerificationKey
constexpr T get_msb(const T in)
Entry point for Barretenberg command-line interface.
void write(std::vector< uint8_t > &buf, Chonk::VerificationKey const &vk)
OriginTag extract_transcript_tag(const TranscriptType &transcript)
Extract origin tag context from a transcript.
void read(uint8_t const *&it, Chonk::VerificationKey &vk)
VKSerializationMode
Enum to control verification key metadata serialization.
RefArray< T,(Ns+...)> constexpr concatenate(const RefArray< T, Ns > &... ref_arrays)
Concatenates multiple RefArray objects into a single RefArray.
constexpr size_t compute_number_of_subrelations()
Utility function to find the number of subrelations.
constexpr auto create_tuple_of_arrays_of_values()
constexpr size_t compute_max_partial_relation_length()
Utility function to find max PARTIAL_RELATION_LENGTH tuples of Relations.
constexpr auto create_sumcheck_tuple_of_tuples_of_univariates()
Utility function to construct a container for the subrelation accumulators of sumcheck proving.
auto get_unshifted_then_shifted(const auto &all_entities)
VerifierCommitmentKey< Curve > vk
void read(auto &it, msgpack_concepts::HasMsgPack auto &obj)
Automatically derived read for any object that defines .msgpack() (implicitly defined by MSGPACK_FIEL...
void write(auto &buf, const msgpack_concepts::HasMsgPack auto &obj)
Automatically derived write for any object that defines .msgpack() (implicitly defined by MSGPACK_FIE...
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
TUPLET_INLINE constexpr auto make_tuple(Ts &&... args)
The precomputed data needed to compute a Honk VK.
RefArray< Polynomial, NUM_PRECOMPUTED_ENTITIES > polynomials