Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::numeric::uint256_t Class Reference

#include <uint256.hpp>

Public Member Functions

constexpr uint256_t (const uint64_t a=0) noexcept
 
constexpr uint256_t (const uint64_t a, const uint64_t b, const uint64_t c, const uint64_t d) noexcept
 
constexpr uint256_t (const uint256_t &other) noexcept
 
constexpr uint256_t (uint256_t &&other) noexcept=default
 
constexpr uint256_t (std::string input) noexcept
 
constexpr operator uint128_t ()
 
constexpr uint256_toperator= (const uint256_t &other) noexcept=default
 
constexpr uint256_toperator= (uint256_t &&other) noexcept=default
 
constexpr ~uint256_t () noexcept=default
 
constexpr operator bool () const
 
template<std::integral T>
constexpr operator T () const
 
constexpr bool get_bit (uint64_t bit_index) const
 
constexpr uint64_t get_msb () const
 
constexpr uint256_t slice (uint64_t start, uint64_t end) const
 
constexpr uint256_t pow (const uint256_t &exponent) const
 
constexpr uint256_t operator+ (const uint256_t &other) const
 
constexpr uint256_t operator- (const uint256_t &other) const
 
constexpr uint256_t operator- () const
 
constexpr uint256_t operator* (const uint256_t &other) const
 
constexpr uint256_t operator/ (const uint256_t &other) const
 
constexpr uint256_t operator% (const uint256_t &other) const
 
constexpr uint256_t operator>> (const uint256_t &other) const
 
constexpr uint256_t operator<< (const uint256_t &other) const
 
constexpr uint256_t operator& (const uint256_t &other) const
 
constexpr uint256_t operator^ (const uint256_t &other) const
 
constexpr uint256_t operator| (const uint256_t &other) const
 
constexpr uint256_t operator~ () const
 
constexpr bool operator== (const uint256_t &other) const
 
constexpr bool operator!= (const uint256_t &other) const
 
constexpr bool operator! () const
 
constexpr bool operator> (const uint256_t &other) const
 
constexpr bool operator< (const uint256_t &other) const
 
constexpr bool operator>= (const uint256_t &other) const
 
constexpr bool operator<= (const uint256_t &other) const
 
constexpr uint256_toperator+= (const uint256_t &other)
 
constexpr uint256_toperator-= (const uint256_t &other)
 
constexpr uint256_toperator*= (const uint256_t &other)
 
constexpr uint256_toperator/= (const uint256_t &other)
 
constexpr uint256_toperator%= (const uint256_t &other)
 
constexpr uint256_toperator++ ()
 
constexpr uint256_toperator-- ()
 
constexpr uint256_toperator&= (const uint256_t &other)
 
constexpr uint256_toperator^= (const uint256_t &other)
 
constexpr uint256_toperator|= (const uint256_t &other)
 
constexpr uint256_toperator>>= (const uint256_t &other)
 
constexpr uint256_toperator<<= (const uint256_t &other)
 
constexpr std::pair< uint256_t, uint256_tmul_extended (const uint256_t &other) const
 Compute the result of multiplication modulu 2**512.
 
constexpr std::pair< uint256_t, uint256_tdivmod (const uint256_t &b) const
 
size_t hash () const noexcept
 
void msgpack_pack (auto &packer) const
 
void msgpack_unpack (auto o)
 
void msgpack_schema (auto &packer) const
 

Static Public Member Functions

static constexpr uint256_t from_uint128 (const uint128_t a) noexcept
 
static constexpr size_t length ()
 

Public Attributes

uint64_t data [4]
 

Static Private Member Functions

static constexpr std::pair< uint64_t, uint64_t > mul_wide (uint64_t a, uint64_t b)
 
static constexpr std::pair< uint64_t, uint64_t > addc (uint64_t a, uint64_t b, uint64_t carry_in)
 
static constexpr uint64_t addc_discard_hi (uint64_t a, uint64_t b, uint64_t carry_in)
 
static constexpr uint64_t sbb_discard_hi (uint64_t a, uint64_t b, uint64_t borrow_in)
 
static constexpr std::pair< uint64_t, uint64_t > sbb (uint64_t a, uint64_t b, uint64_t borrow_in)
 
static constexpr uint64_t mac_discard_hi (uint64_t a, uint64_t b, uint64_t c, uint64_t carry_in)
 
static constexpr std::pair< uint64_t, uint64_t > mac (uint64_t a, uint64_t b, uint64_t c, uint64_t carry_in)
 
