Botan
2.6.0
Crypto and TLS for C++11
|
#include <point_gfp.h>
Public Types | |
enum | { WORKSPACE_SIZE = 7 } |
enum | Compression_Type { UNCOMPRESSED = 0, COMPRESSED = 1, HYBRID = 2 } |
Public Member Functions | |
void | add (const PointGFp &other, 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) |
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) |
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 PointGFp &)=default | |
PointGFp (PointGFp &&other) | |
PointGFp (const CurveGFp &curve, const BigInt &x, const BigInt &y) | |
void | randomize_repr (RandomNumberGenerator &rng) |
void | randomize_repr (RandomNumberGenerator &rng, secure_vector< word > &ws) |
void | swap (PointGFp &other) |
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 43 of file point_gfp.h.
anonymous enum |
Enumerator | |
---|---|
UNCOMPRESSED | |
COMPRESSED | |
HYBRID |
Definition at line 46 of file point_gfp.h.
|
default |
Construct an uninitialized PointGFp
Referenced by mult2(), and operator-=().
|
explicit |
Construct the zero point
curve | The base curve |
Definition at line 17 of file point_gfp.cpp.
References Botan::CurveGFp::get_ws_size(), and Botan::CurveGFp::to_rep().
|
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 29 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 195 of file point_gfp.cpp.
References Botan::CurveGFp::get_p(), Botan::BigInt::get_word_vector(), Botan::CurveGFp::get_ws_size(), Botan::BigInt::is_negative(), is_zero(), Botan::BigInt::is_zero(), Botan::CurveGFp::mul(), mult2(), and Botan::CurveGFp::sqr().
Referenced by Botan::PointGFp_Var_Point_Precompute::mul(), Botan::operator*(), operator+=(), and plus().
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 92 of file point_gfp.cpp.
References BOTAN_DEBUG_ASSERT, Botan::BigInt::data(), Botan::CurveGFp::get_p_words(), 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 102 of file point_gfp.cpp.
References Botan::CurveGFp::get_p(), Botan::CurveGFp::get_ws_size(), Botan::BigInt::is_negative(), is_zero(), Botan::BigInt::is_zero(), Botan::CurveGFp::mul(), mult2(), Botan::CurveGFp::sqr(), and Botan::CurveGFp::to_rep().
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 587 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_Encryptor::ECIES_Encryptor(), and Botan::EC_PublicKey::public_key_bits().
void Botan::PointGFp::force_affine | ( | ) |
Force this point to affine coordinates
Definition at line 470 of file point_gfp.cpp.
References Botan::CurveGFp::invert_element(), is_zero(), Botan::CurveGFp::mul_to_tmp(), Botan::CurveGFp::sqr_to_tmp(), and Botan::CurveGFp::to_rep().
Referenced by force_all_affine().
|
static |
Force all points on the list to affine coordinates
Definition at line 409 of file point_gfp.cpp.
References force_affine(), Botan::CurveGFp::get_ws_size(), Botan::CurveGFp::invert_element(), Botan::CurveGFp::mul(), Botan::CurveGFp::mul_to_tmp(), Botan::CurveGFp::sqr(), and Botan::CurveGFp::to_rep().
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 491 of file point_gfp.cpp.
References Botan::CurveGFp::from_rep(), 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 510 of file point_gfp.cpp.
References Botan::CurveGFp::from_rep(), 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 262 of file point_gfp.h.
Referenced by Botan::EC_PublicKey::EC_PublicKey().
|
inline |
Definition at line 151 of file point_gfp.h.
|
inline |
Definition at line 152 of file point_gfp.h.
|
inline |
Definition at line 153 of file point_gfp.h.
bool Botan::PointGFp::is_affine | ( | ) | const |
Definition at line 486 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 172 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 288 of file point_gfp.cpp.
References Botan::CurveGFp::get_a_rep(), Botan::CurveGFp::get_p(), Botan::BigInt::get_word_vector(), Botan::CurveGFp::get_ws_size(), Botan::BigInt::is_negative(), is_zero(), Botan::BigInt::is_zero(), Botan::CurveGFp::mul(), PointGFp(), Botan::BigInt::reduce_below(), and Botan::CurveGFp::sqr().
Referenced by add(), add_affine(), Botan::PointGFp_Var_Point_Precompute::mul(), Botan::PointGFp_Multi_Point_Precompute::multi_exp(), Botan::operator*(), and Botan::PointGFp_Multi_Point_Precompute::PointGFp_Multi_Point_Precompute().
|
inline |
Negate this point
Definition at line 132 of file point_gfp.h.
References Botan::CT::is_zero().
Referenced by Botan::PointGFp_Multi_Point_Precompute::multi_exp(), 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 530 of file point_gfp.cpp.
References Botan::CurveGFp::from_rep(), 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::EC_Group::verify_group(), and Botan::EC_Group::verify_public_element().
*= Operator
scalar | the PointGFp to multiply with *this |
Definition at line 377 of file point_gfp.cpp.
+= Operator
rhs | the PointGFp to add to the local value |
Definition at line 358 of file point_gfp.cpp.
References add(), and WORKSPACE_SIZE.
-= Operator
rhs | the PointGFp to subtract from the local value |
Definition at line 365 of file point_gfp.cpp.
References is_zero(), and PointGFp().
bool Botan::PointGFp::operator== | ( | const PointGFp & | other | ) | const |
Equality operator
Definition at line 573 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 244 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 46 of file point_gfp.cpp.
References Botan::CurveGFp::get_ws_size().
Referenced by Botan::PointGFp_Base_Point_Precompute::mul(), and Botan::PointGFp_Var_Point_Precompute::mul().
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 52 of file point_gfp.cpp.
References Botan::BigInt::is_zero(), Botan::CurveGFp::mul_to_tmp(), Botan::BigInt::randomize(), 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 565 of file point_gfp.cpp.
References Botan::BigInt::swap(), and Botan::CurveGFp::swap().
|
inline |
Return the zero (aka infinite) point associated with this curve
Definition at line 254 of file point_gfp.h.
Referenced by Botan::PointGFp_Base_Point_Precompute::mul(), Botan::operator*(), and Botan::PointGFp_Var_Point_Precompute::PointGFp_Var_Point_Precompute().