3

What is the difference between a private key, password, brain wallet, recovery passphrase, and wallet, if any? Is there any connection between these?

9

(I've left this as an answer, rather than a wiki, to encourage multiple answers since there may be other explanations that resonate better with people)

For brevity, this answer assumes that the underlying cryptography of Ethereum has not been broken.

TLDR:

  • private key = only way to access an Ethereum account
  • password = protects private key via encryption; private key + password -> encrypted key. Encrypted key + password -> private key
  • brain wallet = a bunch of characters that generate a private key; brain wallet phrase -> private key
  • recovery passphrase = a bunch of words that generate a series of private keys; recovery passphrase -> multiple private key
  • wallet = program for using blockchain; uses keys to manage accounts.

Private key

An Ethereum account is constructed starting from a 256-bit private key. 256 bits is a sequence of 256 binary digits (0s and 1s). A private key is the basis for signing transactions in Ethereum; only someone possessing the private key is authorized to control an Ethereum account. If one has been diligent in protecting one's private keys, then proof of possession of a private key also serves as an effective authentication mechanism. This is because it is astronomically unlikely that someone has chosen the same random bits as you have -- 1 in 2^256, or about 1 followed by 77 zeros; the number of grains of sand on the planet is only about 1 followed by 18 zeros and the number of atoms in the average human is, if my chemistry serves, is on the order 1 followed by 27 or 28 zeros. We'd have to generate on average of 2^128 keys (~3 followed by 38 zeros) before we'd expect to see two identical keys due to the birthday paradox.

Note that signing a transaction does not reveal your private key (assuming Ethereum has no protocol-level flaws, your wallet has no implementation flaws, and the assumptions behind the underlying cryptography hold). If lost the private key cannot be recovered (except see recovery passphrase below). Most/all wallet software stores the private key as a file. Anyone possessing this file (or its contents) can authorize transactions from the associated account. This is why it is imperative to never share your Ethereum private key or keyfiles.

Aside: If you keep your funds in an exchange, then you do not have access to the private keys associated with any deposited tokens/ether. That is, as far as Ethereum is concerned, you do not hold any ether or tokens since you can't prove ownership of an account. It's like if you deposit money in a bank (or, similarly, buying something at a store): once your cash is in the hands of the bank, you trust that they'll hold up their end of the deal by crediting your account with the deposited amount. And you also hope that the bank doesn't go under. Since the exchange now holds your tokens/ether on your behalf, you now prove your identity to the exchange by logging into it (probably with a password), just like you have to prove your identity to a bank to access the funds (this includes in-person with a bank card and remotely using a debit card + pin/signature/etc.).

Password

If you keep control of your own account (so you are not using an exchange, for example), you must be using some kind of wallet software. Some wallet software allows you to add extra protection to your private key. This is done through encryption, a reversible process. The password allows the encryption and the reverse process, decryption, of data. Using encryption, your private key is changed into an encrypted form that is unusable to anyone without the correct password. With the correct password, the original data containing your private key can be restored.

Because a password is required to convert the encrypted form of data back to its original form, a password is useless without private keys encrypted with the password. Similarly, the encrypted form of the private key is useless without the password. The whole point of passwords is to thwart an attacker who has access to the data on your disk. Thus, you are no less safe giving out your password for your private keys as you are by not encrypting them (not that I recommend this practice). It's a bit like how you need to enter a PIN to use a bank card at a teller machine -- having only the bank card (private key) is insufficient. If you have multiple bank cards with the same PINs, you increase your attack surface -- someone knowing your PIN can steal any of your bank cards. Similarly, reusing a password means that any private keyfile stolen will yield a reward to the attacker.

Note that an attacker who has your encrypted private key can make as many attempts as he/she wants, time permitting. Thus, it is imperative that a strong password be chosen if one is worried about this attack scenario. A six digit pin code (as you might use on your phone) is useless against such an attacker -- the phone (hopefully) is configured to delete data after a few attempts or exponentially slow down the rate at which passwords can be entered onto the phone to unlock it.

Brain wallet

Recall that a private key is 256 ones and zeroes. One way of generating a private key is to flip a coin 256 times and store a 0 for every tail and a 1 for every head. This is tedious. Instead, it's useful if we can take an arbitrary amount of data and turn it into a seemingly random stream of 256 bits. As it turns out, our current grasp of mathematics suggests that certain hash functions (cryptographically secure ones) have this handy property. So one thing we can do is feed one of these functions something "memorable" to a human, like 396 eXTRAORDINARY [Chic#kens Presumably PRESCRIBE sINISTER vAPORS! (as it turns out, this is still far less entropy using my linked-to software than a 256-bit hash function can make use of). By memorizing this phrase and using software that turns the phrase into a corresponding private key (and public key and account), there is no need to store a copy of a private key -- it can be generated whenever needed. Note that people are horrible at generating passwords. Unless you are sure you are generating passwords in a secure fashion with enough entropy, I would not recommend using a brain wallet. Plug: my passphrase generator is an attempt to simplify the process of generating moderately secure passphrases, but I do not guarantee that it works correctly. The source is deliberately small to make it easy to audit. This program was not designed for use with cryptocurrencies.

With a brain wallet, unlike a password-encrypted keyfile, it is absolutely imperative that you keep the password safe. As soon as someone learns the password, you've already been compromised.

Recovery passphrase

Taking the brain wallet one step further, some wallets use a standard for generating multiple accounts using only a single (pseudo or truly) random value. Note that we can take any number and represent it as a series of words. For example, if we have the following: Zero = 0, One = 1, Two = 2, etc., we can represent any number. Like one hundred twelve (112) can be stored as one one two. Instead of using just ten words, we can store more digits at a time using a larger vocabulary. Recovery passphrases thus allow a relatively short sequence of words to be turned into a private key. But instead of using this key to generate a SINGLE account, it can be used to generate a series. Here is a simplified example:

  • d72979c91b77462791012dd218d98025ca647e0bc9a34e81197e55c3bba033c8
  • 0581f7d25cc2e7e23a988ffd79118e23f87f5b2dd4f555b703172b4b346490f3
  • 76cb09e89fa33377a660877308ce1840b30504c7e3e8fdd0ed8d67d98d5ad393

This is not a random sequence of hexadecimal numbers. If you knew that these were hashes generated using the sha256 algorithm with a salt of stackexchange followed by the strings 1, 2, and 3, you'd know that the next value in the sequence is the perfectly deterministic value b777f9cf9036352c9adf739668b2be0cd8ace1b355122fe56c5ec9aaa9c00a95, the sha256 hash of stackexchange4. Hence, a recovery passphrase for a hierarchical deterministic (HD) wallet is all that is needed to regenerate private keys. Just like in a brain wallet, the "password" is used to generate private keys and must be kept secure.

Wallet

A wallet is a program used to interact with the blockchain (for example, to view balances for particular accounts or to call a smart contract). When modifying the blockchain, the wallet must authenticate (prove the identity of) the user doing the modification and requires a private key to do so.

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.