52 "field_conversion: convert_challenge");
70 static constexpr bb::fr shift(
static_cast<uint256_t>(1) << NUM_LIMB_BITS);
71 std::vector<fr> result(2);
87 return 2 * calc_num_fields<typename T::BaseField>();
90 return calc_num_fields<typename T::value_type>() * (std::tuple_size<T>::value);
133 using bigfield_ct =
fq;
135 constexpr size_t expected_size = calc_num_fields<T>();
138 BB_ASSERT(validate_context<Builder>(fr_vec));
146 T result(fr_vec[0], fr_vec[1]);
147 result.assert_is_in_field();
151 return T(fr_vec[0], fr_vec[1]);
154 using Basefield =
typename T::BaseField;
156 constexpr size_t base_field_frs = expected_size / 2;
158 Basefield x = deserialize_from_fields<Basefield>(fr_vec.subspan(0, base_field_frs));
159 Basefield y = deserialize_from_fields<Basefield>(fr_vec.subspan(base_field_frs, base_field_frs));
165 return T(x, y,
true);
169 using element_type =
typename T::value_type;
170 const size_t scalar_frs = calc_num_fields<element_type>();
173 for (
auto& x : val) {
174 x = deserialize_from_fields<element_type>(fr_vec.subspan(scalar_frs * i, scalar_frs));
234 using bigfield_ct =
fq;
244 auto is_inf = val.is_point_at_infinity();
247 return { canon_x, canon_y };
251 if (val.get_value().is_point_at_infinity()) {
252 BB_ASSERT(val.x().get_value() == 0 && val.y().get_value() == 0,
253 "serialize_to_fields: bn254_commitment point at infinity must be canonical (0,0)");
255 using BaseField =
typename T::BaseField;
260 fr_vec.insert(fr_vec.end(), fr_vec_y.begin(), fr_vec_y.end());
265 for (
auto& x : val) {
266 auto tmp_vec = serialize_to_fields<typename T::value_type>(x);
267 fr_vec.insert(fr_vec.end(), tmp_vec.begin(), tmp_vec.end());
283 constexpr size_t lo_bits = TOTAL_BITS / 2;
301 constexpr size_t num_frs = calc_num_fields<TargetType>();
303 TargetType result = deserialize_from_fields<TargetType>(elements.subspan(num_frs_read, num_frs));
304 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 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 T convert_challenge(const fr &challenge)
A stdlib Transcript method needed to convert an fr challenge to a bigfield one. Assumes that challeng...
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 constexpr uint64_t NUM_LIMB_BITS
std::array< Limb, NUM_LIMBS > binary_basis_limbs
Represents a bigfield element in the binary basis. A bigfield element is represented as a combination...
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
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 decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept