Botan 3.0.0-alpha0
Crypto and TLS for C&
|
#include <point_gfp.h>
Public Types | |
enum | { WORKSPACE_SIZE = 8 } |
enum | Compression_Type { UNCOMPRESSED = 0 , COMPRESSED = 1 , HYBRID = 2 } |
Public Member Functions | |
void | add (const PointGFp &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 PointGFp &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) |
PointGFp | double_of (std::vector< BigInt > &workspace) const |
std::vector< uint8_t > | encode (PointGFp::Compression_Type 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) |
PointGFp & | negate () |
bool | on_the_curve () const |
PointGFp & | operator*= (const BigInt &scalar) |
PointGFp & | operator+= (const PointGFp &rhs) |
PointGFp & | operator-= (const PointGFp &rhs) |
PointGFp & | operator= (const PointGFp &)=default |
PointGFp & | operator= (PointGFp &&other) |
bool | operator== (const PointGFp &other) const |
PointGFp | plus (const PointGFp &other, std::vector< BigInt > &workspace) const |
PointGFp ()=default | |
PointGFp (const CurveGFp &curve) | |
PointGFp (const CurveGFp &curve, const BigInt &x, const BigInt &y) | |
PointGFp (const PointGFp &)=default | |
PointGFp (PointGFp &&other) | |
void | randomize_repr (RandomNumberGenerator &rng) |
void | randomize_repr (RandomNumberGenerator &rng, secure_vector< word > &ws) |
void | swap (PointGFp &other) |
void | swap_coords (BigInt &new_x, BigInt &new_y, BigInt &new_z) |
PointGFp | zero () const |
Static Public Member Functions | |
static void | force_all_affine (std::vector< PointGFp > &points, secure_vector< word > &ws) |
This class represents one point on a curve of GF(p)
Definition at line 22 of file point_gfp.h.
anonymous enum |
Enumerator | |
---|---|
UNCOMPRESSED | |
COMPRESSED | |
HYBRID |
Definition at line 25 of file point_gfp.h.
|
default |
Construct an uninitialized PointGFp
Referenced by mult2(), mult2i(), and operator-=().
|
explicit |
Construct the zero point
curve | The base curve |
Definition at line 17 of file point_gfp.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 26 of file point_gfp.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 196 of file point_gfp.h.
References BOTAN_ARG_CHECK, Botan::BigInt::data(), and Botan::BigInt::size().
Referenced by Botan::PointGFp_Var_Point_Precompute::mul(), Botan::PointGFp_Multi_Point_Precompute::multi_exp(), Botan::operator*(), operator+=(), and plus().
void Botan::PointGFp::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 172 of file point_gfp.cpp.
References 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 229 of file point_gfp.h.
References BOTAN_ASSERT_NOMSG, BOTAN_DEBUG_ASSERT, Botan::BigInt::data(), is_affine(), and Botan::BigInt::size().
Referenced by Botan::PointGFp_Base_Point_Precompute::mul(), and Botan::PointGFp_Multi_Point_Precompute::multi_exp().
void Botan::PointGFp::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 89 of file point_gfp.cpp.
References 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 284 of file point_gfp.h.
References mult2().
std::vector< uint8_t > Botan::PointGFp::encode | ( | PointGFp::Compression_Type | format | ) | const |
EC2OSP - elliptic curve to octet string primitive
format | which format to encode using |
Definition at line 600 of file point_gfp.cpp.
References Botan::BigInt::bytes(), COMPRESSED, Botan::BigInt::encode_1363(), get_affine_x(), get_affine_y(), Botan::BigInt::get_bit(), Botan::CurveGFp::get_p(), HYBRID, is_zero(), and 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::PointGFp::force_affine | ( | ) |
Force this point to affine coordinates
Definition at line 484 of file point_gfp.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 419 of file point_gfp.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::PointGFp_Multi_Point_Precompute::PointGFp_Multi_Point_Precompute().
BigInt Botan::PointGFp::get_affine_x | ( | ) | const |
get affine x coordinate
Definition at line 504 of file point_gfp.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::PointGFp::get_affine_y | ( | ) | const |
get affine y coordinate
Definition at line 523 of file point_gfp.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 302 of file point_gfp.h.
|
inline |
Definition at line 131 of file point_gfp.h.
|
inline |
Definition at line 132 of file point_gfp.h.
|
inline |
Definition at line 133 of file point_gfp.h.
bool Botan::PointGFp::is_affine | ( | ) | const |
Definition at line 499 of file point_gfp.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 159 of file point_gfp.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::PointGFp::mult2 | ( | std::vector< BigInt > & | workspace | ) |
Point doubling
workspace | temp space, at least WORKSPACE_SIZE elements |
Definition at line 278 of file point_gfp.cpp.
References Botan::CurveGFp::a_is_minus_3(), Botan::CurveGFp::a_is_zero(), 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(), PointGFp(), Botan::CurveGFp::sqr(), and Botan::BigInt::swap().
Referenced by add(), add_affine(), double_of(), mult2i(), Botan::operator*(), and Botan::PointGFp_Multi_Point_Precompute::PointGFp_Multi_Point_Precompute().
void Botan::PointGFp::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 258 of file point_gfp.cpp.
References Botan::BigInt::is_zero(), mult2(), and PointGFp().
Referenced by Botan::PointGFp_Var_Point_Precompute::mul(), and Botan::PointGFp_Multi_Point_Precompute::multi_exp().
|
inline |
Negate this point
Definition at line 112 of file point_gfp.h.
Referenced by Botan::PointGFp_Multi_Point_Precompute::multi_exp(), Botan::operator*(), and Botan::operator-().
bool Botan::PointGFp::on_the_curve | ( | ) | const |
Checks whether the point is to be found on the underlying curve; used to prevent fault attacks.
Definition at line 543 of file point_gfp.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_PrivateKey::EC_PrivateKey(), Botan::GOST_3410_PublicKey::GOST_3410_PublicKey(), Botan::PointGFp_Base_Point_Precompute::mul(), Botan::PointGFp_Var_Point_Precompute::mul(), Botan::operator*(), Botan::OS2ECP(), Botan::PointGFp_Multi_Point_Precompute::PointGFp_Multi_Point_Precompute(), Botan::EC_Group::verify_group(), and Botan::EC_Group::verify_public_element().
*= Operator
scalar | the PointGFp to multiply with *this |
Definition at line 387 of file point_gfp.cpp.
+= Operator
rhs | the PointGFp to add to the local value |
Definition at line 368 of file point_gfp.cpp.
References add(), and WORKSPACE_SIZE.
-= Operator
rhs | the PointGFp to subtract from the local value |
Definition at line 375 of file point_gfp.cpp.
References is_zero(), and PointGFp().
Move Assignment
Definition at line 65 of file point_gfp.h.
bool Botan::PointGFp::operator== | ( | const PointGFp & | other | ) | const |
Equality operator
Definition at line 586 of file point_gfp.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 272 of file point_gfp.h.
References add().
Referenced by Botan::PointGFp_Multi_Point_Precompute::PointGFp_Multi_Point_Precompute().
void Botan::PointGFp::randomize_repr | ( | RandomNumberGenerator & | rng | ) |
Randomize the point representation The actual value (get_affine_x, get_affine_y) does not change
Definition at line 42 of file point_gfp.cpp.
References Botan::CurveGFp::get_ws_size(), and randomize_repr().
Referenced by Botan::PointGFp_Base_Point_Precompute::mul(), Botan::PointGFp_Var_Point_Precompute::mul(), and randomize_repr().
void Botan::PointGFp::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 48 of file point_gfp.cpp.
References Botan::CurveGFp::get_p(), Botan::CurveGFp::mul_to_tmp(), Botan::BigInt::random_integer(), and Botan::CurveGFp::sqr_to_tmp().
void Botan::PointGFp::swap | ( | PointGFp & | other | ) |
swaps the states of *this and other, does not throw!
other | the object to swap values with |
Definition at line 578 of file point_gfp.cpp.
References Botan::BigInt::swap(), and Botan::CurveGFp::swap().
Referenced by std::swap< Botan::PointGFp >().
Definition at line 135 of file point_gfp.h.
|
inline |
Return the zero (aka infinite) point associated with this curve
Definition at line 294 of file point_gfp.h.
Referenced by Botan::PointGFp_Base_Point_Precompute::mul(), Botan::operator*(), and Botan::PointGFp_Multi_Point_Precompute::PointGFp_Multi_Point_Precompute().