51 "field_conversion: convert_challenge");
58 return T(challenge, high_limb);
76 static constexpr size_t LOW_BITS = 2 * T::NUM_LIMB_BITS;
77 const auto [low_bits, high_bits] =
split_unique(challenge, LOW_BITS);
78 return T(low_bits, high_bits);
108 return 2 * calc_num_fields<typename T::BaseField>();
111 return calc_num_fields<typename T::value_type>() * (std::tuple_size<T>::value);
154 using bigfield_ct =
fq;
156 constexpr size_t expected_size = calc_num_fields<T>();
159 BB_ASSERT(validate_context<Builder>(fr_vec));
167 T
result(fr_vec[0], fr_vec[1]);
168 result.assert_is_in_field();
172 return T(fr_vec[0], fr_vec[1]);
175 using Basefield =
typename T::BaseField;
177 constexpr size_t base_field_frs = expected_size / 2;
179 Basefield x = deserialize_from_fields<Basefield>(fr_vec.subspan(0, base_field_frs));
180 Basefield y = deserialize_from_fields<Basefield>(fr_vec.subspan(base_field_frs, base_field_frs));
186 return T(x, y,
true);
190 using element_type =
typename T::value_type;
191 const size_t scalar_frs = calc_num_fields<element_type>();
194 for (
auto& x : val) {
195 x = deserialize_from_fields<element_type>(fr_vec.subspan(scalar_frs * i, scalar_frs));
255 using bigfield_ct =
fq;
265 auto is_inf = val.is_point_at_infinity();
268 return { canon_x, canon_y };
272 if (val.get_value().is_point_at_infinity()) {
273 BB_ASSERT(val.x().get_value() == 0 && val.y().get_value() == 0,
274 "serialize_to_fields: bn254_commitment point at infinity must be canonical (0,0)");
276 using BaseField =
typename T::BaseField;
281 fr_vec.insert(fr_vec.end(), fr_vec_y.begin(), fr_vec_y.end());
286 for (
auto& x : val) {
287 auto tmp_vec = serialize_to_fields<typename T::value_type>(x);
288 fr_vec.insert(fr_vec.end(), tmp_vec.begin(), tmp_vec.end());
304 constexpr size_t lo_bits = TOTAL_BITS / 2;
322 constexpr size_t num_frs = calc_num_fields<TargetType>();
324 TargetType
result = deserialize_from_fields<TargetType>(elements.subspan(num_frs_read, num_frs));
325 num_frs_read += num_frs;
#define BB_ASSERT(expression,...)
#define BB_ASSERT_GTE(left, right,...)
#define BB_ASSERT_EQ(actual, expected,...)
#define BB_ASSERT_LT(left, right,...)
static constexpr size_t NUM_BN254_SCALARS
static constexpr size_t NUM_BN254_SCALARS
constexpr uint64_t get_msb() const
static constexpr size_t calc_num_fields()
Calculates the size of a type (in its native form) in terms of frs.
bigfield< Builder, bb::Bn254FqParams > fq
typename Field::Builder Builder
static T convert_full_challenge(const fr &challenge)
Convert a full-width challenge to a target type (fr or fq).
static std::vector< fr > convert_goblin_fr_to_bn254_frs(const goblin_field< Builder > &input)
static std::vector< fr > convert_grumpkin_fr_to_bn254_frs(const fq &input)
element< Builder, fq, fr, curve::BN254::Group > bn254_commitment
static std::array< fr, 2 > split_challenge(const fr &challenge)
Split a challenge field element into two equal-width challenges.
static T deserialize_from_fields(std::span< const fr > fr_vec)
Core stdlib Transcript deserialization method.
static TargetType deserialize_from_frs(std::span< fr > elements, size_t &num_frs_read)
A stdlib VerificationKey-specific method.
static std::vector< fr > serialize_to_fields(const T &val)
Core stdlib Transcript serialization method.
static T convert_short_challenge(const fr &challenge)
A stdlib Transcript method needed to convert a short fr challenge limb to a bigfield one.
static constexpr uint64_t NUM_LIMB_BITS
const Limb & get_limb(size_t i) const
Read-only access to a binary basis limb (element + maximum_value).
cycle_group represents a group Element of the proving system's embedded curve, i.e....
static field_t from_witness_index(Builder *ctx, uint32_t witness_index)
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 constexpr uint256_t modulus
static field_t conditional_assign(const bool_t< Builder > &predicate, const field_t &lhs, const field_t &rhs)
goblin_field wraps x/y coordinates of bn254 group elements when using goblin
std::array< field_ct, 2 > limbs
std::pair< field_t< Builder >, field_t< Builder > > split_unique(const field_t< Builder > &field, const size_t lo_bits, const bool skip_range_constraints)
Split a bn254 scalar field element into unique lo and hi limbs.
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...
constexpr ScalarIndex shift(ScalarIndex ctx, size_t d)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept