8#include "../bool/bool.hpp"
9#include "../circuit_builders/circuit_builders.hpp"
10#include "../circuit_builders/circuit_builders_fwd.hpp"
11#include "../field/field.hpp"
12#include "../witness/witness.hpp"
84 parent_context->assert_equal_constant(out.
witness_index,
value,
"create_constant_witness");
86 result.set_free_witness_tag();
102 const size_t difference_bit_size,
103 std::string
const& description =
"")
const;
110 const size_t quotient_bit_size,
111 const size_t remainder_bit_size,
112 std::string
const& description =
"",
133 "Exceeded modulus in madd");
155 *
this = *
this + other;
161 *
this = *
this * other;
197 void assert_is_not_zero(std::string
const& msg =
"safe_uint_t::assert_is_not_zero")
const;
198 void assert_is_zero(std::string
const& msg =
"safe_uint_t::assert_is_zero")
const;
218 return os << v.
value;
#define BB_ASSERT_EQ(actual, expected,...)
#define BB_ASSERT_LTE(left, right,...)
constexpr uint64_t get_msb() const
Implements boolean logic in-circuit.
uint32_t set_public() const
void assert_equal(const field_t &rhs, std::string const &msg="field_t::assert_equal") const
Copy constraint: constrain that *this field is equal to rhs element.
field_t madd(const field_t &to_mul, const field_t &to_add) const
void create_range_constraint(size_t num_bits, std::string const &msg="field_t::range_constraint") const
Let x = *this.normalize(), constrain x.v < 2^{num_bits}.
void unset_free_witness_tag() const
Unset the free witness flag for the field element's tag.
OriginTag get_origin_tag() const
void set_free_witness_tag()
Set the free witness flag for the field element's tag.
void set_origin_tag(const OriginTag &new_tag) const
field_t add_two(const field_t &add_b, const field_t &add_c) const
Efficiently compute (this + a + b) using big_mul gate.
uint32_t get_witness_index() const
Get the witness index of the current field element.
safe_uint_t & operator=(safe_uint_t &&other)
void assert_is_zero(std::string const &msg="safe_uint_t::assert_is_zero") const
safe_uint_t(const unsigned int &const_value)
safe_uint_t subtract(const safe_uint_t &other, const size_t difference_bit_size, std::string const &description="") const
Subtraction when you have a pre-determined bound on the difference size.
bool_t< Builder > bool_ct
safe_uint_t operator/(const safe_uint_t &other) const
Potentially less efficient than divide function - bounds remainder and quotient by max of this.
static constexpr uint256_t MAX_VALUE
safe_uint_t(field_ct const &value, size_t bit_num, std::string const &description="unknown")
safe_uint_t & operator=(const safe_uint_t &other)
static constexpr size_t IS_UNSAFE
static safe_uint_t< Builder > create_constant_witness(Builder *parent_context, bb::fr const &value)
void assert_equal(const safe_uint_t &rhs, std::string const &msg="safe_uint_t::assert_equal") const
safe_uint_t(const safe_uint_t &other)
static safe_uint_t from_witness_index(Builder *parent_context, const uint32_t witness_index)
OriginTag get_origin_tag() const
uint32_t get_witness_index() const
safe_uint_t normalize() const
static constexpr size_t MAX_BIT_NUM
std::array< safe_uint_t< Builder >, 3 > slice(const uint8_t msb, const uint8_t lsb) const
safe_uint_t(const bb::fr &const_value)
bool_ct operator==(const safe_uint_t &other) const
safe_uint_t(const uint256_t &const_value)
safe_uint_t operator-(const safe_uint_t &other) const
Subtraction on two safe_uint_t objects.
void set_origin_tag(OriginTag tag) const
Builder * get_context() const
void set_free_witness_tag()
safe_uint_t(field_ct const &value, const uint256_t ¤t_max, size_t safety)
void unset_free_witness_tag()
safe_uint_t add_two(const safe_uint_t &add_a, const safe_uint_t &add_b) const
static safe_uint_t conditional_assign(const bool_ct &predicate, const safe_uint_t &lhs, const safe_uint_t &rhs)
safe_uint_t(const bool_ct &other)
safe_uint_t operator*(const safe_uint_t &other) const
safe_uint_t operator+(const safe_uint_t &other) const
bool_ct operator!=(const safe_uint_t &other) const
safe_uint_t divide(const safe_uint_t &other, const size_t quotient_bit_size, const size_t remainder_bit_size, std::string const &description="", const std::function< std::pair< uint256_t, uint256_t >(uint256_t, uint256_t)> &get_quotient=[](uint256_t val, uint256_t divisor) { return std::make_pair((uint256_t)(val/(uint256_t) divisor),(uint256_t)(val %(uint256_t) divisor));}) const
division when you have a pre-determined bound on the sizes of the quotient and remainder
safe_uint_t operator*=(const safe_uint_t &other)
void assert_is_not_zero(std::string const &msg="safe_uint_t::assert_is_not_zero") const
field_t< Builder > field_ct
safe_uint_t operator+=(const safe_uint_t &other)
safe_uint_t madd(const safe_uint_t &to_mul, const safe_uint_t &to_add) const
std::string format(Args... args)
std::ostream & operator<<(std::ostream &os, uint256_t const &a)
Entry point for Barretenberg command-line interface.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
static constexpr uint256_t modulus