# EC Private and Public Key Pair

### Get familiar with elliptic curve private and public key pairs.

Join the DZone community and get the full member experience.

Join For FreeAn EC (Elliptic Curve) key-pair is a pair of a private and public key constructed from a given subgroup generator in a given elliptic curve group.

Here are the steps to generate an EC private and public key pair:

1. Alice selects an elliptic curve subgroup defined by a set of domain parameters, (p,a,b,G,n,h):

```
p: The modulo used to specify the reduced elliptic curve group.
a: The first coefficient of the elliptic curve.
b: The second coefficient of the elliptic curve.
G: The generator (base point) of the subgroup.
n: The order of the subgroup.
h: The cofactor of the subgroup.
```

2. Alice selects a private number, d, and puts it together with domain parameters as the private key:

`Private key = {d, p, a, b, G, n, h} `

3. Alice performs the scalar multiplication of Q = d*G and puts it together with domain parameters as the public key:

`Private key = {Q, p, a, b, G, n, h} `

Actually, the order of the subgroup, n, and the cofactor of the subgroup, h, are not really important because they can be derived from the generator, G.

Also, if the subgroup (or domain parameters) is publicly known to everyone, we can simply refer to d as the private key and Q as the public key.

For example, if Alice decides to use the subgroup generated by G = (15, 13) in the elliptic curve group of E_{17}(0, 7). The domain parameters will be:

`{p, a, b, G, n, h} = {17, 0, 7, (15,3), 17, 1}`

If Alice selects d = 11 as the private number, her private key will be:

`{d, p, a, b, G, n, h} = {11, 17, 0, 7, (15,3), 17, 1}`

Alice then calculates Q = d*G = 11*(15, 3) = (10, 2). Her key public key will be:

`{Q, p, a, b, G, n, h} = {(10,2), 17, 0, 7, (15,3), 17, 1}`

Opinions expressed by DZone contributors are their own.

Comments