<p>To convert to <code>cardano-cli</code> compatible key files, start with the <code>cardano-address</code> formatted <strong>stake.xsk</strong> signing key file, then work your way down using the following commands.</p>
<pre><code>cardano-address recovery-phrase generate --size 15 &gt; phrase.prv
cardano-address key from-recovery-phrase Shelley &lt; phrase.prv &gt; root.xsk
cardano-address key child 1852H/1815H/0H/2/0 &lt; root.xsk &gt; stake.xsk
cardano-cli key convert-cardano-address-key --shelley-stake-key --signing-key-file stake_0_0.xsk --out-file stake.skey
</code></pre>
<p>You will then need to generate the non-extended (i.e. without the chain code) <strong>stake.vkey</strong> file which the <code>cardano-cli</code> accepts.</p>
<pre><code>cardano-address key public --without-chain-code &lt; stake.xsk | tee stake.vk
VKEYHEX=$( cat stake.vk | bech32)
cat &lt;&lt; EOF &gt; stake.vkey
{
    &quot;type&quot;: &quot;StakeVerificationKeyShelley_ed25519&quot;,
    &quot;description&quot;: &quot;&quot;,
    &quot;cborHex&quot;: &quot;5820$VKEYHEX&quot;
}
EOF
</code></pre>
<p>Now that you have the <code>cardano-cli</code> compatible <strong>stake.skey</strong> and <strong>stake.vkey</strong>, generate the stake registration certificate you can use the same command as before</p>
<pre><code>cardano-cli stake-address registration-certificate --stake-verification-key-file stake.vkey --out-file stake.cert
</code></pre>
<p>You should then be able to sign the transaction using the extended <strong>stake.skey</strong> file.</p>

CC BY-SA 4.0
2022-04-18T06:06:19.750Z
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
CC BY-SA 4.0
2022-04-18T09:14:39.310Z
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
CC BY-SA 4.0
2022-04-18T05:12:36.370Z
2022-04-18T09:54:10.690Z
2022-04-18T09:54:10.690Z
keefie
<p>To be able to generate the stake.vkey, the process is the following:</p>
<pre><code>cardano-address key child 1852H/1815H/0H/2/0 &lt; root.xsk &gt; 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 &lt;&lt; EOF &gt; stake.skey
{
    &quot;type&quot;: &quot;StakeExtendedSigningKeyShelley_ed25519_bip32&quot;,
    &quot;description&quot;: &quot;&quot;,
    &quot;cborHex&quot;: &quot;5880\$SESKEY&quot;
}
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
</code></pre>
<p>Once you have the stake.vkey, you can generate the staking certificate with the command that you listed:</p>
<pre><code>cardano-cli stake-address registration-certificate \
--staking-verification-key-file stake.vkey \
--out-file stake.cert
</code></pre>
<p>Credits to <a href="https://gist.github.com/ilap/3fd57e39520c90f084d25b0ef2b96894" rel="nofollow noreferrer">ilap</a> (I took the commands from his script)</p>

CC BY-SA 4.0
2022-04-18T06:53:47.043Z
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
CC BY-SA 4.0
2022-04-19T03:22:31.893Z
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
CC BY-SA 4.0
2022-04-19T03:58:43.853Z
Well done, this will be helpful also for other people. Happy to help :-)
Nic_T2H
CC BY-SA 4.0
2022-04-18T05:20:45.187Z
2022-04-18T05:20:45.187Z
Nic_T2H
<p>Is there a way for <code>cardano-cli</code> to generate stake registration certificate using the extended stake address verification key (<code>stake_xvk</code>) that was generated from <code>cardano-address</code> CLI?</p>
<p>Steps to generate extended stake address verification key:</p>
<pre><code> cardano-address recovery-phrase generate --size 15 &gt; phrase.prv
 cardano-address key from-recovery-phrase Shelley &lt; phrase.prv &gt; root.xsk
 cardano-address key child 1852H/1815H/0H/2/0 &lt; root.xsk | cardano-address key public --with-chain-code &gt; stake.xvk
</code></pre>
<p>Now I have extended stake address verification key <code>stake.xvk</code>.</p>
<p>From here, I want to generate stake registration certificate using cardano-cli like so:</p>
<pre><code>cardano-cli stake-address registration-certificate \
--staking-verification-key-file stake.vkey \
--out-file stake.cert
</code></pre>
<p>But this doesn't work because the content of <code>--staking-verification-key-file</code> is much different that of <code>stake_xvk</code>.</p>

<cardano-cli><cardano-address>
How to generate stake registration certificate from extended stake address verification key using cardano-cli
# How to generate stake registration certificate from extended stake address verification key using cardano-cli

(Asked by: username_0 on 2022-04-18)

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.

**Tags:** cardano-cli, cardano-address

---

## 2 answers

### Answer by username_1 on 2022-04-18. Score: 2 | Accepted answer

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.

> **Comments:**
> **username_0**: 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.  
> **username_1**: 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 :)  

---

### Answer by username_2 on 2022-04-18. Score: 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)

> **Comments:**
> **username_0**: 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  
> **username_0**: 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)  
> **username_2**: Well done, this will be helpful also for other people. Happy to help :-)  

---

