Title: base58 for private key Post by: redPanda on March 17, 2015, 06:23:55 PM I would like to generate a WIF private key from a random 256 bit private key.
I use the private key given in "mastering Bitcoin" : http://chimera.labs.oreilly.com/books/1234000001802/ch04.html#_implementing_keys_and_addresses_in_python Example 4-4. Code: print "Private Key (hex) is: ", private_key Code: Private Key (hex) is: 3aba4162c7251c891207b747840551a71939b0de081f85c4e44cf7c13e41daa6 Code: #include <iostream> Code: while(x > 0) Code: privKeyHexa: 3aba4162c7251c891207b747840551a71939b0de081f85c4e44cf7c13e41daa6 Questions: according to: mastering Bitcoin Table 4-1. I have to add a version prefix of 0x80, but where ? I have the same bigNumber than Example 4-4. if I add 0x80 to privKeyHexa : 803aba4162c7251c89.... I have a different big number and a wrong result: f6Lnp6NkNmwag.... So where do I add this prefix ? And do I have to do a checksum somewhere ? Title: Re: base58 for private key Post by: redPanda on March 17, 2015, 07:34:09 PM I found this tuto : https://en.bitcoin.it/wiki/Wallet_import_format
All the steps are well explained. I checked my code and my functions are right except the output of the SHA256. So my question is now: Are there different implementations of SHA256 ? (see https://bitcointalk.org/index.php?topic=994088.0) Title: Re: base58 for private key Post by: cr1776 on March 18, 2015, 12:12:32 AM I found this tuto : https://en.bitcoin.it/wiki/Wallet_import_format All the steps are well explained. I checked my code and my functions are right except the output of the SHA256. So my question is now: Are there different implementations of SHA256 ? (see https://bitcointalk.org/index.php?topic=994088.0) I answered you in the other thread, but the values you have for the SHA-256, are hashing the string (ASCII representation of the hex number) instead of the hex number itself. Like hashing the number 120 vs the ASCII representation of "120", you'll get much different values. If you do the hash on the number instead of the ASCII string, I suspect that things may fall into place quite quickly. ;-) Does that help? Title: Re: base58 for private key Post by: redPanda on March 18, 2015, 03:38:26 PM Yes, perfect
Thanks |