solana-labs / solana

Web-Scale Blockchain for fast, secure, scalable, decentralized apps and marketplaces.
https://solanalabs.com
Apache License 2.0
13.19k stars 4.3k forks source link

unable to retrieve private keys from an HD wallet #17114

Closed solannn closed 3 years ago

solannn commented 3 years ago

Problem

Unable to acquire multiple different Keypairs from an HD wallet Currently only able derive the "base" wallet keypair, but not able to move up/down the tree. i am able to derive the PUBKEYS in an HD way, but not the corresponding private keys (which are required for importation into Sollet).

I wish to generate the seed + passphrase OFFLINE elsewhere, then use the Solana CLI to derive multiple HD keypairs, where i can then import a few private keys into Sollet for regular "not-very-secure" use, and keep the rest of the keys safely stored.

logic tells me something like this should work :

solana-keygen recover -o ./test.json ask://?key=5/0

but alas, the command is not valid.

Proposed Solution

None, i am a newcomer and was unable to access other support channels, discord is an irritating mess with no permissions for new users to ask for help. This post was a last resort.

t-nelson commented 3 years ago

This feature was only recently introduced. Are you using the v1.6.7 release of the CLI tools?

solannn commented 3 years ago

Indeed i am,

Is there a particular command that i'm supposed to use?

For edification, the command :

solana-keygen recover -o ./test.json

works to retrieve the base wallet keypair, but i see no way to target different keypairs from the same HD seed

t-nelson commented 3 years ago

Ah I see the issue. solana-keygen recover doesn't have any way to specify the derivation path yet.

You can use ask:?key=A/C directly as a signer any other command, but will always need the seed phrase handy for re-entry. Which defeats the purpose.

This should be fairly trivial to add. I can look into it next week

cc/ @CriesofCarrots

--

A minimal example of ask:?key=A/C working as expected

$ solana-keygen pubkey ask:?key=0/0
[pubkey recovery] seed phrase:
[pubkey recovery] If this seed phrase has an associated passphrase, enter it now. Otherwise, press ENTER to continue:
GiE4zSsgYuWifG29g2BCd2NZp5ZMVWBXf2esdATxtFiH

$ solana-keygen pubkey ask:?key=1/0
[pubkey recovery] seed phrase:
[pubkey recovery] If this seed phrase has an associated passphrase, enter it now. Otherwise, press ENTER to continue:
jREZuo92tG2UFn84KD4WcTgiLcpdKqWLcoMbJZEfG3tQ
solannn commented 3 years ago

Yes, fetching the PUBKEY for various derivation paths works fine, its fetching the corresponding private key that's the particular issue im having.

Anyway, i'm glad to see you confirm it's not an official feature yet and that it wasnt an oversight on my part.