static constexpr void wasm_madd (const uint64_t &left_limb, const uint64_t *right_limbs, uint64_t &result_0, uint64_t &result_1, uint64_t &result_2, uint64_t &result_3, uint64_t &result_4, uint64_t &result_5, uint64_t &result_6, uint64_t &result_7, uint64_t &result_8)
 Multiply one limb by 9 limbs and add to resulting limbs.
 
static constexpr std::array< uint64_t, WASM_NUM_LIMBSwasm_convert (const uint64_t *data)
 Convert from 4 64-bit limbs to 9 29-bit limbs.
 

Detailed Description

Definition at line 32 of file uint256.hpp.

Constructor & Destructor Documentation

◆ uint256_t() [1/5]

constexpr bb::numeric::uint256_t::uint256_t ( const uint64_t  a = 0)
inlineconstexprnoexcept

Definition at line 39 of file uint256.hpp.

◆ uint256_t() [2/5]

constexpr bb::numeric::uint256_t::uint256_t ( const uint64_t  a,
const uint64_t  b,
const uint64_t  c,
const uint64_t  d 
)
inlineconstexprnoexcept

Definition at line 43 of file uint256.hpp.

◆ uint256_t() [3/5]

constexpr bb::numeric::uint256_t::uint256_t ( const uint256_t other)
inlineconstexprnoexcept

Definition at line 47 of file uint256.hpp.

◆ uint256_t() [4/5]

constexpr bb::numeric::uint256_t::uint256_t ( uint256_t &&  other)
constexprdefaultnoexcept

◆ uint256_t() [5/5]

constexpr bb::numeric::uint256_t::uint256_t ( std::string  input)
inlineexplicitconstexprnoexcept

Definition at line 52 of file uint256.hpp.

◆ ~uint256_t()

constexpr bb::numeric::uint256_t::~uint256_t ( )
constexprdefaultnoexcept

Member Function Documentation

◆ addc()

constexpr std::pair< uint64_t, uint64_t > bb::numeric::uint256_t::addc ( uint64_t  a,
uint64_t  b,
uint64_t  carry_in 
)
staticconstexprprivate

Definition at line 31 of file uint256_impl.hpp.

◆ addc_discard_hi()

constexpr uint64_t bb::numeric::uint256_t::addc_discard_hi ( uint64_t  a,
uint64_t  b,
uint64_t  carry_in 
)
staticconstexprprivate

Definition at line 40 of file uint256_impl.hpp.

◆ divmod()

constexpr std::pair< uint256_t, uint256_t > bb::numeric::uint256_t::divmod ( const uint256_t b) const
constexpr

Definition at line 128 of file uint256_impl.hpp.

◆ from_uint128()

static constexpr uint256_t bb::numeric::uint256_t::from_uint128 ( const uint128_t  a)
inlinestaticconstexprnoexcept

Definition at line 94 of file uint256.hpp.

◆ get_bit()

constexpr bool bb::numeric::uint256_t::get_bit ( uint64_t  bit_index) const
constexpr

Definition at line 318 of file uint256_impl.hpp.

◆ get_msb()

constexpr uint64_t bb::numeric::uint256_t::get_msb ( ) const
constexpr

Definition at line 329 of file uint256_impl.hpp.

◆ hash()

size_t bb::numeric::uint256_t::hash ( ) const
inlinenoexcept

Definition at line 212 of file uint256.hpp.

◆ length()

static constexpr size_t bb::numeric::uint256_t::length ( )
inlinestaticconstexpr

Definition at line 140 of file uint256.hpp.

◆ mac()

constexpr std::pair< uint64_t, uint64_t > bb::numeric::uint256_t::mac ( uint64_t  a,
uint64_t  b,
uint64_t  c,
uint64_t  carry_in 
)
staticconstexprprivate

Definition at line 61 of file uint256_impl.hpp.

◆ mac_discard_hi()

constexpr uint64_t bb::numeric::uint256_t::mac_discard_hi ( uint64_t  a,
uint64_t  b,
uint64_t  c,
uint64_t  carry_in 
)
staticconstexprprivate

Definition at line 75 of file uint256_impl.hpp.

◆ msgpack_pack()

void bb::numeric::uint256_t::msgpack_pack ( auto &  packer) const

Definition at line 629 of file uint256_impl.hpp.

◆ msgpack_schema()

void bb::numeric::uint256_t::msgpack_schema ( auto &  packer) const
inline

Definition at line 217 of file uint256.hpp.

◆ msgpack_unpack()

void bb::numeric::uint256_t::msgpack_unpack ( auto  o)

Definition at line 642 of file uint256_impl.hpp.

◆ mul_extended()

