Create EC Public Key File

This section provides a tutorial example on how to extract the public key out of an EC private key file with the 'openssl ec -pubout' command.

As you can see from previous tutorials, the EC public key is stored together with the private key in a private key file.

But you need to extract the public key out into a separate file, so that you send it to others publicly. Here is how you can do it with the "openssl ec -pubout" command:

C:\herong> openssl ecparam -genkey -name secp256k1 \
   -out ec_key.pem -param_enc explicit

C:\herong> openssl ec -in ec_key.pem -pubout -out ec_key_public.pem
read EC key
writing EC key

C:\herong> type ec_key_public.pem
-----BEGIN PUBLIC KEY-----
MIH1MIGuBgcqhkjOPQIBMIGiAgEBMCwGByqGSM49AQECIQD/////////////////
///////////////////+///8LzAGBAEABAEHBEEEeb5mfvncu6xVoGKVzocLBwKb
/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIh
AP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABPt7sLuj+VfF
9LXLE072LbdLPVULdneOe+oLW1bVNA01gQd5vb4PTpkNVm0L+AIO09D9m7lUQ0ch
qwCa1sMd5Go=
-----END PUBLIC KEY-----

Last update: 2019.

Table of Contents

 About This Book

 Geometric Introduction to Elliptic Curves

 Algebraic Introduction to Elliptic Curves

 Abelian Group and Elliptic Curves

 Discrete Logarithm Problem (DLP)

 Finite Fields

 Generators and Cyclic Subgroups

 Reduced Elliptic Curve Groups

 Elliptic Curve Subgroups

 tinyec - Python Library for ECC

EC (Elliptic Curve) Key Pair

 EC Private and Public Key Pair

 Is EC Private Key Secure

 EC Private Key Example - secp256k1

 Generate secp256k1 Keys with OpenSSL

 EC Key in PEM File Format

 EC Key File with Curve Name

Create EC Public Key File

 ECDH (Elliptic Curve Diffie-Hellman) Key Exchange

 ECDSA (Elliptic Curve Digital Signature Algorithm)

 ECES (Elliptic Curve Encryption Scheme)

 Terminology

 References

 Full Version in PDF/EPUB