class
PrivateKeyRepresent an BIP32-Ed25519 private key.
Public static functions
- static auto fromMnemonic(const Mnemonic& mn) → PrivateKey
- Generate a key from a mnemonic seed phrase.
-
static auto fromMnemonic(const cardano::
Mnemonic& mn, std:: string_view passphrase) → PrivateKey - Generate a key from a mnemonic seed phrase.
- static auto fromMnemonicByron(const Mnemonic& mn) → PrivateKey
- Generate a key from a mnemonic seed phrase.
-
static auto fromSeed(std::
span<const uint8_t, SEED_ SIZE> pub) → PrivateKey - Create a new BIP32-Ed25519 private key from a root seed.
- static auto generate() → PrivateKey
Constructors, destructors, conversion operators
- PrivateKey() protected defaulted
-
PrivateKey(std::
span<const uint8_t, XKEY_ SIZE> prv) explicit - Construct a key object from a span of key bytes.
-
PrivateKey(std::
span<const uint8_t, KEY_ SIZE> pub, std:: span<const uint8_t, CHAIN_ CODE_ SIZE> cc) - Construct a key object from bytes.
Public functions
- auto bytes() const → const KeyByteArray& constexpr
- Return a constant reference to the private key secure byte array.
- auto deriveChild(const uint32_t index, const DerivationMode derivation_mode = DerivationMode::V2) const → PrivateKey
- Derive a child key from the private key.
-
auto encrypt(std::
string_view password) const → EncryptedPrivateKey - auto publicKey() const → PublicKey
- Derive the public key paired with this private key.
-
auto sign(std::
span<const uint8_t> msg) const → ByteArray<SIGNATURE_ SIZE> - Generate a message signature from the private key.
-
auto xbytes() const → SecureByteArray<XKEY_
SIZE> - Return a byte array containing both the key and chain code.
Function documentation
static PrivateKey cardano:: bip32_ed25519:: PrivateKey:: fromMnemonic(const Mnemonic& mn)
Generate a key from a mnemonic seed phrase.
Parameters | |
---|---|
mn | The mnemonic object. |
Returns | A new private key. |
static PrivateKey cardano:: bip32_ed25519:: PrivateKey:: fromMnemonic(const cardano:: Mnemonic& mn,
std:: string_view passphrase)
Generate a key from a mnemonic seed phrase.
Parameters | |
---|---|
mn | The mnemonic object. |
passphrase | An optional passphrase to combine with the seed. |
Returns | A new private key. |
static PrivateKey cardano:: bip32_ed25519:: PrivateKey:: fromMnemonicByron(const Mnemonic& mn)
Generate a key from a mnemonic seed phrase.
Parameters | |
---|---|
mn | The mnemonic object. |
Returns | A new private key. |
Use the key generation method employed by Daedalus for generating Byron addresses.
static PrivateKey cardano:: bip32_ed25519:: PrivateKey:: generate()
Factory method to create a new BIP32-Ed25519 private key from a cryptographically secure random number generator.
cardano:: bip32_ed25519:: PrivateKey:: PrivateKey() protected defaulted
Make the default constructor protected so that it can only be used internally. The key will be all zeros.
cardano:: bip32_ed25519:: PrivateKey:: PrivateKey(std:: span<const uint8_t, XKEY_ SIZE> prv) explicit
Construct a key object from a span of key bytes.
Parameters | |
---|---|
prv | A span of bytes containing the key and chain code that will be moved into the object. |
cardano:: bip32_ed25519:: PrivateKey:: PrivateKey(std:: span<const uint8_t, KEY_ SIZE> pub,
std:: span<const uint8_t, CHAIN_ CODE_ SIZE> cc)
Construct a key object from bytes.
Parameters | |
---|---|
pub | The private key as a span of bytes. |
cc | The chain code as a span of bytes. |
PrivateKey cardano:: bip32_ed25519:: PrivateKey:: deriveChild(const uint32_t index,
const DerivationMode derivation_mode = DerivationMode::V2) const
Derive a child key from the private key.
Parameters | |
---|---|
index | BIP32 derivation index. |
derivation_mode | V1 - Byron, V2 - Shelley |
EncryptedPrivateKey cardano:: bip32_ed25519:: PrivateKey:: encrypt(std:: string_view password) const
Parameters | |
---|---|
password | The password to use for the encryption. |
Encrypt the private key bytes with a password using the same method as that used by the Daedalus wallet. This clears the unencrypted private key of the calling object.
ByteArray<SIGNATURE_ SIZE> cardano:: bip32_ed25519:: PrivateKey:: sign(std:: span<const uint8_t> msg) const
Generate a message signature from the private key.
Parameters | |
---|---|
msg | A span of bytes (uint8_t) representing the message to sign. |