<p>You need:</p>

<p>1) <a href="https://github.com/bitcoin-core/secp256k1/" rel="nofollow noreferrer">libsecp256k1</a> to calculate the public key from a private key</p>

<p>2) Hash the result with Sha2/256 + RipeMD160</p>

<p>3) Add version byte and 4-byte checksum</p>

<p>4) Encode it using Base58. My <a href="https://bitcoin.stackexchange.com/a/76485/38618">minimal code</a> would work.</p>

<p>So, it's not really simple</p>

CC BY-SA 4.0
2018-11-29T11:05:27.723Z
May i ask what the function in libsecp256k1 use to create pubkey from pivkey called? the base58 code worked well though
Huang Lee
CC BY-SA 4.0
2018-11-29T13:17:17.530Z
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
CC BY-SA 4.0
2018-11-28T14:54:35.173Z
2018-11-28T14:54:35.173Z
MCCCS
<p>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 <a href="https://github.com/libbitcoin/libbitcoin/wiki/Examples-from-Addresses-and-HD-Wallets?fbclid=IwAR3WDz1klDlklh_6OzDISgLtM4t5b4gJm2gPys4lq-4vqGZMWC3f9EPDpek" rel="nofollow noreferrer">this</a> 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</p>

CC BY-SA 4.0
2018-11-28T15:06:47.840Z
be careful: https://bitcoin.stackexchange.com/questions/8449/how-safe-is-a-brain-wallet?noredirect=1&lq=1
JBaczuk
CC BY-SA 4.0
2018-11-29T11:10:22.810Z
@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
CC BY-SA 4.0
2018-11-29T12:05:03.780Z
@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
<cryptography><c++>
Looking for code generate bitcoin address from passphase in C++
Huang Lee
# Looking for code generate bitcoin address from passphase in C++

(Asked by: username_0 on 2018-11-28)

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](https://github.com/libbitcoin/libbitcoin/wiki/Examples-from-Addresses-and-HD-Wallets?fbclid=IwAR3WDz1klDlklh_6OzDISgLtM4t5b4gJm2gPys4lq-4vqGZMWC3f9EPDpek) 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

**Tags:** cryptography, c++

> **Comments:**
> **username_1**: be careful: https://bitcoin.stackexchange.com/questions/8449/how-safe-is-a-brain-wallet?noredirect=1&lq=1  
> **username_0**: @username_1 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  
> **username_2**: @username_0 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.  

---

## 1 answers

### Answer by username_3 on 2018-11-28. Score: 1 | Accepted answer

You need:

1) [libsecp256k1](https://github.com/bitcoin-core/secp256k1/) 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](https://bitcoin.stackexchange.com/a/76485/38618) would work.

So, it's not really simple

> **Comments:**
> **username_0**: May i ask what the function in libsecp256k1 use to create pubkey from pivkey called? the base58 code worked well though  
> **username_3**: 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 @username_0  

---

