cardano::bip32_ed25519::PublicKey class

Represent a BIP32-Ed25519 prublic key.

The BIP32-Ed25519 public key is the same as a regular Ed25519 public key only it contains a chain code for non-hardened key derivation.

Constructors, destructors, conversion operators

PublicKey() protected defaulted
PublicKey(std::span<const uint8_t, XPUBLIC_KEY_SIZE> pub) explicit
Construct a key object from a span of key bytes.
PublicKey(std::span<const uint8_t, PUBLIC_KEY_SIZE> pub, std::span<const uint8_t, CHAIN_CODE_SIZE> cc)
Construct a key object from bytes.

Public functions

auto bytes() const →  const PubKeyByteArray& constexpr
Return a constant reference to the public key byte array.
auto deriveChild(const uint32_t index, const DerivationMode derivation_mode = DerivationMode::V2) const →  PublicKey
Derive a child (non-hardened) key from the public key.
auto verifySignature(std::span<const uint8_t> msg, std::span<const uint8_t, SIGNATURE_SIZE> sig) const →  bool
Verify a signature using the public key.
auto xbytes() const →  ByteArray<XPUBLIC_KEY_SIZE>
Return a byte array containing both the key and chain code.

Function documentation

cardano::bip32_ed25519::PublicKey::PublicKey() protected defaulted

Make the default constructor protected so that it can only be used internally. The key will be all zeros.

cardano::bip32_ed25519::PublicKey::PublicKey(std::span<const uint8_t, XPUBLIC_KEY_SIZE> pub) explicit

Construct a key object from a span of key bytes.

Parameters
pub A span of bytes containing the public key and chain code that will be copied into the object.

cardano::bip32_ed25519::PublicKey::PublicKey(std::span<const uint8_t, PUBLIC_KEY_SIZE> pub, std::span<const uint8_t, CHAIN_CODE_SIZE> cc)

Construct a key object from bytes.

Parameters
pub The public key as a span of bytes.
cc The chain code as a span of bytes.

PublicKey cardano::bip32_ed25519::PublicKey::deriveChild(const uint32_t index, const DerivationMode derivation_mode = DerivationMode::V2) const

Derive a child (non-hardened) key from the public key.

Parameters
index Non-hardened BIP32 derivation index.
derivation_mode V1 - Byron, V2 - Shelley

bool cardano::bip32_ed25519::PublicKey::verifySignature(std::span<const uint8_t> msg, std::span<const uint8_t, SIGNATURE_SIZE> sig) const

Verify a signature using the public key.

Parameters
msg A span of bytes (uint8_t) representing the original message.
sig A span of 64 bytes (uint8_t) representing the signature.