Botan 3.9.0
Crypto and TLS for C&
Botan::EC_AffinePoint Class Referencefinal

#include <ec_apoint.h>

Public Member Functions

const std::shared_ptr< const EC_Group_Data > & _group () const
const EC_AffinePoint_Data_inner () const
EC_AffinePoint add (const EC_AffinePoint &q) const
 EC_AffinePoint (const EC_AffinePoint &other)
 EC_AffinePoint (const EC_Group &group, std::span< const uint8_t > bytes)
 EC_AffinePoint (EC_AffinePoint &&other) noexcept
size_t field_element_bytes () const
bool is_identity () const
 Return true if this point is the identity element.
EC_AffinePoint mul (const EC_Scalar &scalar, RandomNumberGenerator &rng) const
 Multiply a point by a scalar returning a complete point.
EC_AffinePoint mul (const EC_Scalar &scalar, RandomNumberGenerator &rng, std::vector< BigInt > &) const
secure_vector< uint8_t > mul_x_only (const EC_Scalar &scalar, RandomNumberGenerator &rng) const
 Multiply a point by a scalar, returning the byte encoding of the x coordinate only.
secure_vector< uint8_t > mul_x_only (const EC_Scalar &scalar, RandomNumberGenerator &rng, std::vector< BigInt > &) const
 Multiply a point by a scalar, returning the byte encoding of the x coordinate only.
EC_AffinePoint negate () const
 Point negation.
bool operator!= (const EC_AffinePoint &other) const
EC_AffinePointoperator= (const EC_AffinePoint &other)
EC_AffinePointoperator= (EC_AffinePoint &&other) noexcept
bool operator== (const EC_AffinePoint &other) const
std::vector< uint8_t > serialize (EC_Point_Format format) const
 Return an encoding depending on the requested format.
template<concepts::resizable_byte_buffer T = std::vector<uint8_t>>
serialize_compressed () const
void serialize_compressed_to (std::span< uint8_t > bytes) const
template<concepts::resizable_byte_buffer T = std::vector<uint8_t>>
serialize_uncompressed () const
void serialize_uncompressed_to (std::span< uint8_t > bytes) const
void serialize_x_to (std::span< uint8_t > bytes) const
void serialize_xy_to (std::span< uint8_t > bytes) const
void serialize_y_to (std::span< uint8_t > bytes) const
template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
x_bytes () const
template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
xy_bytes () const
template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
y_bytes () const
 ~EC_AffinePoint ()

Static Public Member Functions

static EC_AffinePoint _from_inner (std::unique_ptr< EC_AffinePoint_Data > inner)
static std::optional< EC_AffinePointdeserialize (const EC_Group &group, std::span< const uint8_t > bytes)
static std::optional< EC_AffinePointfrom_bigint_xy (const EC_Group &group, const BigInt &x, const BigInt &y)
static EC_AffinePoint g_mul (const EC_Scalar &scalar, RandomNumberGenerator &rng)
 Multiply by the group generator returning a complete point.
static EC_AffinePoint g_mul (const EC_Scalar &scalar, RandomNumberGenerator &rng, std::vector< BigInt > &)
static EC_AffinePoint generator (const EC_Group &group)
 Return the standard group generator.
static EC_AffinePoint hash_to_curve_nu (const EC_Group &group, std::string_view hash_fn, std::span< const uint8_t > input, std::span< const uint8_t > domain_sep)
static EC_AffinePoint hash_to_curve_nu (const EC_Group &group, std::string_view hash_fn, std::span< const uint8_t > input, std::string_view domain_sep)
static EC_AffinePoint hash_to_curve_ro (const EC_Group &group, std::string_view hash_fn, std::span< const uint8_t > input, std::span< const uint8_t > domain_sep)
static EC_AffinePoint hash_to_curve_ro (const EC_Group &group, std::string_view hash_fn, std::span< const uint8_t > input, std::string_view domain_sep)
static EC_AffinePoint identity (const EC_Group &group)
 Return the identity element.
static std::optional< EC_AffinePointmul_px_qy (const EC_AffinePoint &p, const EC_Scalar &x, const EC_AffinePoint &q, const EC_Scalar &y, RandomNumberGenerator &rng)

