ccwalletio/tracker

Public Key (xpub) is incorrect

Closed this issue · 9 comments

eode commented

By following the process:

cat mnemonic.txt | cardano-wallet key from-recovery-phrase Shelley > root.xprv
cat root.xprv | cardano-wallet key child 1852H/1815H/0H > acct.xprv
cat acct.xprv | cardano-wallet key public --with-chain-code > acct.xpub

I receive a different key than is provided by [wallet]->Settings->Export Wallet and Transaction History->Export Account Pub Key.

The former works with sites (at least Koinly) that accept a Cardano Public Key. The latter does not, and does not match the Public Key from Daedalus or Yoroi.

Using Chrome Eternl Extension v1.6.4 in Brave.

Could you please generate an example using

cat acct.xprv | cardano-wallet key public --with-chain-code > acct.xpub
cat acct.xprv | cardano-wallet key public --without-chain-code > acct.pub

And show what the three strings look like.

eode commented

A development unused wallet:

Eternl: 
xpub1ece8lh98yp2zqe8a06985yje3fpexc7lls6dkyyczn8dc395p869kvjaup3mjuf3zy2sz43lqjgs4k3tecj2l5vzp7m80dmkzfjf9yq6v86vv

--with-chain-code:    # this one works.
acct_xvk1ece8lh98yp2zqe8a06985yje3fpexc7lls6dkyyczn8dc395p869kvjaup3mjuf3zy2sz43lqjgs4k3tecj2l5vzp7m80dmkzfjf9yqfn260n

--without-chain-code:
acct_vk1ece8lh98yp2zqe8a06985yje3fpexc7lls6dkyyczn8dc395p86qhesk5x

Ok, so you need to decode bech32 and then encode again bech32 with the acct_xvk prefix instead of xpub.

eode commented
# prefixes snipped
1ece8lh98yp2zqe8a06985yje3fpexc7lls6dkyyczn8dc395p869kvjaup3mjuf3zy2sz43lqjgs4k3tecj2l5vzp7m80dmkzfjf9yq6v86vv
1ece8lh98yp2zqe8a06985yje3fpexc7lls6dkyyczn8dc395p869kvjaup3mjuf3zy2sz43lqjgs4k3tecj2l5vzp7m80dmkzfjf9yqfn260n
                                                                                                        ^^^^^^

Ah, and that's the checksum, altered due to different prefix?

Noted. Just FYI, Yoroi also has a different format than either of these (and that works for me too)

I'll see if I can file a bug with the Tax site to also handle your xpub prefix. ..to my knowledge, there's no specific format that's the account public key for Cardano. That's something that should be taken up as a bug with IOHK, I guess -- obviously, it's not clear, and for technical purposes, an 'official' standard would help prevent issues like this.

Edit: Do you happen to know if the Yoroi and Daedalus account public key styles match?

I guess CIP 5 standard should be used here.
https://cips.cardano.org/cips/cip5/

acct_xvk seems to be the correct one for CIP-1852's extended account public key

eode commented

Agreed, that looks like the one.

Just as a note: This topic was also discussed in: https://forum.cardano.org/t/derive-addresses-from-daedalus-wallet-public-key/104011?u=heptasean

Yoroi shows a pure hex string of the extended public key, Daedalus uses the acct_xvk1 BECH32 format, and Eternl the xpub1 BECH32 format.

There is some example code to derive the stake address from all of these using https://github.com/dcSpark/cardano-multiplatform-lib later in that thread.

@eode As of today with release 1.9.2 you have the option to switch between different output formats.
Please have a look and let us know if it works for you.

Bildschirmfoto 2022-09-15 um 17 02 59

eode commented

Nice, thanks!