Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: khangmartin on September 16, 2019, 03:49:30 AM



Title: Master Key Key
Post by: khangmartin on September 16, 2019, 03:49:30 AM
Following path in source code for the creation of master key in crypter.cpp/.h. The program comment states Wallet Private Keys are encrypted with double sha 256 of public key as the IV and the master key's key as the encryption key. Is the encryption key the variable vchCryptedKey which is a part of the class CMasterKey or is it chKey from private class CCrypter? A second question since the IV is stored in the wallet.dat file, it is safe to assume this encryption key is stored in wallet.dat also? Please advise if I am incorrect? Thanks.


Title: Re: Master Key Key
Post by: Lauda on September 16, 2019, 03:33:21 PM
How about you quote and/or include a link to the code that you are unsure about? Nobody should waste their time trying to find it. ;)


Title: Re: Master Key Key
Post by: achow101 on September 16, 2019, 03:53:12 PM
Within CMasterKey, vchCryptedKey is the encrypted master encryption key. This key is decrypted using a key derived from the user's passphrase (with key stretching parameters specified withing the CMasterKey. The decrypted encryption key is now a CKeyingMaterial and stored as vMasterKey in CWallet.

Encryption keys (along with some metadata) are stored in the wallet.dat file. They are encrypted by a key derived from the user's passphrase.


Title: Re: Master Key Key
Post by: khangmartin on September 16, 2019, 05:41:18 PM
Thanks for the answers to my questions. I have one final question on this topic. When the software client loads the wallet, all variables (majority) contained in wallet.dat file load into program memory and are updated as required, is this a fair assumption?


Title: Re: Master Key Key
Post by: achow101 on September 16, 2019, 05:42:13 PM
When the software client loads the wallet, all variables (majority) contained in wallet.dat file load into program memory and are updated as required, is this a fair assumption?
Yes.