114 ranges.emplace_back(start, end);
115 for (
size_t i = start; i < end; ++i) {
158template <
typename PrecomputedCommitments,
163 using Commitment =
typename PrecomputedCommitments::DataType;
184 size_t commitments_size =
185 PrecomputedCommitments::size() * Transcript::template calc_num_data_types<Commitment>();
186 size_t metadata_size = 0;
189 metadata_size = 3 * Transcript::template calc_num_data_types<uint64_t>();
192 return metadata_size + commitments_size;
205 buffer.insert(
buffer.end(), input_fields.begin(), input_fields.end());
211 serialize(this->log_circuit_size, elements);
212 serialize(this->num_public_inputs, elements);
213 serialize(this->pub_inputs_offset, elements);
217 for (
const Commitment& commitment : this->get_all()) {
222 key.from_field_elements(elements);
234 auto deserialize = [&idx, &elements]<
typename T>(T& target) {
235 size_t size = Transcript::template calc_num_data_types<T>();
236 target = Transcript::template deserialize<T>(elements.subspan(idx, size));
241 deserialize(this->log_circuit_size);
242 deserialize(this->num_public_inputs);
243 deserialize(this->pub_inputs_offset);
247 for (
Commitment& commitment : this->get_all()) {
248 deserialize(commitment);
284 for (
const Commitment& commitment : this->get_all()) {
300template <
typename Builder_,
301 typename PrecomputedCommitments,
307 using Commitment =
typename PrecomputedCommitments::DataType;
331 auto serialize_to_field_buffer = []<
typename T>(
const T& input, std::vector<FF>&
buffer) {
332 std::vector<FF> input_fields = Codec::template serialize_to_fields<T>(input);
333 buffer.insert(
buffer.end(), input_fields.begin(), input_fields.end());
336 std::vector<FF> elements;
338 serialize_to_field_buffer(this->log_circuit_size, elements);
339 serialize_to_field_buffer(this->num_public_inputs, elements);
340 serialize_to_field_buffer(this->pub_inputs_offset, elements);
342 for (
const Commitment& commitment : this->get_all()) {
343 serialize_to_field_buffer(commitment, elements);
378 for (
const Commitment& commitment : this->get_all()) {
385template <
typename FF,
typename VerificationKey>
class VKAndHash_ {
405 std::shared_ptr<VerificationKey>
vk;
412 return concatenate(all_entities.get_unshifted(), all_entities.get_shifted());
424 return std::max({ std::tuple_element_t<Is, Tuple>::RELATION_LENGTH... });
437 return std::max({ std::tuple_element_t<Is, Tuple>::TOTAL_RELATION_LENGTH... });
448 return (0 + ... + std::tuple_element_t<I, Tuple>::SUBRELATION_PARTIAL_LENGTHS.size());
460template <
typename Tuple,
size_t NUM_INSTANCES,
bool optimized = false>
465 if constexpr (optimized) {
467 typename std::tuple_element_t<I, Tuple>::template ProtogalaxyTupleOfUnivariatesOverSubrelations<
468 NUM_INSTANCES>{}...);
472 template ProtogalaxyTupleOfUnivariatesOverSubrelationsNoOptimisticSkipping<NUM_INSTANCES>{}...);
488 typename std::tuple_element_t<I, RelationsTuple>::SumcheckTupleOfUnivariatesOverSubrelations{}...);
511 typename std::tuple_element_t<I, RelationsTuple>::SumcheckArrayOfValuesOverSubrelations{}...);
521class UltraRollupFlavor;
523class UltraKeccakFlavor;
524#ifdef STARKNET_GARAGA_FLAVORS
525class UltraStarknetFlavor;
526class UltraStarknetZKFlavor;
528class UltraKeccakZKFlavor;
531class TranslatorFlavor;
532class ECCVMRecursiveFlavor;
533class TranslatorRecursiveFlavor;
534class AvmRecursiveFlavor;
535class MultilinearBatchingRecursiveFlavor;
537template <
typename BuilderType>
class UltraRecursiveFlavor_;
538template <
typename BuilderType>
class UltraZKRecursiveFlavor_;
539template <
typename BuilderType>
class UltraRollupRecursiveFlavor_;
540template <
typename BuilderType>
class MegaRecursiveFlavor_;
541template <
typename BuilderType>
class MegaZKRecursiveFlavor_;
546template <
typename PrecomputedCommitments,
typename Transcript, VKSerializationMode SerializeMetadata>
557 for (
auto& element : field_elements) {
561 vk.from_field_elements(field_elements);
564template <
typename PrecomputedCommitments,
typename Transcript, VKSerializationMode SerializeMetadata>
569 size_t before =
buf.size();
571 auto field_elements =
vk.to_field_elements();
572 for (
const auto& element : field_elements) {
575 size_t after =
buf.size();
#define BB_ASSERT_GTE(left, right,...)
#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 DataType hash(const std::vector< DataType > &data)
Static hash method that forwards to Codec hash.
void add_to_independent_hash_buffer(const std::string &label, const T &element)
Adds an element to an independent hash buffer.
static std::vector< DataType > serialize(const T &element)
Serialize a size_t to a vector of field elements.
DataType hash_independent_buffer()
Hashes the independent hash buffer and clears it.
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
A model function to show how to compute the VK hash(without the Transcript abstracting things away)
uint64_t log_circuit_size
virtual std::vector< typename Transcript::DataType > to_field_elements() const
Serialize verification key to field elements.
NativeVerificationKey_()=default
virtual ~NativeVerificationKey_()=default
uint64_t pub_inputs_offset
virtual Transcript::DataType hash_through_transcript(const std::string &domain_separator, Transcript &transcript) const
Hashes the vk using the transcript's independent buffer and returns the hash.
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_through_transcript(const std::string &domain_separator, Transcript &transcript) const
Hashes the vk using the transcript's independent buffer and returns the 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, ClientIVC::VerificationKey const &vk)
void read(uint8_t const *&it, ClientIVC::VerificationKey &vk)
constexpr auto create_protogalaxy_tuple_of_tuples_of_univariates()
Utility function to construct a container for the subrelation accumulators of Protogalaxy folding.
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 size_t compute_max_total_relation_length()
Utility function to find max TOTAL_RELATION_LENGTH among 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)
std::pair< size_t, size_t > get_range(const size_t idx) const
size_t get_idx(const size_t idx) const
std::vector< std::pair< size_t, size_t > > ranges
size_t num_ranges() const
void add_range(const size_t start, const size_t end)
std::vector< size_t > idxs
std::vector< std::pair< size_t, size_t > > get_ranges() const
The precomputed data needed to compute a Honk VK.
RefArray< Polynomial, NUM_PRECOMPUTED_ENTITIES > polynomials