Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata > Class Template Reference

Base Native verification key class. More...

#include <flavor.hpp>

Inheritance diagram for bb::NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata >:

Public Types

using Commitment = typename PrecomputedCommitments::DataType
 
using DataType = typename Codec::DataType
 

Public Member Functions

bool operator== (const NativeVerificationKey_ &) const =default
 
template<size_t NUM_PRECOMPUTED_ENTITIES, typename StringType >
bool compare (const NativeVerificationKey_ &other, RefArray< StringType, NUM_PRECOMPUTED_ENTITIES > commitment_labels) const
 
virtual ~NativeVerificationKey_ ()=default
 
 NativeVerificationKey_ ()=default
 
 NativeVerificationKey_ (const size_t circuit_size, const size_t num_public_inputs)
 
template<typename PrecomputedData >
requires (!std::is_void_v<CommitmentKey>)
 NativeVerificationKey_ (const PrecomputedData &precomputed)
 Construct VK from precomputed data by committing to polynomials.
 
virtual std::vector< DataTypeto_field_elements () const
 Serialize verification key to field elements.
 
size_t from_field_elements (const std::span< const DataType > &elements)
 Populate verification key from field elements.
 
fr hash () const
 Compute VK hash.
 
virtual DataType hash_with_origin_tagging (const OriginTag &tag) const
 Tag VK components and hash.
 
template<typename Transcript >
DataType hash_with_origin_tagging (const Transcript &transcript) const
 An overload that accepts a transcript and extracts the tag internally.
 

Static Public Member Functions

static size_t calc_num_data_types ()
 Calculate the number of field elements needed for serialization.
 

Public Attributes

uint64_t log_circuit_size = 0
 
uint64_t num_public_inputs = 0
 
uint64_t pub_inputs_offset = 0
 

Detailed Description

template<typename PrecomputedCommitments, typename Codec, typename HashFunction, typename CommitmentKey = void, VKSerializationMode SerializeMetadata = VKSerializationMode::FULL>
class bb::NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata >

Base Native verification key class.

We want a separate native and stdlib verification key class because we don't have nice mappings from native to stdlib and back. Examples of mappings that don't exist are from uint64_t to field_t, .get_value() doesn't have a native equivalent, and Builder also doesn't have a native equivalent.

Template Parameters
PrecomputedEntitiesAn instance of PrecomputedEntities_ with affine_element data type and handle type.
CodecThe codec used for serialization (e.g., FrCodec, U256Codec)
HashFunctionThe hash function used for VK hashing (e.g., Poseidon2, Keccak)

Definition at line 141 of file flavor.hpp.

Member Typedef Documentation

◆ Commitment

template<typename PrecomputedCommitments , typename Codec , typename HashFunction , typename CommitmentKey = void, VKSerializationMode SerializeMetadata = VKSerializationMode::FULL>
using bb::NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata >::Commitment = typename PrecomputedCommitments::DataType

Definition at line 143 of file flavor.hpp.

◆ DataType

template<typename PrecomputedCommitments , typename Codec , typename HashFunction , typename CommitmentKey = void, VKSerializationMode SerializeMetadata = VKSerializationMode::FULL>
using bb::NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata >::DataType = typename Codec::DataType

Definition at line 144 of file flavor.hpp.

Constructor & Destructor Documentation

◆ ~NativeVerificationKey_()

template<typename PrecomputedCommitments , typename Codec , typename HashFunction , typename CommitmentKey = void, VKSerializationMode SerializeMetadata = VKSerializationMode::FULL>
virtual bb::NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata >::~NativeVerificationKey_ ( )
virtualdefault

◆ NativeVerificationKey_() [1/3]

template<typename PrecomputedCommitments , typename Codec , typename HashFunction , typename CommitmentKey = void, VKSerializationMode SerializeMetadata = VKSerializationMode::FULL>
bb::NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata >::NativeVerificationKey_ ( )
default

◆ NativeVerificationKey_() [2/3]

template<typename PrecomputedCommitments , typename Codec , typename HashFunction , typename CommitmentKey = void, VKSerializationMode SerializeMetadata = VKSerializationMode::FULL>
bb::NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata >::NativeVerificationKey_ ( const size_t  circuit_size,
const size_t  num_public_inputs 
)
inline

Definition at line 184 of file flavor.hpp.

◆ NativeVerificationKey_() [3/3]

template<typename PrecomputedCommitments , typename Codec , typename HashFunction , typename CommitmentKey = void, VKSerializationMode SerializeMetadata = VKSerializationMode::FULL>
template<typename PrecomputedData >
requires (!std::is_void_v<CommitmentKey>)
bb::NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata >::NativeVerificationKey_ ( const PrecomputedData &  precomputed)
inlineexplicit

Construct VK from precomputed data by committing to polynomials.

Only available when CommitmentKeyType is specified (not void)

Definition at line 194 of file flavor.hpp.

Member Function Documentation

◆ calc_num_data_types()

