I want to know because I would like to generate a vanity address at Vanity Pool.
Install OpenSSL. When the executable in your path, enter this command to generate a private key:
openssl ecparam -genkey -name secp256k1 -noout -out myprivatekey.pem
To create the corresponding public key, do this:
openssl ec -in myprivatekey.pem -pubout -out mypubkey.pem
This will give you both keys in PEM format. I'm not sure what format the web page wants, but it shouldn't be difficult to convert. You can use variants of the last command to output other formats. Remove
-pubout if you want the private key, leave it if you want the public key. And you can use
-outform DER to get DER format. You can use
-text to get hexadecimal.
Do not give any form of your private key to anyone else.
To generate an Elliptic Curve private key in PEM format using the
secp256k1 curve (which is the one used in Bitcoin):
openssl ecparam -genkey -name secp256k1 -out tmp/data.pem
To convert the private key from PEM (human-readable and extended) to a hex format:
openssl ec -in tmp/data.pem -outform DER|tail -c +8|head -c 32|xxd -p -c 32
To retrieve the public key in a hex format:
openssl ec -in tmp/data.pem -pubout -outform DER|tail -c 65|xxd -p -c 65
Explanation of the piped commands above
openssl ec -in tmp/data.pem -outform DER
Converts the private key from PEM to DER (binary) format.
tail -c +8
Skips the first (due to "+") 8 bytes (due to "c"), which should be the header of the DER format.
head -c 32
Returns the first 32 bytes which is the private key length.
xxd -p -c 32
Does a hex dump on the binary format of the key.
-pis for having the output in plain hexdump style
-c 32is for having the 32 characters in one line, default is 16.