Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/lucid/mod.ts>Core.Bip32PrivateKey

Lucid is a library, which allows you to create Cardano transactions and off-chain code for your Plutus contracts in JavaScript, Deno and Node.js.
Very Popular
Go to Latest
class Core.Bip32PrivateKey
import { Core } from "https://deno.land/x/lucid@0.5.2/mod.ts";
const { Bip32PrivateKey } = Core;

Methods

as_bytes(): Uint8Array
chaincode(): Uint8Array
derive(index: number): Bip32PrivateKey

derive this private key with the given index.

Security considerations

  • hard derivation index cannot be soft derived with the public key

Hard derivation vs Soft derivation

If you pass an index below 0x80000000 then it is a soft derivation. The advantage of soft derivation is that it is possible to derive the public key too. I.e. derivation the private key with a soft derivation index and then retrieving the associated public key is equivalent to deriving the public key associated to the parent private key.

Hard derivation index does not allow public key derivation.

This is why deriving the private key should not fail while deriving the public key may fail (if the derivation index is invalid).

free(): void
to_128_xprv(): Uint8Array

see from_128_xprv

to_bech32(): string

Static Methods

from_128_xprv(bytes: Uint8Array): Bip32PrivateKey

128-byte xprv a key format in Cardano that some software still uses or requires the traditional 96-byte xprv is simply encoded as prv | chaincode however, because some software may not know how to compute a public key from a private key, the 128-byte inlines the public key in the following format prv | pub | chaincode so be careful if you see the term "xprv" as it could refer to either one our library does not require the pub (instead we compute the pub key when needed)

from_bech32(bech32_str: string): Bip32PrivateKey
from_bip39_entropy(entropy: Uint8Array, password: Uint8Array): Bip32PrivateKey
from_bytes(bytes: Uint8Array): Bip32PrivateKey