27template <
typename Builder>
38 std::vector<uint64_t> native_slices;
39 stdlib_slices.reserve(num_slices);
40 native_slices.reserve(num_slices);
43 return { stdlib_slices, native_slices };
47 const uint64_t table_mask = (1ULL << table_bits) - 1ULL;
49 for (
size_t i = 0; i < num_slices; ++i) {
50 uint64_t slice_value =
static_cast<uint64_t
>(raw_value.
data[0]) & table_mask;
51 stdlib_slices.push_back(
field_ct(slice_value));
52 native_slices.push_back(slice_value);
53 raw_value = raw_value >> table_bits;
55 return { stdlib_slices, native_slices };
59 const auto slice_indices =
63 "straus_scalar_slice decompose_into_default_range");
64 for (
auto const& idx : slice_indices) {
66 stdlib_slices.push_back(
slice);
67 native_slices.push_back(
static_cast<uint64_t
>(
slice.get_value()));
69 return { stdlib_slices, native_slices };
81template <
typename Builder>
84 const size_t table_bits)
85 : _table_bits(table_bits)
88 const size_t lo_bits = scalar.
num_bits() > LO_BITS ? LO_BITS : scalar.
num_bits();
89 const size_t hi_bits = scalar.
num_bits() > LO_BITS ? scalar.
num_bits() - LO_BITS : 0;
116 BB_ASSERT_LT(index, slices.size(),
"Straus scalar slice index out of bounds!");
117 return slices[index];
#define BB_ASSERT_LT(left, right,...)
Represents a member of the Grumpkin curve scalar field (i.e. BN254 base field).
OriginTag get_origin_tag() const
Get the origin tag of the cycle_scalar (a merge of the lo and hi tags)
static field_t from_witness_index(Builder *ctx, uint32_t witness_index)
bb::fr get_value() const
Given a := *this, compute its value given by a.v * a.mul + a.add.
uint32_t get_normalized_witness_index() const
Get the index of a normalized version of this element.
straus_scalar_slices decomposes an input scalar into bit-slices of size table_bits....
std::vector< uint64_t > slices_native
static std::pair< std::vector< field_t >, std::vector< uint64_t > > compute_scalar_slices(Builder *context, const field_t &scalar, size_t num_bits, size_t table_bits)
Convert an input cycle_scalar field element into a vector of bit-slices.
field_t operator[](size_t index)
Return a bit-slice associated with round index.
straus_scalar_slices(Builder *context, const cycle_scalar< Builder > &scalars, size_t table_bits)
Construct straus_scalar_slices from an input cycle_scalar and specified table_bits.
std::vector< field_t > slices
StrictMock< MockContext > context
stdlib::field_t< Builder > field_ct
constexpr T ceil_div(const T &numerator, const T &denominator)
Computes the ceiling of the division of two integral types.
std::conditional_t< IsGoblinBigGroup< C, Fq, Fr, G >, element_goblin::goblin_element< C, goblin_field< C >, Fr, G >, element_default::element< C, Fq, Fr, G > > element
element wraps either element_default::element or element_goblin::goblin_element depending on parametr...
C slice(C const &container, size_t start)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept