I'm trying to new Cardano.Bip32PrivateKey from string cborHex which in file skey generate by cardano-cli

import * as Cardano from "@emurgo/cardano-serialization-lib-nodejs";

function genAccountKey(cborHex: string) {
    return Cardano.Bip32PrivateKey.from_bytes(Buffer.from(cborHex, "hex"))
        .derive(harden(1852)) // purpose
        .derive(harden(1815)) // coin type
        .derive(harden(0)); // account #0


but I got this err (node:87994) UnhandledPromiseRejectionWarning: Invalid Secret Key size

  • Is it possible to use .skey(s) and .vkey(s) to construct transactions with the Cardano Serialisation Library? Based on your response it seems as though it is not possible since one cannot backwards derive the necessary privatekeys ... Commented Jan 23, 2022 at 12:40
  • Welcome aboard. Your answer isn't an answer but it would make a good question. Don't forget to check out the tour and read some of the pinned messages in the help center
    – gRebel
    Commented Jan 23, 2022 at 22:24

2 Answers 2


The CLI key you generate is not the same as Bip32PrivateKey associated with HD Wallet, the Root key you're considering is green box below - while the CLI key is red one. You can derive from parent key to child, but not the other way round.

enter image description here


You can derive a private key from skey CBOR using:

    // Sign with the backend wallet
    const signingKeyHexCBOR = 'THISISYUURKEYCBOR'
    const signingKey = this.S.PrivateKey.from_normal_bytes(Buffer.from(signingKeyHexCBOR,'hex'));

    const vkeyWitness2 = this.S.make_vkey_witness(txHash, signingKey);
  • do you know how to go the other way? Starting from a Bip32PrivateKey to a CBOR string that I can paste into an skey file that can be used to sign a transaction with cardano-cli?
    – grim_i_am
    Commented Feb 14, 2022 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.