|
Barretenberg
The ZK-SNARK library at the core of Aztec
|
#include <affine_element.hpp>
Classes | |
| struct | MsgpackRawAffineElement |
Public Types | |
| using | Fq = Fq_ |
| using | Fr = Fr_ |
| using | Params = Params_ |
| using | in_buf = const uint8_t * |
| using | vec_in_buf = const uint8_t * |
| using | out_buf = uint8_t * |
| using | vec_out_buf = uint8_t ** |
Public Member Functions | |
| affine_element () noexcept=default | |
| ~affine_element () noexcept=default | |
| constexpr | affine_element (const Fq &x, const Fq &y) noexcept |
| constexpr | affine_element (const affine_element &other) noexcept=default |
| constexpr | affine_element (affine_element &&other) noexcept=default |
| constexpr affine_element & | operator= (const affine_element &other) noexcept=default |
| constexpr affine_element & | operator= (affine_element &&other) noexcept=default |
| constexpr affine_element | operator+ (const affine_element &other) const noexcept |
| constexpr affine_element | operator* (const Fr &exponent) const noexcept |
| constexpr affine_element | set_infinity () const noexcept |
| constexpr void | self_set_infinity () noexcept |
| constexpr bool | is_point_at_infinity () const noexcept |
| constexpr bool | on_curve () const noexcept |
| constexpr bool | operator== (const affine_element &other) const noexcept |
| constexpr affine_element | operator- () const noexcept |
| constexpr bool | operator> (const affine_element &other) const noexcept |
| constexpr bool | operator< (const affine_element &other) const noexcept |
| std::vector< uint8_t > | to_buffer () const |
| Serialize the point to a byte vector. | |
| void | msgpack_pack (auto &packer) const |
| void | msgpack_unpack (auto o) |
| void | msgpack_schema (auto &packer) const |
| template<typename BaseField , typename CompileTimeEnabled > | |
| constexpr affine_element< Fq, Fr, T > | from_compressed (const uint256_t &compressed) noexcept |
| template<typename BaseField , typename CompileTimeEnabled > | |
| constexpr std::array< affine_element< Fq, Fr, T >, 2 > | from_compressed_unsafe (const uint256_t &compressed) noexcept |
Static Public Member Functions | |
| static constexpr affine_element | one () noexcept |
| template<typename BaseField = Fq, typename CompileTimeEnabled = std::enable_if_t<(BaseField::modulus >> 255) == uint256_t(0), void>> | |
| static constexpr affine_element | from_compressed (const uint256_t &compressed) noexcept |
| Reconstruct a point in affine coordinates from compressed form. | |
| template<typename BaseField = Fq, typename CompileTimeEnabled = std::enable_if_t<(BaseField::modulus >> 255) == uint256_t(1), void>> | |
| static constexpr std::array< affine_element, 2 > | from_compressed_unsafe (const uint256_t &compressed) noexcept |
| Reconstruct a point in affine coordinates from compressed form. | |
| static constexpr affine_element | infinity () |
| static constexpr std::optional< affine_element > | derive_from_x_coordinate (const Fq &x, bool sign_bit) noexcept |
| static affine_element | random_element (numeric::RNG *engine=nullptr) noexcept |
| Samples a random point on the curve. | |
| static constexpr affine_element | hash_to_curve (const std::vector< uint8_t > &seed, uint8_t attempt_count=0) noexcept |
| Hash a seed buffer into a point. | |
| static void | serialize_to_buffer (const affine_element &value, uint8_t *buffer, bool write_x_first=false) |
| Serialize the point to the given buffer. | |
| static affine_element | serialize_from_buffer (const uint8_t *buffer, bool write_x_first=false) |
| Restore point from a buffer. | |
| static affine_element | batch_mul (std::span< const affine_element > points, std::span< const Fr > scalars, size_t max_num_bits=0, bool with_edgecases=true, const Fr &masking_scalar=Fr(1)) noexcept |
| Multi-scalar multiplication: compute sum_i(scalars[i] * points[i]) | |
Public Attributes | |
| Fq | x |
| Fq | y |
Static Public Attributes | |
| static constexpr size_t | PUBLIC_INPUTS_SIZE = 2 * Fq::PUBLIC_INPUTS_SIZE |
| template<typename T > | |
| static constexpr bool | is_field2_v |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const affine_element &a) |
Definition at line 27 of file affine_element.hpp.
| using bb::group_elements::affine_element< Fq_, Fr_, Params_ >::Fq = Fq_ |
Definition at line 29 of file affine_element.hpp.
| using bb::group_elements::affine_element< Fq_, Fr_, Params_ >::Fr = Fr_ |
Definition at line 30 of file affine_element.hpp.
| using bb::group_elements::affine_element< Fq_, Fr_, Params_ >::in_buf = const uint8_t* |
Definition at line 33 of file affine_element.hpp.
| using bb::group_elements::affine_element< Fq_, Fr_, Params_ >::out_buf = uint8_t* |
Definition at line 35 of file affine_element.hpp.
| using bb::group_elements::affine_element< Fq_, Fr_, Params_ >::Params = Params_ |
Definition at line 31 of file affine_element.hpp.
| using bb::group_elements::affine_element< Fq_, Fr_, Params_ >::vec_in_buf = const uint8_t* |
Definition at line 34 of file affine_element.hpp.
| using bb::group_elements::affine_element< Fq_, Fr_, Params_ >::vec_out_buf = uint8_t** |
Definition at line 36 of file affine_element.hpp.
|
defaultnoexcept |
|
defaultnoexcept |
|
constexprnoexcept |
Definition at line 14 of file affine_element_impl.hpp.
|
constexprdefaultnoexcept |
|
constexprdefaultnoexcept |
|
staticnoexcept |
Multi-scalar multiplication: compute sum_i(scalars[i] * points[i])
Interface matches stdlib::biggroup::element::batch_mul for unified native/stdlib usage. Delegates to Pippenger MSM algorithm.
| points | Span of affine points |
| scalars | Span of scalar field elements (same length as points) |
| max_num_bits | Ignored for native (circuit optimization hint in stdlib) |
| with_edgecases | If true, uses Jacobian Pippenger (safe); if false, uses affine (faster) |
| masking_scalar | Ignored for native (needed for safe offset generators in stdlib) |
Definition at line 26 of file element_batch_mul.cpp.
|
staticconstexprnoexcept |
Definition at line 168 of file affine_element_impl.hpp.
|
staticconstexprnoexcept |
Reconstruct a point in affine coordinates from compressed form.
#LARGE_MODULUS_AFFINE_POINT_COMPRESSION Point compression is only implemented for curves of a prime field F_p with p using < 256 bits. One possiblity for extending to a 256-bit prime field: https://patents.google.com/patent/US6252960B1/en.
| compressed | compressed point |
|
constexprnoexcept |
Definition at line 21 of file affine_element_impl.hpp.
|
staticconstexprnoexcept |
Reconstruct a point in affine coordinates from compressed form.
#LARGE_MODULUS_AFFINE_POINT_COMPRESSION Point compression is implemented for curves of a prime field F_p with p being 256 bits. TODO(Suyash): Check with kesha if this is correct.
| compressed | compressed point |
|
constexprnoexcept |
Definition at line 45 of file affine_element_impl.hpp.
|
staticconstexprnoexcept |
Hash a seed buffer into a point.
ALGORITHM DESCRIPTION:
attempt_count = 0seed (initialized to 0)attempt_count as a byte and write into buffer at [buffer.size() - 2]1attempt_count by 1 and go to step 2| Fq | |
| Fr | |
| T |
| seed | Bytes that uniquely define the point being generated |
| attempt_count |
Definition at line 219 of file affine_element_impl.hpp.
|
staticconstexpr |
Definition at line 83 of file affine_element_impl.hpp.
|
constexprnoexcept |
Definition at line 113 of file affine_element_impl.hpp.
|
inline |
Definition at line 224 of file affine_element.hpp.
|
inline |
Definition at line 286 of file affine_element.hpp.
|
inline |
Definition at line 254 of file affine_element.hpp.
|
constexprnoexcept |
Definition at line 125 of file affine_element_impl.hpp.
|
inlinestaticconstexprnoexcept |
Definition at line 52 of file affine_element.hpp.
|
constexprnoexcept |
Definition at line 78 of file affine_element_impl.hpp.
|
constexprnoexcept |
Definition at line 71 of file affine_element_impl.hpp.
|
inlineconstexprnoexcept |
Definition at line 109 of file affine_element.hpp.
|
inlineconstexprnoexcept |
Definition at line 112 of file affine_element.hpp.
|
constexprdefaultnoexcept |
|
constexprdefaultnoexcept |
|
constexprnoexcept |
Definition at line 139 of file affine_element_impl.hpp.
|
constexprnoexcept |
Definition at line 149 of file affine_element_impl.hpp.
|
staticnoexcept |
Samples a random point on the curve.
Definition at line 260 of file affine_element_impl.hpp.
|
constexprnoexcept |
Definition at line 98 of file affine_element_impl.hpp.
|
inlinestatic |
Restore point from a buffer.
| buffer | Buffer from which we deserialize the point |
We support serializing the point at infinity for curves defined over a bb::field (i.e., a native field of prime order) and for points of bb::g2.
Definition at line 150 of file affine_element.hpp.
|
inlinestatic |
Serialize the point to the given buffer.
We support serializing the point at infinity for curves defined over a bb::field (i.e., a native field of prime order) and for points of bb::g2.
Definition at line 123 of file affine_element.hpp.
|
constexprnoexcept |
Definition at line 91 of file affine_element_impl.hpp.
|
inline |
Serialize the point to a byte vector.
Definition at line 174 of file affine_element.hpp.
|
friend |
Definition at line 181 of file affine_element.hpp.
|
staticconstexpr |
Definition at line 208 of file affine_element.hpp.
|
staticconstexpr |
Number of bb::fr elements required to represent an affine_element in the public inputs (2 frs per coordinate)
Definition at line 41 of file affine_element.hpp.
| Fq bb::group_elements::affine_element< Fq_, Fr_, Params_ >::x |
Definition at line 203 of file affine_element.hpp.
| Fq bb::group_elements::affine_element< Fq_, Fr_, Params_ >::y |
Definition at line 204 of file affine_element.hpp.