10#ifndef BOTAN_POINT_GFP_H_
11#define BOTAN_POINT_GFP_H_
13#include <botan/curve_gfp.h>
14#include <botan/exceptn.h>
56 enum { WORKSPACE_SIZE = 8 };
140 m_coord_y = m_curve.get_p() - m_coord_y;
148 BigInt get_affine_x()
const;
154 BigInt get_affine_y()
const;
162 m_coord_x.swap(new_x);
163 m_coord_y.swap(new_y);
164 m_coord_z.swap(new_z);
175 static void force_all_affine(std::vector<PointGFp>& points,
178 bool is_affine()
const;
184 bool is_zero()
const {
return m_coord_z.is_zero(); }
191 bool on_the_curve()
const;
225 const size_t p_words = m_curve.get_p_words();
227 add(other.m_coord_x.
data(), std::min(p_words, other.m_coord_x.
size()),
228 other.m_coord_y.
data(), std::min(p_words, other.m_coord_y.
size()),
229 other.m_coord_z.
data(), std::min(p_words, other.m_coord_z.
size()),
244 void add(
const word x_words[],
size_t x_size,
245 const word y_words[],
size_t y_size,
246 const word z_words[],
size_t z_size,
247 std::vector<BigInt>& workspace);
259 const size_t p_words = m_curve.get_p_words();
260 add_affine(other.m_coord_x.
data(), std::min(p_words, other.m_coord_x.
size()),
261 other.m_coord_y.
data(), std::min(p_words, other.m_coord_y.
size()),
274 void add_affine(
const word x_words[],
size_t x_size,
275 const word y_words[],
size_t y_size,
276 std::vector<BigInt>& workspace);
282 void mult2(std::vector<BigInt>& workspace);
289 void mult2i(
size_t i, std::vector<BigInt>& workspace);
300 x.
add(other, workspace);
331 BigInt m_coord_x, m_coord_y, m_coord_z;
340BOTAN_PUBLIC_API(2,0) PointGFp operator*(const BigInt& scalar, const PointGFp& point);
351 const PointGFp& p1, const BigInt& z1,
352 const PointGFp& p2, const BigInt& z2);
357 return !(rhs == lhs);
380 return scalar * point;
384inline secure_vector<uint8_t> BOTAN_DEPRECATED(
"Use PointGFp::encode")
396 const CurveGFp& curve);
409 const BigInt& curve_p,
410 const BigInt& curve_a,
411 const BigInt& curve_b);
413template<typename Alloc>
415 {
return OS2ECP(data.data(), data.size(), curve); }
417class PointGFp_Var_Point_Precompute;
432 std::vector<BigInt> m_ws;
434 std::unique_ptr<PointGFp_Var_Point_Precompute> m_point_mul;
#define BOTAN_ASSERT_NOMSG(expr)
#define BOTAN_DEBUG_ASSERT(expr)
const word * data() const
Illegal_Point(const std::string &err)
void mult2(std::vector< BigInt > &workspace)
const BigInt & get_x() const
PointGFp double_of(std::vector< BigInt > &workspace) const
PointGFp & operator=(const PointGFp &)=default
void swap_coords(BigInt &new_x, BigInt &new_y, BigInt &new_z)
void add_affine(const PointGFp &other, std::vector< BigInt > &workspace)
PointGFp & operator=(PointGFp &&other)
PointGFp(const PointGFp &)=default
void swap(PointGFp &other)
PointGFp(PointGFp &&other)
const BigInt & get_y() const
PointGFp plus(const PointGFp &other, std::vector< BigInt > &workspace) const
const CurveGFp & get_curve() const
const BigInt & get_z() const
void add(const PointGFp &other, std::vector< BigInt > &workspace)
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
#define BOTAN_UNSTABLE_API
std::string encode(const uint8_t der[], size_t length, const std::string &label, size_t width)
PointGFp OS2ECP(const uint8_t data[], size_t data_len, const CurveGFp &curve)
BigInt operator*(const BigInt &x, const BigInt &y)
secure_vector< uint8_t > EC2OSP(const PointGFp &point, uint8_t format)
PointGFp multi_exponentiate(const PointGFp &p1, const BigInt &z1, const PointGFp &p2, const BigInt &z2)
BigInt operator-(const BigInt &x, const BigInt &y)
OID operator+(const OID &oid, uint32_t new_comp)
bool operator==(const AlgorithmIdentifier &a1, const AlgorithmIdentifier &a2)
std::vector< T, Alloc > & operator+=(std::vector< T, Alloc > &out, const std::vector< T, Alloc2 > &in)
std::vector< T, secure_allocator< T > > secure_vector