10#ifndef BOTAN_EC_POINT_H_
11#define BOTAN_EC_POINT_H_
13#include <botan/curve_gfp.h>
14#include <botan/exceptn.h>
46 enum { WORKSPACE_SIZE = 8 };
139 m_coord_y = m_curve.get_p() - m_coord_y;
161 bool is_affine()
const;
167 bool is_zero()
const {
return m_coord_z.is_zero(); }
174 bool on_the_curve()
const;
195 BigInt get_affine_x()
const;
201 BigInt get_affine_y()
const;
225 void swap(
EC_Point& other)
noexcept;
227#if defined(BOTAN_DISABLE_DEPRECATED_FEATURES)
257 m_coord_x.
swap(new_x);
258 m_coord_y.swap(new_y);
259 m_coord_z.swap(new_z);
276 BOTAN_ARG_CHECK(m_curve == other.m_curve,
"cannot add points on different curves");
278 const size_t p_words = m_curve.get_p_words();
280 add(other.m_coord_x.
_data(),
281 std::min(p_words, other.m_coord_x.
size()),
282 other.m_coord_y.
_data(),
283 std::min(p_words, other.m_coord_y.
size()),
284 other.m_coord_z.
_data(),
285 std::min(p_words, other.m_coord_z.
size()),
300 void add(
const word x_words[],
302 const word y_words[],
304 const word z_words[],
306 std::vector<BigInt>& workspace);
321 const size_t p_words = m_curve.get_p_words();
322 add_affine(other.m_coord_x.
_data(),
323 std::min(p_words, other.m_coord_x.
size()),
324 other.m_coord_y.
_data(),
325 std::min(p_words, other.m_coord_y.
size()),
339 const word x_words[],
size_t x_size,
const word y_words[],
size_t y_size, std::vector<BigInt>& workspace);
345 void mult2(std::vector<BigInt>& workspace);
352 void mult2i(
size_t i, std::vector<BigInt>& workspace);
362 x.
add(other, workspace);
387 BigInt m_coord_x, m_coord_y, m_coord_z;
399EC_Point
multi_exponentiate(const EC_Point& p1, const BigInt& z1, const EC_Point& p2, const BigInt& z2);
417 return point.
mul(scalar);
421 return point.
mul(scalar);
443 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)