As I was looking over Tor specifications and I noticed that when a circuit is generated then on each circuit's node a Diffie-Hellman key exchange is being done over an encrypted path on each Node as the image shows bellow:

In other words:

Diffie-Hellman Key Exchange when circuit is generated

So Let us suppose that Alice Cooper wants to visit a website through the Tor Network:

Alice Cooper Visits google via Tor

Would the N1 perform a Diffie-Hellman Key exchange with N3?

1 Answer 1


No, the key exchange is done between the client and each relay. This is the general technique behind onion routing. For the modern Tor protocol, the client will exchange a symmetric key (AES128) with three relays using ECDHE (not DHE), specifically using Curve25519. A message being sent from the client will be encrypted three times with each key, and each relay will strip a single layer of encryption. Once the message reaches the exit relay, there is only one layer left, the layer encrypted with the key known by the exit. The exit decrypts it and sends it on its way.

Note that each link between nodes is additionally encrypted using TLS.

onion routing

Also note that your diagram is incorrect. The SOCKS protocol is not used to connect to the first relay (the guard), but rather to allow a local program on your computer to connect to your Tor client (usually over localhost). The protocol used to connect to the first relay is the Tor protocol itself.

  • It helps to remember that TOR is an acronym for “The Onion Router”. The client wraps the payload in layers of encryption (like an onion), and then each node on the route gets to unwrap one layer.
    – nbering
    Apr 3, 2018 at 4:35
  • @nbering That's a backronym, meaning it is not really an acronym and never was, it's just a fun coincidence that it spells out the same thing. It's also Tor, not TOR.
    – forest
    Apr 3, 2018 at 4:37
  • Oh... good to know. I did a project on Tor in 2001 for school, and all the sources seemed to imply it was intentional, but reliable sources were harder to come by back then.
    – nbering
    Apr 3, 2018 at 4:55
  • Well the original source of course is the first paper: Tor: The Second-Generation Onion Router.
    – forest
    Apr 3, 2018 at 4:57
  • @nbering Wait, how did you do a project on it in 2001, if the original paper was from 2004?
    – forest
    Apr 3, 2018 at 5:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .