Skip to content

ethereum::EthereumKeyGenerator

Creates a pair of ECDSA keys and a ethereum address.

#include <EthereumKeyGenerator.hpp>

Public Types

Name
using std::pair< std::vector< std::uint8_t >, std::vector< std::uint8_t > > PubKeyPair_t

Public Functions

Name
EthereumKeyGenerator()
Construct a new Ethereum Key Generator.
EthereumKeyGenerator(std::string_view private_key)
Import a private key and construct a new Ethereum Key Generator.
EthereumKeyGenerator(const ethereum::scalar_field_value_type & private_key)
Import a private key and construct a new Ethereum Key Generator.
pubkey::ext_private_key< ethereum::policy_type > get_private_key() const
Getter for private key (be careful with security implications).
pubkey::public_key< ethereum::policy_type > get_public_key() const
Getter for public key.
const std::string & get_address() const
Getter for the Ethereum address.
const std::string & GetUsedPubKeyValue() const
Get the single public key value used by ethereum addressing.
std::string GetEntirePubValue() const
Get all key value of the public key.
template <typename T >
T
ExtractPubKeyFromField(const pubkey::public_key< ethereum::policy_type > & pub_key)
Extract the key vector data from the ECDSA public key.
std::string DeriveAddress(const std::vector< std::uint8_t > & pub_key_vect)
Derive the ethereum address from de XY concatenated coordinates.
std::shared_ptr< pubkey::ext_private_key< ethereum::policy_type > > CreateKeys()
Create the ECDSA key pair.
pubkey::public_key< ethereum::policy_type > BuildPublicKey(const std::string & pubkey_data)

Public Types Documentation

using PubKeyPair_t

using ethereum::EthereumKeyGenerator::PubKeyPair_t = std::pair<std::vector<std::uint8_t>, std::vector<std::uint8_t>>;

Public Functions Documentation

function EthereumKeyGenerator

EthereumKeyGenerator()

Construct a new Ethereum Key Generator.

function EthereumKeyGenerator

EthereumKeyGenerator(
    std::string_view private_key
)

Import a private key and construct a new Ethereum Key Generator.

Parameters:

  • private_key Private key in string form

function EthereumKeyGenerator

EthereumKeyGenerator(
    const ethereum::scalar_field_value_type & private_key
)

Import a private key and construct a new Ethereum Key Generator.

Parameters:

  • private_key Private key in string form

function get_private_key

inline pubkey::ext_private_key< ethereum::policy_type > get_private_key() const

Getter for private key (be careful with security implications).

Return: Reference to the private key

function get_public_key

inline pubkey::public_key< ethereum::policy_type > get_public_key() const

Getter for public key.

Return: Reference to the public key

function get_address

inline const std::string & get_address() const

Getter for the Ethereum address.

Return: Ethereum address

function GetUsedPubKeyValue

inline const std::string & GetUsedPubKeyValue() const

Get the single public key value used by ethereum addressing.

Return: The concatenated X and Y coordinates in string form

function GetEntirePubValue

inline std::string GetEntirePubValue() const

Get all key value of the public key.

Return: The concatenated X+Y key

function ExtractPubKeyFromField

template <typename T >
static T ExtractPubKeyFromField(
    const pubkey::public_key< ethereum::policy_type > & pub_key
)

Extract the key vector data from the ECDSA public key.

Parameters:

  • pub_key Public ECDSA key

Return: Key data (X + Y) of the public key

function DeriveAddress

static std::string DeriveAddress(
    const std::vector< std::uint8_t > & pub_key_vect
)

Derive the ethereum address from de XY concatenated coordinates.

Parameters:

  • pub_key_vect The concatenated vector representation of both X and Y coordinates

Return: Ethereum address in string form

Warning: The LSB is the 0 index and the MSB is the 63th.

function CreateKeys

static std::shared_ptr< pubkey::ext_private_key< ethereum::policy_type > > CreateKeys()

Create the ECDSA key pair.

Return: Private key pointer

function BuildPublicKey

static pubkey::public_key< ethereum::policy_type > BuildPublicKey(
    const std::string & pubkey_data
)

Updated on 2026-03-04 at 13:10:43 -0800