10#ifndef BOTAN_EC_POINT_H_
11#define BOTAN_EC_POINT_H_
13#include <botan/curve_gfp.h>
14#include <botan/exceptn.h>
26 HYBRID BOTAN_DEPRECATED(
"Use EC_Point_Format::Hybrid") =
Hybrid,
38 enum { WORKSPACE_SIZE = 8 };
122 m_coord_y = m_curve.get_p() - m_coord_y;
130 BigInt get_affine_x()
const;
136 BigInt get_affine_y()
const;
161 m_coord_x.swap(new_x);
162 m_coord_y.swap(new_y);
163 m_coord_z.swap(new_z);
174 static void force_all_affine(std::vector<EC_Point>& points,
177 bool is_affine()
const;
183 bool is_zero()
const {
return m_coord_z.is_zero(); }
190 bool on_the_curve()
const;
222 BOTAN_ARG_CHECK(m_curve == other.m_curve,
"cannot add points on different curves");
224 const size_t p_words = m_curve.get_p_words();
226 add(other.m_coord_x.
data(), std::min(p_words, other.m_coord_x.
size()),
227 other.m_coord_y.
data(), std::min(p_words, other.m_coord_y.
size()),
228 other.m_coord_z.
data(), std::min(p_words, other.m_coord_z.
size()),
243 void add(
const word x_words[],
size_t x_size,
244 const word y_words[],
size_t y_size,
245 const word z_words[],
size_t z_size,
246 std::vector<BigInt>& workspace);
258 const size_t p_words = m_curve.get_p_words();
259 add_affine(other.m_coord_x.
data(), std::min(p_words, other.m_coord_x.
size()),
260 other.m_coord_y.
data(), std::min(p_words, other.m_coord_y.
size()),
273 void add_affine(
const word x_words[],
size_t x_size,
274 const word y_words[],
size_t y_size,
275 std::vector<BigInt>& workspace);
281 void mult2(std::vector<BigInt>& workspace);
288 void mult2i(
size_t i, std::vector<BigInt>& workspace);
299 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);
350 const EC_Point& p1, const BigInt& z1,
351 const EC_Point& p2, const BigInt& z2);
356 return !(rhs == lhs);
379 return scalar * point;
387 const CurveGFp& curve);
400 const BigInt& curve_p,
401 const BigInt& curve_a,
402 const BigInt& curve_b);
404template<typename Alloc>
406 {
return OS2ECP(data.data(), data.size(), curve); }
408class 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
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
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)
std::vector< T, secure_allocator< T > > secure_vector
void swap< Botan::EC_Point >(Botan::EC_Point &x, Botan::EC_Point &y)