Bitcoin Forum
November 14, 2024, 11:36:13 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: A basic question about the pre-generated addresses in wallet.dat  (Read 569 times)
pf (OP)
Full Member
***
Offline Offline

Activity: 176
Merit: 105


View Profile
July 14, 2015, 08:02:28 PM
 #1

I launched a fresh Bitcoin Core 0.11.0 (bitcoin-qt) from a new (offline) Ubuntu Linux installation.

Then I encrypted my wallet with a passphrase and restarted bitcoin-qt.

Then I went into "Receive" and clicked "Request payment". I now saw a new receiving address added to the list.

Here is the thing: I was not asked to decrypt my wallet before adding that new receiving address. This must mean that Bitcoin Core had already pre-generated this address for me. (Other sources seem to mention that the program pre-generates 100 addresses, one benefit of which is to make backups more stable.)

Here is my question: Were these pre-generated addresses (and the corresponding private keys) created BEFORE the encryption, or AFTER the encryption?

This is a pretty important question IMO. If the pre-generated addresses were created before the encryption, it means that the private keys have already been written unencrypted to the hard drive. This is a security risk I have to take into account.
grue
Legendary
*
Offline Offline

Activity: 2058
Merit: 1452



View Profile
July 14, 2015, 08:12:15 PM
 #2

Here is my question: Were these pre-generated addresses (and the corresponding private keys) created BEFORE the encryption, or AFTER the encryption?
after.

source code responsible for this behavior: https://github.com/bitcoin/bitcoin/blob/086cb336cd8ac0b2a7ad9ff0544c014569c7db38/src/wallet/wallet.cpp#L557

It is pitch black. You are likely to be eaten by a grue.

Adblock for annoying signature ads | Enhanced Merit UI
pf (OP)
Full Member
***
Offline Offline

Activity: 176
Merit: 105


View Profile
July 14, 2015, 08:43:04 PM
 #3

Here is my question: Were these pre-generated addresses (and the corresponding private keys) created BEFORE the encryption, or AFTER the encryption?
after.

source code responsible for this behavior: https://github.com/bitcoin/bitcoin/blob/086cb336cd8ac0b2a7ad9ff0544c014569c7db38/src/wallet/wallet.cpp#L557
To make sure I understand things correctly, if I do this:

1. Launch Bitcoin Core for the first time (with an unencrypted wallet).
2. Generate 3 receiving addresses.
3. Encrypt wallet and restart Bitcoin Core.
4. Generate 5 receiving addresses.

This means that the first 3 private keys were exposed unencrypted to the hard drive, but the second 5 private keys were only written out encrypted to the hard drive. Am I right?
shorena
Copper Member
Legendary
*
Offline Offline

Activity: 1498
Merit: 1540


No I dont escrow anymore.


View Profile
July 14, 2015, 08:49:31 PM
 #4

Here is my question: Were these pre-generated addresses (and the corresponding private keys) created BEFORE the encryption, or AFTER the encryption?
after.

source code responsible for this behavior: https://github.com/bitcoin/bitcoin/blob/086cb336cd8ac0b2a7ad9ff0544c014569c7db38/src/wallet/wallet.cpp#L557
To make sure I understand things correctly, if I do this:

1. Launch Bitcoin Core for the first time (with an unencrypted wallet).
2. Generate 3 receiving addresses.
3. Encrypt wallet and restart Bitcoin Core.
4. Generate 5 receiving addresses.

This means that the first 3 private keys were exposed unencrypted to the hard drive, but the second 5 private keys were only written out encrypted to the hard drive. Am I right?

Yes, those keys that have been shown to the user before the encryption will still be part of the wallet.dat and thus stored w/o encryption. Those that have been generated afterwards will never be stored without the encryption (well unless you export them manually or something similar).

Im not really here, its just your imagination.
pf (OP)
Full Member
***
Offline Offline

Activity: 176
Merit: 105


View Profile
July 14, 2015, 08:56:07 PM
 #5

Here is my question: Were these pre-generated addresses (and the corresponding private keys) created BEFORE the encryption, or AFTER the encryption?
after.

source code responsible for this behavior: https://github.com/bitcoin/bitcoin/blob/086cb336cd8ac0b2a7ad9ff0544c014569c7db38/src/wallet/wallet.cpp#L557
To make sure I understand things correctly, if I do this:

1. Launch Bitcoin Core for the first time (with an unencrypted wallet).
2. Generate 3 receiving addresses.
3. Encrypt wallet and restart Bitcoin Core.
4. Generate 5 receiving addresses.

This means that the first 3 private keys were exposed unencrypted to the hard drive, but the second 5 private keys were only written out encrypted to the hard drive. Am I right?

Yes, those keys that have been shown to the user before the encryption will still be part of the wallet.dat and thus stored w/o encryption. Those that have been generated afterwards will never be stored without the encryption (well unless you export them manually or something similar).
Thank you. Appreciated!
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!