Friends

class EC_Mul2Table

Detailed Description

Elliptic Curve Point in Affine Representation

Definition at line 36 of file ec_apoint.h.

Constructor & Destructor Documentation

◆ EC_AffinePoint() [1/3]

Botan::EC_AffinePoint::EC_AffinePoint ( const EC_Group & group,
std::span< const uint8_t > bytes )

Point deserialization. Throws if wrong length or not a valid point

This accepts SEC1 compressed or uncompressed formats

Definition at line 36 of file ec_apoint.cpp.

36 {
37 m_point = group._data()->point_deserialize(bytes);
38 if(!m_point) {
39 throw Decoding_Error("Failed to deserialize elliptic curve point");
40 }
41}

References Botan::EC_Group::_data().

Referenced by _from_inner(), add(), deserialize(), EC_AffinePoint(), EC_AffinePoint(), EC_Mul2Table, g_mul(), g_mul(), generator(), hash_to_curve_nu(), hash_to_curve_nu(), hash_to_curve_ro(), hash_to_curve_ro(), identity(), mul(), mul(), mul_px_qy(), negate(), operator!=(), operator=(), operator=(), and operator==().

◆ EC_AffinePoint() [2/3]

Botan::EC_AffinePoint::EC_AffinePoint ( const EC_AffinePoint & other)

Definition at line 20 of file ec_apoint.cpp.

20: m_point(other.inner().clone()) {}

References EC_AffinePoint().

◆ EC_AffinePoint() [3/3]

Botan::EC_AffinePoint::EC_AffinePoint ( EC_AffinePoint && other)
noexcept

Definition at line 22 of file ec_apoint.cpp.

22: m_point(std::move(other.m_point)) {}

References EC_AffinePoint().

◆ ~EC_AffinePoint()

Botan::EC_AffinePoint::~EC_AffinePoint ( )
default

Member Function Documentation

◆ _from_inner()

EC_AffinePoint Botan::EC_AffinePoint::_from_inner ( std::unique_ptr< EC_AffinePoint_Data > inner)
static

Definition at line 234 of file ec_apoint.cpp.

234 {
235 return EC_AffinePoint(std::move(inner));
236}
EC_AffinePoint(const EC_Group &group, std::span< const uint8_t > bytes)
Definition ec_apoint.cpp:36

References EC_AffinePoint().

Referenced by Botan::EC_Group::Mul2Table::mul2_vartime().

◆ _group()

const std::shared_ptr< const EC_Group_Data > & Botan::EC_AffinePoint::_group ( ) const

Definition at line 238 of file ec_apoint.cpp.

238 {
239 return inner().group();
240}

Referenced by operator==().

◆ _inner()

const EC_AffinePoint_Data & Botan::EC_AffinePoint::_inner ( ) const
inline

Definition at line 263 of file ec_apoint.h.

263{ return inner(); }

Referenced by add(), mul_px_qy(), and negate().

◆ add()

EC_AffinePoint Botan::EC_AffinePoint::add ( const EC_AffinePoint & q) const

Point addition

Note that this is quite slow since it converts the resulting projective point immediately to affine coordinates, which requires a field inversion. This can be sufficient when implementing protocols that just need to perform a few additions.

In the future a cooresponding EC_ProjectivePoint type may be added which would avoid the expensive affine conversions

Definition at line 184 of file ec_apoint.cpp.

184 {
185 auto pt = _inner().group()->affine_add(_inner(), q._inner());
186 return EC_AffinePoint(std::move(pt));
187}
virtual const std::shared_ptr< const EC_Group_Data > & group() const =0
const EC_AffinePoint_Data & _inner() const
Definition ec_apoint.h:263

References _inner(), EC_AffinePoint(), and Botan::EC_AffinePoint_Data::group().

◆ deserialize()

std::optional< EC_AffinePoint > Botan::EC_AffinePoint::deserialize ( const EC_Group & group,
std::span< const uint8_t > bytes )
static

Point deserialization. Returns nullopt if wrong length or not a valid point

