7#ifndef BOTAN_EC_APOINT_H_
8#define BOTAN_EC_APOINT_H_
10#include <botan/concepts.h>
11#include <botan/ec_point_format.h>
12#include <botan/secmem.h>
13#include <botan/types.h>
27#if defined(BOTAN_HAS_LEGACY_EC_POINT)
46 static std::optional<EC_AffinePoint>
deserialize(
const EC_Group& group, std::span<const uint8_t> bytes);
67 std::string_view hash_fn,
68 std::span<const uint8_t> input,
69 std::span<const uint8_t> domain_sep);
75 std::string_view hash_fn,
76 std::span<const uint8_t> input,
77 std::string_view domain_sep);
83 std::string_view hash_fn,
84 std::span<const uint8_t> input,
85 std::span<const uint8_t> domain_sep);
91 std::string_view hash_fn,
92 std::span<const uint8_t> input,
93 std::string_view domain_sep);
172 template <concepts::resizable_
byte_buffer T = secure_vector<u
int8_t>>
174 T bytes(this->field_element_bytes());
175 this->serialize_x_to(bytes);
182 template <concepts::resizable_
byte_buffer T = secure_vector<u
int8_t>>
184 T bytes(this->field_element_bytes());
185 this->serialize_y_to(bytes);
192 template <concepts::resizable_
byte_buffer T = secure_vector<u
int8_t>>
194 T bytes(2 * this->field_element_bytes());
195 this->serialize_xy_to(bytes);
202 template <concepts::resizable_
byte_buffer T = std::vector<u
int8_t>>
204 T bytes(1 + 2 * this->field_element_bytes());
205 this->serialize_uncompressed_to(bytes);
212 template <concepts::resizable_
byte_buffer T = std::vector<u
int8_t>>
214 T bytes(1 + this->field_element_bytes());
215 this->serialize_compressed_to(bytes);
232#if defined(BOTAN_HAS_LEGACY_EC_POINT)
251 return this->mul(scalar, rng);
257 std::vector<BigInt>& )
const {
258 return this->mul_x_only(scalar, rng);
265 static EC_AffinePoint _from_inner(std::unique_ptr<EC_AffinePoint_Data> inner);
267 const std::shared_ptr<const EC_Group_Data>& _group()
const;
272 explicit EC_AffinePoint(std::unique_ptr<EC_AffinePoint_Data> point);
276 std::unique_ptr<EC_AffinePoint_Data> m_point;
#define BOTAN_PUBLIC_API(maj, min)
#define BOTAN_DEPRECATED(msg)
static EC_AffinePoint hash_to_curve_ro(const EC_Group &group, std::string_view hash_fn, std::span< const uint8_t > input, std::span< const uint8_t > domain_sep)
EC_AffinePoint negate() const
Point negation.
size_t field_element_bytes() const
void serialize_xy_to(std::span< uint8_t > bytes) const
static EC_AffinePoint hash_to_curve_nu(const EC_Group &group, std::string_view hash_fn, std::span< const uint8_t > input, std::span< const uint8_t > domain_sep)
bool operator!=(const EC_AffinePoint &other) const
bool is_identity() const
Return true if this point is the identity element.
static EC_AffinePoint identity(const EC_Group &group)
Return the identity element.
static std::optional< EC_AffinePoint > from_bigint_xy(const EC_Group &group, const BigInt &x, const BigInt &y)
static std::optional< EC_AffinePoint > mul_px_qy(const EC_AffinePoint &p, const EC_Scalar &x, const EC_AffinePoint &q, const EC_Scalar &y, RandomNumberGenerator &rng)
static EC_AffinePoint g_mul(const EC_Scalar &scalar, RandomNumberGenerator &rng)
Multiply by the group generator returning a complete point.
T serialize_uncompressed() const
EC_AffinePoint(const EC_Group &group, std::span< const uint8_t > bytes)
EC_AffinePoint mul(const EC_Scalar &scalar, RandomNumberGenerator &rng) const
Multiply a point by a scalar returning a complete point.
static std::optional< EC_AffinePoint > deserialize(const EC_Group &group, std::span< const uint8_t > bytes)
void serialize_x_to(std::span< uint8_t > bytes) const
T serialize_compressed() const
void serialize_compressed_to(std::span< uint8_t > bytes) const
secure_vector< uint8_t > mul_x_only(const EC_Scalar &scalar, RandomNumberGenerator &rng) const
Multiply a point by a scalar, returning the byte encoding of the x coordinate only.
const EC_AffinePoint_Data & _inner() const
secure_vector< uint8_t > mul_x_only(const EC_Scalar &scalar, RandomNumberGenerator &rng, std::vector< BigInt > &) const
Multiply a point by a scalar, returning the byte encoding of the x coordinate only.
void serialize_uncompressed_to(std::span< uint8_t > bytes) const
void serialize_y_to(std::span< uint8_t > bytes) const
EC_AffinePoint add(const EC_AffinePoint &q) const
friend class EC_Mul2Table
static EC_AffinePoint generator(const EC_Group &group)
Return the standard group generator.
bool operator==(const AlgorithmIdentifier &a1, const AlgorithmIdentifier &a2)
std::vector< T, secure_allocator< T > > secure_vector