26template <
typename T,
typename =
void>
struct is_iterable : std::false_type {};
30struct is_iterable<T,
std::void_t<decltype(std::begin(std::declval<T&>())), decltype(std::end(std::declval<T&>()))>>
35#define STANDARD_TESTING_TAGS \
36 const size_t parent_id = 0; \
37 [[maybe_unused]] const auto clear_tag = OriginTag::constant(); \
38 [[maybe_unused]] const auto constant_tag = OriginTag::constant(); \
39 [[maybe_unused]] const auto submitted_value_origin_tag = OriginTag( \
40 parent_id, 0, true); \
41 [[maybe_unused]] const auto next_submitted_value_origin_tag = OriginTag( \
42 parent_id, 1, true); \
43 [[maybe_unused]] const auto challenge_origin_tag = OriginTag( \
44 parent_id, 0, false); \
45 [[maybe_unused]] const auto next_challenge_tag = OriginTag( \
46 parent_id, 1, false); \
47 [[maybe_unused]] const auto first_two_merged_tag = \
48 OriginTag(submitted_value_origin_tag, \
49 challenge_origin_tag);
51 [[maybe_unused]] const auto first_and_third_merged_tag = \
52 OriginTag(submitted_value_origin_tag, \
55 [[maybe_unused]] const auto first_second_third_merged_tag = OriginTag( \
56 first_two_merged_tag, next_challenge_tag);
58 [[maybe_unused]] const auto first_to_fourth_merged_tag = \
59 OriginTag(first_second_third_merged_tag, \
60 next_submitted_value_origin_tag);
62 [[maybe_unused]] const auto instant_death_tag = \
63 OriginTag::poisoned();
68#ifndef AZTEC_NO_ORIGIN_TAGS
71 static constexpr size_t CONSTANT =
static_cast<size_t>(-1);
72 static constexpr size_t FREE_WITNESS =
static_cast<size_t>(-2);
112 OriginTag(
size_t transcript_idx,
size_t round_number,
bool is_submitted =
true)
139 template <
class... T>
147 for (
const auto& next_tag : { rest... }) {
205inline std::ostream&
operator<<(std::ostream& os, OriginTag
const& v)
207 return os <<
"{ transcript_idx: " << v.transcript_index <<
", round_prov: " << v.round_provenance
208 <<
", instadeath: " << v.instant_death <<
" }";
221 OriginTag(
size_t transcript_idx [[maybe_unused]],
222 size_t round_number [[maybe_unused]],
223 bool is_submitted [[maybe_unused]] =
true)
232 static bool is_empty() {
return true; };
245inline std::ostream&
operator<<(std::ostream& os, OriginTag
const&)
247 return os <<
"{ Origin Tag tracking is disabled in release builds }";
260template <
bool in_circuit,
typename T>
inline void assign_origin_tag(T& elem,
const OriginTag&
tag)
262 if constexpr (in_circuit) {
263 if constexpr (is_iterable_v<T>) {
264 for (
auto& e : elem) {
265 e.set_origin_tag(
tag);
268 elem.set_origin_tag(
tag);
281template <
bool in_circuit,
typename T>
inline void check_origin_tag(T& elem,
const OriginTag&
tag)
283 if constexpr (in_circuit) {
284 if constexpr (is_iterable_v<T>) {
285 for (
auto& e : elem) {
303 if constexpr (in_circuit) {
304 for (
auto& entry : input) {
305 entry.unset_free_witness_tag();
320template <
bool in_circuit,
typename Codec,
typename T>
323 if constexpr (in_circuit) {
324 assign_origin_tag<in_circuit>(
const_cast<T&
>(component),
tag);
327 return Codec::serialize_to_fields(component);
338template <
typename TranscriptType>
inline OriginTag
extract_transcript_tag(
const TranscriptType& transcript)
340 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 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