Derives a new Bip32PublicKey based on the given derivation path.
This method computes a child BIP32 public key by following a derivation path specified as an array of indices. The indices represent the hierarchical levels in the BIP32 standard, where each level derives a unique child key from its parent.
Hardened keys cannot be derived directly from public keys, as the private key is required
for hardened derivations. Indices in the range [0, 2^31 - 1] represent non-hardened keys
and are valid for public key derivation.
An array of numbers representing the derivation path.
- Each number corresponds to an index in the hierarchy.
- Only non-hardened indices (less than 2^31) are supported for public keys.
A derived Bip32PublicKey instance corresponding to the specified derivation path.
- The returned key is independent of the original key and can be used for cryptographic operations.
try {
const rootKey = Bip32PublicKey.fromBytes(new Uint8Array([0x01, 0x02, 0x03, 0x04]));
const indices = [44, 1815, 0];
const childKey = rootKey.derive(indices);
console.log('Derived child public key:', childKey.toHex());
} catch (error) {
console.error('Failed to derive Bip32PublicKey:', error);
}
The reference count retrieved by this method reflects the number of references maintained internally by libcardano-c for this native instance of the object. This is unrelated to the reference counting mechanism in JavaScript, which is managed by the JavaScript engine's garbage collector.
This method is primarily intended for diagnostic purposes.
The current reference count of the object in the WASM context.
Converts the Bip32PublicKey to an Ed25519PublicKey.
This method extracts the Ed25519 public key from the BIP32 hierarchical deterministic (HD) public key format. The Ed25519 public key is used for cryptographic operations such as verifying digital signatures and signing data.
An Ed25519PublicKey instance representing the extracted public key.
try {
const bip32Key = Bip32PublicKey.fromBytes(new Uint8Array([0x01, 0x02, 0x03, 0x04]));
const ed25519Key = bip32Key.toEd25519Key();
console.log('Extracted Ed25519 public key:', ed25519Key.toHex());
} catch (error) {
console.error('Failed to convert Bip32PublicKey to Ed25519PublicKey:', error);
}
Converts the Bip32PublicKey to a cryptographic hash using the BLAKE2b hashing algorithm.
This method computes a BLAKE2b hash of the BIP32 public key.
A Uint8Array containing the BLAKE2b hash of the BIP32 public key.
- The length of the hash depends on the BLAKE2b configuration in the underlying implementation.
try {
const bip32Key = Bip32PublicKey.fromBytes(new Uint8Array([0x01, 0x02, 0x03, 0x04]));
const hash = bip32Key.toHash();
console.log('BLAKE2b hash of the Bip32PublicKey:', Buffer.from(hash).toString('hex'));
} catch (error) {
console.error('Failed to compute the hash of Bip32PublicKey:', error);
}
Converts the Bip32PublicKey to a hexadecimal string representing its cryptographic hash.
This method first computes the BLAKE2b hash of the Bip32PublicKey and then converts
the resulting hash from its binary form (Uint8Array) to a hexadecimal string.
A string containing the hexadecimal representation of the BLAKE2b hash of the Bip32PublicKey.
StaticfromCreates a Bip32PublicKey instance from raw bytes.
This method allows the construction of a Bip32PublicKey using its raw binary representation.
The raw byte data of the BIP32 public key.
A new Bip32PublicKey instance that encapsulates the provided raw bytes.
StaticfromCreates a Bip32PublicKey instance from a hexadecimal string.
This method allows the construction of a Bip32PublicKey using its hexadecimal representation.
The hexadecimal string representing the BIP32 public key.
A new Bip32PublicKey instance that encapsulates the provided hexadecimal data.
The
Bip32PublicKeyclass encapsulates a public key following the BIP32 standard, which is a specification for hierarchical deterministic (HD) wallets. In HD wallets, a single master seed can derive an entire tree-like structure of cryptographic keys. Public keys in this structure are used for generating wallet addresses and verifying transactions without exposing private keys.