Botan 3.1.1
Crypto and TLS for C&
|
#include <ec_point.h>
Public Types | |
enum | { WORKSPACE_SIZE = 8 } |
typedef EC_Point_Format | Compression_Type |
Public Member Functions | |
void | add (const EC_Point &other, std::vector< BigInt > &workspace) |
void | add (const word x_words[], size_t x_size, const word y_words[], size_t y_size, const word z_words[], size_t z_size, std::vector< BigInt > &workspace) |
void | add_affine (const EC_Point &other, std::vector< BigInt > &workspace) |
void | add_affine (const word x_words[], size_t x_size, const word y_words[], size_t y_size, std::vector< BigInt > &workspace) |
EC_Point | double_of (std::vector< BigInt > &workspace) const |
EC_Point ()=default | |
EC_Point (const CurveGFp &curve) | |
EC_Point (const CurveGFp &curve, const BigInt &x, const BigInt &y) | |
EC_Point (const EC_Point &)=default | |
EC_Point (EC_Point &&other) | |
std::vector< uint8_t > | encode (EC_Point_Format format) const |
void | force_affine () |
BigInt | get_affine_x () const |
BigInt | get_affine_y () const |
const CurveGFp & | get_curve () const |
const BigInt & | get_x () const |
const BigInt & | get_y () const |
const BigInt & | get_z () const |
bool | is_affine () const |
bool | is_zero () const |
void | mult2 (std::vector< BigInt > &workspace) |
void | mult2i (size_t i, std::vector< BigInt > &workspace) |
EC_Point & | negate () |
bool | on_the_curve () const |
EC_Point & | operator*= (const BigInt &scalar) |
EC_Point & | operator+= (const EC_Point &rhs) |
EC_Point & | operator-= (const EC_Point &rhs) |
EC_Point & | operator= (const EC_Point &)=default |
EC_Point & | operator= (EC_Point &&other) |
bool | operator== (const EC_Point &other) const |
EC_Point | plus (const EC_Point &other, std::vector< BigInt > &workspace) const |
void | randomize_repr (RandomNumberGenerator &rng) |
void | randomize_repr (RandomNumberGenerator &rng, secure_vector< word > &ws) |
void | swap (EC_Point &other) |
void | swap_coords (BigInt &new_x, BigInt &new_y, BigInt &new_z) |
EC_Point | zero () const |
Static Public Member Functions | |
static void | force_all_affine (std::vector< EC_Point > &points, secure_vector< word > &ws) |
This class represents one point on a curve of GF(p)
Definition at line 32 of file ec_point.h.
Definition at line 34 of file ec_point.h.
anonymous enum |
|
default |
Construct an uninitialized EC_Point
Referenced by mult2(), mult2i(), and operator-=().
|
explicit |
Construct the zero point
curve | The base curve |
Definition at line 18 of file ec_point.cpp.
|
default |
Copy constructor
|
inline |
Construct a point from its affine coordinates Prefer EC_Group::point(x,y) for this operation.
curve | the base curve |
x | affine x coordinate |
y | affine y coordinate |
Definition at line 22 of file ec_point.cpp.
References Botan::CurveGFp::get_p(), Botan::CurveGFp::get_ws_size(), and Botan::CurveGFp::to_rep().
Point addition
other | the point to add to *this |
workspace | temp space, at least WORKSPACE_SIZE elements |
Definition at line 212 of file ec_point.h.
References BOTAN_ARG_CHECK, Botan::BigInt::data(), and Botan::BigInt::size().
Referenced by Botan::EC_Point_Var_Point_Precompute::mul(), Botan::EC_Point_Multi_Point_Precompute::multi_exp(), Botan::operator*(), operator+=(), and plus().
void Botan::EC_Point::add | ( | const word | x_words[], |
size_t | x_size, | ||
const word | y_words[], | ||
size_t | y_size, | ||
const word | z_words[], | ||
size_t | z_size, | ||
std::vector< BigInt > & | workspace | ||
) |
Point addition. Array version.
x_words | the words of the x coordinate of the other point |
x_size | size of x_words |
y_words | the words of the y coordinate of the other point |
y_size | size of y_words |
z_words | the words of the z coordinate of the other point |
z_size | size of z_words |
workspace | temp space, at least WORKSPACE_SIZE elements |
Definition at line 150 of file ec_point.cpp.
References Botan::CT::all_zeros(), Botan::BigInt::clear(), Botan::CurveGFp::get_1_rep(), Botan::CurveGFp::get_p(), Botan::CurveGFp::get_ws_size(), Botan::BigInt::is_zero(), is_zero(), Botan::BigInt::mod_sub(), Botan::CurveGFp::mul(), mult2(), Botan::BigInt::set_words(), and Botan::CurveGFp::sqr().
|
inline |
Point addition - mixed J+A
other | affine point to add - assumed to be affine! |
workspace | temp space, at least WORKSPACE_SIZE elements |
Definition at line 250 of file ec_point.h.
References BOTAN_ASSERT_NOMSG, BOTAN_DEBUG_ASSERT, Botan::BigInt::data(), is_affine(), and Botan::BigInt::size().
Referenced by Botan::EC_Point_Base_Point_Precompute::mul(), and Botan::EC_Point_Multi_Point_Precompute::multi_exp().
void Botan::EC_Point::add_affine | ( | const word | x_words[], |
size_t | x_size, | ||
const word | y_words[], | ||
size_t | y_size, | ||
std::vector< BigInt > & | workspace | ||
) |
Point addition - mixed J+A. Array version.
x_words | the words of the x coordinate of the other point |
x_size | size of x_words |
y_words | the words of the y coordinate of the other point |
y_size | size of y_words |
workspace | temp space, at least WORKSPACE_SIZE elements |
Definition at line 73 of file ec_point.cpp.
References Botan::CT::all_zeros(), Botan::BigInt::clear(), Botan::CurveGFp::get_1_rep(), Botan::CurveGFp::get_p(), Botan::CurveGFp::get_ws_size(), Botan::BigInt::is_zero(), is_zero(), Botan::BigInt::mod_sub(), Botan::CurveGFp::mul(), mult2(), Botan::BigInt::set_words(), Botan::CurveGFp::sqr(), and Botan::BigInt::swap().
Point doubling
workspace | temp space, at least WORKSPACE_SIZE elements |
Definition at line 304 of file ec_point.h.
References mult2().
Referenced by Botan::EC_Point_Var_Point_Precompute::EC_Point_Var_Point_Precompute().
std::vector< uint8_t > Botan::EC_Point::encode | ( | EC_Point_Format | format | ) | const |
EC2OSP - elliptic curve to octet string primitive
format | which format to encode using |
Definition at line 568 of file ec_point.cpp.
References Botan::BigInt::bytes(), Botan::Compressed, Botan::BigInt::encode_1363(), get_affine_x(), get_affine_y(), Botan::BigInt::get_bit(), Botan::CurveGFp::get_p(), Botan::Hybrid, is_zero(), and Botan::Uncompressed.
Referenced by Botan::ECIES_KA_Operation::derive_secret(), Botan::ECIES_Encryptor::ECIES_Encryptor(), Botan::EC_PrivateKey::private_key_bits(), and Botan::EC_PublicKey::public_key_bits().
void Botan::EC_Point::force_affine | ( | ) |
Force this point to affine coordinates
Definition at line 450 of file ec_point.cpp.
References Botan::CurveGFp::get_1_rep(), Botan::CurveGFp::invert_element(), is_zero(), Botan::CurveGFp::mul_to_tmp(), and Botan::CurveGFp::sqr_to_tmp().
|
static |
Force all points on the list to affine coordinates
Definition at line 388 of file ec_point.cpp.
References Botan::CurveGFp::get_1_rep(), Botan::CurveGFp::get_ws_size(), Botan::CurveGFp::invert_element(), Botan::CurveGFp::mul(), Botan::CurveGFp::mul_to_tmp(), Botan::BigInt::resize(), and Botan::CurveGFp::sqr().
Referenced by Botan::EC_Point_Base_Point_Precompute::EC_Point_Base_Point_Precompute(), and Botan::EC_Point_Multi_Point_Precompute::EC_Point_Multi_Point_Precompute().
BigInt Botan::EC_Point::get_affine_x | ( | ) | const |
get affine x coordinate
Definition at line 469 of file ec_point.cpp.
References Botan::CurveGFp::from_rep(), Botan::CurveGFp::from_rep_to_tmp(), Botan::CurveGFp::invert_element(), is_affine(), is_zero(), Botan::CurveGFp::mul(), and Botan::CurveGFp::sqr_to_tmp().
Referenced by Botan::EC_Group::blinded_base_point_multiply_x(), encode(), operator==(), Botan::GOST_3410_PublicKey::public_key_bits(), and Botan::sm2_compute_za().
BigInt Botan::EC_Point::get_affine_y | ( | ) | const |
get affine y coordinate
Definition at line 489 of file ec_point.cpp.
References Botan::CurveGFp::from_rep(), Botan::CurveGFp::from_rep_to_tmp(), Botan::CurveGFp::invert_element(), is_affine(), is_zero(), Botan::CurveGFp::mul(), Botan::CurveGFp::mul_to_tmp(), and Botan::CurveGFp::sqr_to_tmp().
Referenced by encode(), operator==(), Botan::GOST_3410_PublicKey::public_key_bits(), and Botan::sm2_compute_za().
|
inline |
Return base curve of this point
You should not need to use this
Definition at line 321 of file ec_point.h.
Referenced by Botan::EC_Point_Base_Point_Precompute::EC_Point_Base_Point_Precompute().
|
inline |
Return the internal x coordinate
Note this may be in Montgomery form
Definition at line 137 of file ec_point.h.
Referenced by Botan::EC_PublicKey::get_int_field().
|
inline |
Return the internal y coordinate
Note this may be in Montgomery form
Definition at line 144 of file ec_point.h.
Referenced by Botan::EC_PublicKey::get_int_field().
|
inline |
Return the internal z coordinate
Note this may be in Montgomery form
Definition at line 151 of file ec_point.h.
bool Botan::EC_Point::is_affine | ( | ) | const |
Definition at line 465 of file ec_point.cpp.
References Botan::CurveGFp::is_one().
Referenced by add_affine(), get_affine_x(), and get_affine_y().
|
inline |
Is this the point at infinity?
Definition at line 175 of file ec_point.h.
Referenced by add(), add_affine(), Botan::EC_Group::blinded_base_point_multiply_x(), Botan::ECIES_KA_Operation::derive_secret(), encode(), force_affine(), get_affine_x(), get_affine_y(), mult2(), on_the_curve(), operator-=(), operator==(), and Botan::EC_Group::verify_public_element().
void Botan::EC_Point::mult2 | ( | std::vector< BigInt > & | workspace | ) |
Point doubling
workspace | temp space, at least WORKSPACE_SIZE elements |
Definition at line 256 of file ec_point.cpp.
References Botan::CurveGFp::a_is_minus_3(), Botan::CurveGFp::a_is_zero(), EC_Point(), Botan::CurveGFp::get_a_rep(), Botan::CurveGFp::get_p(), Botan::CurveGFp::get_ws_size(), Botan::BigInt::is_zero(), is_zero(), Botan::BigInt::mod_add(), Botan::BigInt::mod_mul(), Botan::BigInt::mod_sub(), Botan::CurveGFp::mul(), Botan::CurveGFp::sqr(), and Botan::BigInt::swap().
Referenced by add(), add_affine(), double_of(), Botan::EC_Point_Base_Point_Precompute::EC_Point_Base_Point_Precompute(), Botan::EC_Point_Multi_Point_Precompute::EC_Point_Multi_Point_Precompute(), mult2i(), and Botan::operator*().
void Botan::EC_Point::mult2i | ( | size_t | i, |
std::vector< BigInt > & | workspace | ||
) |
Repeated point doubling
i | number of doublings to perform |
workspace | temp space, at least WORKSPACE_SIZE elements |
Definition at line 236 of file ec_point.cpp.
References EC_Point(), Botan::BigInt::is_zero(), and mult2().
Referenced by Botan::EC_Point_Var_Point_Precompute::mul(), and Botan::EC_Point_Multi_Point_Precompute::multi_exp().
|
inline |
Negate this point
Definition at line 114 of file ec_point.h.
Referenced by Botan::EC_Point_Multi_Point_Precompute::multi_exp(), Botan::operator*(), and Botan::operator-().
bool Botan::EC_Point::on_the_curve | ( | ) | const |
Checks whether the point is to be found on the underlying curve; used to prevent fault attacks.
Definition at line 510 of file ec_point.cpp.
References Botan::CurveGFp::from_rep_to_tmp(), Botan::CurveGFp::get_a_rep(), Botan::CurveGFp::get_b_rep(), is_zero(), Botan::CurveGFp::mul_to_tmp(), and Botan::CurveGFp::sqr_to_tmp().
Referenced by Botan::EC_Point_Multi_Point_Precompute::EC_Point_Multi_Point_Precompute(), Botan::EC_PrivateKey::EC_PrivateKey(), Botan::GOST_3410_PublicKey::GOST_3410_PublicKey(), Botan::EC_Point_Base_Point_Precompute::mul(), Botan::EC_Point_Var_Point_Precompute::mul(), Botan::operator*(), Botan::OS2ECP(), Botan::EC_Group::verify_group(), and Botan::EC_Group::verify_public_element().
*= Operator
scalar | the EC_Point to multiply with *this |
Definition at line 358 of file ec_point.cpp.
+= Operator
rhs | the EC_Point to add to the local value |
Definition at line 340 of file ec_point.cpp.
References add(), and WORKSPACE_SIZE.
-= Operator
rhs | the EC_Point to subtract from the local value |
Definition at line 346 of file ec_point.cpp.
References EC_Point(), and is_zero().
Move Assignment
Definition at line 68 of file ec_point.h.
bool Botan::EC_Point::operator== | ( | const EC_Point & | other | ) | const |
Equality operator
Definition at line 554 of file ec_point.cpp.
References get_affine_x(), get_affine_y(), and is_zero().
|
inline |
Point addition
other | the point to add to *this |
workspace | temp space, at least WORKSPACE_SIZE elements |
Definition at line 293 of file ec_point.h.
References add().
Referenced by Botan::EC_Point_Multi_Point_Precompute::EC_Point_Multi_Point_Precompute(), and Botan::EC_Point_Var_Point_Precompute::EC_Point_Var_Point_Precompute().
void Botan::EC_Point::randomize_repr | ( | RandomNumberGenerator & | rng | ) |
Randomize the point representation The actual value (get_affine_x, get_affine_y) does not change
Definition at line 36 of file ec_point.cpp.
References Botan::CurveGFp::get_ws_size(), and randomize_repr().
Referenced by Botan::EC_Point_Base_Point_Precompute::mul(), Botan::EC_Point_Var_Point_Precompute::mul(), and randomize_repr().
void Botan::EC_Point::randomize_repr | ( | RandomNumberGenerator & | rng, |
secure_vector< word > & | ws | ||
) |
Randomize the point representation The actual value (get_affine_x, get_affine_y) does not change
Definition at line 41 of file ec_point.cpp.
References Botan::CurveGFp::get_p(), Botan::CurveGFp::mul_to_tmp(), Botan::BigInt::random_integer(), and Botan::CurveGFp::sqr_to_tmp().
void Botan::EC_Point::swap | ( | EC_Point & | other | ) |
swaps the states of *this and other, does not throw!
other | the object to swap values with |
Definition at line 547 of file ec_point.cpp.
References Botan::BigInt::swap(), and Botan::CurveGFp::swap().
Referenced by Botan::EC_Point_Base_Point_Precompute::EC_Point_Base_Point_Precompute(), and std::swap< Botan::EC_Point >().
Definition at line 153 of file ec_point.h.
|
inline |
Return the zero (aka infinite) point associated with this curve
Definition at line 313 of file ec_point.h.
Referenced by Botan::EC_Point_Multi_Point_Precompute::EC_Point_Multi_Point_Precompute(), Botan::EC_Point_Var_Point_Precompute::EC_Point_Var_Point_Precompute(), Botan::EC_Point_Base_Point_Precompute::mul(), and Botan::operator*().