Botan 3.5.0
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 |
EC_Point | mul (const BigInt &scalar) const |
void | mult2 (std::vector< BigInt > &workspace) |
void | mult2i (size_t i, std::vector< BigInt > &workspace) |
EC_Point & | negate () |
bool | on_the_curve () const |
bool | operator!= (const EC_Point &other) const =default |
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) noexcept |
void | swap_coords (BigInt &new_x, BigInt &new_y, BigInt &new_z) |
secure_vector< uint8_t > | x_bytes () const |
secure_vector< uint8_t > | xy_bytes () const |
secure_vector< uint8_t > | y_bytes () const |
EC_Point | zero () const |
Static Public Member Functions | |
static void | force_all_affine (std::span< EC_Point > points, secure_vector< word > &ws) |
Friends | |
class | EC_Point_Base_Point_Precompute |
class | EC_Point_Multi_Point_Precompute |
class | EC_Point_Var_Point_Precompute |
void | swap (EC_Point &x, EC_Point &y) |
This class represents one point on a curve of GF(p)
Definition at line 33 of file ec_point.h.
Definition at line 39 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 19 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 23 of file ec_point.cpp.
References Botan::CurveGFp::get_p().
Point addition
other | the point to add to *this |
workspace | temp space, at least WORKSPACE_SIZE elements |
Definition at line 263 of file ec_point.h.
References Botan::BigInt::_data(), BOTAN_ARG_CHECK, and Botan::BigInt::size().
Referenced by mul(), Botan::EC_Point_Var_Point_Precompute::mul(), Botan::EC_Point_Multi_Point_Precompute::multi_exp(), 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 151 of file ec_point.cpp.
References Botan::CT::all_zeros(), Botan::BigInt::clear(), Botan::CurveGFp::get_p(), Botan::BigInt::is_zero(), is_zero(), Botan::BigInt::mod_sub(), mult2(), and Botan::BigInt::set_words().
|
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 301 of file ec_point.h.
References Botan::BigInt::_data(), BOTAN_ASSERT_NOMSG, BOTAN_DEBUG_ASSERT, 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 74 of file ec_point.cpp.
References Botan::CT::all_zeros(), Botan::BigInt::clear(), Botan::CurveGFp::get_p(), Botan::BigInt::is_zero(), is_zero(), Botan::BigInt::mod_sub(), mult2(), Botan::BigInt::set_words(), and Botan::BigInt::swap().
Point doubling
workspace | temp space, at least WORKSPACE_SIZE elements |
Definition at line 355 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 589 of file ec_point.cpp.
References Botan::BufferStuffer::append(), Botan::BigInt::bytes(), Botan::Compressed, get_affine_x(), get_affine_y(), Botan::BigInt::get_bit(), Botan::CurveGFp::get_p(), Botan::Hybrid, is_zero(), Botan::BufferStuffer::next(), Botan::BigInt::serialize_to(), 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::raw_public_key_bits().
void Botan::EC_Point::force_affine | ( | ) |
Force this point to affine coordinates
Definition at line 449 of file ec_point.cpp.
References is_zero().
Referenced by force_all_affine().
|
static |
Force all points on the list to affine coordinates
Definition at line 387 of file ec_point.cpp.
References force_affine(), and Botan::BigInt::resize().
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 490 of file ec_point.cpp.
References is_affine(), and is_zero().
Referenced by Botan::EC_Group::blinded_base_point_multiply_x(), encode(), operator==(), and xy_bytes().
BigInt Botan::EC_Point::get_affine_y | ( | ) | const |
get affine y coordinate
Definition at line 510 of file ec_point.cpp.
References is_affine(), and is_zero().
Referenced by encode(), operator==(), and xy_bytes().
|
inline |
Return base curve of this point
You should not need to use this
Definition at line 367 of file ec_point.h.
|
inline |
Return the internal x coordinate
Note this may be in Montgomery form
Definition at line 226 of file ec_point.h.
|
inline |
Return the internal y coordinate
Note this may be in Montgomery form
Definition at line 233 of file ec_point.h.
|
inline |
Return the internal z coordinate
Note this may be in Montgomery form
Definition at line 240 of file ec_point.h.
bool Botan::EC_Point::is_affine | ( | ) | const |
Definition at line 464 of file ec_point.cpp.
Referenced by add_affine(), get_affine_x(), and get_affine_y().
|
inline |
Is this the point at infinity?
Definition at line 156 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().
Point multiplication operator
Simple unblinded Montgomery ladder
Warning: prefer the functions on EC_Group such as blinded_var_point_multiply
scalar | the scalar value |
Definition at line 364 of file ec_point.cpp.
References add(), Botan::BigInt::bits(), BOTAN_DEBUG_ASSERT, Botan::BigInt::get_bit(), Botan::BigInt::is_negative(), mult2(), negate(), on_the_curve(), WORKSPACE_SIZE, and zero().
Referenced by Botan::operator*(), and Botan::operator*().
void Botan::EC_Point::mult2 | ( | std::vector< BigInt > & | workspace | ) |
Point doubling
workspace | temp space, at least WORKSPACE_SIZE elements |
Definition at line 257 of file ec_point.cpp.
References EC_Point(), Botan::CurveGFp::get_p(), Botan::BigInt::is_zero(), is_zero(), Botan::BigInt::mod_add(), Botan::BigInt::mod_mul(), Botan::BigInt::mod_sub(), 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(), mul(), and mult2i().
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 237 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 133 of file ec_point.h.
Referenced by mul(), Botan::EC_Point_Multi_Point_Precompute::multi_exp(), Botan::operator-(), and 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 531 of file ec_point.cpp.
References is_zero().
Referenced by Botan::EC_Point_Multi_Point_Precompute::EC_Point_Multi_Point_Precompute(), Botan::EC_PrivateKey::EC_PrivateKey(), Botan::EC_PrivateKey::EC_PrivateKey(), Botan::GOST_3410_PublicKey::GOST_3410_PublicKey(), mul(), Botan::EC_Point_Base_Point_Precompute::mul(), Botan::EC_Point_Var_Point_Precompute::mul(), Botan::OS2ECP(), Botan::EC_Group::verify_group(), and Botan::EC_Group::verify_public_element().
|
default |
*= Operator
scalar | the EC_Point to multiply with *this |
Definition at line 359 of file ec_point.cpp.
+= Operator
rhs | the EC_Point to add to the local value |
Definition at line 341 of file ec_point.cpp.
References add(), and WORKSPACE_SIZE.
-= Operator
rhs | the EC_Point to subtract from the local value |
Definition at line 347 of file ec_point.cpp.
References EC_Point(), is_zero(), and negate().
Move Assignment
Definition at line 73 of file ec_point.h.
bool Botan::EC_Point::operator== | ( | const EC_Point & | other | ) | const |
Equality operator
Definition at line 575 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 344 of file ec_point.h.
References add().
Referenced by Botan::EC_Point_Base_Point_Precompute::EC_Point_Base_Point_Precompute(), 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 37 of file ec_point.cpp.
References randomize_repr().
Referenced by Botan::EC_Point_Var_Point_Precompute::EC_Point_Var_Point_Precompute(), 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 42 of file ec_point.cpp.
References Botan::CurveGFp::get_p(), and Botan::BigInt::random_integer().
|
noexcept |
swaps the states of *this and other
other | the object to swap values with |
Definition at line 568 of file ec_point.cpp.
References Botan::BigInt::swap().
Referenced by Botan::EC_Point_Base_Point_Precompute::EC_Point_Base_Point_Precompute().
Definition at line 244 of file ec_point.h.
References Botan::BigInt::swap().
secure_vector< uint8_t > Botan::EC_Point::x_bytes | ( | ) | const |
Return the fixed length big endian encoding of x coordinate
Definition at line 468 of file ec_point.cpp.
References Botan::BigInt::encode_1363().
secure_vector< uint8_t > Botan::EC_Point::xy_bytes | ( | ) | const |
Return the fixed length concatenation of the x and y coordinates
Definition at line 482 of file ec_point.cpp.
References Botan::BigInt::encode_1363(), get_affine_x(), and get_affine_y().
Referenced by Botan::GOST_3410_PublicKey::public_key_bits(), and Botan::sm2_compute_za().
secure_vector< uint8_t > Botan::EC_Point::y_bytes | ( | ) | const |
Return the fixed length big endian encoding of y coordinate
Definition at line 475 of file ec_point.cpp.
References Botan::BigInt::encode_1363().
|
inline |
Return the zero (aka infinite) point associated with this curve
Definition at line 195 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(), mul(), and Botan::EC_Point_Base_Point_Precompute::mul().
|
friend |
Definition at line 37 of file ec_point.h.
|
friend |
Definition at line 36 of file ec_point.h.
|
friend |
Definition at line 35 of file ec_point.h.
Definition at line 250 of file ec_point.h.