1

See title. I've tried using https://github.com/input-output-hk/cardano-addresses to derive the skey, but it only gives an extended version that I'm unable to sign transactions with using the CLI.

Trying to figure out how to get the standard non-extended signing key.

1 Answer 1

3

Let's say your extended signing key is named payment.xkey, in the following format:

{
    "type": "PaymentExtendedSigningKeyShelley_ed25519_bip32",
    "description": "",
    "cborHex": "5880687fda2ea05211f09e1544efd4e2da4f5c607dddd06051e6471a754a7efe02411ca42fca7e8e17821485144ba42a12a9814279caf665cb9026faaaf85dffeceb8f206b4eaec7ee07722deab4f17e8705afa7fce7d58b347e1e24ff4f031cdc8ce0c1e06e4934512cc678314402f6c04a7cb999d4efdb324f03a416dfcbda498f"
}

Run the following command:

cat payment.xkey | cardano-address key inspect

It will output a 64 byte chain code, and a 128 byte extended signing key. The first 64 bytes of this extended key is what you are looking for. You can manually create the non-extended signing key by copy-pasting these first 64 bytes (exactly half) of the "extended_key" section into an appropriately formatted normal signing-key file. For example, if I run the above command and I get the following:

{
    "chain_code": "e0c1e06e4934512cc678314402f6c04a7cb999d4efdb324f03a416dfcbda498f",
    "extended_key": "687fda2ea05211f09e1544efd4e2da4f5c607dddd06051e6471a754a7efe02411ca42fca7e8e17821485144ba42a12a9814279caf665cb9026faaaf85dffeceb",
    "key_type": "private"
}

The string you're looking for would be: 687fda2ea05211f09e1544efd4e2da4f5c607dddd06051e6471a754a7efe0241

Now, use cardano-cli to generate a random, normal signing key file:

cardano-cli address key-gen --signing-key-file payment.skey --verification-key-file payment.vkey

Now, discard the vkey (it is irrelevant), open the payment.skey in an editor, and delete everything in the cborHex field following the 5820, replacing it with the first 64 bytes of the xprv above. This is your non-extended signing key. Final result should look like:

{
    "type": "PaymentSigningKeyShelley_ed25519",
    "description": "Payment Signing Key",
    "cborHex": "5820687fda2ea05211f09e1544efd4e2da4f5c607dddd06051e6471a754a7efe0241"
}

Repeat the same process for stake-keys, as well as for any other key indexes that are needed.

1
  • 1
    Thanks for this. However, what worked for me was to pass my root private key (the value starting with "root_") to cardano-address key inspect and not the extended key file you make reference to in payment.xkey. In other words: cat root.prv | cardano-address key inspect. This is the command that gave me the JSON with "chain_code", "extended_key" and "key_type".
    – caike
    Oct 19 at 1:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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