|
barretenberg
|
Public Member Functions | |
| safe_uint_t (field_ct const &value, size_t bit_num, std::string const &description="unknown") | |
| safe_uint_t (const barretenberg::fr &const_value) | |
| safe_uint_t (const uint256_t &const_value) | |
| safe_uint_t (const unsigned int &const_value) | |
| safe_uint_t (const safe_uint_t &other) | |
| safe_uint_t (const bool_ct &other) | |
| operator bool_ct () | |
| 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. | |
| safe_uint_t | operator- (const safe_uint_t &other) const |
| Subtraction on two safe_uint_t objects. | |
| 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) const |
| Potentially less efficient than divide function - bounds remainder and quotient by max of this. | |
| safe_uint_t | add_two (const safe_uint_t &add_a, const safe_uint_t &add_b) const |
| safe_uint_t | madd (const safe_uint_t &to_mul, const safe_uint_t &to_add) const |
| safe_uint_t & | operator= (const safe_uint_t &other) |
| safe_uint_t & | operator= (safe_uint_t &&other) |
| safe_uint_t | operator+= (const safe_uint_t &other) |
| safe_uint_t | operator*= (const safe_uint_t &other) |
| std::array< safe_uint_t< Builder >, 3 > | slice (const uint8_t msb, const uint8_t lsb) const |
| void | set_public () const |
| operator field_ct () | |
| operator field_ct () const | |
| 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 |
| bool_ct | operator!= (const safe_uint_t &other) const |
| safe_uint_t | normalize () const |
| barretenberg::fr | get_value () const |
| Builder * | get_context () const |
| bool_ct | is_zero () const |
| void | assert_equal (const safe_uint_t &rhs, std::string const &msg="safe_uint_t::assert_equal") const |
| void | assert_is_not_zero (std::string const &msg="safe_uint_t::assert_is_not_zero") const |
| void | assert_is_zero (std::string const &msg="safe_uint_t::assert_is_zero") const |
| bool | is_constant () const |
| uint32_t | get_witness_index () const |
Static Public Member Functions | |
| static safe_uint_t< Builder > | create_constant_witness (Builder *parent_context, barretenberg::fr const &value) |
| static safe_uint_t | from_witness_index (Builder *parent_context, const uint32_t witness_index) |
| static safe_uint_t | conditional_assign (const bool_ct &predicate, const safe_uint_t &lhs, const safe_uint_t &rhs) |
Public Attributes | |
| field_ct | value |
| uint256_t | current_max |
Static Public Attributes | |
| static constexpr size_t | MAX_BIT_NUM = barretenberg::fr::modulus.get_msb() |
| static constexpr uint256_t | MAX_VALUE = barretenberg::fr::modulus - 1 |
| static constexpr size_t | IS_UNSAFE = 143 |
| safe_uint_t< Builder > proof_system::plonk::stdlib::safe_uint_t< Builder >::divide | ( | const safe_uint_t< Builder > & | 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
| Builder |
| other | |
| quotient_bit_size | |
| remainder_bit_size | |
| description | |
| get_quotient |
| bool_t< Builder > proof_system::plonk::stdlib::safe_uint_t< Builder >::is_zero |
is_zero will return a bool_ct, and add constraints that enforce its correctness N.B. If you want to ENFORCE that a safe_uint_t object is zero, use assert_is_zero
| safe_uint_t< Builder > proof_system::plonk::stdlib::safe_uint_t< Builder >::normalize |
normalize returns a safe_uint_t element where multiplicative_constant = 1 and additive_constant = 0 i.e. the value is defined entirely by the builder variable that witness_index points to If the witness_index is ever needed, normalize should be called first
Will cost 1 constraint if the field element is not already normalized (or is constant)
| safe_uint_t< Builder > proof_system::plonk::stdlib::safe_uint_t< Builder >::operator- | ( | const safe_uint_t< Builder > & | other | ) | const |
Subtraction on two safe_uint_t objects.
The function first checks the case when both operands are constants and there is underflow. Then, it computes the difference and create a safe_uint_t from its value with the same max value as current_max. Constructing the difference safe_uint_t will create a range constraint, which catches underflow as long as the difference value does not end up in the range [0, current_max]. The only case where it is possible that the difference value can end up in this range, is when current_max + other.current_max exceeds MAX_VALUE (the modulus - 1), so we throw an error in this case.
| Builder |
| other |
| safe_uint_t< Builder > proof_system::plonk::stdlib::safe_uint_t< Builder >::operator/ | ( | const safe_uint_t< Builder > & | other | ) | const |
Potentially less efficient than divide function - bounds remainder and quotient by max of this.
| Builder |
| other |
| safe_uint_t< Builder > proof_system::plonk::stdlib::safe_uint_t< Builder >::subtract | ( | const safe_uint_t< Builder > & | other, |
| const size_t | difference_bit_size, | ||
| std::string const & | description = "" |
||
| ) | const |
Subtraction when you have a pre-determined bound on the difference size.
Same as operator- except with this pre-determined bound difference_bit_size.
| Builder |
| other | |
| difference_bit_size | |
| description |