Paperwallet addresses - bad guide in Solana DOCS

Hello solaners!
I am trying to walking on my personal learning path reading the solana online docs.
Here you are the paradox: verify fails on what they teach!
I create the paperwallet by this command:

$ solana-keygen new --no-outfile

The uotput is:

======================================================================
pubkey: 7m96d8YqCk4TKxgzZ7xRP9tmNv58w1PNa81zqmx5yN3Y
======================================================================
Save this seed phrase and your BIP39 passphrase to recover your new keypair:
prize detail huge ring boil cruel laugh coral treat advice fold answer
======================================================================

The passfrase I set was: solana2021.
Verify process:

$ solana-keygen verify 7m96d8YqCk4TKxgzZ7xRP9tmNv58w1PNa81zqmx5yN3Y prompt://

I inserted the passphrase and the seedphrase and the verification fails!!


Second step: to recover the address by the following command:

$ solana-keygen pubkey prompt://

The output is a new address!! What is my address now? Let go to verify the new address by the following command (with the just generated new address):

$ solana-keygen verify AJktBeAnbnwwgRnTkMLG4NNG9vpM3BvcA3cCNF5jBz3o prompt://

And the verification process succeded!!! And now what is my address?
Simple!! Go to ASK it by the following command:

$ solana-keygen pubkey ASK

By inserting the same passphrase and the seedphare I had the following address!!

7m96d8YqCk4TKxgzZ7xRP9tmNv58w1PNa81zqmx5yN3Y

And so, now, what is my address?
Let try on Firefox using Solarflare!! I imported the address by insert the KEIPAIR (seed and pass).
And here you are a tird address: 8UVPZ65ibs9U2fPa4sq2QfTKURsaJrXpwnSBv5P3bZtq.

Now I have 3 addresses with single passphrase and a single seedphrase.

Probably there is omething that I did not understand!

1 Like

Hey @jeyjey you have discovered the great key derivation mystery that me and some other users have stumbled upon! Very good breakdown of your experiences, by the way. :slight_smile:

It is not a bug, it is actually a very cool feature ( :upside_down_face: ), but it is very confusing and not necessarily well documented. I’ll do my best to explain it step by step. While this info may not be 100% accurate, it is correct to the best of my knowlege.


Seed Phrases and Derived Keys

Keypairs in Solana, as you know, can be generated from seed phrases. But, what is less obvious is that you can generate any number of different keys from the same seed phrase. :astonished:

The Root Key

There is one key that is called the root or master key, that is derived from the seed phrase. This is generally not used by wallets and you generally shouldn’t use it to receive SOL, but it is the address output when you first do a solana-keygen new.

Here is the seed phrase for these examples if you want to follow along:

unknown gauge drastic estate obey absorb liberty decade risk couple impose toe

Obviously never use this wallet for storing funds in real life!!

:bulb:Remember: You generally don’t use the root key for receiving SOL, making transactions, etc., but it’s good to know that it’s the key that is output by solana-keygen new.

When trying to access the root key derived from a seed phrase in the Solana CLI, you use the keyword ASK. For instance, to get the root key’s public key:

$ solana-keygen pubkey ASK
[pubkey recovery] seed phrase: 
[pubkey recovery] If this seed phrase has an associated passphrase, enter it now. Otherwise, press ENTER to continue: 
CzpMz6hWmtHWuztJoSvi6PNKEw3zYkJqDkcamTu3FmXm

The Derivation Path

Other than the root key, you can derive any number of other keys from the same seed phrase in an arbitrary hierarchy that is represented by what is called a derivation path.

The derivation path is basically a sequence that looks like this: m/44'/501'/0'/0'. Let’s break that down:

  • The derivation path always starts with m, which I think stands for “master”, as in the master, or root, key
  • Each element of the path is separated by a /
  • Each element in the path is a positive integer or zero
  • Each element may or may not have a single-quote after the number. This indicates “hardened”, but you don’t need to understand exactly what that means ( I don’t ). Just know that in Solana, all of the numbers should have the single-quote after them, and on the CLI, even if you don’t specify the single-quote, it acts as if it is there.

This derivation path can be as long or as short as possible. For instance, both of these paths are valid: m/11'/22'/33'/44'/55'/66' or m/0'/1'.

Because these derivation paths could be anything, BIP-0044 was created as a standard that crypto wallets and other apps could use to determine what derivation path to use for seed phrases for different situations.

In Solana, all standard derivation paths by default should follow this pattern:

m / 44' / 501' / account_index' / 0'

Let’s break this down:

  • 44': This first number is defined by BIP-0044 as the “purpose” of the derivation path. This should always be 44, just to indicated that the derivation follows the BIP-0044 standard.
  • 501': This second number is a number representing the coin type. The 501 is the registered number for the SOL token. So this second number will never change for Solana wallets following the BIP-0044 standard.
  • account_index': This third number can be any positive integer or zero. This number can be incremented every time you want to get a new account key from the same seed phrase
  • 0': This fourth number should be 0 for all keys that you want to use publicly.

OK, that’s a lot of info, but the gist of it is that wallets such as Sollet and Phantom will use this derivation path, and for every account you create, they will increment the account_index in the derivation path so that you can have multiple accounts, all with the same seed phrase.

A scenario might make this easier to understand:

  • If you created a wallet using Sollet
  • And you used the seed phrase we’ve been using in our examples so far
  • And you created 3 accounts in Sollet
  • Sollet would derive 3 accounts from that seed phrase
  • The three accounts would use these three derivation paths:
    • m/44'/501'/0'/0'
    • m/44'/501'/1'/0'
    • m/44'/501'/2'/0'

