Chapter 3 Cryptography 77
Cryptography Overview
6. Compute an authentication tag, tag = SHA1 (x1 || M). That is, tag is the SHA1
hash of concatenation of the x-coordinate of the secret point k1Q and the message
M. Since tag is an SHA1 hash, tag is 20 bytes long.
7. Transmit the ciphertext c=(Q1,M,tag). The total length of c in bytes is: 21+2 ·(the
length of a field element in bytes) + f.

Decrypting a Message Using the Private Key

A message that had been encrypted in the previous example can be decrypted using
the private key as follows:
1. Parse the received ciphertext c=(Q1,M,tag) into its components, Q1, M, and tag.
2. Use the private key k2 to compute the elliptic curve point S2=k2Q1. S2 is a pair
(x2,y2). If the message was transmitted correctly and encoded with the correct
public key, S2 is equal to S1.
3. To ve ri fy t ha t S2 is equal to S1, compute tag' = SHA1 (x2 || M'). If tag' is different
from tag, output an error and stop.
4. Compute a one time pad, otp, of length f, from x2 using the key derivation
function outlined in Step 4 on page 76. Use x2 instead of x1. Since x1 = x2,
otp=otp.
5. Compute M=otp XOR M.
Elliptic Curve Diffie-Hellman Key Agreement
It is possible to construct a version of the Diffie-Hellman key agreement that uses
elliptic curves. (For more information on Diffie-Hellman key agreement, see Diffie-
Hellman Public Key Agreement on page 62.) Like Diffie-Hellman, EC Diffie-
Hellman provides for key agreement, but not encryption or authentication.
The elliptic curve Diffie-Hellman key agreement algorithm provides a method for two
parties to each compute the same secret key without exchanging secret information.
The algorithm is made up of two parts: Phase 1 and Phase 2. Before they begin, the
two parties must agree on the elliptic curve parameters: a base field, an elliptic curve
over the base field, and point P of prime order, along with its order n. See the section
Elliptic Curve Parameters on page 66 for details. See Figure 3-13 on page 79 for an
illustration of Elliptic Curve Diffie-Hellman key agreement.