7#include "../field/field.hpp"
8#include "../field/field_utils.hpp"
30 *
this = constant_infinity(_context);
40template <
typename Builder>
71 if (assert_on_curve) {
85template <
typename Builder>
89 , _is_infinity(is_infinity)
91 if (_x.get_context() !=
nullptr) {
93 }
else if (_y.get_context() !=
nullptr) {
100 *
this = constant_infinity(this->
context);
105 if (_x.is_constant() != _y.is_constant()) {
106 if (_x.is_constant()) {
107 _x.convert_constant_to_fixed_witness(
context);
109 _y.convert_constant_to_fixed_witness(
context);
114 BB_ASSERT(!(_x.is_constant() && _y.is_constant() && !_is_infinity.is_constant()),
115 "cycle_group: constant coordinates with non-constant infinity flag");
118 BB_ASSERT(get_value().on_curve(),
"cycle_group: Point is not on curve");
119 if (assert_on_curve) {
133template <
typename Builder>
135 : _x(_in.is_point_at_infinity() ? 0 : _in.x)
136 , _y(_in.is_point_at_infinity() ? 0 : _in.y)
137 , _is_infinity(_in.is_point_at_infinity())
167 if (_context !=
nullptr) {
188template <
typename Builder>
214template <
typename Builder>
220 result = constant_infinity(_context);
235 if (get_context() !=
nullptr) {
236 return get_context();
244 if (is_point_at_infinity().get_value()) {
260 static_assert(Group::curve_a == 0);
263 auto res = _y.madd(_y, -xxx - Group::curve_b);
265 res *= !is_point_at_infinity();
266 res.assert_is_zero();
297template <
typename Builder>
301 if (this->is_constant_point_at_infinity()) {
312 if (hint.has_value()) {
316 const bb::fr x1 = _x.get_value();
317 const bb::fr y1 = modified_y.get_value();
323 const bb::fr x_pow_4 = x1 * (y_pow_2 - Group::curve_b);
324 const bb::fr lambda_squared = (x_pow_4 * 9) / (y_pow_2 * 4);
325 const bb::fr lambda = (x1 * x1 * 3) / (y1 + y1);
326 x3 = lambda_squared - x1 - x1;
327 y3 = lambda * (x1 - x3) - y1;
333 result =
cycle_group(x3, y3, is_point_at_infinity(),
false);
342 .
x1 = _x.get_witness_index(),
343 .y1 = modified_y.get_witness_index(),
368template <
typename Builder>
374 BB_ASSERT(!this->is_constant_point_at_infinity(),
375 "cycle_group::_unconditional_add_or_subtract called on constant point at infinity");
377 "cycle_group::_unconditional_add_or_subtract called on constant point at infinity");
379 auto context = get_context(other);
383 const bool lhs_constant = is_constant();
386 if (lhs_constant && !rhs_constant) {
388 lhs.set_origin_tag(get_origin_tag());
389 return lhs._unconditional_add_or_subtract(other, is_addition, hint);
391 if (!lhs_constant && rhs_constant) {
394 return _unconditional_add_or_subtract(rhs, is_addition, hint);
400 if (hint.has_value()) {
416 if (lhs_constant && rhs_constant) {
424 .
x1 = _x.get_witness_index(),
425 .y1 = _y.get_witness_index(),
430 .is_addition = is_addition,
446template <
typename Builder>
450 return _unconditional_add_or_subtract(other,
true, hint);
459template <
typename Builder>
463 return _unconditional_add_or_subtract(other,
false, hint);
477template <
typename Builder>
481 const field_t x_delta = this->_x - other.
_x;
485 x_delta.
assert_is_not_zero(
"cycle_group::checked_unconditional_add, x-coordinate collision");
487 return unconditional_add(other, hint);
502template <
typename Builder>
506 const field_t x_delta = this->_x - other.
_x;
510 x_delta.
assert_is_not_zero(
"cycle_group::checked_unconditional_subtract, x-coordinate collision");
512 return unconditional_subtract(other, hint);
533 if (this->is_constant_point_at_infinity()) {
540 const bool_t x_coordinates_match = (_x == other.
_x);
541 const bool_t y_coordinates_match = (_y == other.
_y);
554 lambda = (y2 - y1).divide_no_zero_check(x_diff);
564 const field_t add_result_x = lambda.
madd(lambda, -(x2 + x1));
565 const field_t add_result_y = lambda.
madd(x1 - add_result_x, -y1);
571 const bool_t double_predicate = (x_coordinates_match && y_coordinates_match);
576 const bool_t lhs_infinity = is_point_at_infinity();
587 const bool_t infinity_predicate = (x_coordinates_match && !y_coordinates_match);
588 bool_t result_is_infinity = infinity_predicate && (!lhs_infinity && !rhs_infinity);
589 result_is_infinity = result_is_infinity || (lhs_infinity && rhs_infinity);
591 return cycle_group(result_x, result_y, result_is_infinity,
false);
612 if (this->is_constant_point_at_infinity()) {
622 const bool_t x_coordinates_match = (_x == other.
_x);
623 const bool_t y_coordinates_match = (_y == other.
_y);
636 lambda = (-y2 - y1).divide_no_zero_check(x_diff);
645 const field_t sub_result_x = lambda.
madd(lambda, -(x2 + x1));
646 const field_t sub_result_y = lambda.
madd(x1 - sub_result_x, -y1);
654 const bool_t double_predicate = (x_coordinates_match && !y_coordinates_match);
662 const bool_t lhs_infinity = is_point_at_infinity();
673 const bool_t infinity_predicate = (x_coordinates_match && y_coordinates_match);
675 bool_t result_is_infinity = infinity_predicate && (!lhs_infinity && !rhs_infinity);
676 result_is_infinity = result_is_infinity || (lhs_infinity && rhs_infinity);
678 return cycle_group(result_x, result_y, result_is_infinity,
false);
694 result.
_y = (-_y).normalize();
700 *
this = *
this + other;
706 *
this = *
this - other;
730template <
typename Builder>
735 const bool unconditional_add)
737 BB_ASSERT_EQ(!scalars.empty(),
true,
"Empty scalars provided to variable base batch mul!");
738 BB_ASSERT_EQ(scalars.size(), base_points.size(),
"Points/scalars size mismatch in variable base batch mul!");
739 BB_ASSERT_EQ(offset_generators.size(), base_points.size() + 1,
"Too few offset generators provided!");
740 const size_t num_points = scalars.size();
744 for (
auto [scalar, point] :
zip_view(scalars, base_points)) {
759 scalar_slices.reserve(num_points);
760 for (
const auto& scalar : scalars) {
761 scalar_slices.emplace_back(
context, scalar, ROM_TABLE_BITS);
769 std::vector<Element> operation_transcript;
770 Element offset_generator_accumulator = offset_generators[0];
774 for (
size_t i = 0; i < num_points; ++i) {
780 native_straus_tables.emplace_back(
std::move(table));
784 Element accumulator = offset_generators[0];
785 for (
size_t i = 0; i < num_rounds; ++i) {
788 for (
size_t j = 0; j < ROM_TABLE_BITS; ++j) {
789 accumulator = accumulator.
dbl();
790 operation_transcript.push_back(accumulator);
791 offset_generator_accumulator = offset_generator_accumulator.
dbl();
794 for (
size_t j = 0; j < num_points; ++j) {
796 auto slice_value =
static_cast<size_t>(scalar_slices[j].slices_native[num_rounds - i - 1]);
797 const Element point = native_straus_tables[j][slice_value];
798 accumulator += point;
801 operation_transcript.push_back(accumulator);
802 offset_generator_accumulator +=
Element(offset_generators[j + 1]);
808 Element::batch_normalize(&operation_transcript[0], operation_transcript.size());
809 std::vector<AffineElement> operation_hints;
810 operation_hints.reserve(operation_transcript.size());
817 point_tables.reserve(num_points);
818 const size_t hints_per_table = (1ULL << ROM_TABLE_BITS) - 1;
819 for (
size_t i = 0; i < num_points; ++i) {
823 point_tables.push_back(
std::move(table));
827 AffineElement* hint_ptr = &operation_hints[num_points * hints_per_table];
832 field_t coordinate_check_product = 1;
833 for (
size_t i = 0; i < num_rounds; ++i) {
836 for (
size_t j = 0; j < ROM_TABLE_BITS; ++j) {
837 accumulator = accumulator.
dbl(*hint_ptr);
842 for (
size_t j = 0; j < num_points; ++j) {
843 const field_t scalar_slice = scalar_slices[j][num_rounds - i - 1];
845 const cycle_group point = point_tables[j].read(scalar_slice);
846 if (!unconditional_add) {
847 coordinate_check_product *= point.
_x - accumulator.
_x;
856 if (!unconditional_add) {
857 coordinate_check_product.
assert_is_not_zero(
"_variable_base_batch_mul_internal x-coordinate collision");
867 return { accumulator,
AffineElement(offset_generator_accumulator) };
893template <
typename Builder>
897 BB_ASSERT_EQ(scalars.size(), base_points.size(),
"Points/scalars size mismatch in fixed-base batch mul");
906 for (
const auto [point, scalar] :
zip_view(base_points, scalars)) {
908 multitable_ids.push_back(table_id[0]);
909 multitable_ids.push_back(table_id[1]);
910 scalar_limbs.push_back(scalar.lo());
911 scalar_limbs.push_back(scalar.hi());
916 Element offset_generator_accumulator = Group::point_at_infinity;
917 for (
const auto [table_id, scalar] :
zip_view(multitable_ids, scalar_limbs)) {
922 for (
size_t j = 0; j < lookup_data[ColumnIdx::C2].size(); ++j) {
923 const field_t x = lookup_data[ColumnIdx::C2][j];
924 const field_t y = lookup_data[ColumnIdx::C3][j];
928 lookup_points.push_back(
cycle_group(x, y, is_infinity,
false));
931 offset_generator_accumulator += table::get_generator_offset_for_table_id(table_id);
935 std::vector<Element> operation_transcript;
937 Element accumulator = lookup_points[0].get_value();
938 for (
size_t i = 1; i < lookup_points.size(); ++i) {
939 accumulator += (lookup_points[i].get_value());
940 operation_transcript.push_back(accumulator);
946 Element::batch_normalize(&operation_transcript[0], operation_transcript.size());
947 std::vector<AffineElement> operation_hints;
948 operation_hints.reserve(operation_transcript.size());
958 for (
auto& point : lookup_points) {
959 point.set_origin_tag(const_tag);
962 for (
size_t i = 1; i < lookup_points.size(); ++i) {
963 accumulator = accumulator.
unconditional_add(lookup_points[i], operation_hints[i - 1]);
969 return { accumulator, offset_generator_accumulator };
985template <
typename Builder>
990 const size_t table_bits)
992 BB_ASSERT_EQ(!scalars.empty(),
true,
"Empty scalars provided to fixed base plookup batch mul!");
993 BB_ASSERT_EQ(scalars.size(), base_points.size(),
"Points/scalars size mismatch in fixed base plookup batch mul!");
994 BB_ASSERT_EQ(offset_generators.size(), base_points.size() + 1,
"Too few offset generators provided!");
995 const size_t num_points = scalars.size();
998 for (
const auto& scalar : scalars) {
1006 "table_bits must evenly divide cycle_scalar::LO_BITS. The Straus algorithm splits the scalar "
1007 "into lo/hi limbs and decomposes each separately; if LO_BITS is not a multiple of table_bits, "
1008 "the hi-limb slices start at the wrong bit-offset and the MSM result is incorrect. "
1009 "Valid values for table_bits (given LO_BITS=128) are: 1, 2, 4, 8, 16, 32, 64, 128.");
1015 scalar_slices.reserve(num_points);
1016 for (
const auto& scalar : scalars) {
1017 scalar_slices.emplace_back(
context, scalar, table_bits);
1025 precomputed_tables[i] =
1029 point_tables.reserve(num_points);
1030 for (
size_t i = 0; i < num_points; ++i) {
1038 std::vector<Element> operation_transcript;
1039 Element offset_generator_accumulator = offset_generators[0];
1042 Element accumulator = offset_generators[0];
1043 for (
size_t i = 0; i < num_rounds; ++i) {
1045 for (
size_t j = 0; j < table_bits; ++j) {
1046 accumulator = accumulator.
dbl();
1047 operation_transcript.push_back(accumulator);
1048 offset_generator_accumulator = offset_generator_accumulator.
dbl();
1051 for (
size_t j = 0; j < num_points; ++j) {
1052 auto slice_value =
static_cast<size_t>(scalar_slices[j].slices_native[num_rounds - i - 1]);
1053 const Element point(point_tables[j].get_native_table()[slice_value]);
1054 accumulator += point;
1055 operation_transcript.push_back(accumulator);
1056 offset_generator_accumulator +=
Element(offset_generators[j + 1]);
1062 Element::batch_normalize(operation_transcript.data(), operation_transcript.size());
1063 std::vector<AffineElement> operation_hints;
1064 operation_hints.reserve(operation_transcript.size());
1073 for (
size_t i = 0; i < num_rounds; ++i) {
1075 for (
size_t j = 0; j < table_bits; ++j) {
1076 accumulator = accumulator.
dbl(*hint_ptr);
1080 for (
size_t j = 0; j < num_points; ++j) {
1081 const field_t scalar_slice = scalar_slices[j][num_rounds - i - 1];
1082 const cycle_group point = point_tables[j].read(scalar_slice);
1091 return { accumulator,
AffineElement(offset_generator_accumulator) };
1106template <
typename Builder>
1110 const size_t table_bits)
1112 BB_ASSERT_EQ(scalars.size(), constant_points.size(),
"Points/scalars size mismatch in fixed_batch_mul!");
1114 if (scalars.empty()) {
1120 for (
auto [point, scalar] :
zip_view(constant_points, scalars)) {
1121 result_tag =
OriginTag(result_tag,
OriginTag(point.get_origin_tag(), scalar.get_origin_tag()));
1125 std::vector<AffineElement> plookup_points;
1126 bool has_non_constant_component =
false;
1127 Element constant_acc = Group::point_at_infinity;
1129 for (
const auto [point, scalar] :
zip_view(constant_points, scalars)) {
1131 if (scalar.is_constant()) {
1133 constant_acc += point.get_value() * scalar.get_value();
1135 if (point.get_value().is_point_at_infinity()) {
1137 auto* ctx = scalar.get_context();
1138 ctx->create_limbed_range_constraint(scalar.lo().get_witness_index(),
1141 "fixed_batch_mul: lo range constraint for scalar with constant "
1143 ctx->create_limbed_range_constraint(scalar.hi().get_witness_index(),
1146 "fixed_batch_mul: hi range constraint for scalar with constant "
1150 plookup_scalars.push_back(scalar);
1151 plookup_points.push_back(point.get_value());
1152 has_non_constant_component =
true;
1156 if (!has_non_constant_component) {
1158 result.set_origin_tag(result_tag);
1163 const size_t num_offset_generators = plookup_points.size() + 1;
1165 context.generators->get(num_offset_generators, 0, OFFSET_GENERATOR_DOMAIN_SEPARATOR);
1168 Element offset_accumulator = -constant_acc;
1169 const auto [accumulator, offset_generator_delta] =
1170 _fixed_base_plookup_batch_mul_internal(plookup_scalars, plookup_points, offset_generators, table_bits);
1171 offset_accumulator += offset_generator_delta;
1222template <
typename Builder>
1227 BB_ASSERT_EQ(scalars.size(), base_points.size(),
"Points/scalars size mismatch in batch mul!");
1229 if (scalars.empty()) {
1237 std::vector<AffineElement> fixed_base_points;
1241 for (
auto [point, scalar] :
zip_view(base_points, scalars)) {
1242 result_tag =
OriginTag(result_tag,
OriginTag(point.get_origin_tag(), scalar.get_origin_tag()));
1247 bool can_unconditional_add =
true;
1248 bool has_non_constant_component =
false;
1249 Element constant_acc = Group::point_at_infinity;
1250 for (
const auto [point, scalar] :
zip_view(base_points, scalars)) {
1251 if (scalar.is_constant() && point.is_constant()) {
1253 constant_acc += (point.get_value()) * (scalar.get_value());
1254 }
else if (!scalar.is_constant() && point.is_constant()) {
1255 if (point.get_value().is_point_at_infinity()) {
1257#ifndef FUZZING_DISABLE_WARNINGS
1258 info(
"Warning: Performing batch mul with constant point at infinity!");
1262 auto* ctx = scalar.get_context();
1263 ctx->create_limbed_range_constraint(scalar.lo().get_witness_index(),
1266 "batch_mul: lo range constraint for scalar with constant "
1268 ctx->create_limbed_range_constraint(scalar.hi().get_witness_index(),
1271 "batch_mul: hi range constraint for scalar with constant "
1277 fixed_base_scalars.push_back(scalar);
1278 fixed_base_points.push_back(point.get_value());
1281 variable_base_scalars.push_back(scalar);
1282 variable_base_points.push_back(point);
1284 has_non_constant_component =
true;
1287 variable_base_scalars.push_back(scalar);
1288 variable_base_points.push_back(point);
1289 can_unconditional_add =
false;
1290 has_non_constant_component =
true;
1295 if (!has_non_constant_component) {
1297 result.set_origin_tag(result_tag);
1303 Element offset_accumulator = -constant_acc;
1304 const bool has_variable_points = !variable_base_points.empty();
1305 const bool has_fixed_points = !fixed_base_points.empty();
1308 if (has_fixed_points) {
1310 const auto [fixed_accumulator, offset_generator_delta] =
1311 _fixed_base_batch_mul_internal(fixed_base_scalars, fixed_base_points);
1312 offset_accumulator += offset_generator_delta;
1313 result = fixed_accumulator;
1316 if (has_variable_points) {
1318 const size_t num_offset_generators = variable_base_points.size() + 1;
1320 context.generators->get(num_offset_generators, 0, OFFSET_GENERATOR_DOMAIN_SEPARATOR);
1323 const auto [variable_accumulator, offset_generator_delta] = _variable_base_batch_mul_internal(
1324 variable_base_scalars, variable_base_points, offset_generators, can_unconditional_add);
1325 offset_accumulator += offset_generator_delta;
1328 if (has_fixed_points) {
1332 result = variable_accumulator;
1364 return batch_mul({ *
this }, { scalar });
1375 return batch_mul({ *
this }, { scalar });
1386 this->standardize();
1388 const auto equal = (_x == other.
_x) && (_y == other.
_y) && (this->_is_infinity == other.
_is_infinity);
1394 this->standardize();
1396 _x.assert_equal(other.
_x, msg);
1397 _y.assert_equal(other.
_y, msg);
1401template <
typename Builder>
1408 auto _is_infinity_res =
#define BB_ASSERT(expression,...)
#define BB_ASSERT_EQ(actual, expected,...)
constexpr bool is_point_at_infinity() const noexcept
constexpr void self_set_infinity() noexcept
element class. Implements ecc group arithmetic using Jacobian coordinates See https://hyperelliptic....
constexpr element dbl() const noexcept
BB_INLINE constexpr bool is_point_at_infinity() const noexcept
Container for lookup accumulator values and table reads.
Generates plookup tables required to perform fixed-base scalar multiplication over a fixed number of ...
static bool lookup_table_exists_for_point(const affine_element &input)
Returns true iff provided point is one of the two for which we have a precomputed lookup table.
Implements boolean logic in-circuit.
static bool_t conditional_assign(const bool_t< Builder > &predicate, const bool_t &lhs, const bool_t &rhs)
Conditionally assign lhs or rhs based on predicate, always returns normalized result.
Builder * get_context() const
cycle_group represents a group Element of the proving system's embedded curve, i.e....
cycle_group dbl(const std::optional< AffineElement > hint=std::nullopt) const
Evaluates a point doubling using Ultra ECC double gate (if non-constant)
static cycle_group from_constant_witness(Builder *_context, const AffineElement &_in)
Converts a native AffineElement into a witness, but constrains the witness values to be known constan...
cycle_group & operator*=(const cycle_scalar &scalar)
void standardize()
Convert the point to standard form.
cycle_group unconditional_add(const cycle_group &other, const std::optional< AffineElement > hint=std::nullopt) const
Evaluate incomplete ECC point addition over *this and other.
void validate_on_curve() const
On-curve check.
bool_t operator==(cycle_group &other)
Builder * get_context(const cycle_group &other) const
cycle_group & operator-=(const cycle_group &other)
static cycle_group conditional_assign(const bool_t &predicate, const cycle_group &lhs, const cycle_group &rhs)
void unset_free_witness_tag()
Unset the free witness flag for the cycle_group's tags.
cycle_group checked_unconditional_subtract(const cycle_group &other, const std::optional< AffineElement > hint=std::nullopt) const
Evaluate incomplete ECC point subtraction over *this and other, with x-coordinate collision checks.
cycle_group _unconditional_add_or_subtract(const cycle_group &other, bool is_addition, const std::optional< AffineElement > hint) const
Will evaluate ECC point addition or subtraction over *this and other.
static cycle_group from_witness(Builder *_context, const AffineElement &_in)
Converts an AffineElement into a circuit witness.
cycle_group operator-() const
Negates a point.
static cycle_group one(Builder *_context)
Construct a constant cycle_group representation of Group::one.
void set_free_witness_tag()
Set the free witness flag for the cycle_group's tags.
void set_origin_tag(OriginTag tag) const
Set the origin tag for x, y and _is_infinity members of cycle_group.
cycle_group & operator+=(const cycle_group &other)
static batch_mul_internal_output _fixed_base_plookup_batch_mul_internal(std::span< cycle_scalar > scalars, std::span< AffineElement const > base_points, std::span< AffineElement const > offset_generators, size_t table_bits=ROM_TABLE_BITS)
Internal algorithm to perform a fixed-base batch mul using plookup tables.
static cycle_group constant_infinity(Builder *_context=nullptr)
Construct a constant point at infinity.
bool is_constant_point_at_infinity() const
static cycle_group fixed_batch_mul(const std::vector< cycle_group > &constant_points, const std::vector< BigScalarField > &scalars, GeneratorContext context={}, size_t table_bits=ROM_TABLE_BITS)
bool_t is_point_at_infinity() const
static batch_mul_internal_output _variable_base_batch_mul_internal(std::span< cycle_scalar > scalars, std::span< cycle_group > base_points, std::span< AffineElement const > offset_generators, bool unconditional_add)
Internal logic to perform a variable-base batch mul using the Straus MSM algorithm.
cycle_group(Builder *_context=nullptr)
Construct a new constant point at infinity cycle group object.
AffineElement get_value() const
OriginTag get_origin_tag() const
Get the origin tag of cycle_group (a merege of origin tags of x, y and _is_infinity members)
cycle_group operator*(const cycle_scalar &scalar) const
static batch_mul_internal_output _fixed_base_batch_mul_internal(std::span< cycle_scalar > scalars, std::span< AffineElement > base_points)
Internal algorithm to perform a fixed-base batch mul.
void assert_equal(cycle_group &other, std::string const &msg="cycle_group::assert_equal")
cycle_group operator+(const cycle_group &other) const
Evaluate ECC point addition over *this and other.
cycle_group unconditional_subtract(const cycle_group &other, const std::optional< AffineElement > hint=std::nullopt) const
Evaluate incomplete ECC point subtraction over *this and other.
Builder * get_context() const
cycle_group checked_unconditional_add(const cycle_group &other, const std::optional< AffineElement > hint=std::nullopt) const
Evaluate incomplete ECC point addition over *this and other, with x-coordinate collision checks.
static cycle_group batch_mul(const std::vector< cycle_group > &base_points, const std::vector< BigScalarField > &scalars, GeneratorContext context={})
Represents a member of the Grumpkin curve scalar field (i.e. BN254 base field).
static constexpr size_t NUM_BITS
static constexpr size_t LO_BITS
static constexpr size_t HI_BITS
void assert_equal(const field_t &rhs, std::string const &msg="field_t::assert_equal") const
Copy constraint: constrain that *this field is equal to rhs element.
field_t madd(const field_t &to_mul, const field_t &to_add) const
static void evaluate_polynomial_identity(const field_t &a, const field_t &b, const field_t &c, const field_t &d, const std::string &msg="field_t::evaluate_polynomial_identity")
Given a, b, c, d, constrain a * b + c + d = 0 by creating a big_mul_gate.
Builder * get_context() const
OriginTag get_origin_tag() const
bb::fr get_value() const
Given a := *this, compute its value given by a.v * a.mul + a.add.
static field_t from_witness(Builder *ctx, const bb::fr &input)
bool_t< Builder > is_zero() const
Validate whether a field_t element is zero.
void convert_constant_to_fixed_witness(Builder *ctx)
void set_origin_tag(const OriginTag &new_tag) const
field_t add_two(const field_t &add_b, const field_t &add_c) const
Efficiently compute (this + a + b) using big_mul gate.
static field_t conditional_assign(const bool_t< Builder > &predicate, const field_t &lhs, const field_t &rhs)
void assert_is_not_zero(std::string const &msg="field_t::assert_is_not_zero") const
Constrain *this to be non-zero by establishing that it has an inverse.
uint32_t get_witness_index() const
Get the witness index of the current field element.
static plookup::ReadData< field_pt > get_lookup_accumulators(const plookup::MultiTableId id, const field_pt &key_a, const field_pt &key_b=0, const bool is_2_to_1_lookup=false)
straus_lookup_table computes a lookup table of size 1 << table_bits
static std::vector< Element > compute_native_table(const Element &base_point, const Element &offset_generator, size_t table_bits)
Compute the output points generated when computing the Straus lookup table.
static PrecomputedData build_precomputed_data(const AffineElement &base_point, const AffineElement &offset_generator, size_t table_bits)
Compute native table entries and BasicTable column data without touching the circuit builder.
StrictMock< MockContext > context
bb::curve::BN254::Element Element
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...
void mark_witness_as_used(const field_t< Builder > &field)
Mark a field_t witness as used (for UltraBuilder only).
field< Bn254FrParams > fr
Univariate< Fr, domain_end > operator*(const Fr &ff, const Univariate< Fr, domain_end > &uv)
void parallel_for(size_t num_iterations, const std::function< void(size_t)> &func)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
This file contains part of the logic for the Origin Tag mechanism that tracks the use of in-circuit p...
static OriginTag constant()
BB_INLINE constexpr field sqr() const noexcept
static constexpr field zero()
Stores temporary variables produced by internal multiplication algorithms.