1

I want to generate bitcoin priv/pub key manually. I generated random binary numbers by flipping some coins and converted them to hex.

Now,I got a bitcoin private key in hex:d1267088f0defab13969dd34c899d28268119cf9e68f3856d0ee9b581f5a1bca

in WIF:L4EGhR5Fdon96W2zepTAE3CxtayBqiN3v2pBmkB9dxG4r8JaVKf2

how to gerate Public Key using openssl command line in linux?

I tried to use

openssl ec -in priv_key.pem -pubout

but terminal said: unable to load Key, and lots error file uris.

Maby I got something wrong with PEM private key format.

The priv_key.pem ,I converted private key hex to base64 format.

-----BEGIN EC PRIVATE KEY-----
ZDEyNjcwODhmMGRlZmFiMTM5NjlkZDM0Yzg5OWQyODI2ODExOWNmOWU2OGYzODU2
ZDBlZTliNTgxZjVhMWJjYQ==
-----END EC PRIVATE KEY-----
1

1 Answer 1

1

OpenSSL will compute a public key corresponding to a private key, try:

$ openssl ec -in private_key.openssl.pem -text 

There must be correct input provided to OpenSSL. It is not enough to convert private key from hex string to base64 in order for it to be accepted by OpenSSL. There must be eliptic curve parameters included in the .pem file, like shown in the short script:

https://gist.github.com/vkobel/52048e12d8930ef63930949a717ddcbf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.