0glabs / 0g-chain

The First Modular AI Chain
Apache License 2.0
26 stars 37 forks source link

Got error when unsafe-export-eth-key #14

Closed Josephtran102 closed 1 month ago

Josephtran102 commented 3 months ago

When I created wallet I forgot flag --eth with command: 0gchaind keys add josephtran. After that I created Validator with this address. How could I recover this address with --eth flag to export unsafe-export-eth-key? I got error: Error: invalid key algorithm, got secp256k1, expected eth_secp256k1

I did 0gchaind keys add "josephtran" --eth --recover with seed phrase and it gives me others address. If recover with 0gchaind keys add "josephtran" --recover. It gives me old address I want.

Is there any way to export private key for this case?

Many thanks

ethanz0g commented 1 month ago

Hello @Josephtran102 ,

The following command would export the private key for you

$ 0gchaind keys export josephtran
Josephtran102 commented 1 month ago

Hi @ethanz0g,

Thanks for reply. I can export private key. But I mean export EVM wallet address.

ethanz0g commented 1 month ago

Hi @Josephtran102 ,

It's good that you can export private key now. I thought your concern was the private key, since you'd asked "is there any way to export private key for this case" in your original post.

As to the EVM wallet address, most likely you've figured it out in your original post:

0gchaind keys add "josephtran" --eth --recover.

Josephtran102 commented 1 month ago

Hi @ethanz0g,

Let me make clear:

Firstly, I used this command for add wallet (without --eth):

0gchaind keys add josephtran

Result:

address: 0g1hh5ekqp4ej09fn8602xzdr0wgr47gxnvjdp2st name: josephtran pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AgO/0Wd4dsqlGSAb7ETFOzQUru+lUI5rpqXT3u79BkxY"}' type: localImportant write this mnemonic phrase in a safe place.It is the only way to recover your account if you ever forget your password.
xxx ladder xxxx anger foster xxxx monitor bounce edge main small open pink gallery nothing trumpet mandate tribe manual fortune width xxxx gorilla xxx

When I recover with the same mnemonic phrase I created. It give me the other wallet:

ubuntu@josephtran:~$ 0gchaind keys add joseph2 --recover --eth

eth flag specified: using coin-type 60 and signing algorithm eth_secp256k1

Enter your bip39 mnemonic xxx ladder xxxx anger foster xxxx monitor bounce edge main small open pink gallery nothing trumpet mandate tribe manual fortune width xxxx gorilla xxx Enter keyring passphrase:

Result:

ethanz0g commented 1 month ago

Hi @Josephtran102 ,

When you create keys without "--eth", you get Cosmos SDK compatible keys. And you will get Ethereum compatible keys if including option "--eth". These 2 sets of keys are not interchangeable. Since you have the mnemonic words, both sets of keys belong to you.

Your EVM wallet address is "0g1fex0drs8ekh465yxf6c0vzcezppetk240frytv", which is from your command 0gchaind keys add joseph2 --recover --eth