7#include <botan/internal/ec_key_data.h>
9#include <botan/mem_ops.h>
15 m_group(std::move(group)), m_point(std::move(pt)) {
16#if defined(BOTAN_HAS_LEGACY_EC_POINT)
17 m_legacy_point = m_point.to_legacy_point();
26 m_group(std::move(group)), m_scalar(std::move(x)), m_legacy_x(m_scalar.to_bigint()) {
34EC_Scalar decode_ec_secret_key_scalar(
const EC_Group& group, std::span<const uint8_t> bytes) {
37 if(bytes.size() < order_bytes) {
48 copy_mem(std::span{padded_sk}.last(bytes.size()), bytes);
49 return decode_ec_secret_key_scalar(group, padded_sk);
55 throw Decoding_Error(
"EC private key is invalid for this group");
69 bool with_modular_inverse)
const {
70 auto public_point = [&] {
71 if(with_modular_inverse) {
78 return std::make_shared<EC_PublicKey_Data>(m_group, public_point());
83 return this->
public_key(null_rng, with_modular_inverse);
#define BOTAN_ARG_CHECK(expr, msg)
bool is_identity() const
Return true if this point is the identity element.
static EC_AffinePoint g_mul(const EC_Scalar &scalar, RandomNumberGenerator &rng)
Multiply by the group generator returning a complete point.
size_t get_order_bytes() const
void serialize_to(std::span< uint8_t > output) const
std::shared_ptr< EC_PublicKey_Data > public_key(RandomNumberGenerator &rng, bool with_modular_inverse) const
EC_PrivateKey_Data(EC_Group group, EC_Scalar x)
EC_PublicKey_Data(EC_Group group, EC_AffinePoint pt)
static std::optional< EC_Scalar > deserialize(const EC_Group &group, std::span< const uint8_t > bytes)
void serialize_to(std::span< uint8_t > bytes) const
constexpr void copy_mem(T *out, const T *in, size_t n)
std::vector< T, secure_allocator< T > > secure_vector