Elliptic Curve Keys

Poby’s Home
1 min readDec 5, 2020

How to create elliptic curve parameters and private/public keys using OpenSSL

check openssl version

$ openssl version
OpenSSL 1.1.1b 26 Feb 2019

Generate EC parameters

$ openssl ecparam -name secp256k1 -out secp256k1.pem

Examine the EC parameters
- OpenSSL will only store the name of the curve in the generated parameters

$ openssl ecparam -in secp256k1.pem -text -noout
ASN1 OID: secp256k1

Examine details
- Examine the specific details of the parameters associated with a particular curve

$ openssl ecparam -in secp256k1.pem -text -param_enc explicit -noout
Field Type: prime-field
Prime:
00:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:
ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:fe:ff:
ff:fc:2f
A: 0
B: 7 (0x7)
Generator (uncompressed):
04:79:be:66:7e:f9:dc:bb:ac:55:a0:62:95:ce:87:
0b:07:02:9b:fc:db:2d:ce:28:d9:59:f2:81:5b:16:
f8:17:98:48:3a:da:77:26:a3:c4:65:5d:a4:fb:fc:
0e:11:08:a8:fd:17:b4:48:a6:85:54:19:9c:47:d0:
8f:fb:10:d4:b8
Order:
00:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:
ff:fe:ba:ae:dc:e6:af:48:a0:3b:bf:d2:5e:8c:d0:
36:41:41
Cofactor: 1 (0x1)

Generate a private key and public key pair from EC parameter

openssl ecparam -in secp256k1.pem -genkey -noout -out secp256k1-key.pem

Examine a generated private key / public key pair

$ openssl ec -in secp256k1-key.pem -text -noout
read EC key
Private-Key: (256 bit)
priv:
59:a8:90:72:25:50:68:42:48:a6:97:99:9a:88:6c:
64:14:15:94:b0:ad:d9:c3:f1:dd:30:8b:09:da:63:
0e:77
pub:
04:93:9d:52:94:21:fd:ce:73:4a:4f:0c:0b:6e:a2:
24:30:76:45:53:eb:ae:d8:7d:7d:e4:91:4e:7f:06:
0b:54:ce:e8:06:88:63:ab:ae:24:3a:fe:20:38:79:
59:89:ec:c7:79:60:43:68:0d:51:c9:50:84:48:9c:
5c:bc:af:ba:11
ASN1 OID: secp256k1

--

--