10#ifndef BOTAN_EC_POINT_H_
11#define BOTAN_EC_POINT_H_
13#include <botan/curve_gfp.h>
14#include <botan/exceptn.h>
38 enum { WORKSPACE_SIZE = 8 };
118 m_coord_y = m_curve.get_p() - m_coord_y;
127 BigInt get_affine_x()
const;
133 BigInt get_affine_y()
const;
157 m_coord_x.swap(new_x);
158 m_coord_y.swap(new_y);
159 m_coord_z.swap(new_z);
172 bool is_affine()
const;
178 bool is_zero()
const {
return m_coord_z.is_zero(); }
185 bool on_the_curve()
const;
218 BOTAN_ARG_CHECK(m_curve == other.m_curve,
"cannot add points on different curves");
220 const size_t p_words = m_curve.get_p_words();
222 add(other.m_coord_x.
data(),
223 std::min(p_words, other.m_coord_x.
size()),
224 other.m_coord_y.
data(),
225 std::min(p_words, other.m_coord_y.
size()),
226 other.m_coord_z.
data(),
227 std::min(p_words, other.m_coord_z.
size()),
242 void add(
const word x_words[],
244 const word y_words[],
246 const word z_words[],
248 std::vector<BigInt>& workspace);
259 const size_t p_words = m_curve.get_p_words();
260 add_affine(other.m_coord_x.
data(),
261 std::min(p_words, other.m_coord_x.
size()),
262 other.m_coord_y.
data(),
263 std::min(p_words, other.m_coord_y.
size()),
277 const word x_words[],
size_t x_size,
const word y_words[],
size_t y_size, std::vector<BigInt>& workspace);
283 void mult2(std::vector<BigInt>& workspace);
290 void mult2i(
size_t i, std::vector<BigInt>& workspace);
300 x.
add(other, workspace);
330 BigInt m_coord_x, m_coord_y, m_coord_z;
339BOTAN_PUBLIC_API(2, 0) EC_Point operator*(const BigInt& scalar, const EC_Point& point);
350EC_Point
multi_exponentiate(const EC_Point& p1, const BigInt& z1, const EC_Point& p2, const BigInt& z2);
354 return !(rhs == lhs);
373 return scalar * point;
393OS2ECP(const uint8_t data[],
size_t data_len, const BigInt& curve_p, const BigInt& curve_a, const BigInt& curve_b);
395template <typename Alloc>
397 return OS2ECP(data.data(), data.size(), curve);
400class EC_Point_Var_Point_Precompute;
#define BOTAN_ASSERT_NOMSG(expr)
#define BOTAN_DEBUG_ASSERT(expr)
#define BOTAN_ARG_CHECK(expr, msg)
const word * data() const
EC_Point & operator=(EC_Point &&other)
EC_Point plus(const EC_Point &other, std::vector< BigInt > &workspace) const
void swap(EC_Point &other)
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
const BigInt & get_y() const
const BigInt & get_z() const
void swap_coords(BigInt &new_x, BigInt &new_y, BigInt &new_z)
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)
const BigInt & get_x() const
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)