Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
origin_tag.hpp File Reference

This file contains part of the logic for the Origin Tag mechanism that tracks the use of in-circuit primitives through tainting (common term meaning adding information that allows to track value origins) them. It then allows us to detect dangerous behaviours in-circuit. The mechanism is only enabled in DEBUG builds. More...

#include "barretenberg/common/assert.hpp"
#include "barretenberg/common/throw_or_abort.hpp"
#include "barretenberg/numeric/uint256/uint256.hpp"
#include <atomic>
#include <cstddef>
#include <iterator>
#include <ostream>
#include <type_traits>
#include <vector>

Go to the source code of this file.

Classes

struct  is_iterable< T, typename >
 
struct  is_iterable< T, std::void_t< decltype(std::begin(std::declval< T & >())), decltype(std::end(std::declval< T & >()))> >
 
struct  bb::OriginTag
 

Namespaces

namespace  bb
 Entry point for Barretenberg command-line interface.
 

Concepts

concept  usesTag
 

Macros

#define STANDARD_TESTING_TAGS
 

Functions

void bb::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.
 
std::ostream & bb::operator<< (std::ostream &os, OriginTag const &v)
 
template<bool in_circuit, typename T >
void bb::assign_origin_tag (T &elem, const OriginTag &tag)
 Assigns an origin tag to an element or all elements in an iterable container.
 
template<bool in_circuit, typename T >
void bb::check_origin_tag (T &elem, const OriginTag &tag)
 Checks that an element or all elements in an iterable container have the expected origin tag.
 
template<bool in_circuit, typename DataType >
void bb::unset_free_witness_tags (std::vector< DataType > &input)
 Unsets free witness tags on all elements in a vector.
 
template<bool in_circuit, typename Codec , typename T >
std::vector< typename Codec::DataType > bb::tag_and_serialize (const T &component, const OriginTag &tag)
 Tag a component with a given origin tag and serialize it to field elements.
 
template<typename TranscriptType >
OriginTag bb::extract_transcript_tag (const TranscriptType &transcript)
 Extract origin tag context from a transcript.
 

Variables

template<typename T >
constexpr bool is_iterable_v = is_iterable<T>::value
 

Detailed Description

This file contains part of the logic for the Origin Tag mechanism that tracks the use of in-circuit primitives through tainting (common term meaning adding information that allows to track value origins) them. It then allows us to detect dangerous behaviours in-circuit. The mechanism is only enabled in DEBUG builds.

Author
Rumata888

Definition in file origin_tag.hpp.

Macro Definition Documentation

◆ STANDARD_TESTING_TAGS

#define STANDARD_TESTING_TAGS
Value:
/*Tags reused in tests*/ \
const size_t parent_id = 0; \
[[maybe_unused]] const auto clear_tag = OriginTag::constant(); /* A tag representing a constant value */ \
[[maybe_unused]] const auto constant_tag = OriginTag::constant(); /* Alias for clear_tag */ \
[[maybe_unused]] const auto submitted_value_origin_tag = OriginTag( \
parent_id, /*round_id=*/0, /*is_submitted=*/true); /*A tag describing a value submitted in the 0th round*/ \
[[maybe_unused]] const auto next_submitted_value_origin_tag = OriginTag( \
parent_id, /*round_id=*/1, /*is_submitted=*/true); /*A tag describing a value submitted in the 1st round*/ \
[[maybe_unused]] const auto challenge_origin_tag = OriginTag( \
parent_id, /*round_id=*/0, /*is_submitted=*/false); /*A tag describing a challenge derived in the 0th round*/ \
[[maybe_unused]] const auto next_challenge_tag = OriginTag( \
parent_id, /*round_id=*/1, /*is_submitted=*/false); /*A tag describing a challenge derived in the 1st round*/ \
[[maybe_unused]] const auto first_two_merged_tag = \
OriginTag(submitted_value_origin_tag, \
challenge_origin_tag); /*A tag describing a value constructed from values submitted by the prover in \
the 0th round and challenges from the same round */ \
[[maybe_unused]] const auto first_and_third_merged_tag = \
OriginTag(submitted_value_origin_tag, \
next_challenge_tag); /* A tag describing a value constructed from values submitted in the 0th round \
and challenges computed in the 1st round*/ \
[[maybe_unused]] const auto first_second_third_merged_tag = OriginTag( \
first_two_merged_tag, next_challenge_tag); /* A tag describing a value computed from values submitted in the \
0th round and challenges generated in the 0th and 1st round*/ \
[[maybe_unused]] const auto first_to_fourth_merged_tag = \
OriginTag(first_second_third_merged_tag, \
next_submitted_value_origin_tag); /* A tag describing a value computed from values submitted in the \
0th and 1st round and challenges generated in the 0th and 1st round*/ \
[[maybe_unused]] const auto instant_death_tag = \
OriginTag::poisoned(); /* A tag that causes an abort on any arithmetic*/

Definition at line 36 of file origin_tag.hpp.

Variable Documentation

◆ is_iterable_v

template<typename T >
constexpr bool is_iterable_v = is_iterable<T>::value
constexpr

Definition at line 34 of file origin_tag.hpp.