Say I have an unencrypted wallet of 50mb and it turns to 25mb when encrypted. What happens to the other 25mb of unencrypted wallet file that's left on the hard drive? Couldn't a data recovery specialist recover these keys unencrypted?
Sorry if I am being ignorant and thanks for any input.
Edit: unless the encryption is done before the compression.. Duh lol
The reason you see a size reduction is actually not because of compression. When your wallet is unencrypted, the private key format is much larger for backwards compatibility reasons. In the original Bitcoin client, private keys were stored as OpenSSL serialized them. This serialization included things like curve parameters and the uncompressed public key for that private key. This information is redundant and completely unnecessary, but has to be serialized for backwards compatibility reasons. When you encrypt the wallet, the private key that gets encrypted no longer contains all of that unnecessary information, it just contains the private key itself. This is much smaller even when encrypted , and since it happens to every single private key, a lot of space is saved.