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();
22 BOTAN_ARG_CHECK(!m_point.is_identity(),
"ECC public key cannot be point at infinity");
26 m_group(std::move(
group)), m_scalar(std::move(x)), m_legacy_x(m_scalar.to_bigint()) {
29 BOTAN_ARG_CHECK(m_scalar.is_nonzero(),
"ECC private key cannot be zero");
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);
65 bool with_modular_inverse)
const {
66 auto public_point = [&] {
67 if(with_modular_inverse) {
74 return std::make_shared<EC_PublicKey_Data>(m_group, public_point());
79 return this->
public_key(null_rng, with_modular_inverse);
83 m_scalar.serialize_to(output);
#define BOTAN_ARG_CHECK(expr, msg)
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
const EC_Group & group() 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)
const EC_Group & group() const
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)
std::vector< T, secure_allocator< T > > secure_vector
constexpr void copy_mem(T *out, const T *in, size_t n)