ccwalletio / tracker

An issue tracker for ccwallet.io feature requests
25 stars 2 forks source link

Public Key (xpub) is incorrect #116

Closed eode closed 1 year ago

eode commented 2 years ago

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.

MarcelKlammer commented 2 years ago

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 2 years ago

A development unused wallet:

Eternl: 
xpub1ece8lh98yp2zqe8a06985yje3fpexc7lls6dkyyczn8dc395p869kvjaup3mjuf3zy2sz43lqjgs4k3tecj2l5vzp7m80dmkzfjf9yq6v86vv

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

--without-chain-code:
acct_vk1ece8lh98yp2zqe8a06985yje3fpexc7lls6dkyyczn8dc395p86qhesk5x
MarcelKlammer commented 2 years ago

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

eode commented 2 years ago
# 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?

Scitz0 commented 2 years ago

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 2 years ago

Agreed, that looks like the one.

HeptaSean commented 2 years ago

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.

marcuspuchalla commented 1 year ago

@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 1 year ago

Nice, thanks!