This accepts SEC1 compressed or uncompressed formats

Definition at line 150 of file ec_apoint.cpp.

150 {
151 if(auto pt = group._data()->point_deserialize(bytes)) {
152 return EC_AffinePoint(std::move(pt));
153 } else {
154 return {};
155 }
156}

References Botan::EC_Group::_data(), and EC_AffinePoint().

Referenced by from_bigint_xy().

◆ field_element_bytes()

size_t Botan::EC_AffinePoint::field_element_bytes ( ) const

Return the number of bytes of a field element

A point consists of two field elements, plus possibly a header

Definition at line 110 of file ec_apoint.cpp.

110 {
111 return inner().field_element_bytes();
112}

◆ from_bigint_xy()

std::optional< EC_AffinePoint > Botan::EC_AffinePoint::from_bigint_xy ( const EC_Group & group,
const BigInt & x,
const BigInt & y )
static

Create a point from a pair (x,y) of integers

The integers must be within the field - in the range [0,p) and must satisfy the curve equation

Definition at line 93 of file ec_apoint.cpp.

93 {
94 if(x.is_negative() || x >= group.get_p()) {
95 return {};
96 }
97 if(y.is_negative() || y >= group.get_p()) {
98 return {};
99 }
100
101 const size_t fe_bytes = group.get_p_bytes();
102 std::vector<uint8_t> sec1(1 + 2 * fe_bytes);
103 sec1[0] = 0x04;
104 x.serialize_to(std::span{sec1}.subspan(1, fe_bytes));
105 y.serialize_to(std::span{sec1}.last(fe_bytes));
106
107 return EC_AffinePoint::deserialize(group, sec1);
108}
static std::optional< EC_AffinePoint > deserialize(const EC_Group &group, std::span< const uint8_t > bytes)

References deserialize(), Botan::EC_Group::get_p(), Botan::EC_Group::get_p_bytes(), Botan::BigInt::is_negative(), and Botan::BigInt::serialize_to().

Referenced by generator().

◆ g_mul() [1/2]

EC_AffinePoint Botan::EC_AffinePoint::g_mul ( const EC_Scalar & scalar,
RandomNumberGenerator & rng )
static

Multiply by the group generator returning a complete point.

Definition at line 158 of file ec_apoint.cpp.

158 {
159 auto pt = scalar._inner().group()->point_g_mul(scalar.inner(), rng);
160 return EC_AffinePoint(std::move(pt));
161}

References Botan::EC_Scalar::_inner(), EC_AffinePoint(), and Botan::EC_Scalar_Data::group().

Referenced by g_mul(), and Botan::EC_PrivateKey_Data::public_key().

◆ g_mul() [2/2]

EC_AffinePoint Botan::EC_AffinePoint::g_mul ( const EC_Scalar & scalar,
RandomNumberGenerator & rng,
std::vector< BigInt > &  )
inlinestatic

Definition at line 245 of file ec_apoint.h.

245 {
246 return EC_AffinePoint::g_mul(scalar, rng);
247 }
static EC_AffinePoint g_mul(const EC_Scalar &scalar, RandomNumberGenerator &rng)
Multiply by the group generator returning a complete point.

References EC_AffinePoint(), and g_mul().

◆ generator()

EC_AffinePoint Botan::EC_AffinePoint::generator ( const EC_Group & group)
static

Return the standard group generator.

Definition at line 84 of file ec_apoint.cpp.

84 {
85 // TODO it would be nice to improve this (pcurves supports returning generator directly)
86 if(auto g = EC_AffinePoint::from_bigint_xy(group, group.get_g_x(), group.get_g_y())) {
87 return *g;
88 } else {
89 throw Internal_Error("EC_AffinePoint::generator curve rejected generator");
90 }
91}
static std::optional< EC_AffinePoint > from_bigint_xy(const EC_Group &group, const BigInt &x, const BigInt &y)
Definition ec_apoint.cpp:93

References EC_AffinePoint(), from_bigint_xy(), Botan::EC_Group::get_g_x(), and Botan::EC_Group::get_g_y().

Referenced by Botan::EC_Group::DER_encode().