constexpr std::pair< uint256_t, uint256_t > bb::numeric::uint256_t::mul_extended ( const uint256_t other) const
constexpr

Compute the result of multiplication modulu 2**512.

Definition at line 180 of file uint256_impl.hpp.

◆ mul_wide()

constexpr std::pair< uint64_t, uint64_t > bb::numeric::uint256_t::mul_wide ( uint64_t  a,
uint64_t  b 
)
staticconstexprprivate

Definition at line 13 of file uint256_impl.hpp.

◆ operator bool()

constexpr bb::numeric::uint256_t::operator bool ( ) const
inlineexplicitconstexpr

Definition at line 105 of file uint256.hpp.

◆ operator T()

template<std::integral T>
constexpr bb::numeric::uint256_t::operator T ( ) const
inlineexplicitconstexpr

Definition at line 107 of file uint256.hpp.

◆ operator uint128_t()

constexpr bb::numeric::uint256_t::operator uint128_t ( )
inlineexplicitconstexpr

Definition at line 99 of file uint256.hpp.

◆ operator!()

constexpr bool bb::numeric::uint256_t::operator! ( ) const
constexpr

Definition at line 503 of file uint256_impl.hpp.

◆ operator!=()

constexpr bool bb::numeric::uint256_t::operator!= ( const uint256_t other) const
constexpr

Definition at line 498 of file uint256_impl.hpp.

◆ operator%()

constexpr uint256_t bb::numeric::uint256_t::operator% ( const uint256_t other) const
constexpr

Definition at line 468 of file uint256_impl.hpp.

◆ operator%=()

constexpr uint256_t & bb::numeric::uint256_t::operator%= ( const uint256_t other)
inlineconstexpr

Definition at line 162 of file uint256.hpp.

◆ operator&()

constexpr uint256_t bb::numeric::uint256_t::operator& ( const uint256_t other) const
constexpr

Definition at line 473 of file uint256_impl.hpp.

◆ operator&=()

constexpr uint256_t & bb::numeric::uint256_t::operator&= ( const uint256_t other)
inlineconstexpr

Definition at line 179 of file uint256.hpp.

◆ operator*()

constexpr uint256_t bb::numeric::uint256_t::operator* ( const uint256_t other) const
constexpr

Definition at line 362 of file uint256_impl.hpp.

◆ operator*=()

constexpr uint256_t & bb::numeric::uint256_t::operator*= ( const uint256_t other)
inlineconstexpr

Definition at line 152 of file uint256.hpp.

◆ operator+()

constexpr uint256_t bb::numeric::uint256_t::operator+ ( const uint256_t other) const
constexpr

Definition at line 338 of file uint256_impl.hpp.

◆ operator++()

constexpr uint256_t & bb::numeric::uint256_t::operator++ ( )
inlineconstexpr

Definition at line 168 of file uint256.hpp.

◆ operator+=()

constexpr uint256_t & bb::numeric::uint256_t::operator+= ( const uint256_t other)
inlineconstexpr

Definition at line 142 of file uint256.hpp.

◆ operator-() [1/2]

constexpr uint256_t bb::numeric::uint256_t::operator- ( ) const
constexpr

Definition at line 357 of file uint256_impl.hpp.

◆ operator-() [2/2]

constexpr uint256_t bb::numeric::uint256_t::operator- ( const uint256_t other) const
constexpr

Definition at line 347 of file uint256_impl.hpp.

◆ operator--()

constexpr uint256_t & bb::numeric::uint256_t::operator-- ( )
inlineconstexpr

Definition at line 173 of file uint256.hpp.

◆ operator-=()

constexpr uint256_t & bb::numeric::uint256_t::operator-= ( const uint256_t other)
inlineconstexpr

Definition at line 147 of file uint256.hpp.

◆ operator/()

constexpr uint256_t bb::numeric::uint256_t::operator/ ( const uint256_t other) const
constexpr

Definition at line 463 of file uint256_impl.hpp.

◆ operator/=()

constexpr uint256_t & bb::numeric::uint256_t::operator/= ( const uint256_t other)
inlineconstexpr

Definition at line 157 of file uint256.hpp.

◆ operator<()

constexpr bool bb::numeric::uint256_t::operator< ( const uint256_t other) const
constexpr

Definition at line 523 of file uint256_impl.hpp.

◆ operator<<()

constexpr uint256_t bb::numeric::uint256_t::operator<< ( const uint256_t other) const
constexpr

Definition at line 581 of file uint256_impl.hpp.

◆ operator<<=()

constexpr uint256_t & bb::numeric::uint256_t::operator<<= ( const uint256_t other)
inlineconstexpr

