|
Barretenberg
The ZK-SNARK library at the core of Aztec
|
Classes | |
| class | DebugEngine |
| class | RandomEngine |
| class | RNG |
| class | sparse_int |
| Integer type that stores each bit as a separate digit in the given base. Supports addition with single-pass carry propagation. Used to build plookup tables for bitwise operations (XOR, AND) where two sparse_ints are added and the resulting per-digit values encode the operation's truth table. More... | |
| class | uint256_t |
| class | uintx |
Typedefs | |
| using | uint512_t = uintx< uint256_t > |
| using | uint1024_t = uintx< uint512_t > |
Functions | |
| template<typename T > | |
| constexpr size_t | count_leading_zeros (T const &u) |
| template<> | |
| constexpr size_t | count_leading_zeros< uint32_t > (uint32_t const &u) |
| template<> | |
| constexpr size_t | count_leading_zeros< uint64_t > (uint64_t const &u) |
| template<> | |
| constexpr size_t | count_leading_zeros< uint128_t > (uint128_t const &u) |
| template<> | |
| constexpr size_t | count_leading_zeros< uint256_t > (uint256_t const &u) |
| constexpr uint32_t | get_msb32 (const uint32_t in) |
| constexpr uint64_t | get_msb64 (const uint64_t in) |
| template<typename T > | |
| constexpr T | get_msb (const T in) |
| constexpr uint32_t | get_lsb32 (const uint32_t in) |
| constexpr uint64_t | get_lsb64 (const uint64_t in) |
| template<typename T > | |
| constexpr T | get_lsb (const T in) |
| template<typename T > | |
| constexpr T | round_up_power_2 (const T in) |
| template<typename T > | |
| T | keep_n_lsb (T const &input, size_t num_bits) |
| constexpr uint64_t | pow64 (const uint64_t input, const uint64_t exponent) |
| constexpr bool | is_power_of_two (uint64_t x) |
| constexpr uint64_t | rotate64 (const uint64_t value, const uint64_t rotation) |
| constexpr uint32_t | rotate32 (const uint32_t value, const uint32_t rotation) |
| std::vector< uint64_t > | slice_input (const uint256_t &input, const uint64_t base, const size_t num_slices) |
| Decompose a uint256_t into digits in the given base (least-significant digit first). If num_slices > 0, returns exactly that many digits. If num_slices == 0, returns as many as needed. | |
| std::vector< uint64_t > | slice_input_using_variable_bases (const uint256_t &input, const std::vector< uint64_t > &bases) |
| Decompose a uint256_t using a different base for each digit position (least-significant first). Throws if the input is too large to be fully represented by the given bases. | |
| template<uint64_t base, uint64_t num_slices> | |
| constexpr std::array< uint256_t, num_slices > | get_base_powers () |
| Compute [1, base, base^2, ..., base^(num_slices-1)] as uint256_t values. | |
| template<uint64_t base> | |
| constexpr uint256_t | map_into_sparse_form (const uint64_t input) |
| Encode a 32-bit value into sparse form: each binary bit of input becomes a digit in the given base. E.g. with base=3, binary 0b101 becomes 1*3^2 + 0*3^1 + 1*3^0 = 10. Used by plookup tables (SHA256, Keccak, AES, Blake2s) to encode XOR/AND via lookup-friendly representations. | |
| template<uint64_t base> | |
| constexpr uint64_t | map_from_sparse_form (const uint256_t &input) |
| Decode a sparse-form uint256_t back to a 32-bit value. Extracts the base-adic digits from most-significant to least-significant, and recovers the original binary value by reading the low bit of each digit. | |
| template<typename T > | |
| constexpr T | ceil_div (const T &numerator, const T &denominator) |
| Computes the ceiling of the division of two integral types. | |
| RNG & | get_debug_randomness (bool reset, std::uint_fast64_t seed) |
| RNG & | get_randomness () |
| std::ostream & | operator<< (std::ostream &os, uint256_t const &a) |
| template<typename B > | |
| void | read (B &it, uint256_t &value) |
| template<typename B > | |
| void | write (B &it, uint256_t const &value) |
| template<typename B , typename Params > | |
| void | read (B &it, uintx< Params > &value) |
| template<typename B , typename Params > | |
| void | write (B &it, uintx< Params > const &value) |
| template<class base_uint > | |
| std::ostream & | operator<< (std::ostream &os, uintx< base_uint > const &a) |
| constexpr uint512_t | TEST_MODULUS (uint256_t{ "0x04689e957a1242c84a50189c6d96cadca602072d09eac1013b5458a2275d69b1" }, uint256_t{ "0x0925c4b8763cbf9c599a6f7c0348d21cb00b85511637560626edfa5c34c6b38d" }) |
uint256_t Copyright Aztec 2020
An unsigned 256 bit integer type.
Constructor and all methods are constexpr. Ideally, uint256_t should be able to be treated like any other literal type.
Not optimized for performance, this code doesn't touch any of our hot paths when constructing proofs.
uintx: a wide unsigned integer formed by pairing two base_uint halves (lo, hi).
Instantiated as: uintx<uint256_t> = uint512_t (two 256-bit halves) uintx<uint512_t> = uint1024_t (two 512-bit halves)
Constructor and all methods are constexpr. Not optimized for performance; does not touch hot paths when constructing proofs.
| using bb::numeric::uint1024_t = typedef uintx<uint512_t> |
| using bb::numeric::uint512_t = typedef uintx<uint256_t> |
|
constexpr |
Computes the ceiling of the division of two integral types.
Calculates the ceiling of the division of numerator by denominator. Ensures that the denominator is greater than zero and that the type is an integral type.
| T | The integral type of numerator and denominator. |
| numerator | The value to be divided. |
| denominator | The value to divide by. |
Definition at line 23 of file general.hpp.
|
inlineconstexpr |
Returns the number of leading 0 bits for a given integer type. Implemented in terms of intrinsics which will use instructions such as bsr or lzcnt for best performance. Undefined behavior when input is 0.
|
inlineconstexpr |
Definition at line 31 of file count_leading_zeros.hpp.
|
inlineconstexpr |
Definition at line 44 of file count_leading_zeros.hpp.
|
inlineconstexpr |
Definition at line 21 of file count_leading_zeros.hpp.
|
inlineconstexpr |
Definition at line 26 of file count_leading_zeros.hpp.
|
constexpr |
Compute [1, base, base^2, ..., base^(num_slices-1)] as uint256_t values.
Definition at line 65 of file sparse_form.hpp.
| RNG & bb::numeric::get_debug_randomness | ( | bool | reset, |
| std::uint_fast64_t | seed | ||
| ) |
Used by tests to ensure consistent behavior.
Definition at line 217 of file engine.cpp.
|
inlineconstexpr |
Definition at line 70 of file get_msb.hpp.
|
inlineconstexpr |
Definition at line 54 of file get_msb.hpp.
|
inlineconstexpr |
Definition at line 62 of file get_msb.hpp.
|
inlineconstexpr |
Definition at line 49 of file get_msb.hpp.
|
inlineconstexpr |
Definition at line 16 of file get_msb.hpp.
|
inlineconstexpr |
Definition at line 32 of file get_msb.hpp.
| RNG & bb::numeric::get_randomness | ( | ) |
Default engine. If wanting consistent proof construction, uncomment the line to return the debug engine.
Definition at line 230 of file engine.cpp.
|
constexpr |
|
inline |
Definition at line 12 of file keep_n_lsb.hpp.
|
constexpr |
Decode a sparse-form uint256_t back to a 32-bit value. Extracts the base-adic digits from most-significant to least-significant, and recovers the original binary value by reading the low bit of each digit.
Definition at line 100 of file sparse_form.hpp.
|
constexpr |
Encode a 32-bit value into sparse form: each binary bit of input becomes a digit in the given base. E.g. with base=3, binary 0b101 becomes 1*3^2 + 0*3^1 + 1*3^0 = 10. Used by plookup tables (SHA256, Keccak, AES, Blake2s) to encode XOR/AND via lookup-friendly representations.
Definition at line 80 of file sparse_form.hpp.
|
inline |
Definition at line 258 of file uint256.hpp.
|
inline |
|
constexpr |
|
inline |
Definition at line 267 of file uint256.hpp.
|
inlineconstexpr |
Definition at line 18 of file rotate.hpp.
|
inlineconstexpr |
Definition at line 13 of file rotate.hpp.
|
inlineconstexpr |
Definition at line 75 of file get_msb.hpp.
|
inline |
Decompose a uint256_t into digits in the given base (least-significant digit first). If num_slices > 0, returns exactly that many digits. If num_slices == 0, returns as many as needed.
Definition at line 23 of file sparse_form.hpp.
|
inline |
Decompose a uint256_t using a different base for each digit position (least-significant first). Throws if the input is too large to be fully represented by the given bases.
Definition at line 46 of file sparse_form.hpp.
|
constexpr |
|
inline |
Definition at line 281 of file uint256.hpp.