Bitcoin Forum
September 04, 2024, 07:59:43 PM *
News: Latest Bitcoin Core release: 27.1 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Other / Beginners & Help / Bitcoin algorithms, need help with base58 encoding on: December 08, 2012, 11:42:43 AM
I'm writing some code to learn more about the bitcoin processes. I've got most of everything figured out, but I'm wondering about base58 encoding. https://en.bitcoin.it/wiki/Base58Check_encoding
Let's say I have the following bitcoin address and private key (obviously I won't be using this one for anything important.)

Address: 1JHYG91McMgviqDDLSXq1TsPvZB7LYxV1s
PrivKey: 5JczEN6uCWESxHLyvnLbCWtjBJkTmHCtZBYcQztspvDJctmdKmF

If I use the chart on the base58 page linked above, then I convert each character of the private key into a number from 0 to 57. Do I use 6 bits to represent each number, and the concatenate the result?

If so, then , I end up with something like this:
Code:
000001010001110001100111001011010101000101001011001101010111001011010011111011000001011001000111101011101101011001010001001101010111110011010101000101010001110101001011001101000001001101110011000001000101011111110001011101100111110011010011111101101011000011010001110001110011001101001001001001001101000111

Or in hex,
Code:
28E3396A8A59AB969F60B23D76B289ABE6A8A8EA59A09B9822BF8BB3E69FB5868E399A49268E

Since that doesnt really bear any resemblance to anything else I've encountered, I'm wondering - how exactly do I get a private key from the WIF and vice versa? Is there an easy "for dummies" link somewhere around from which I can get the rundown?

What I'd like to do ultimately is have a function that I can enter an arbitrary 256 bit number and then be able to transform it into the WIF, and take a WIF value and convert it back into the 256 bit number.

My mindset so far essentially goes like the following - Convert each character of the private key into a 6 bit number, concatenate each successive value into a single string.
I'm guessing this is the wrong approach, and would love a little bit of help (yeah, pun intended.)

I have a SHA256 library and everything else that's necessary pretty much ready to go, at this point I'm just stuck on base58. Thanks!
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!