◆ hash_to_curve_nu() [1/2]

EC_AffinePoint Botan::EC_AffinePoint::hash_to_curve_nu ( const EC_Group & group,
std::string_view hash_fn,
std::span< const uint8_t > input,
std::span< const uint8_t > domain_sep )
static

Hash to curve (RFC 9380), non uniform variant

Only supported for specific groups

Definition at line 133 of file ec_apoint.cpp.

136 {
137 auto pt = group._data()->point_hash_to_curve_nu(hash_fn, input, domain_sep);
138 return EC_AffinePoint(std::move(pt));
139}

References Botan::EC_Group::_data(), and EC_AffinePoint().

Referenced by hash_to_curve_nu().

◆ hash_to_curve_nu() [2/2]

EC_AffinePoint Botan::EC_AffinePoint::hash_to_curve_nu ( const EC_Group & group,
std::string_view hash_fn,
std::span< const uint8_t > input,
std::string_view domain_sep )
static

Hash to curve (RFC 9380), non uniform variant

Only supported for specific groups

Definition at line 141 of file ec_apoint.cpp.

144 {
145 return EC_AffinePoint::hash_to_curve_nu(group, hash_fn, input, as_span_of_bytes(domain_sep));
146}
static EC_AffinePoint hash_to_curve_nu(const EC_Group &group, std::string_view hash_fn, std::span< const uint8_t > input, std::span< const uint8_t > domain_sep)
std::span< const uint8_t > as_span_of_bytes(const char *s, size_t len)
Definition mem_utils.h:28

References Botan::as_span_of_bytes(), EC_AffinePoint(), and hash_to_curve_nu().

◆ hash_to_curve_ro() [1/2]

EC_AffinePoint Botan::EC_AffinePoint::hash_to_curve_ro ( const EC_Group & group,
std::string_view hash_fn,
std::span< const uint8_t > input,
std::span< const uint8_t > domain_sep )
static

Hash to curve (RFC 9380), random oracle variant

Only supported for specific groups

Definition at line 118 of file ec_apoint.cpp.

121 {
122 auto pt = group._data()->point_hash_to_curve_ro(hash_fn, input, domain_sep);
123 return EC_AffinePoint(std::move(pt));
124}

References Botan::EC_Group::_data(), and EC_AffinePoint().

Referenced by hash_to_curve_ro().

◆ hash_to_curve_ro() [2/2]

EC_AffinePoint Botan::EC_AffinePoint::hash_to_curve_ro ( const EC_Group & group,
std::string_view hash_fn,
std::span< const uint8_t > input,
std::string_view domain_sep )
static

Hash to curve (RFC 9380), random oracle variant

Only supported for specific groups

Definition at line 126 of file ec_apoint.cpp.

129 {
130 return EC_AffinePoint::hash_to_curve_ro(group, hash_fn, input, as_span_of_bytes(domain_sep));
131}
static EC_AffinePoint hash_to_curve_ro(const EC_Group &group, std::string_view hash_fn, std::span< const uint8_t > input, std::span< const uint8_t > domain_sep)

References Botan::as_span_of_bytes(), EC_AffinePoint(), and hash_to_curve_ro().

◆ identity()

EC_AffinePoint Botan::EC_AffinePoint::identity ( const EC_Group & group)
static

Return the identity element.

Definition at line 79 of file ec_apoint.cpp.

79 {
80 const uint8_t id_encoding[1] = {0};
81 return EC_AffinePoint(group, id_encoding);
82}

References EC_AffinePoint().

◆ is_identity()

bool Botan::EC_AffinePoint::is_identity ( ) const

Return true if this point is the identity element.

Definition at line 114 of file ec_apoint.cpp.

114 {
115 return inner().is_identity();
116}

Referenced by Botan::EC_PublicKey::check_key(), Botan::ECIES_KA_Operation::derive_secret(), operator==(), serialize_compressed_to(), serialize_uncompressed_to(), serialize_x_to(), serialize_xy_to(), and serialize_y_to().

◆ mul() [1/2]

EC_AffinePoint Botan::EC_AffinePoint::mul ( const EC_Scalar & scalar,
RandomNumberGenerator & rng ) const

