10#ifndef BOTAN_POINT_GFP_H_
11#define BOTAN_POINT_GFP_H_
13#include <botan/curve_gfp.h>
14#include <botan/exceptn.h>
31 enum { WORKSPACE_SIZE = 8 };
115 m_coord_y = m_curve.get_p() - m_coord_y;
123 BigInt get_affine_x()
const;
129 BigInt get_affine_y()
const;
137 m_coord_x.swap(new_x);
138 m_coord_y.swap(new_y);
139 m_coord_z.swap(new_z);
150 static void force_all_affine(std::vector<PointGFp>& points,
153 bool is_affine()
const;
159 bool is_zero()
const {
return m_coord_z.is_zero(); }
166 bool on_the_curve()
const;
198 BOTAN_ARG_CHECK(m_curve == other.m_curve,
"cannot add points on different curves");
200 const size_t p_words = m_curve.get_p_words();
202 add(other.m_coord_x.
data(), std::min(p_words, other.m_coord_x.
size()),
203 other.m_coord_y.
data(), std::min(p_words, other.m_coord_y.
size()),
204 other.m_coord_z.
data(), std::min(p_words, other.m_coord_z.
size()),
219 void add(
const word x_words[],
size_t x_size,
220 const word y_words[],
size_t y_size,
221 const word z_words[],
size_t z_size,
222 std::vector<BigInt>& workspace);
234 const size_t p_words = m_curve.get_p_words();
235 add_affine(other.m_coord_x.
data(), std::min(p_words, other.m_coord_x.
size()),
236 other.m_coord_y.
data(), std::min(p_words, other.m_coord_y.
size()),
249 void add_affine(
const word x_words[],
size_t x_size,
250 const word y_words[],
size_t y_size,
251 std::vector<BigInt>& workspace);
257 void mult2(std::vector<BigInt>& workspace);
264 void mult2i(
size_t i, std::vector<BigInt>& workspace);
275 x.
add(other, workspace);
306 BigInt m_coord_x, m_coord_y, m_coord_z;
315BOTAN_PUBLIC_API(2,0) PointGFp operator*(const BigInt& scalar, const PointGFp& point);
326 const PointGFp& p1, const BigInt& z1,
327 const PointGFp& p2, const BigInt& z2);
332 return !(rhs == lhs);
355 return scalar * point;
363 const CurveGFp& curve);
376 const BigInt& curve_p,
377 const BigInt& curve_a,
378 const BigInt& curve_b);
380template<typename Alloc>
382 {
return OS2ECP(data.data(), data.size(), curve); }
384class PointGFp_Var_Point_Precompute;
#define BOTAN_ASSERT_NOMSG(expr)
#define BOTAN_DEBUG_ASSERT(expr)
#define BOTAN_ARG_CHECK(expr, msg)
const word * data() const
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)
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