In fact, we can test this out in Sollet right now by importing our example seed phrase into it.

image

When importing our seed phrase, Sollet will show us the list of accounts that it can derive from our seed phrase!

Derivation Paths in the CLI

The really confusing part about this is that when you use the Solana CLI, the default derivation path is different than the web wallets! The default derivation path for the Solana CLI is m/44'/501'.

So when we use the prompt:// syntax on the Solana CLI like below, we get a key that doesn’t match what is in Sollet:

$ 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: 
371Rsvbif9QWuANEpAjRvAEpkAX9dmeRqgk16Zw9LDKp

We’re not stuck, though! We can tell the CLI exactly what derivation path we want to use manually like this:

$ solana-keygen pubkey "prompt://?full-path=m/44'/501'/0'/0'"
[pubkey recovery] seed phrase: 
[pubkey recovery] If this seed phrase has an associated passphrase, enter it now. Otherwise, press ENTER to continue: 
AWwD9CBDSrCkELSQtt6JzDvZq25M4kFaMLeCNWn74utz

By specifying the full derivation path manually on the commandline, we can now get all the same acccount keys that we see in Sollet!

Why Multiple Keys?

That about wraps up the mystery of the multiple wallet addresses! We can now see how we could, astonishingly enough, have gotten so many different wallet addresses all from the same seed phrase.

But why would you want to do that? It has to do with privacy. By only having to remember one seed phrase, you can have access to control any number of different accounts. There is no observable relationship between any of these different accounts, though. Nobody can tell that you control them all, which means that you could conduct your transactions with any of these different accounts to make it harder for people observing the chain to tell that it is the same person making all of the transactions.

Helloo guys and thanks very much for consider me and my question. I have to write that with these keypair I cannot find the way to import the SOLANA-CLI paperwallet to a Solarflare Firefox wallet. I need to work by command line because I want to work on a project that needs to build a service on this blockchain. I need to work via command line but my partners would love to work on a WebWallet like Phantom or Solflare.
Ho do I import my command line wallets in Solflare? I tryed but I see some addresses without the one that I created manually.

I just edited my comment above, which has the detailed walkthrough.

The short answer to your question is don’t use ASK or prompt:// on the command-line to get your public key. In order to match the Sollet wallet you need to use prompt://?full-path=m/44'/501'/1'/0' instead of just prompt:// to load your paper wallet on the command-line.

For example, this will return the address from your seed phrase that should match the address of the first account in Sollet, Phantom, or Solflare:

solana-keygen pubkey "prompt://?full-path=m/44'/501'/1'/0'"

Let me know if you have any other questions! This is a confusing one. :slight_smile:

Hello. Thanks for your suggestions that helped me to understand more about command line client. I am afraid but the adderres produced were not the same I found in Solflare. I tested also in phantom. Phantom wallet is different and there is only one address (public key). Solflare gives a list of addresses that the first is THE SAME of Phantom wallet. But it is not the same of the solana-keygen command gives. I tryed to change the pattern using the dropdown menu and the addresses gived are not the same. Obviously I changed the pattern to the command string too.

Hello again. I made the inverse procedure. I create a Solflare wallet with mnemonic seedphrase:

pitch monster question genre stable pattern rug usual actress bronze axis aunt dial mail south safe pigeon jeans casino session thunder habit cruel upset

The first address generated is: 42LRBZywpS6HwyEQN4Rb5E2Yz87CDFVDRnqBA1zuzUZN


I logged off the wallet vriting down the seedphrase. I set obviously a passphrase and I wrote it on a peper note.


I exported the private numeric key and I wrote it ina file called: newtoken_solflare.key and with the command below I set the keyfile path:

$ solana config set --keypair newtoken_solflare.key

After that I tried to recreate the same public address with the perfect Solflare pattern:

$ solana-keygen pubkey "prompt://?full-path=m/44'/501'/0'"

After that, since the private key is the same, the mnemonic is the same and the password is the same, the result should be: 42LRBZywpS6HwyEQN4Rb5E2Yz87CDFVDRnqBA1zuzUZN

But the result on solana-cli is:
6emrTTxFu2adARECnR5AnDfBWaASJyQew7hXpN1f811C


I would like to be less confused to undderstand how to SAVE my wallets for future use.

Many thanks for the precious help.

Oh, sorry, I gave you the wrong command! I think this one will work:

solana-keygen pubkey "prompt://?full-path=m/44'/501'/0'/0'"

Yes, Phantom by default only has one account, but you can get more with the add account button:

image


Wait! I think I just figured out your problem!

When you set a password in your web wallet it does not add a passphrase to your wallet seed phrase.

Here’s exactly what I did:

  1. Create a new wallet in Solflare
  2. View the public address in Solflare
  3. Run this command: solana-keygen pubkey "prompt://?full-path=m/44'/501'/0'/0'"
    • Note: Do not specify any passphrase on the command-line prompt. Only specify the seed phrase and a blank passphrase.

  4. The public key matches!

Where I think you are getting stuck is that all the web wallets I’ve seen don’t use passphrases on your wallet. The password they ask for is used to encrypt the data saved locally, and is only used in your browser. All of the keys generated, though, do not actually use a passphrase. This allows you to change your web wallet password, without changing the generated keys.

So if you want to generate a paper wallet that will be compatible with web wallets, don’t specify a passphrase. Web wallets, so far, don’t seem to support wallets with passphrases.

Hello solaners! It works!!! Ok I understand the mistake! Solana password is for logging in the online wallet, there is a kind of security that I would like to mantain. I made an import WITH Solflare new password but for a paperwallet made WITHOUT passphrase …
Thanks very mutch. I continue the study path!!!

:hugs:

1 Like