Multiply a point by a scalar returning a complete point.

Definition at line 163 of file ec_apoint.cpp.

163 {
164 return EC_AffinePoint(inner().mul(scalar._inner(), rng));
165}
EC_AffinePoint mul(const EC_Scalar &scalar, RandomNumberGenerator &rng) const
Multiply a point by a scalar returning a complete point.

References Botan::EC_Scalar::_inner(), EC_AffinePoint(), and mul().

Referenced by mul(), and mul().

◆ mul() [2/2]

EC_AffinePoint Botan::EC_AffinePoint::mul ( const EC_Scalar & scalar,
RandomNumberGenerator & rng,
std::vector< BigInt > &  ) const
inline

Definition at line 250 of file ec_apoint.h.

250 {
251 return this->mul(scalar, rng);
252 }

References EC_AffinePoint(), and mul().

◆ mul_px_qy()

std::optional< EC_AffinePoint > Botan::EC_AffinePoint::mul_px_qy ( const EC_AffinePoint & p,
const EC_Scalar & x,
const EC_AffinePoint & q,
const EC_Scalar & y,
RandomNumberGenerator & rng )
static

Compute 2-ary multiscalar multiplication - p*x + q*y

This operation runs in constant time with respect to p, x, q, and y

Returns
p*x+q*y, or nullopt if the result was the point at infinity

Definition at line 171 of file ec_apoint.cpp.

175 {
176 auto pt = p._inner().group()->mul_px_qy(p._inner(), x._inner(), q._inner(), y._inner(), rng);
177 if(pt) {
178 return EC_AffinePoint(std::move(pt));
179 } else {
180 return {};
181 }
182}

References _inner(), Botan::EC_Scalar::_inner(), EC_AffinePoint(), and Botan::EC_AffinePoint_Data::group().

◆ mul_x_only() [1/2]

secure_vector< uint8_t > Botan::EC_AffinePoint::mul_x_only ( const EC_Scalar & scalar,
RandomNumberGenerator & rng ) const

Multiply a point by a scalar, returning the byte encoding of the x coordinate only.

Definition at line 167 of file ec_apoint.cpp.

167 {
168 return inner().mul_x_only(scalar._inner(), rng);
169}

References Botan::EC_Scalar::_inner().

◆ mul_x_only() [2/2]

secure_vector< uint8_t > Botan::EC_AffinePoint::mul_x_only ( const EC_Scalar & scalar,
RandomNumberGenerator & rng,
std::vector< BigInt > &  ) const
inline

Multiply a point by a scalar, returning the byte encoding of the x coordinate only.

Definition at line 255 of file ec_apoint.h.

257 {
258 return this->mul_x_only(scalar, rng);
259 }
secure_vector< uint8_t > mul_x_only(const EC_Scalar &scalar, RandomNumberGenerator &rng) const
Multiply a point by a scalar, returning the byte encoding of the x coordinate only.

◆ negate()

EC_AffinePoint Botan::EC_AffinePoint::negate ( ) const

Point negation.

Definition at line 189 of file ec_apoint.cpp.

189 {
190 auto pt = this->_inner().group()->affine_neg(this->_inner());
191 return EC_AffinePoint(std::move(pt));
192}

References _inner(), EC_AffinePoint(), and Botan::EC_AffinePoint_Data::group().

◆ operator!=()

bool Botan::EC_AffinePoint::operator!= ( const EC_AffinePoint & other) const
inline

Definition at line 221 of file ec_apoint.h.

221{ return !(*this == other); }

References EC_AffinePoint().

◆ operator=() [1/2]

EC_AffinePoint & Botan::EC_AffinePoint::operator= ( const EC_AffinePoint & other)

Definition at line 24 of file ec_apoint.cpp.

24 {
25 if(this != &other) {
26 m_point = other.inner().clone();
27 }
28 return (*this);
29}

References Botan::EC_AffinePoint_Data::clone(), and EC_AffinePoint().

◆ operator=() [2/2]

EC_AffinePoint & Botan::EC_AffinePoint::operator= ( EC_AffinePoint && other)
noexcept

