Bitcoin Forum
December 05, 2016, 08:45:30 PM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: What is the "wallet export format"?  (Read 2016 times)
ThePiachu
Sr. Member
****
Offline Offline

Activity: 442



View Profile WWW
January 10, 2012, 01:38:45 AM
 #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?

1HWbVLhxj7bhewhyapMZpyhqWAeAhJd51E
My Bitcoin Calculator:
http://tpbitcalc.appspot.com/
1480970730
Hero Member
*
Offline Offline

Posts: 1480970730

View Profile Personal Message (Offline)

Ignore
1480970730
Reply with quote  #2

1480970730
Report to moderator
"With e-currency based on cryptographic proof, without the need to trust a third party middleman, money can be secure and transactions effortless." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1480970730
Hero Member
*
Offline Offline

Posts: 1480970730

View Profile Personal Message (Offline)

Ignore
1480970730
Reply with quote  #2

1480970730
Report to moderator
1480970730
Hero Member
*
Offline Offline

Posts: 1480970730

View Profile Personal Message (Offline)

Ignore
1480970730
Reply with quote  #2

1480970730
Report to moderator
bitfreak!
Legendary
*
Offline Offline

Activity: 1514


electronic [r]evolution


View Profile WWW
January 10, 2012, 05: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.

XCN: CYsvPpb2YuyAib5ay9GJXU8j3nwohbttTz | BTC: 18MWPVJA9mFLPFT3zht5twuNQmZBDzHoWF
Cryptonite - 1st mini-blockchain altcoin | BitShop - digital shop script
Web Developer - PHP, SQL, JS, AJAX, JSON, XML, RSS, HTML, CSS
bitfreak!
Legendary
*
Offline Offline

Activity: 1514


electronic [r]evolution


View Profile WWW
January 10, 2012, 06: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

XCN: CYsvPpb2YuyAib5ay9GJXU8j3nwohbttTz | BTC: 18MWPVJA9mFLPFT3zht5twuNQmZBDzHoWF
Cryptonite - 1st mini-blockchain altcoin | BitShop - digital shop script
Web Developer - PHP, SQL, JS, AJAX, JSON, XML, RSS, HTML, CSS
mcorlett
Donator
Sr. Member
*
Offline Offline

Activity: 308



View Profile
January 10, 2012, 06:24:56 AM
 #4

The export/import wording can be used interchangeably.

ThePiachu
Sr. Member
****
Offline Offline

Activity: 442



View Profile WWW
January 10, 2012, 08: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.

1HWbVLhxj7bhewhyapMZpyhqWAeAhJd51E
My Bitcoin Calculator:
http://tpbitcalc.appspot.com/
bitfreak!
Legendary
*
Offline Offline

Activity: 1514


electronic [r]evolution


View Profile WWW
January 10, 2012, 08: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').

XCN: CYsvPpb2YuyAib5ay9GJXU8j3nwohbttTz | BTC: 18MWPVJA9mFLPFT3zht5twuNQmZBDzHoWF
Cryptonite - 1st mini-blockchain altcoin | BitShop - digital shop script
Web Developer - PHP, SQL, JS, AJAX, JSON, XML, RSS, HTML, CSS
ThePiachu
Sr. Member
****
Offline Offline

Activity: 442



View Profile WWW
January 10, 2012, 10: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.

1HWbVLhxj7bhewhyapMZpyhqWAeAhJd51E
My Bitcoin Calculator:
http://tpbitcalc.appspot.com/
bitfreak!
Legendary
*
Offline Offline

Activity: 1514


electronic [r]evolution


View Profile WWW
January 10, 2012, 10: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.

XCN: CYsvPpb2YuyAib5ay9GJXU8j3nwohbttTz | BTC: 18MWPVJA9mFLPFT3zht5twuNQmZBDzHoWF
Cryptonite - 1st mini-blockchain altcoin | BitShop - digital shop script
Web Developer - PHP, SQL, JS, AJAX, JSON, XML, RSS, HTML, CSS
ThePiachu
Sr. Member
****
Offline Offline

Activity: 442



View Profile WWW
January 10, 2012, 01:25:59 PM
 #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

1HWbVLhxj7bhewhyapMZpyhqWAeAhJd51E
My Bitcoin Calculator:
http://tpbitcalc.appspot.com/
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!