barretenberg
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | List of all members
proof_system::honk::BaseTranscript Class Reference

Common transcript class for both parties. Stores the data for the current round, as well as the manifest. More...

#include <transcript.hpp>

Inheritance diagram for proof_system::honk::BaseTranscript:
proof_system::honk::flavor::AvmMiniFlavor::Transcript proof_system::honk::flavor::ECCVMBase< CycleGroup_T, Curve_T, PCS_T >::Transcript proof_system::honk::flavor::GoblinUltra::Transcript_< Commitment > proof_system::honk::flavor::ToyAVM::Transcript proof_system::honk::flavor::Ultra::Transcript

Public Types

using Proof = std::vector< uint8_t >
 

Public Member Functions

 BaseTranscript (const Proof &proof_data)
 Construct a new Base Transcript object for Verifier using proof_data.
 
std::vector< uint8_t > export_proof ()
 Return the proof data starting at proof_start.
 
void load_proof (const std::vector< uint8_t > &proof)
 
template<typename... Strings>
std::array< uint256_t, sizeof...(Strings)> get_challenges (const Strings &... labels)
 After all the prover messages have been sent, finalize the round by hashing all the data and then create the number of requested challenges.
 
template<class T >
void send_to_verifier (const std::string &label, const T &element)
 Adds a prover message to the transcript, only intended to be used by the prover.
 
template<class T >
receive_from_prover (const std::string &label)
 Reads the next element of type T from the transcript, with a predefined label, only used by verifier.
 
uint256_t get_challenge (const std::string &label)
 
TranscriptManifest get_manifest () const
 
void print ()
 

Static Public Member Functions

static std::shared_ptr< BaseTranscriptprover_init_empty ()
 For testing: initializes transcript with some arbitrary data so that a challenge can be generated after initialization. Only intended to be used by Prover.
 
static std::shared_ptr< BaseTranscriptverifier_init_empty (const std::shared_ptr< BaseTranscript > &transcript)
 For testing: initializes transcript based on proof data then receives junk data produced by BaseTranscript::prover_init_empty(). Only intended to be used by Verifier.
 

Public Attributes

std::ptrdiff_t proof_start = 0
 
size_t num_bytes_written = 0
 
size_t num_bytes_read = 0
 
size_t round_number = 0
 
Proof proof_data
 

Static Public Attributes

static constexpr size_t HASH_OUTPUT_SIZE = 32
 

Protected Member Functions

void consume_prover_element_bytes (const std::string &label, std::span< const uint8_t > element_bytes)
 Adds challenge elements to the current_round_buffer and updates the manifest.
 
template<typename T >
void serialize_to_buffer (const T &element, Proof &proof_data)
 Serializes object and appends it to proof_data.
 
template<typename T >
deserialize_from_buffer (const Proof &proof_data, size_t &offset) const
 Deserializes the bytes starting at offset into the typed element and returns that element.
 

Detailed Description

Common transcript class for both parties. Stores the data for the current round, as well as the manifest.

Constructor & Destructor Documentation

◆ BaseTranscript()

proof_system::honk::BaseTranscript::BaseTranscript ( const Proof &  proof_data)
inlineexplicit

Construct a new Base Transcript object for Verifier using proof_data.

Parameters
proof_data

Member Function Documentation

◆ consume_prover_element_bytes()

void proof_system::honk::BaseTranscript::consume_prover_element_bytes ( const std::string &  label,
std::span< const uint8_t >  element_bytes 
)
inlineprotected

Adds challenge elements to the current_round_buffer and updates the manifest.

Parameters
labelof the element sent
element_bytesserialized

◆ deserialize_from_buffer()

template<typename T >
T proof_system::honk::BaseTranscript::deserialize_from_buffer ( const Proof &  proof_data,
size_t &  offset 
) const
inlineprotected

Deserializes the bytes starting at offset into the typed element and returns that element.

Using the template parameter and the offset argument, this function deserializes the bytes with from_buffer and then increments the offset appropriately based on the number of bytes that were deserialized.

Template Parameters
T
Parameters
proof_data
offset
Returns
T

◆ export_proof()

std::vector< uint8_t > proof_system::honk::BaseTranscript::export_proof ( )
inline

Return the proof data starting at proof_start.

This is useful for when two different provers share a transcript.

◆ get_challenges()

template<typename... Strings>
std::array< uint256_t, sizeof...(Strings)> proof_system::honk::BaseTranscript::get_challenges ( const Strings &...  labels)
inline

After all the prover messages have been sent, finalize the round by hashing all the data and then create the number of requested challenges.

Challenges are generated by iteratively hashing over the previous challenge, using get_next_challenge_buffer(). TODO(#741): Optimizations for this function include generalizing type of hash, splitting hashes into multiple challenges.

Parameters
labelshuman-readable names for the challenges for the manifest
Returns
std::array<uint256_t, num_challenges> challenges for this round.

◆ prover_init_empty()

static std::shared_ptr< BaseTranscript > proof_system::honk::BaseTranscript::prover_init_empty ( )
inlinestatic

For testing: initializes transcript with some arbitrary data so that a challenge can be generated after initialization. Only intended to be used by Prover.

Returns
BaseTranscript

◆ receive_from_prover()

template<class T >
T proof_system::honk::BaseTranscript::receive_from_prover ( const std::string &  label)
inline

Reads the next element of type T from the transcript, with a predefined label, only used by verifier.

Parameters
labelHuman readable name for the challenge.
Returns
deserialized element of type T

◆ send_to_verifier()

template<class T >
void proof_system::honk::BaseTranscript::send_to_verifier ( const std::string &  label,
const T &  element 
)
inline

Adds a prover message to the transcript, only intended to be used by the prover.

Serializes the provided object into proof_data, and updates the current round state in consume_prover_element_bytes.

Parameters
labelDescription/name of the object being added.
elementSerializable object that will be added to the transcript
Todo:
Use a concept to only allow certain types to be passed. Requirements are that the object should be serializable.

◆ serialize_to_buffer()

template<typename T >
void proof_system::honk::BaseTranscript::serialize_to_buffer ( const T &  element,
Proof &  proof_data 
)
inlineprotected

Serializes object and appends it to proof_data.

Calls to_buffer on element to serialize, and modifies proof_data object by appending the serialized bytes to it.

Template Parameters
T
Parameters
element
proof_data

◆ verifier_init_empty()

static std::shared_ptr< BaseTranscript > proof_system::honk::BaseTranscript::verifier_init_empty ( const std::shared_ptr< BaseTranscript > &  transcript)
inlinestatic

For testing: initializes transcript based on proof data then receives junk data produced by BaseTranscript::prover_init_empty(). Only intended to be used by Verifier.

Parameters
transcript
Returns
BaseTranscript

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