Botan 3.6.1
Crypto and TLS for C&
Botan::EC_PrivateKey_Data Class Referencefinal

#include <ec_key_data.h>

Public Member Functions

 EC_PrivateKey_Data (EC_Group group, const BigInt &x)
 
 EC_PrivateKey_Data (EC_Group group, EC_Scalar x)
 
 EC_PrivateKey_Data (EC_Group group, RandomNumberGenerator &rng)
 
 EC_PrivateKey_Data (EC_Group group, std::span< const uint8_t > bytes)
 
const EC_Groupgroup () const
 
const BigIntlegacy_bigint () const
 
const EC_Scalarprivate_key () const
 
std::shared_ptr< EC_PublicKey_Datapublic_key (bool with_modular_inverse) const
 
std::shared_ptr< EC_PublicKey_Datapublic_key (RandomNumberGenerator &rng, bool with_modular_inverse) const
 
template<typename T >
T serialize () const
 
void serialize_to (std::span< uint8_t > output) const
 

Detailed Description

Definition at line 40 of file ec_key_data.h.

Constructor & Destructor Documentation

◆ EC_PrivateKey_Data() [1/4]

Botan::EC_PrivateKey_Data::EC_PrivateKey_Data ( EC_Group group,
RandomNumberGenerator & rng )

Definition at line 16 of file ec_key_data.cpp.

16 :
17 m_group(std::move(group)), m_scalar(EC_Scalar::random(m_group, rng)), m_legacy_x(m_scalar.to_bigint()) {}
const EC_Group & group() const
Definition ec_key_data.h:63
BigInt to_bigint() const
Definition ec_scalar.cpp:73
static EC_Scalar random(const EC_Group &group, RandomNumberGenerator &rng)
Definition ec_scalar.cpp:57

◆ EC_PrivateKey_Data() [2/4]

Botan::EC_PrivateKey_Data::EC_PrivateKey_Data ( EC_Group group,
const BigInt & x )

Definition at line 19 of file ec_key_data.cpp.

19 :
20 m_group(std::move(group)), m_scalar(EC_Scalar::from_bigint(m_group, x)), m_legacy_x(m_scalar.to_bigint()) {}
static EC_Scalar from_bigint(const EC_Group &group, const BigInt &bn)
Definition ec_scalar.cpp:65

◆ EC_PrivateKey_Data() [3/4]

Botan::EC_PrivateKey_Data::EC_PrivateKey_Data ( EC_Group group,
EC_Scalar x )

Definition at line 22 of file ec_key_data.cpp.

22 :
23 m_group(std::move(group)), m_scalar(std::move(x)), m_legacy_x(m_scalar.to_bigint()) {}

◆ EC_PrivateKey_Data() [4/4]

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

Definition at line 25 of file ec_key_data.cpp.

25 :
26 m_group(std::move(group)), m_scalar(m_group, bytes), m_legacy_x(m_scalar.to_bigint()) {}

Member Function Documentation

◆ group()

const EC_Group & Botan::EC_PrivateKey_Data::group ( ) const
inline

Definition at line 63 of file ec_key_data.h.

63{ return m_group; }

Referenced by serialize().

◆ legacy_bigint()

const BigInt & Botan::EC_PrivateKey_Data::legacy_bigint ( ) const
inline

Definition at line 67 of file ec_key_data.h.

67{ return m_legacy_x; }

◆ private_key()

const EC_Scalar & Botan::EC_PrivateKey_Data::private_key ( ) const
inline

Definition at line 65 of file ec_key_data.h.

65{ return m_scalar; }

◆ public_key() [1/2]

std::shared_ptr< EC_PublicKey_Data > Botan::EC_PrivateKey_Data::public_key ( bool with_modular_inverse) const

Definition at line 42 of file ec_key_data.cpp.

42 {
43 Null_RNG null_rng;
44 return this->public_key(null_rng, with_modular_inverse);
45}
std::shared_ptr< EC_PublicKey_Data > public_key(RandomNumberGenerator &rng, bool with_modular_inverse) const

References public_key().

◆ public_key() [2/2]

std::shared_ptr< EC_PublicKey_Data > Botan::EC_PrivateKey_Data::public_key ( RandomNumberGenerator & rng,
bool with_modular_inverse ) const

Definition at line 28 of file ec_key_data.cpp.

29 {
30 auto public_point = [&] {
31 std::vector<BigInt> ws;
32 if(with_modular_inverse) {
33 return EC_AffinePoint::g_mul(m_scalar.invert(), rng, ws);
34 } else {
35 return EC_AffinePoint::g_mul(m_scalar, rng, ws);
36 }
37 };
38
39 return std::make_shared<EC_PublicKey_Data>(m_group, public_point());
40}
static EC_AffinePoint g_mul(const EC_Scalar &scalar, RandomNumberGenerator &rng, std::vector< BigInt > &ws)
EC_Scalar invert() const

References Botan::EC_AffinePoint::g_mul(), and Botan::EC_Scalar::invert().

Referenced by public_key().

◆ serialize()

template<typename T >
T Botan::EC_PrivateKey_Data::serialize ( ) const
inline

Definition at line 57 of file ec_key_data.h.

57 {
58 T bytes(this->group().get_order_bytes());
59 this->serialize_to(bytes);
60 return bytes;
61 }
void serialize_to(std::span< uint8_t > output) const
FE_25519 T
Definition ge.cpp:34

References group(), serialize_to(), and T.

◆ serialize_to()

void Botan::EC_PrivateKey_Data::serialize_to ( std::span< uint8_t > output) const

Definition at line 47 of file ec_key_data.cpp.

47 {
48 m_scalar.serialize_to(output);
49}
void serialize_to(std::span< uint8_t > bytes) const
Definition ec_scalar.cpp:84

References Botan::EC_Scalar::serialize_to().

Referenced by serialize().


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