Backup of private keys

#1

Hello I create some address, on my terminal, how I can make a backup of the private keys?

Thank you

#2

Hi, Gabriele! Good question.
For now, the preferred way of backing up your keys is to back up the entire kmd-v0.* directory, located in your Algorand data directory. Here, I’m running kmd-v0.4:

Evans-Laptop:go-algorand evan$ ls ~/.algorand/kmd-v0.4
kmd.log		kmd.net		kmd.pid		kmd.token	sqlite_wallets
Evans-Laptop:go-algorand evan$ tar czf keys_backup.tar.gz ~/.algorand/kmd-v0.4/
tar: Removing leading '/' from member names
Evans-Laptop:go-algorand evan$ mv keys_backup.tar.gz ~/somewhere_safe/keys_backup.tar.gz

I hope this helps! Let me know if I can clarify anything.
Evan

1 Like
#3

Ok, thank you!
Will be nice to have a simple explanation fo each file and relative scope :wink:

Opening the sqllite file in data/sqllite_wallets I cant see my Private Key is this correct location of PK?

#4

Looks right. What you see there is public key which is random, 32 byte long. Wallet address as you see it is determinate from public key. Not sure is that public info, so can’t really discuss how is it generated, but let’s say that there’s sha256(private key) + 4 more bytes and then base32 of that (without ='s at the end).

Anyway, backing up that directory should take care of your keys as Evan stated…

Regards,
Ivica

#5

Thanks for the reply, I will like to see my private key some where, is there a way to get just the private key of an address and not the whole folder?

#6

Will be usefull to know how the keys are generated. For example to offer some web application like paper wallet. @David there is some documentation about the process in Algorand to generate a couple of public and private keys?

#7

Algorand spending keys are standard ed25519 keys (https://ed25519.cr.yp.to/). Spending keys generated by kmd are derived from a single “master derivation key” which is generated when the wallet is first created. By backing up this master derivation key, you can back up all of the keys a given wallet will ever generate (it can be exported as a 25-word mnemonic). Functionality to import/export this master derivation key will be coming in a goal update really soon (tomorrow?).

Some other things you might find useful: to go from an ed25519 public key to a printable address, we append a short checksum to the public key (the first four bytes of its SHA512_256 sum), and then base-32 encode the result. Also coming very soon are Javascript and Golang SDKs for doing this and other common key/address operations. Hope this helps. [Thanks Max for the details]

2 Likes
#8

we append a short checksum to the public key (the first four bytes of its SHA512_256 sum), and then base-32 encode the result.

Before base32 there’s actually one more step, last 4 bytes of original public key are added to sha256 of public key and then sha32 of all that.