Elliptic Curve Public Key Formats

Denys Popov
2 min readJun 9, 2021

Understanding what is the difference

Let's first define what Elliptic Curve is.

Elliptic Curve is one of the main public-key cryptography cryptosystem approaches where finite field is a set of points on this curve.
The general function of the elliptic curve is: y² = x³ + ax + b

secp256k1 — it's one of the specific elliptic curves, which become a standard and widely using.
Its: y² mod p= (x³ + 7) mod p
e.g. it's using at bitcoin, ethereum, and number of did methods at SSI

Public as well as Private keys at this system — it's just points/dots at this curve. So in other words public key here is just a presentation of the X and Y coordinates of the point, so any public key format just contains this data.

JWK (JSON Web Key) format — it’s a presentation that building on separate X and Y values.

Hex format —it's just a combination of it x and y, and also there is a prefix there that determines if that key uncompressed or compressed.
prefix = 04 when it's uncompressed and 02 or 03 when it's compressed
So public key in a general way at hex format looks like: <prefix><x><y>

Uncompressed Hex format: 04<x><y>
Compressed Hex format: 02<x> or 03<x> Compressed format using mostly to reduce the size of data (transaction, etc). Since the function of a given elliptic curve is known you always can calculate a Y for a given X.
Since the elliptic curve is x-axis symmetric — this means that will be always 2 variants of points for defined X, so that's why for compressed version of publicKey present 2 versions of a prefix, which represent if that y value positive or negative (prefix 02 if the y is even, and 03 if it is odd).

--

--