Every time Tor extends a circuit to a new relay, the client and that relay need a fresh shared secret. ntor is the handshake that produces it. It was designed by Goldberg, Stebila and Ustaoglu and replaced the older TAP handshake, which used 1024-bit RSA and Diffie-Hellman and was showing its age.

ntor uses Diffie-Hellman over Curve25519. The client generates a throwaway key pair for each hop and combines it with the relay's long-term "onion key" and identity. The relay proves it holds the onion key, which authenticates it, and both sides derive the same symmetric keys. Since the client's half is ephemeral, the session keys have forward secrecy.

It's fast too, which matters when relays handle thousands of circuit creations. A newer variant called ntor v3 adds the ability to send extra encrypted data inside the handshake, used for things like negotiating circuit features. Most users never need to know any of this, but if you read the Tor spec, "CREATE2 with ntor" is what you'll keep seeing.