Definition at line 200 of file uint256.hpp.

◆ operator<=()

constexpr bool bb::numeric::uint256_t::operator<= ( const uint256_t other) const
constexpr

Definition at line 528 of file uint256_impl.hpp.

◆ operator=() [1/2]

constexpr uint256_t & bb::numeric::uint256_t::operator= ( const uint256_t other)
constexprdefaultnoexcept

◆ operator=() [2/2]

constexpr uint256_t & bb::numeric::uint256_t::operator= ( uint256_t &&  other)
constexprdefaultnoexcept

◆ operator==()

constexpr bool bb::numeric::uint256_t::operator== ( const uint256_t other) const
constexpr

Definition at line 493 of file uint256_impl.hpp.

◆ operator>()

constexpr bool bb::numeric::uint256_t::operator> ( const uint256_t other) const
constexpr

Definition at line 508 of file uint256_impl.hpp.

◆ operator>=()

constexpr bool bb::numeric::uint256_t::operator>= ( const uint256_t other) const
constexpr

Definition at line 518 of file uint256_impl.hpp.

◆ operator>>()

constexpr uint256_t bb::numeric::uint256_t::operator>> ( const uint256_t other) const
constexpr

Definition at line 533 of file uint256_impl.hpp.

◆ operator>>=()

constexpr uint256_t & bb::numeric::uint256_t::operator>>= ( const uint256_t other)
inlineconstexpr

Definition at line 195 of file uint256.hpp.

◆ operator^()

constexpr uint256_t bb::numeric::uint256_t::operator^ ( const uint256_t other) const
constexpr

Definition at line 478 of file uint256_impl.hpp.

◆ operator^=()

constexpr uint256_t & bb::numeric::uint256_t::operator^= ( const uint256_t other)
inlineconstexpr

Definition at line 184 of file uint256.hpp.

◆ operator|()

constexpr uint256_t bb::numeric::uint256_t::operator| ( const uint256_t other) const
constexpr

Definition at line 483 of file uint256_impl.hpp.

◆ operator|=()

constexpr uint256_t & bb::numeric::uint256_t::operator|= ( const uint256_t other)
inlineconstexpr

Definition at line 189 of file uint256.hpp.

◆ operator~()

constexpr uint256_t bb::numeric::uint256_t::operator~ ( ) const
constexpr

Definition at line 488 of file uint256_impl.hpp.

◆ pow()

constexpr uint256_t bb::numeric::uint256_t::pow ( const uint256_t exponent) const
constexpr

Definition at line 298 of file uint256_impl.hpp.

◆ sbb()

constexpr std::pair< uint64_t, uint64_t > bb::numeric::uint256_t::sbb ( uint64_t  a,
uint64_t  b,
uint64_t  borrow_in 
)
staticconstexprprivate

Definition at line 45 of file uint256_impl.hpp.

◆ sbb_discard_hi()

constexpr uint64_t bb::numeric::uint256_t::sbb_discard_hi ( uint64_t  a,
uint64_t  b,
uint64_t  borrow_in 
)
staticconstexprprivate

Definition at line 55 of file uint256_impl.hpp.

◆ slice()

constexpr uint256_t bb::numeric::uint256_t::slice ( uint64_t  start,
uint64_t  end 
) const
constexpr

Viewing this uint256_t as a bit string, and counting bits from 0, slices a substring.

Returns
the uint256_t equal to the substring of bits from (and including) the start-th bit, to (but excluding) the end-th bit of this.

Definition at line 291 of file uint256_impl.hpp.

◆ wasm_convert()

constexpr std::array< uint64_t, WASM_NUM_LIMBS > bb::numeric::uint256_t::wasm_convert ( const uint64_t *  data)
staticconstexprprivate

Convert from 4 64-bit limbs to 9 29-bit limbs.

Definition at line 115 of file uint256_impl.hpp.

◆ wasm_madd()

constexpr void bb::numeric::uint256_t::wasm_madd ( const uint64_t &  left_limb,
const uint64_t *  right_limbs,
uint64_t &  result_0,
uint64_t &  result_1,
uint64_t &  result_2,
uint64_t &  result_3,
uint64_t &  result_4,
uint64_t &  result_5,
uint64_t &  result_6,
uint64_t &  result_7,
uint64_t &  result_8 
)
staticconstexprprivate

Multiply one limb by 9 limbs and add to resulting limbs.

Definition at line 88 of file uint256_impl.hpp.

Member Data Documentation

◆ data

uint64_t bb::numeric::uint256_t::data[4]

Definition at line 208 of file uint256.hpp.


The documentation for this class was generated from the following files: