Author

Topic: What is the "wallet export format"? (Read 2385 times)

sr. member
Activity: 444
Merit: 313
January 10, 2012, 08:25:59 AM
#9
Oh well, now it's all nice and explained:
https://en.bitcoin.it/wiki/Wallet_import_format
And I've also written a test suite:
http://gobittest.appspot.com/PrivateKey
legendary
Activity: 1536
Merit: 1000
electronic [r]evolution
January 10, 2012, 05:44:01 AM
#8
So in the end, to convert things from WIF to a private key, I would:
1) Convert the WIF into a hex array as any base58 encoded string
2) Drop the first byte and last 4 bytes

And I should also perform some checks to make sure the string wasn't corrupted by calculating the checksum.
Yeah I think that would be pretty much how to do it. Make sure to use the Base58 character set used by Bitcoin when doing the Base58 conversions.
sr. member
Activity: 444
Merit: 313
January 10, 2012, 05:24:45 AM
#7
Okay, now I get it. You were just explaining things the other way around (private key -> import format), whereas I was trying to understand how to convert things back.

So in the end, to convert things from WIF to a private key, I would:
1) Convert the WIF into a hex array as any base58 encoded string
2) Drop the first byte and last 4 bytes

And I should also perform some checks to make sure the string wasn't corrupted by calculating the checksum.
legendary
Activity: 1536
Merit: 1000
electronic [r]evolution
January 10, 2012, 03:27:25 AM
#6
Quote
That link is about creating a Bitcoin address from a key pair, not from the "wallet import/export format" which is said to "include built-in error checking codes" (from the "Private key" wiki entry).
Steps 4 to 9 describe how to do Base58Check encoding (but remember what I said about step 9). A WIF (wallet import format) key is simply a Base58Check encoded private key.

EDIT: so let me make this clearer:

1) Attach '80' to start of private key.
2) Perform SHA-256 hash on the whole string.
3) Perform SHA-256 hash on the result of the previous SHA-256 hash.
4) Take the first 4 bytes of the last SHA-256 hash. This is the checksum.
5) Add the 4 checksum bytes from point 4 to the end of the string from point 1.
6) Convert the result from a byte string into a base58 string.

EDIT: If you look here you'll see the process (Base58Check encoding) described in a few steps:

Quote
A Base58Check string is created from a version/application byte and payload as follows.

1.  Take the version/application byte and payload bytes, and concatenate them together (bytewise).
2.  Take the first four bytes of SHA256(SHA256(results of step 1))
3.  Concatenate the results of step 1 and the results of step 2 together (bytewise).
4.  Treating the results of step 3 - a series of bytes - as a single big-endian bignumber, convert to base-58 using normal mathematical steps (bignumber division) and the base-58 alphabet described below. The result should be normalized to not have any leading base-58 zeroes (character '1').
sr. member
Activity: 444
Merit: 313
January 10, 2012, 03:24:19 AM
#5
You mean "wallet import format" right?

Quote
Is it just a base58 encoded private key, or is there more to it than that?
To turn a normal private key into a WIF key you need to perform Base58Check encoding.

I'm pretty sure steps 4 to 9 on this page describe the process.
EDIT: btw, at step 4 you start with the private key and attach 0x80 to the front instead of 0x00.
That link is about creating a Bitcoin address from a key pair, not from the "wallet import/export format" which is said to "include built-in error checking codes" (from the "Private key" wiki entry).
Quote
9 - Convert the result from a byte string into a base58 string using Base58Check encoding.

I think this step is incorrect. The process completed between steps 4 and 9 is Base58Check encoding from what I understand.
The steps are correct for creating a Bitcoin address from a key pair, wrote that step-by-step guide myself, originally basing it off a public key used by Satoshi.
To turn a public key into a bitcoin address it's the exact same process, except you need to start at step 1 instead of step 4. So you perform Base58Check encoding on the RIPEMD-160 hash.
Didn't ask about turning a public key into a Bitcoin address, but turning the "wallet import/export format" into a private key. The rest I understand.

Also have a look at this: Base 58 Wallet Import format
That Wiki page is a bit vague on the details as to how one should convert the WIF into a private key.
donator
Activity: 308
Merit: 250
January 10, 2012, 01:24:56 AM
#4
The export/import wording can be used interchangeably.
legendary
Activity: 1536
Merit: 1000
electronic [r]evolution
January 10, 2012, 01:14:32 AM
#3
Ok I see what you were referring to now:

Quote
This sample key in wallet export format is 5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ, and the corresponding Bitcoin address is 1GAehh7TsJAHuUAeKZcXf5CnwuGuGgyX2S.

I think that's actually meant to say "wallet import format".

Also have a look at this: Base 58 Wallet Import format
legendary
Activity: 1536
Merit: 1000
electronic [r]evolution
January 10, 2012, 12:56:18 AM
#2
You mean "wallet import format" right?

Quote
Is it just a base58 encoded private key, or is there more to it than that?
To turn a normal private key into a WIF key you need to perform Base58Check encoding.

I'm pretty sure steps 4 to 9 on this page describe the process.
EDIT: btw, at step 4 you start with the private key and attach 0x80 to the front instead of 0x00.

Quote
9 - Convert the result from a byte string into a base58 string using Base58Check encoding.

I think this step is incorrect. The process completed between steps 4 and 9 is Base58Check encoding from what I understand. At step 9 you convert the result from a byte string into a base58 string using a specialized base58 character set: Base58 symbol chart. On that same page you'll also see another step by step guide for Creating a Base58Check string.

To turn a public key into a bitcoin address it's the exact same process, except you need to start at step 1 instead of step 4. So you perform Base58Check encoding on the RIPEMD-160 hash.
sr. member
Activity: 444
Merit: 313
January 09, 2012, 08:38:45 PM
#1
It was mentioned here:
https://en.bitcoin.it/wiki/Mini_private_key_format
but it doesn't seem to be explained on the wiki. Is it just a base58 encoded private key, or is there more to it than that?
Jump to: