So, I have created this script which pulls out every public and private key in your wallet and stores them into flat files. The "keylistpub.txt" will contain every public key in the wallet file whether it's yours or not, and "keylistpair.txt" contains a list of just the keys for which there is an associated private key in the wallet, and includes both. This script should avoid duplicate keys in the output files.
http://dl.dropbox.com/u/1139081/extractKeys.tar.gzKeep in mind, this utility is going to create a new file on your computer with your private keys. Handle with care!
Now, I want to create something that converts the flat file back into a wallet. This will allow someone to extract keys from multiple wallets, combine them into a single file, and the create a merged wallet. The output file format looks like this:
1MRAs5doMqqbLQVuAUqGcxHBzrexMiTBG:
PubKey:
cfd41f6ab9a217380bd2dc370592635797759c7de172f5cc6b228c1d4f83dde2
44f5a373bf80e66db4c0d34a892def09d1f605aef0d94f6b2c3e0322dfdd331e
PrivKey:
7bb1e283fe1007757c75966706553e16cdb5f148c22712811a78e6bcf30c9a1b
1QXg28gA7mLBB9LSMgf4sjoB9batJBXEtB:
PubKey:
47634c35731a35b5b70d4959418dae2e1c6676a1007626092eef8bceb80e1b16
0d048e2a917c80a3f5f085a06ce4c88f78d66c82abf2f2a1683c171f8bbdb7ab
PrivKey:
6cd77c1cc66929e6db9bf4b502f4ce4868cb76037b66d630fd931a0ea2fb8bce
...
(don't get too excited, I have mangled the private keys)
-- The first string is the address, which should be fairly obvious.
-- The PubKey is two 32-byte numbers (x,y), which correspond to a point on the secp256k1 elliptic curve (the ECDSA curve used by the bitcoin network)
-- The PrivKey is literally a random 32-byte number, which gives the public key when you multiply the generator point by this number. Yes, a private key is just a random number. As such, there is no way to identify whether a string of digits is a private key, without having a public key to compare to. Or rather,
every 256-bit number is a private key, so a "private key" is only meaningful in the context of a public key point (x,y). (all hex numbers are encoded in BigEndian)
Anyone want to help converting pub/priv keypairs into a wallet file? I believe it can be done with the bsddb package in Python, but I haven't gotten it to work, myself, yet.