Botan 3.7.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 | |
bool | _is_x_eq_to_v_mod_order (const BigInt &v) const |
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, BigInt x, 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) |
Deprecated elliptic curve type
Use EC_AffinePoint in new code; this type is no longer used internally at all except to support very unfortunate (and deprecated) curve types, specifically those with a cofactor, or with unreasonable sizes (above 521 bits), which cannot be accomodated by the new faster EC library in math/pcurves. For normal curves EC_AffinePoint will typically be 2 or 3 times faster.
This type will be completely removed in Botan4
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(), operator-=(), and zero().
|
explicit |
Construct the zero point
curve | The base curve |
Definition at line 97 of file ec_point.cpp.
|
default |
Copy constructor
|
inline |
Construct a point from its affine coordinates
curve | the base curve |
x | affine x coordinate |
y | affine y coordinate |
Definition at line 103 of file ec_point.cpp.
bool Botan::EC_Point::_is_x_eq_to_v_mod_order | ( | const BigInt & | v | ) | const |
For internal use only
Definition at line 675 of file ec_point.cpp.
References Botan::fe_mul(), get_affine_x(), get_x(), get_z(), and is_zero().
Referenced by Botan::EC_Mul2Table_Data_BN::mul2_vartime_x_mod_order_eq().
Point addition
other | the point to add to *this |
workspace | temp space, at least WORKSPACE_SIZE elements |
Definition at line 274 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 243 of file ec_point.cpp.
References Botan::CT::all_zeros(), Botan::BigInt::clear(), Botan::fe_mul(), Botan::BigInt::is_zero(), is_zero(), Botan::BigInt::mod_sub(), mult2(), and Botan::BigInt::set_words().
|
inline |
Point addition - mixed J+A
other
is affine, if this is not correct the result will be invalid.other | affine point to add - assumed to be affine! |
workspace | temp space, at least WORKSPACE_SIZE elements |
Definition at line 316 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 164 of file ec_point.cpp.
References Botan::CT::all_zeros(), Botan::BigInt::clear(), Botan::fe_mul(), 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 370 of file ec_point.h.
References mult2().
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 762 of file ec_point.cpp.
References Botan::BufferStuffer::append(), Botan::Compressed, get_affine_x(), get_affine_y(), Botan::BigInt::get_bit(), Botan::Hybrid, is_zero(), Botan::BufferStuffer::next(), Botan::EC_Group_Data::p_bytes(), Botan::BigInt::serialize_to(), and Botan::Uncompressed.
void Botan::EC_Point::force_affine | ( | ) |
Force this point to affine coordinates
Convert the point to its equivalent affine coordinates. Throws if this is the point at infinity.
Definition at line 545 of file ec_point.cpp.
References Botan::fe_mul(), and is_zero().
|
static |
Force all points on the list to affine coordinates
Force several points to be affine at once. Uses Montgomery's trick to reduce number of inversions required, so this is much faster than calling force_affine
on each point in sequence.
Definition at line 483 of file ec_point.cpp.
References Botan::fe_mul().
Referenced by Botan::EC_Point_Base_Point_Precompute::EC_Point_Base_Point_Precompute().
BigInt Botan::EC_Point::get_affine_x | ( | ) | const |
get affine x coordinate
Definition at line 592 of file ec_point.cpp.
References Botan::fe_mul(), is_affine(), and is_zero().
Referenced by _is_x_eq_to_v_mod_order(), encode(), operator==(), and xy_bytes().
BigInt Botan::EC_Point::get_affine_y | ( | ) | const |
get affine y coordinate
Definition at line 614 of file ec_point.cpp.
References Botan::fe_mul(), 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 382 of file ec_point.h.
|
inline |
Return the internal x coordinate
Note this may be in Montgomery form
Definition at line 237 of file ec_point.h.
Referenced by _is_x_eq_to_v_mod_order().
|
inline |
Return the internal y coordinate
Note this may be in Montgomery form
Definition at line 244 of file ec_point.h.
|
inline |
Return the internal z coordinate
Note this may be in Montgomery form
Definition at line 251 of file ec_point.h.
Referenced by _is_x_eq_to_v_mod_order().
bool Botan::EC_Point::is_affine | ( | ) | const |
Definition at line 562 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 162 of file ec_point.h.
Referenced by _is_x_eq_to_v_mod_order(), add(), add_affine(), Botan::EC_AffinePoint_Data_BN::EC_AffinePoint_Data_BN(), Botan::EC_AffinePoint_Data_BN::EC_AffinePoint_Data_BN(), encode(), force_affine(), get_affine_x(), get_affine_y(), mult2(), on_the_curve(), operator-=(), and operator==().
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 460 of file ec_point.cpp.
References add(), Botan::b, 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 351 of file ec_point.cpp.
References EC_Point(), Botan::fe_mul(), 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 331 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 132 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 636 of file ec_point.cpp.
References Botan::fe_mul(), and is_zero().
Referenced by Botan::EC_Point_Multi_Point_Precompute::EC_Point_Multi_Point_Precompute(), mul(), Botan::EC_Point_Base_Point_Precompute::mul(), Botan::EC_Point_Var_Point_Precompute::mul(), Botan::OS2ECP(), and Botan::EC_Group::verify_group().
|
default |
*= Operator
scalar | the EC_Point to multiply with *this |
Definition at line 455 of file ec_point.cpp.
+= Operator
rhs | the EC_Point to add to the local value |
Definition at line 437 of file ec_point.cpp.
References add(), and WORKSPACE_SIZE.
-= Operator
rhs | the EC_Point to subtract from the local value |
Definition at line 443 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 748 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 359 of file ec_point.h.
References add().
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().
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 120 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 126 of file ec_point.cpp.
References Botan::fe_mul(), Botan::RandomNumberGenerator::is_seeded(), and Botan::BigInt::random_integer().
|
noexcept |
swaps the states of *this and other
other | the object to swap values with |
Definition at line 741 of file ec_point.cpp.
Referenced by Botan::EC_Point_Base_Point_Precompute::EC_Point_Base_Point_Precompute().
Definition at line 255 of file ec_point.h.
secure_vector< uint8_t > Botan::EC_Point::x_bytes | ( | ) | const |
Return the fixed length big endian encoding of x coordinate
Definition at line 567 of file ec_point.cpp.
References Botan::b, Botan::BigInt::encode_1363(), and Botan::EC_Group_Data::p_bytes().
secure_vector< uint8_t > Botan::EC_Point::xy_bytes | ( | ) | const |
Return the fixed length concatenation of the x and y coordinates
Definition at line 583 of file ec_point.cpp.
References Botan::b, Botan::BigInt::encode_1363(), get_affine_x(), get_affine_y(), and Botan::EC_Group_Data::p_bytes().
Referenced by Botan::EC_AffinePoint_Data_BN::EC_AffinePoint_Data_BN().
secure_vector< uint8_t > Botan::EC_Point::y_bytes | ( | ) | const |
Return the fixed length big endian encoding of y coordinate
Definition at line 575 of file ec_point.cpp.
References Botan::b, Botan::BigInt::encode_1363(), and Botan::EC_Group_Data::p_bytes().
EC_Point Botan::EC_Point::zero | ( | ) | const |
Return the zero (aka infinite) point associated with this curve
Definition at line 99 of file ec_point.cpp.
References EC_Point().
Referenced by Botan::EC_Point_Multi_Point_Precompute::EC_Point_Multi_Point_Precompute(), mul(), Botan::EC_Point_Base_Point_Precompute::mul(), and Botan::EC_Point_Multi_Point_Precompute::multi_exp().
|
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 261 of file ec_point.h.