10#ifndef BOTAN_EC_POINT_H_
11#define BOTAN_EC_POINT_H_
13#include <botan/curve_gfp.h>
14#include <botan/exceptn.h>
42 enum { WORKSPACE_SIZE = 8 };
135 m_coord_y = m_curve.get_p() - m_coord_y;
150 bool is_affine()
const;
156 bool is_zero()
const {
return m_coord_z.is_zero(); }
163 bool on_the_curve()
const;
184 BigInt get_affine_x()
const;
190 BigInt get_affine_y()
const;
214 void swap(
EC_Point& other)
noexcept;
216#if defined(BOTAN_DISABLE_DEPRECATED_FEATURES)
245 m_coord_x.
swap(new_x);
246 m_coord_y.swap(new_y);
247 m_coord_z.swap(new_z);
264 BOTAN_ARG_CHECK(m_curve == other.m_curve,
"cannot add points on different curves");
266 const size_t p_words = m_curve.get_p_words();
268 add(other.m_coord_x.
_data(),
269 std::min(p_words, other.m_coord_x.
size()),
270 other.m_coord_y.
_data(),
271 std::min(p_words, other.m_coord_y.
size()),
272 other.m_coord_z.
_data(),
273 std::min(p_words, other.m_coord_z.
size()),
288 void add(
const word x_words[],
290 const word y_words[],
292 const word z_words[],
294 std::vector<BigInt>& workspace);
305 const size_t p_words = m_curve.get_p_words();
306 add_affine(other.m_coord_x.
_data(),
307 std::min(p_words, other.m_coord_x.
size()),
308 other.m_coord_y.
_data(),
309 std::min(p_words, other.m_coord_y.
size()),
323 const word x_words[],
size_t x_size,
const word y_words[],
size_t y_size, std::vector<BigInt>& workspace);
329 void mult2(std::vector<BigInt>& workspace);
336 void mult2i(
size_t i, std::vector<BigInt>& workspace);
346 x.
add(other, workspace);
371 BigInt m_coord_x, m_coord_y, m_coord_z;
383EC_Point
multi_exponentiate(const EC_Point& p1, const BigInt& z1, const EC_Point& p2, const BigInt& z2);
401 return point.
mul(scalar);
405 return point.
mul(scalar);
427 OS2ECP(const uint8_t data[],
size_t data_len, const BigInt& curve_p, const BigInt& curve_a, const BigInt& curve_b);
#define BOTAN_ASSERT_NOMSG(expr)
#define BOTAN_DEBUG_ASSERT(expr)
#define BOTAN_ARG_CHECK(expr, msg)
const word * _data() const
void swap(EC_Point &other) noexcept
bool operator!=(const EC_Point &other) const =default
EC_Point & operator=(EC_Point &&other)
EC_Point plus(const EC_Point &other, std::vector< BigInt > &workspace) const
void add(const EC_Point &other, std::vector< BigInt > &workspace)
EC_Point(EC_Point &&other)
void add_affine(const EC_Point &other, std::vector< BigInt > &workspace)
void mult2(std::vector< BigInt > &workspace)
EC_Point double_of(std::vector< BigInt > &workspace) const
EC_Point mul(const BigInt &scalar) const
EC_Point(const EC_Point &)=default
const CurveGFp & get_curve() const
EC_Point & operator=(const EC_Point &)=default
friend void swap(EC_Point &x, EC_Point &y)
EC_Point_Format Compression_Type
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
#define BOTAN_UNSTABLE_API
#define BOTAN_DEPRECATED(msg)
BigInt operator*(const BigInt &x, const BigInt &y)
OctetString operator+(const OctetString &k1, const OctetString &k2)
EC_Point multi_exponentiate(const EC_Point &p1, const BigInt &z1, const EC_Point &p2, const BigInt &z2)
BigInt operator-(const BigInt &x, const BigInt &y)
bool operator==(const AlgorithmIdentifier &a1, const AlgorithmIdentifier &a2)
EC_Point OS2ECP(const uint8_t data[], size_t data_len, const CurveGFp &curve)
std::vector< T, Alloc > & operator+=(std::vector< T, Alloc > &out, const std::vector< T, Alloc2 > &in)
constexpr auto operator-=(Strong< T1, Tags... > &a, T2 b)
std::vector< T, secure_allocator< T > > secure_vector
constexpr auto operator*=(Strong< T1, Tags... > &a, T2 b)