Author

Topic: What is stored in the wallet.dat file? (Read 5696 times)

member
Activity: 81
Merit: 1002
It was only the wind.
February 22, 2013, 03:06:29 PM
#11
If you're not clear on why compressed keys give you a different address and how they are handled in Bitcoin-Qt, you should do a little research before moving keys between wallets.  

I'm working on that right now. From my existing knowledge of compression, however, compressed keys should just need to be decompressed. Obviously, that's not the case, so I'll be looking into it.

I was short because I was in a hurry to respond.   Now I have 30 more seconds Smiley 

The reason is that your bitcoin address is the hash of your public key.  If you use a compressed public key, you get a different hash than if you used the uncompressed key.  The ECDSA is all the same after uncompressing, but you need to make sure you're using the right address.

As such, the Bitcoin-Qt devs decided to add a 0x01 byte to the end of all private keys that use compressed public keys.  If it was not there, then having the raw ECDSA key would give no indiciation of whether to use compressed or uncompressed for hashing to create the address.   For instance -- in Armory, the 0x01 byte will be added when keys are "encoded" to be moved around, but in the file format, they will be stored as 32-byte integers with a one-bit flag identifying whether they are compressed.  That's why it matters.

I see. Also, while examining the code to pywallet, I see they have an AES implementation. Good thing I already have one I wrote, or this could take a while.
member
Activity: 81
Merit: 1002
It was only the wind.
February 22, 2013, 02:55:41 PM
#9
If you're not clear on why compressed keys give you a different address and how they are handled in Bitcoin-Qt, you should do a little research before moving keys between wallets.  

I'm working on that right now. From my existing knowledge of compression, however, compressed keys should just need to be decompressed. Obviously, that's not the case, so I'll be looking into it.
legendary
Activity: 1428
Merit: 1093
Core Armory Developer
February 22, 2013, 02:59:35 PM
#7
If you're not clear on why compressed keys give you a different address and how they are handled in Bitcoin-Qt, you should do a little research before moving keys between wallets.  

I'm working on that right now. From my existing knowledge of compression, however, compressed keys should just need to be decompressed. Obviously, that's not the case, so I'll be looking into it.

I was short because I was in a hurry to respond.   Now I have 30 more seconds Smiley 

The reason is that your bitcoin address is the hash of your public key.  If you use a compressed public key, you get a different hash than if you used the uncompressed key.  The ECDSA is all the same after uncompressing, but you need to make sure you're using the right address.

As such, the Bitcoin-Qt devs decided to add a 0x01 byte to the end of all private keys that use compressed public keys.  If it was not there, then having the raw ECDSA key would give no indiciation of whether to use compressed or uncompressed for hashing to create the address.   For instance -- in Armory, the 0x01 byte will be added when keys are "encoded" to be moved around, but in the file format, they will be stored as 32-byte integers with a one-bit flag identifying whether they are compressed.  That's why it matters.
legendary
Activity: 1428
Merit: 1093
Core Armory Developer
February 22, 2013, 02:19:02 PM
#6
For reference, Armory's wallet format is documented here:

http://bitcoinarmory.com/armory-wallet-files/

Armory, at one point, also had code for reading the Satoshi wallet, encrypted or not.  The code was based on pywallet's code.  However, that code is commented out because Armory couldn't support Bitcoin-Qt's switch to compressed public keys.  Thus, there actually is not a way to convert new wallets to Armory format, because it will calculate different (incorrect) addresses for the private keys.  This will be fixed soon in Armory (with new wallet format), but I suspect Armory won't be the only app that has this problem.

Why not simply decompress the keys?

Because you get a different address.

EDIT:  It's not terribly complicated to implement the correct logic, it's just that I tested the bejeezuz out of the current wallet format, and it is the most sensitive part of the application.  I didn't want to mess with what was working.

If you're not clear on why compressed keys give you a different address and how they are handled in Bitcoin-Qt, you should do a little research before moving keys between wallets.  
legendary
Activity: 3472
Merit: 4801
February 22, 2013, 12:02:45 PM
#5
Could someone point me to pywallet? I searched for it, but couldn't find it.

http://bit.ly/WZmG1x
legendary
Activity: 1428
Merit: 1093
Core Armory Developer
February 21, 2013, 07:48:19 PM
#4
For reference, Armory's wallet format is documented here:

http://bitcoinarmory.com/armory-wallet-files/

Armory, at one point, also had code for reading the Satoshi wallet, encrypted or not.  The code was based on pywallet's code.  However, that code is commented out because Armory couldn't support Bitcoin-Qt's switch to compressed public keys.  Thus, there actually is not a way to convert new wallets to Armory format, because it will calculate different (incorrect) addresses for the private keys.  This will be fixed soon in Armory (with new wallet format), but I suspect Armory won't be the only app that has this problem.
hero member
Activity: 756
Merit: 501
There is more to Bitcoin than bitcoins.
February 21, 2013, 07:17:43 PM
#3
Could someone point me to pywallet? I searched for it, but couldn't find it.
Try searching the Internet using your favorite search engine.
legendary
Activity: 1512
Merit: 1036
February 20, 2013, 05:48:25 PM
#2
1. The wallet can be encrypted, you must know how to recognize this and properly decrypt and reencrypt data,
2. Examine the code of pywallet, and run pywallet to do a wallet dump to get an idea what data is stored,
3. Understand what you are doing 110%, there's stuff in there like reserve keys, transactions, address book, etc.
member
Activity: 81
Merit: 1002
It was only the wind.
February 19, 2013, 08:34:50 PM
#1
NaN.
Jump to: