简体   繁体   中英

Solana keygen pubkey not matching

I am running the solana-keygen tool and am confused about its output. I was under the impression that the pubkey output by the first command should be the same as the one re-created using the second command. But they are different. What does the first one represent?

C:\Users\MSHIRAZ>solana-keygen new --no-outfile
Generating a new keypair

For added security, enter a BIP39 passphrase

NOTE! This passphrase improves security of the recovery seed phrase NOT the
keypair file itself, which is stored as insecure plain text

BIP39 Passphrase (empty for none):

=========================================================================
pubkey: Gu3nU5cW7W8mZesDUhjaym8e1mbsyUBey8fvhgnq7nMM
=========================================================================
Save this seed phrase and your BIP39 passphrase to recover your new keypair:
motor rate october crawl visa family prison hair annual fault tilt animal
=========================================================================

C:\Users\MSHIRAZ>solana-keygen pubkey prompt://
[pubkey recovery] seed phrase:
[pubkey recovery] If this seed phrase has an associated passphrase, enter it now. Otherwise, press ENTER to continue:
ADarcoVBd5USiMpycBGrhforf2EHqUJTc4YyByC7A8xP

C:\Users\MSHIRAZ>solana-keygen verify ADarcoVBd5USiMpycBGrhforf2EHqUJTc4YyByC7A8xP prompt://
[pubkey recovery] seed phrase:
[pubkey recovery] If this seed phrase has an associated passphrase, enter it now. Otherwise, press ENTER to continue:
Verification for public key: ADarcoVBd5USiMpycBGrhforf2EHqUJTc4YyByC7A8xP: Success

The pubkey printed on create is the raw ed25519 keypair pubkey, while solana-keygen pubkey prompt:// prints the pubkey at m/44'/501'. If you run solana-keygen pubkey ASK it should print the original pubkey

There is currently an open PR to update the CLI but for now you can do as described above.

https://github.com/solana-labs/solana/issues/17325#issuecomment-844317674

I'm not sure but it might have to do with the derivation path you are providing. The Blockchain API has an endpoint for deriving a public key for a Solana wallet, and you can do so reliably with it. It states:

You can generate a unique public key with each combination of secret recovery phrase, passphrase, and derivation path. Thus, with a single secret recovery phrase, you can generate many public keys. If you are just starting, just supply the secret recovery phrase you generated with the Solana Wallet Secret Recovery Phrase endpoint. If you are trying to get a public key that already exists (eg, created in the Phantom wallet), make sure you use the correct derivation path and passphrase. To read more about that, see the descriptions of those parameters below.

Derivation paths are used to derive the public key from the secret recovery phrase. Only certain paths are accepted. We use "m/44/501/0/0" by default, if it is not provided. This is the path that the Phantom and Sollet wallets use. If you provide the empty string "" as the value for the derivation path, then we will use the Solana CLI default value. The SolFlare recommended path is "m/44/501/0". You can also arbitrarily increment the default path ("m/44/501/0/0") to generate more wallets (eg, "m/44/501/0/1", "m/44/501/0/2", ...). This is how Phantom generates more wallets. To learn more about derivation paths, check out this tutorial .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM