1

Is there a way for cardano-cli to generate stake registration certificate using the extended stake address verification key (stake_xvk) that was generated from cardano-address CLI?

Steps to generate extended stake address verification key:

 cardano-address recovery-phrase generate --size 15 > phrase.prv
 cardano-address key from-recovery-phrase Shelley < phrase.prv > root.xsk
 cardano-address key child 1852H/1815H/0H/2/0 < root.xsk | cardano-address key public --with-chain-code > stake.xvk

Now I have extended stake address verification key stake.xvk.

From here, I want to generate stake registration certificate using cardano-cli like so:

cardano-cli stake-address registration-certificate \
--staking-verification-key-file stake.vkey \
--out-file stake.cert

But this doesn't work because the content of --staking-verification-key-file is much different that of stake_xvk.

2 Answers 2

1

To convert to cardano-cli compatible key files, start with the cardano-address formatted stake.xsk signing key file, then work your way down using the following commands.

cardano-address recovery-phrase generate --size 15 > phrase.prv
cardano-address key from-recovery-phrase Shelley < phrase.prv > root.xsk
cardano-address key child 1852H/1815H/0H/2/0 < root.xsk > stake.xsk
cardano-cli key convert-cardano-address-key --shelley-stake-key --signing-key-file stake_0_0.xsk --out-file stake.skey

You will then need to generate the non-extended (i.e. without the chain code) stake.vkey file which the cardano-cli accepts.

cardano-address key public --without-chain-code < stake.xsk | tee stake.vk
VKEYHEX=$( cat stake.vk | bech32)
cat << EOF > stake.vkey
{
    "type": "StakeVerificationKeyShelley_ed25519",
    "description": "",
    "cborHex": "5820$VKEYHEX"
}
EOF

Now that you have the cardano-cli compatible stake.skey and stake.vkey, generate the stake registration certificate you can use the same command as before

cardano-cli stake-address registration-certificate --stake-verification-key-file stake.vkey --out-file stake.cert

You should then be able to sign the transaction using the extended stake.skey file.

2
  • Thanks for the quick response! Sorry if my question was a misleading but I need to find a way to generate certificates just with the verification key. This is because my application is separated into two components; ones generating unsigned transactions and others signing it.
    – Hiroto
    Apr 18 at 6:06
  • With the commands I posted you will have the stake.skey and stake.vkey. To generate the certificate you just need to run the same command as before, i.e. cardano-cli stake-address registration-certificate --stake-verification-key-file stake.vkey --out-file stake.cert. I will edit the answer for completeness' sake :)
    – keefie
    Apr 18 at 9:14
1

To be able to generate the stake.vkey, the process is the following:

cardano-address key child 1852H/1815H/0H/2/0 < root.xsk > stake.xprv
cardano-address address delegation $(cat stake.xprv | cardano-address key public | tee stake.xpub)

SESKEY=$( cat stake.xprv | bech32 | cut -b -128 )\$( cat stake.xpub | bech32)

cat << EOF > stake.skey
{
    "type": "StakeExtendedSigningKeyShelley_ed25519_bip32",
    "description": "",
    "cborHex": "5880\$SESKEY"
}
EOF

cardano-cli shelley key verification-key --signing-key-file stake.skey --verification-key-file stake.evkey
cardano-cli shelley key non-extended-key --extended-verification-key-file stake.evkey --verification-key-file stake.vkey

Once you have the stake.vkey, you can generate the staking certificate with the command that you listed:

cardano-cli stake-address registration-certificate \
--staking-verification-key-file stake.vkey \
--out-file stake.cert

Credits to ilap (I took the commands from his script)

3
  • Okay it worked, but instead of addding 5880 at the beginning, I've added 5840 instead. Adding 5580 threw the following exception: ``` Command failed: key non-extended-key Error: ShelleyStake.vkey: TextEnvelope decode error: DecoderErrorDeserialiseFailure "VerificationKey StakeExtendedKey" (DeserialiseFailure 2 "end of input") ``` Do you know what this number means? cardano-cli that I'm currently using is: cardano-cli 1.33.0 - linux-x86_64 - ghc-8.10 git rev 814df2c146f5d56f8c35a681fe75e85b905aed5d
    – Hiroto
    Apr 18 at 6:53
  • 1
    Okay my friend did a little bit of research and this is what 5580 means. The cborhex here contains of 4 parts: 1. prefix 5880 - bytestring of 128 bytes 2. signing key (64 bytes) 3. verification key (32 bytes) 4. chain code (32 bytes) Rule for prefixes: - CBOR-encoded bytestring (which is what the 58 identifies) - size (80 means 128 bytes, whereas 40 means 64 bytes, 20 means 32 bytes)
    – Hiroto
    Apr 19 at 3:22
  • Well done, this will be helpful also for other people. Happy to help :-)
    – Nic_T2H
    Apr 19 at 3:58

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.