Definition at line 31 of file ec_apoint.cpp.

31 {
32 m_point.swap(other.m_point);
33 return (*this);
34}

References EC_AffinePoint().

◆ operator==()

bool Botan::EC_AffinePoint::operator== ( const EC_AffinePoint & other) const

Definition at line 54 of file ec_apoint.cpp.

54 {
55 if(this == &other) {
56 return true;
57 }
58
59 // We are relying on EC_Group to ensure there is just a single shared_ptr
60 // for any set of group params
61 if(this->_group() != other._group()) {
62 return false;
63 }
64
65 auto a_is_id = this->is_identity();
66 auto b_is_id = other.is_identity();
67
68 if(a_is_id || b_is_id) {
69 return (a_is_id == b_is_id);
70 }
71
72 auto a_xy = this->serialize_uncompressed();
73 auto b_xy = other.serialize_uncompressed();
74 BOTAN_ASSERT_NOMSG(a_xy.size() == b_xy.size());
75
76 return CT::is_equal(a_xy.data(), b_xy.data(), a_xy.size()).as_bool();
77}
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:75
bool is_identity() const
Return true if this point is the identity element.
T serialize_uncompressed() const
Definition ec_apoint.h:203
const std::shared_ptr< const EC_Group_Data > & _group() const
constexpr CT::Mask< T > is_equal(const T x[], const T y[], size_t len)
Definition ct_utils.h:826

References _group(), BOTAN_ASSERT_NOMSG, EC_AffinePoint(), Botan::CT::is_equal(), is_identity(), and serialize_uncompressed().

◆ serialize()

std::vector< uint8_t > Botan::EC_AffinePoint::serialize ( EC_Point_Format format) const

Return an encoding depending on the requested format.

Definition at line 194 of file ec_apoint.cpp.

194 {
195 if(format == EC_Point_Format::Compressed) {
196 return this->serialize_compressed();
197 } else if(format == EC_Point_Format::Uncompressed) {
198 return this->serialize_uncompressed();
199 } else {
200 // The deprecated "hybrid" point encoding
201 // TODO(Botan4) Remove this
202 auto enc = this->serialize_uncompressed();
203 const bool y_is_odd = (enc[enc.size() - 1] & 0x01) == 0x01;
204 enc.front() = y_is_odd ? 0x07 : 0x06;
205 return enc;
206 }
207}
T serialize_compressed() const
Definition ec_apoint.h:213
BOTAN_FORCE_INLINE BOTAN_FN_ISA_AES void enc(uint8x16_t &B, uint8x16_t K)
Definition aes_armv8.cpp:21

References Botan::Compressed, serialize_compressed(), serialize_uncompressed(), and Botan::Uncompressed.

Referenced by Botan::ECDH_PublicKey::public_value(), and Botan::EC_PublicKey::raw_public_key_bits().

◆ serialize_compressed()

template<concepts::resizable_byte_buffer T = std::vector<uint8_t>>
T Botan::EC_AffinePoint::serialize_compressed ( ) const
inline

Return the bytes of the affine x and y coordinates in a container

This function will fail if this point is the identity element

Definition at line 213 of file ec_apoint.h.

213 {
214 T bytes(1 + this->field_element_bytes());
215 this->serialize_compressed_to(bytes);
216 return bytes;
217 }
size_t field_element_bytes() const
void serialize_compressed_to(std::span< uint8_t > bytes) const

Referenced by Botan::ECDSA_PublicKey::recovery_param(), and serialize().

◆ serialize_compressed_to()

void Botan::EC_AffinePoint::serialize_compressed_to ( std::span< uint8_t > bytes) const

Write the fixed length SEC1 compressed encoding

The output span must be exactly 1 + field_element_bytes long

This function will fail if this point is the identity element

Definition at line 224 of file ec_apoint.cpp.

224 {
226 m_point->serialize_compressed_to(bytes);
227}
#define BOTAN_STATE_CHECK(expr)
Definition assert.h:49

References BOTAN_STATE_CHECK, and is_identity().

◆ serialize_uncompressed()

