27template <
typename T,
typename =
void>
struct is_iterable : std::false_type {};
31struct is_iterable<T,
std::void_t<decltype(std::begin(std::declval<T&>())), decltype(std::end(std::declval<T&>()))>>
36#define STANDARD_TESTING_TAGS \
37 const size_t parent_id = 0; \
38 [[maybe_unused]] const auto clear_tag = OriginTag::constant(); \
39 [[maybe_unused]] const auto constant_tag = OriginTag::constant(); \
40 [[maybe_unused]] const auto submitted_value_origin_tag = OriginTag( \
41 parent_id, 0, true); \
42 [[maybe_unused]] const auto next_submitted_value_origin_tag = OriginTag( \
43 parent_id, 1, true); \
44 [[maybe_unused]] const auto challenge_origin_tag = OriginTag( \
45 parent_id, 0, false); \
46 [[maybe_unused]] const auto next_challenge_tag = OriginTag( \
47 parent_id, 1, false); \
48 [[maybe_unused]] const auto first_two_merged_tag = \
49 OriginTag(submitted_value_origin_tag, \
50 challenge_origin_tag);
52 [[maybe_unused]] const auto first_and_third_merged_tag = \
53 OriginTag(submitted_value_origin_tag, \
56 [[maybe_unused]] const auto first_second_third_merged_tag = OriginTag( \
57 first_two_merged_tag, next_challenge_tag);
59 [[maybe_unused]] const auto first_to_fourth_merged_tag = \
60 OriginTag(first_second_third_merged_tag, \
61 next_submitted_value_origin_tag);
63 [[maybe_unused]] const auto instant_death_tag = \
64 OriginTag::poisoned();
69#ifndef AZTEC_NO_ORIGIN_TAGS
77 static constexpr size_t CONSTANT =
static_cast<size_t>(-1);
78 static constexpr size_t FREE_WITNESS =
static_cast<size_t>(-2);
118 OriginTag(
size_t transcript_idx,
size_t round_number,
bool is_submitted =
true)
145 template <
class... T>
153 for (
const auto& next_tag : { rest... }) {
211inline std::ostream&
operator<<(std::ostream& os, OriginTag
const& v)
213 return os <<
"{ id: " << v.tag_id <<
", transcript_idx: " << v.transcript_index
214 <<
", round_prov: " << v.round_provenance <<
", instadeath: " << v.instant_death <<
" }";
227 OriginTag(
size_t transcript_idx [[maybe_unused]],
228 size_t round_number [[maybe_unused]],
229 bool is_submitted [[maybe_unused]] =
true)
238 static bool is_empty() {
return true; };
251inline std::ostream&
operator<<(std::ostream& os, OriginTag
const&)
253 return os <<
"{ Origin Tag tracking is disabled in release builds }";
266template <
bool in_circuit,
typename T>
inline void assign_origin_tag(T& elem,
const OriginTag&
tag)
268 if constexpr (in_circuit) {
269 if constexpr (is_iterable_v<T>) {
270 for (
auto& e : elem) {
271 e.set_origin_tag(
tag);
274 elem.set_origin_tag(
tag);
287template <
bool in_circuit,
typename T>
inline void check_origin_tag(T& elem,
const OriginTag&
tag)
289 if constexpr (in_circuit) {
290 if constexpr (is_iterable_v<T>) {
291 for (
auto& e : elem) {
309 if constexpr (in_circuit) {
310 for (
auto& entry : input) {
311 entry.unset_free_witness_tag();
326template <
bool in_circuit,
typename Codec,
typename T>
329 if constexpr (in_circuit) {
330 assign_origin_tag<in_circuit>(
const_cast<T&
>(component),
tag);
333 return Codec::serialize_to_fields(component);
344template <
typename TranscriptType>
inline OriginTag
extract_transcript_tag(
const TranscriptType& transcript)
346 return OriginTag(transcript.transcript_index, transcript.round_index,
true);
#define BB_ASSERT(expression,...)
#define BB_ASSERT_LT(left, right,...)
std::ostream & operator<<(std::ostream &os, uint256_t const &a)
Entry point for Barretenberg command-line interface.
std::vector< typename Codec::DataType > tag_and_serialize(const T &component, const OriginTag &tag)
Tag a component with a given origin tag and serialize it to field elements.
void check_round_provenance(const uint256_t &provenance_a, const uint256_t &provenance_b)
Detect if two elements from the same transcript are performing a suspicious interaction.
OriginTag extract_transcript_tag(const TranscriptType &transcript)
Extract origin tag context from a transcript.
void unset_free_witness_tags(std::vector< DataType > &input)
Unsets free witness tags on all elements in a vector.
void assign_origin_tag(T &elem, const OriginTag &tag)
Assigns an origin tag to an element or all elements in an iterable container.
void check_origin_tag(T &elem, const OriginTag &tag)
Checks that an element or all elements in an iterable container have the expected origin tag.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
constexpr bool is_iterable_v
void unset_free_witness()
static OriginTag constant()
static std::atomic< uint64_t > next_tag_id
static OriginTag poisoned()
static constexpr size_t CONSTANT
OriginTag & operator=(const OriginTag &other)=default
static constexpr size_t FREE_WITNESS
void clear_round_provenance()
Clear the round_provenance to address round provenance false positives.
bool is_free_witness() const
numeric::uint256_t round_provenance
static OriginTag free_witness()
bool operator==(const OriginTag &other) const