liveBook · Manning

Diffie–Hellman key exchange

As explained in Elliptic Curve Cryptography for Developers

A public-key key-agreement protocol that lets parties establish a shared secret over an insecure network using private values and exchanged public values.

Diffie–Hellman key exchange lets two parties derive the same secret without transmitting it directly. In elliptic-curve use, each party combines a private scalar with the other party’s public point; both obtain the same shared point and use its x value as a symmetric-encryption key. section 4.0 section 4.5

The elliptic-curve exchange proceeds as follows:

  • Choose a curve, finite-field parameters, and a base point. section 4.3
  • Create each private key as a large integer; a hash of a pass phrase can generate one without storing the phrase. section 4.0 section 4.5
  • Derive and exchange public points. section 4.1
  • Multiply each private key by the other party’s public point, then use the resulting point’s x value as the shared secret. section 4.1 section 4.5
Figure 4.1 Creating a shared secret key by exchanging public keys
figure

Use the diagram to trace the two public-key transmissions and the converging calculations that produce one shared secret. section 4.1

Testing both sides

A test program computes myshare from one private key and the other public key, then computes theirshare using the reverse pairing. Comparing the two multiprecision results should print “Keys match.” The test verifies the mathematics but does not transmit keys over a network. section 4.3.2

How Elliptic Curve Cryptography for Developers covers it

How deep it goes
Explains the exchange flow and test implementation, but defers detailed curve and prime selection.
Examples
Demonstrates reciprocal multiprecision calculations with pass-phrase and random private-key inputs, producing matching hexadecimal shares.
What it assumes
Assumes elliptic-curve mathematics routines for point addition and multiplication, while introducing their cryptographic use.
What you can do after
Build a testable elliptic-curve exchange and verify that both parties compute identical shared key material.
How it connects
Connects elliptic-curve point multiplication, public-key cryptography, symmetric encryption, AES, hashing, and MQV.

Also explained in

Compare how 4 books explain Diffie–Hellman key exchange →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elliptic Curve Cryptography for Developers. The section links point to the parts of the book it draws on.