template<concepts::resizable_byte_buffer T = std::vector<uint8_t>>
T Botan::EC_AffinePoint::serialize_uncompressed ( ) const
inline

Return the bytes of the affine x and y coordinates in a container

This function will fail if this point is the identity element

Definition at line 203 of file ec_apoint.h.

203 {
204 T bytes(1 + 2 * this->field_element_bytes());
205 this->serialize_uncompressed_to(bytes);
206 return bytes;
207 }
void serialize_uncompressed_to(std::span< uint8_t > bytes) const

Referenced by Botan::EC_Group::DER_encode(), operator==(), and serialize().

◆ serialize_uncompressed_to()

void Botan::EC_AffinePoint::serialize_uncompressed_to ( std::span< uint8_t > bytes) const

Return the fixed length encoding of SEC1 uncompressed encoding

The output span must be exactly 1 + 2*field_element_bytes long

This function will fail if this point is the identity element

Definition at line 229 of file ec_apoint.cpp.

229 {
231 m_point->serialize_uncompressed_to(bytes);
232}

References BOTAN_STATE_CHECK, and is_identity().

◆ serialize_x_to()

void Botan::EC_AffinePoint::serialize_x_to ( std::span< uint8_t > bytes) const

Write the fixed length encoding of affine x coordinate

The output span must be exactly field_element_bytes long

This function will fail if this point is the identity element

Definition at line 209 of file ec_apoint.cpp.

209 {
211 m_point->serialize_x_to(bytes);
212}

References BOTAN_STATE_CHECK, and is_identity().

◆ serialize_xy_to()

void Botan::EC_AffinePoint::serialize_xy_to ( std::span< uint8_t > bytes) const

Write the fixed length encoding of affine x and y coordinates

The output span must be exactly 2*field_element_bytes long

This function will fail if this point is the identity element

Definition at line 219 of file ec_apoint.cpp.

219 {
221 m_point->serialize_xy_to(bytes);
222}

References BOTAN_STATE_CHECK, and is_identity().

◆ serialize_y_to()

void Botan::EC_AffinePoint::serialize_y_to ( std::span< uint8_t > bytes) const

Write the fixed length encoding of affine y coordinate

The output span must be exactly field_element_bytes long

This function will fail if this point is the identity element

Definition at line 214 of file ec_apoint.cpp.

214 {
216 m_point->serialize_y_to(bytes);
217}

References BOTAN_STATE_CHECK, and is_identity().

◆ x_bytes()

template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
T Botan::EC_AffinePoint::x_bytes ( ) const
inline

Return the bytes of the affine x coordinate in a container

This function will fail if this point is the identity element

Definition at line 173 of file ec_apoint.h.

173 {
174 T bytes(this->field_element_bytes());
175 this->serialize_x_to(bytes);
176 return bytes;
177 }
void serialize_x_to(std::span< uint8_t > bytes) const

◆ xy_bytes()

template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
T Botan::EC_AffinePoint::xy_bytes ( ) const
inline

Return the bytes of the affine x and y coordinates in a container

This function will fail if this point is the identity element

Definition at line 193 of file ec_apoint.h.

193 {
194 T bytes(2 * this->field_element_bytes());
195 this->serialize_xy_to(bytes);
196 return bytes;
197 }
void serialize_xy_to(std::span< uint8_t > bytes) const

Referenced by Botan::GOST_3410_PublicKey::public_key_bits(), and Botan::sm2_compute_za().

◆ y_bytes()

template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
T Botan::EC_AffinePoint::y_bytes ( ) const
inline

Return the bytes of the affine y coordinate in a container

This function will fail if this point is the identity element

Definition at line 183 of file ec_apoint.h.

183 {
184 T bytes(this->field_element_bytes());
185 this->serialize_y_to(bytes);
186 return bytes;
187 }
void serialize_y_to(std::span< uint8_t > bytes) const

◆ EC_Mul2Table

friend class EC_Mul2Table
friend

Definition at line 270 of file ec_apoint.h.

References EC_AffinePoint(), and EC_Mul2Table.

Referenced by EC_Mul2Table.


The documentation for this class was generated from the following files: