Goals
Create a random private key(of 64 hexadecimal characters | 256 bits | 32 bytes)
Derive a public key from the above private key(of 128 hexadecimal characters | 512 bits | 64 bytes)
Derive an address from the above derived public key(of 40 hexadecimal characters | 160 bits |20 bytes)
Generate Private Key
openssl ecparam -name secp256k1 -genkey -noout
Example Output
-----BEGIN EC PRIVATE KEY-----
MHQCAQEEIOV/tf2mBMYtygiqAoMLk1weZj2uXmGCagGxALeZnHQWoAcGBSuBBAAK
oUQDQgAEBKrAcZsycPPgJf+uzTF+/xZ35v8og4+P7fvHJ81jCXpNyfyfrg8e1goN
Yamwfd8MEgS3u/qJOSSEsoc+saTDVg==
-----END EC PRIVATE KEY-----
Generate a random Private Key & Derive a Public Key
openssl ecparam -name secp256k1 -genkey -noout | openssl ec -text -noout > Key
Display Key File
cat Key
Example Output
Private-Key: (256 bit)
priv:
00:a8:a6:02:44:37:16:3f:1b:20:1d:61:8c:45:5c:
33:88:09:97:0c:38:59:19:c9:82:1c:10:9d:30:36:
29:e8:53
pub:
04:17:2d:96:31:e3:18:46:9a:80:6c:7f:b5:a3:d1:
27:d8:3f:ac:ca:f9:f5:18:69:65:c7:82:dc:b0:4b:
51:1e:56:7a:67:f9:33:4a:a3:72:fc:3b:55:78:d2:
2d:1a:3f:30:5b:bd:38:69:66:14:41:16:8d:b7:12:
34:19:2c:4f:88
ASN1 OID: secp256k1
Extract the Private Key, remove leading zero, and save to a file 'priv'
cat Key | grep priv -A 3 | tail -n +2 | tr -d '\n[:space:]:' | sed 's/^00//' > priv
cat priv
Example Output
3-00a8a6024437163f1b201d618c455c4-338809970c385919c9821c109d30365-29e853
Extract the Public Key, remove EC prefix 0x04, and save to a file 'pub'
cat Key | grep pub -A 5 | tail -n +2 |tr -d '\n[:space:]:' | sed 's/^04//' > pub
Example Output
7-04172d9631e318469a806c7fb5a3d18-27d83faccaf9f5186965c782dcb04b9-
511e567a67f9334aa372fc3b5578d210-2d1a3f305bbd3869661441168db71211-34192c4f88
Generate the hash, and save to a file 'address'
cat pub | keccak-256sum -x -l | tr -d ' -' | tail -c 41 > address
cat address
Example Output
a95fdeec5607856dd71b3c466af62a6e895a8a6aa
Key Outputs
1. 3-00a8a6024437163f1b201d618c455c4-338809970c385919c9821c109d30365-29e853
2. 7-04172d9631e318469a806c7fb5a3d18-27d83faccaf9f5186965c782dcb04b9-
511e567a67f9334aa372fc3b5578d210-2d1a3f305bbd3869661441168db71211-34192c4f88
3. a95fdeec5607856dd71b3c466af62a6e895a8a6aa