Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: RentGPU on August 26, 2017, 09:15:19 PM



Title: Private key calculations
Post by: RentGPU on August 26, 2017, 09:15:19 PM
Say i don't want to generate a random private key , but i want to convert a number to be my private key , so i tried to do the steps but it seems the sha256 online calculators are not working in the same way, the steps 1-add0x80 byte 2-sha256(step1) 3-sha255(step2) 4-first 4bytes 5-add first 4 bytes to step1(checksum).....the problem here is i use the sha256 online calculators to convert the first step but the result is not anything like it should be , if you know any online calculators i can use plz tell me , thx


Title: Re: Private key calculations
Post by: achow101 on August 26, 2017, 10:18:38 PM
Are you hashing the number as a string? Is it in decimal or hex?

You must be hashing your number as bytes. Otherwise it will not be correct as you would be hashing a string.


Title: Re: Private key calculations
Post by: slavikus on August 27, 2017, 11:08:32 AM
You can also play around and verify your results with http://gobittest.appspot.com/Address


Title: Re: Private key calculations
Post by: Coding Enthusiast on August 27, 2017, 01:12:50 PM
Here you go:
Step2 SHA256: http://www.fileformat.info/tool/hash.htm?hex=800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D
Step3 SHA256: http://www.fileformat.info/tool/hash.htm?hex=8147786c4d15106333bf278d71dadaf1079ef2d2440a4dde37d747ded5403592

Those online tools like this one http://passwordsgenerator.net/sha256-hash-generator/ you use are treating your Hex as a string.

P.S. Example was taken from wiki (https://en.bitcoin.it/wiki/Wallet_import_format), and I hate the person who added _SAMPLE_PRIVATE_KEY_DO_NOT_IMPORT_ to the copied result  >:( Be careful to remove it when you are trying to test and copy things or it will cause you a lot of headache since you may not know why the result is wrong with first look.


Title: Re: Private key calculations
Post by: pebwindkraft on August 29, 2017, 07:24:49 AM
besides the ones already mentioned, I used these links to play with keys and addresses:

https://www.bitaddress.org/
http://lenschulwitz.com/base58
http://ciyam.org/rawtx_helper.html