Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions barretenberg/cpp/src/barretenberg/transcript/transcript.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,19 +606,6 @@ template <typename TranscriptParams> class BaseTranscript {
BB_ASSERT_LTE(num_frs_read + element_size, proof_data.size());

auto element_frs = std::span{ proof_data }.subspan(num_frs_read, element_size);
num_frs_read += element_size;

BaseTranscript::add_element_frs_to_hash_buffer(label, element_frs);

auto element = TranscriptParams::template deserialize<T>(element_frs);
DEBUG_LOG(label, element);

#ifdef LOG_INTERACTIONS
if constexpr (Loggable<T>) {
info("received: ", label, ": ", element);
}
#endif

// In case the transcript is used for recursive verification, we can track proper Fiat-Shamir usage
if constexpr (in_circuit) {
// The verifier is receiving data from the prover. If before this we were in the challenge generation phase,
Expand All @@ -627,16 +614,38 @@ template <typename TranscriptParams> class BaseTranscript {
reception_phase = true;
round_index++;
}
// If the element is iterable, then we need to assign origin tags to all the elements
// Assign an origin tag to the elements going into the hash buffer
const auto element_origin_tag = OriginTag(transcript_index, round_index, /*is_submitted=*/true);
for (auto& subelement : element_frs) {
subelement.set_origin_tag(element_origin_tag);
}
}
num_frs_read += element_size;

BaseTranscript::add_element_frs_to_hash_buffer(label, element_frs);

auto element = TranscriptParams::template deserialize<T>(element_frs);
DEBUG_LOG(label, element);

// Ensure that the element got assigned an origin tag
if constexpr (in_circuit) {
const auto element_origin_tag = OriginTag(transcript_index, round_index, /*is_submitted=*/true);
// If the element is iterable, then we need to check origin tags to all the elements
if constexpr (is_iterable_v<T>) {
for (auto& subelement : element) {
subelement.set_origin_tag(OriginTag(transcript_index, round_index, /*is_submitted=*/true));
ASSERT(subelement.get_origin_tag() == element_origin_tag);
}
} else {
// If the element is not iterable, then we need to assign an origin tag to the element
element.set_origin_tag(OriginTag(transcript_index, round_index, /*is_submitted=*/true));
// If the element is not iterable, then we need to check an origin tag of the element
ASSERT(element.get_origin_tag() == element_origin_tag);
}
}
#ifdef LOG_INTERACTIONS
if constexpr (Loggable<T>) {
info("received: ", label, ": ", element);
}
#endif

return element;
}

Expand Down
Loading