Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: rterwedo on March 28, 2021, 01:34:21 AM



Title: Structure of a master key in old core wallet
Post by: rterwedo on March 28, 2021, 01:34:21 AM
Encryption was implemented in core v 0.4.  A master key was added that encrypts the private keys.  (The master key itself was encrypted via various mechanisms). The master key unlocks the private keys.

Is a master key in the old JBOK wallet simply a private key (with a different name) ie is it the same format as a private key?  I am trying to scan individual bytes to look for it as this wallet was not born encrypted....OR does it just generate a master key on the fly when you encrypt ?

ie a private key typically starts (back then) as 0x01 0x01 0x04 - are there any telltale signs of an unencrypted master key?


Title: Re: Structure of a master key in old core wallet
Post by: achow101 on March 28, 2021, 03:57:40 AM
Is a master key in the old JBOK wallet simply a private key (with a different name) ie is it the same format as a private key?  I am trying to scan individual bytes to look for it as this wallet was not born encrypted....OR does it just generate a master key on the fly when you encrypt ?
It is not a private key nor is it stored in any way similar to a private key. The master key is generated when you encrypt. It is never stored unencrypted.

The thing to look for is a record that begins with mkey


Title: Re: Structure of a master key in old core wallet
Post by: rterwedo on March 28, 2021, 11:40:37 AM
Is a master key in the old JBOK wallet simply a private key (with a different name) ie is it the same format as a private key?  I am trying to scan individual bytes to look for it as this wallet was not born encrypted....OR does it just generate a master key on the fly when you encrypt ?
It is not a private key nor is it stored in any way similar to a private key. The master key is generated when you encrypt. It is never stored unencrypted.

The thing to look for is a record that begins with mkey

Thanks - yes I have that.  I was investigating the encryption bug on 0.4.  It stored keys in plaintext (even for encrypted wallets) in the wallet.dat, logs and __db00X files per Gavin here:  https://bitcointalk.org/index.php?topic=51474.msg616068#msg616068

We have had success finding them in the wallet.dat however the logs and __db files have been a bit more difficult to process.

I was wondering if the master key got mixed up in this db issue as well.   It would provide an alternate means of unlocking the private keys as in my case half the wallet was floating around in plaintext but my addr with coins on it happened to be in the other half.  =)