Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
to_radix.cpp
Go to the documentation of this file.
2
5
6namespace bb::avm2 {
7
8namespace {
9
10// The little endian decompositions of Fr modulus into limbs for each radix.
11// Radix goes up to 256 so we need 257 descompositions.
12std::array<std::vector<uint8_t>, 257> create_p_limbs_per_radix()
13{
14 std::array<std::vector<uint8_t>, 257> limbs_per_radix;
15
16 for (size_t radix = 2; radix < 257; ++radix) {
17 std::vector<uint8_t> p_limbs{};
18 p_limbs.reserve(31);
20 while (p > 0) {
21 p_limbs.push_back(static_cast<uint8_t>(p % radix));
22 p /= radix;
23 }
24
25 limbs_per_radix[radix] = p_limbs;
26 }
27
28 return limbs_per_radix;
29}
30
31} // namespace
32
34{
35 static const std::array<std::vector<uint8_t>, 257> limbs_per_radix = create_p_limbs_per_radix();
36 return limbs_per_radix;
37}
38
39} // namespace bb::avm2
const std::array< std::vector< uint8_t >, 257 > & get_p_limbs_per_radix()
Definition to_radix.cpp:33
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
static constexpr uint256_t modulus