4

Is it possible to recover all your xmr funds from providing only your private spend key? Or do you need the private view key too?

What is the minimum one needs to sweep all coins out from an address? And how can this be done in the cli if you only had the private spend key?

5

Is it possible to recover all your xmr funds from providing only your private spend key?

That depends on whether the private spend key is deterministic or not.

First, a bit of history. In Monero's early days (before 24 (and later on 25) word mnemonic seeds), Monero's private spend key was non-deterministic. In other words, the private spend key and private view key were both independently and randomly generated. As a result, losing access to either of those would result in you not being able to retrieve your funds (note that the .keys wallet file would still contain all your keys). Nowadays, however, the private spend key is deterministic and the private view key is derived from the private spend key by hashing the private spend key with Keccak-256 (hash_to_scalar). Subsequently, the private view key is reduced modulo l (sc_reduce32).

Or do you need the private view key too?

Thus, in sum, you need the private view key too if the private spend key is non-deterministic. If, however, the private spend key is deterministic, you can simply derive it.

And how can this be done in the cli if you only had the private spend key?

For "spend" wallets, the CLI will currently only accept full key pairs, i.e., it requires both the private view key and the private spend key in addition to the public address. Thus, the CLI will not derive the private key for you if your spend key is deterministic.

Fortunately, there are tools out there to derive the private view key from a deterministic private spend key. You can, for instance, use this tool from luigi1111 (a Monero core-team member). It is used as follows (in case of merely possessing the deterministic private spend key):

  1. You can either browse to this link or download the ZIP file from here (in case you want to use it locally and/or offline).

  2. Enter your deterministic private spend key in box 2. Hexadecimal Seed:

  3. Click Gen 3. & 4.

  4. Click Gen 5.

  5. Click Gen 6.

  6. Click Gen 7.

You can now take the private spend key from box 2. Hexadecimal Seed:, the private view key from box 4. Private View Key:, and the public address from box 7. Public Address:. Subsequently, you can proceed to restore / recreate the wallet --restore-from-keys <arg> flag from the CLI. This is done as follows:

Windows:

Go to the folder monero-wallet-cli is located and make sure your cursor isn't located on any of the files. Subsequently do SHIFT + right click and it will give you an option to "Open command window here". Note that, if you're using Windows 10, it'll, most likely, give you an option to open the Powershell. Lastly, type the following command:

monero-wallet-cli.exe --generate-from-keys <new-wallet-name>

If that doesn't work in the Powershell, type:

.\monero-wallet-cli.exe --generate-from-keys <new-wallet-name>

If that doesn't work either in the Powershell, type:

./monero-wallet-cli.exe --generate-from-keys <new-wallet-name>

Linux and Mac OS X:

Open a new terminal from the same directory as monero-wallet-cli and subsequently type:

./monero-wallet-cli --generate-from-keys <new-wallet-name>


In the GUI you can simply select Restore a wallet from keys or mnemonic seed on the second page of the wizard (first page is language selection). If you currently have a wallet open, you ought to go to the Settings page and press Close wallet first.


To end, a few notes:

  1. In general, when restoring a wallet, one has to add a Restore height. It's relevance can be found here: What is the relevance of the restore height?

  2. You can currently still generate a non-deterministic private spend key (using the CLI) with the --non-deterministic flag.

  3. A relevant SE question for visibility: Can you sweep a wallet if you only have the private spend key?

  4. Luigi111's tool also has a great informational part (at the bottom under How Cryptonote Addresses Are Created).

2

Private spend key is usually enough because both the private view key and the address can be generated from it. There's curtently no way to do it with CLI alone. You'd have to convert the private spend key into mnemonic and then restore from mnemonic or reconstruct the viewkey and address and generate from keys. For these prrparation steps you can use a tool like https://xmr.llcoins.net/addresstests.html

There are cases of non-deterministic wallets where viewkey and spendkey are both independently generated at random. For that case, you can not reconstruct and need to know both.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.