Pages:
Author

Topic: Need Help Understanding Base58Check Encoding... - page 2. (Read 1366 times)

staff
Activity: 3374
Merit: 6530
Just writing some code
Sorry, I don't understand what you mean by hex bytes...

I have had no formal coding instruction, I am entirely self-taught so I apologize if I am misunderstanding something very basic.

I tried to look up what you mean using Google but could not seem to find anything relevant.

How would I go about convert my hex string to hex bytes...?
So what you have is a hex string which is different from hex bytes. Hex bytes are the human readable form of binary. If you were to convert a set of hex bytes to binary, you would get the 1's and 0's that a computer reads. On the other hand, if you have a string, you have something completely different. At the binary level, each character in the string is a set of bytes, and when you hash the string, you are hashing those bytes, and not the bytes that you actually want which you read in the string.

To hash the bytes, you can use this site: http://www.fileformat.info/tool/hash.htm. Enter the hex string into "Binary Hash" field and it will give you the hashes down below. When you hash again, make sure you do the same thing and hash the bytes.
member
Activity: 82
Merit: 10
Sorry, I don't understand what you mean by hex bytes...

I have had no formal coding instruction, I am entirely self-taught so I apologize if I am misunderstanding something very basic.

I tried to look up what you mean using Google but could not seem to find anything relevant.

How would I go about convert my hex string to hex bytes...?
staff
Activity: 3374
Merit: 6530
Just writing some code
I found your problem. You are hashing as a string, not as bytes. You need to always hash the hex as hex bytes.
member
Activity: 82
Merit: 10
To convert the last string (step 5) to base58, you just do a normal base conversion. Take the string and think of it as a massive number in base 16. Then you just need to do the standard procedure for converting between bases and convert it to base58. There is a variety of software that will do this because doing it by hand is a major pain. This should help you: https://en.bitcoin.it/wiki/Base58Check_encoding#Base58_symbol_chart

That doesn't seem right... If I take the last string from step 5 and do a normal base conversion from base16 to base58 I get:
Code:
4HJYHtf8hkGGruED9DOGJVsF6StV9Qjc7Va98cfB5hUKdgsIij8

I'm supposed to be getting
Code:
5JLbJxi9koHHvyFEAERHLYwG7VxYATnf8YdA9fiC6kXMghkYXpk
staff
Activity: 3374
Merit: 6530
Just writing some code
To convert the last string (step 5) to base58, you just do a normal base conversion. Take the string and think of it as a massive number in base 16. Then you just need to do the standard procedure for converting between bases and convert it to base58. There is a variety of software that will do this because doing it by hand is a major pain. This should help you: https://en.bitcoin.it/wiki/Base58Check_encoding#Base58_symbol_chart
member
Activity: 82
Merit: 10
For fun, I am attempting to generate bitcoin WIF PrivKeys from random binary strings. I have everything figured out except the final step of converting to WIF using base58check encoding.

Here is where I am at:
Step 1) Generated random binary string
Code:
0100 0100 1101 0000 0000 1111 0110 1110 1011 0010 1110 0101 0100 1001 0001 1100
1101 0111 1010 1011 0111 1110 0111 0001 1000 0101 1101 1000 0001 1011 0110 0111
1010 0010 0011 1100 0100 1001 1000 0000 1111 0110 0010 1011 0010 1110 1101 0000
1001 0001 0100 1101 0011 0010 1011 0111 1110 1011 0001 1100 0101 0101 1000 0001

Step 2) Converted binary string to hex string
Code:
44D00F6EB2E5491CD7AB7E7185D81B67A23C4980F62B2ED0914D32B7EB1C5581

Step 3) Added 0x80 byte to beginning of hexstring
Code:
8044D00F6EB2E5491CD7AB7E7185D81B67A23C4980F62B2ED0914D32B7EB1C5581

Step 4) Hashed new hex string to SHA256 encoded string, took result and hashed to a new SHA256 string
Code:
2897b55427f86f73136d55c1729cb4ce56d72e40e33baf8ca10e9e02cb963434

Step 5) Took first 4 bytes (checksum) and added them to end of hex string from Step 2
Code:
8044D00F6EB2E5491CD7AB7E7185D81B67A23C4980F62B2ED0914D32B7EB1C55812897b554


And this is where I am lost... No matter what information I look up online I can not seem to figure out how to turn the last string into a base58check encoded string to complete the process of turning it into a WIF PrivKey.

Thanks to "TP's Go Bitcoin Tests", I know that the end result should be
Code:
5JLbJxi9koHHvyFEAERHLYwG7VxYATnf8YdA9fiC6kXMghkYXpk

But I have no idea nor can I seem to find a clear, coherent explanation of the base58check process that changed my modified hex string to a WIF PrivKey...

To be clear, I want to actually learn how the process works, so please do not just point me at a tool online and say "Just do it here, it is much easier".

Thank you in advance to anyone who can help explain this to me!
Pages:
Jump to: