i'm try to write a program which generate bitcoin address from given hash sha256 of passphase as private key or given hex private key. I've found a library for this but it required Boost package in visual studio which took nearly 6GB,totally unnessary for a program like this. Is there any available library to convert hex private key straight into address? No need to make wif private key, though
Asked
Active
Viewed 3,961 times
0
-
be careful: https://bitcoin.stackexchange.com/questions/8449/how-safe-is-a-brain-wallet?noredirect=1&lq=1 – JBaczuk Nov 28 '18 at 15:06
-
@JBaczuk you can generate your own hex private key though, it doesn't have to be passphase, i don't like default EC random private key generator – Huang Lee Nov 29 '18 at 11:10
-
@HuangLee generating your own entropy is exactly the point at which most humans will fail miserably, and in bitcoin-land that means your bitcoins get stolen. Be very sure you completely understand the dangers of brain wallets, or else you will find yourself with an empty wallet. – chytrik Nov 29 '18 at 12:05
1 Answers
1
You need:
1) libsecp256k1 to calculate the public key from a private key
2) Hash the result with Sha2/256 + RipeMD160
3) Add version byte and 4-byte checksum
4) Encode it using Base58. My minimal code would work.
So, it's not really simple

MCCCS
- 10,206
- 5
- 27
- 56
-
May i ask what the function in libsecp256k1 use to create pubkey from pivkey called? the base58 code worked well though – Huang Lee Nov 29 '18 at 11:05
-
https://github.com/bitcoin-core/secp256k1/blob/ed7c084/include/secp256k1.h#L518 : In order: secp256k1_ec_seckey_verify, secp256k1_ec_pubkey_create and secp256k1_ec_pubkey_serialize but first you should use secp256k1_context_create and secp256k1_context_randomize Let me know if something's unclear @HuangLee – MCCCS Nov 29 '18 at 13:17