template<typename PrecomputedCommitments , typename Codec , typename HashFunction , typename CommitmentKey = void, VKSerializationMode SerializeMetadata = VKSerializationMode::FULL>
static size_t bb::NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata >::calc_num_data_types ( )
inlinestatic

Calculate the number of field elements needed for serialization.

Returns
size_t Number of field elements

Definition at line 209 of file flavor.hpp.

◆ compare()

template<typename PrecomputedCommitments , typename Codec , typename HashFunction , typename CommitmentKey = void, VKSerializationMode SerializeMetadata = VKSerializationMode::FULL>
template<size_t NUM_PRECOMPUTED_ENTITIES, typename StringType >
bool bb::NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata >::compare ( const NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata > &  other,
RefArray< StringType, NUM_PRECOMPUTED_ENTITIES >  commitment_labels 
) const
inline

Definition at line 152 of file flavor.hpp.

◆ from_field_elements()

template<typename PrecomputedCommitments , typename Codec , typename HashFunction , typename CommitmentKey = void, VKSerializationMode SerializeMetadata = VKSerializationMode::FULL>
size_t bb::NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata >::from_field_elements ( const std::span< const DataType > &  elements)
inline

Populate verification key from field elements.

Parameters
elementsField elements to deserialize from

Definition at line 257 of file flavor.hpp.

◆ hash()

template<typename PrecomputedCommitments , typename Codec , typename HashFunction , typename CommitmentKey = void, VKSerializationMode SerializeMetadata = VKSerializationMode::FULL>
fr bb::NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata >::hash ( ) const
inline

Compute VK hash.

Returns
FF

Definition at line 284 of file flavor.hpp.

◆ hash_with_origin_tagging() [1/2]

template<typename PrecomputedCommitments , typename Codec , typename HashFunction , typename CommitmentKey = void, VKSerializationMode SerializeMetadata = VKSerializationMode::FULL>
virtual DataType bb::NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata >::hash_with_origin_tagging ( const OriginTag tag) const
inlinevirtual

Tag VK components and hash.

Needed to make sure the Origin Tag system works. We need to set the origin tags of the VK witnesses. If we instead did the hashing outside and just submitted the hash, only the origin tag of the hash would be set properly. By tagging the VK components directly, we ensure all VK witnesses have proper origin tags.

Parameters
domain_separator(currently unused, kept for API compatibility)
tagThe origin tag extracted from the transcript
Returns
The hash of the verification key

Reimplemented in bb::ECCVMFlavor::VerificationKey, bb::TranslatorFlavor::VerificationKey, and bb::avm2::AvmFlavor::VerificationKey.

Definition at line 300 of file flavor.hpp.

◆ hash_with_origin_tagging() [2/2]

template<typename PrecomputedCommitments , typename Codec , typename HashFunction , typename CommitmentKey = void, VKSerializationMode SerializeMetadata = VKSerializationMode::FULL>
template<typename Transcript >
DataType bb::NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata >::hash_with_origin_tagging ( const Transcript transcript) const
inline

An overload that accepts a transcript and extracts the tag internally.

Template Parameters
TranscriptTypeThe transcript type (Codec and HashFunction deduced automatically)
Parameters
transcriptThe transcript to extract the origin tag from
Returns
The hash of the verification key

Definition at line 334 of file flavor.hpp.

◆ operator==()

template<typename PrecomputedCommitments , typename Codec , typename HashFunction , typename CommitmentKey = void, VKSerializationMode SerializeMetadata = VKSerializationMode::FULL>
bool bb::NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata >::operator== ( const NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata > &  ) const
default

◆ to_field_elements()

template<typename PrecomputedCommitments , typename Codec , typename HashFunction , typename CommitmentKey = void, VKSerializationMode SerializeMetadata = VKSerializationMode::FULL>
virtual std::vector< DataType > bb::NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata >::to_field_elements ( ) const
inlinevirtual

Serialize verification key to field elements.

Returns
std::vector<FF>

Definition at line 227 of file flavor.hpp.

Member Data Documentation

◆ log_circuit_size

template<typename PrecomputedCommitments , typename Codec , typename HashFunction , typename CommitmentKey = void, VKSerializationMode SerializeMetadata = VKSerializationMode::FULL>
uint64_t bb::NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata >::log_circuit_size = 0

Definition at line 145 of file flavor.hpp.

◆ num_public_inputs

template<typename PrecomputedCommitments , typename Codec , typename HashFunction , typename CommitmentKey = void, VKSerializationMode SerializeMetadata = VKSerializationMode::FULL>
uint64_t bb::NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata >::num_public_inputs = 0

Definition at line 146 of file flavor.hpp.

◆ pub_inputs_offset

template<typename PrecomputedCommitments , typename Codec , typename HashFunction , typename CommitmentKey = void, VKSerializationMode SerializeMetadata = VKSerializationMode::FULL>
uint64_t bb::NativeVerificationKey_< PrecomputedCommitments, Codec, HashFunction, CommitmentKey, SerializeMetadata >::pub_inputs_offset = 0

Definition at line 147 of file flavor.hpp.


The documentation for this class was generated from the following file: