The line
When you send something, the client picks four linked nodes that sit close to one straight line across the network: an entry, two relays and an exit. The entry is where your line cuts into the circle, the exit is where it cuts out.
| Hop | Knows who sent it | Knows where it goes | Sees the content |
|---|---|---|---|
| Entry | Yes, you | Only relay 1 | No |
| Relay 1 | Only the entry | Only relay 2 | No |
| Relay 2 | Only relay 1 | Only the exit | No |
| Exit | Only relay 2 | Yes, the site | Yes, the request |
Layers
The client wraps the request once per hop, starting from the exit and working back to the entry. Each layer is made with a fresh one-time key, so two cells to the same node look nothing alike.
- Make a one-time P-256 key pair.
- ECDH with the hop’s public key gives 32 shared bytes.
- HKDF-SHA-256 with the one-time public key as salt and
secant/layer/v1as info gives an AES-256-GCM key. - Encrypt
{ next, body }, wherebodyis the cell for the next hop. - Prepend the one-time public key and the IV.
| Bytes | Field |
|---|---|
| 0–64 | One-time public key, uncompressed P-256 (65 bytes) |
| 65–76 | AES-GCM IV (12 bytes) |
| 77… | Ciphertext and 16-byte tag |
Peeling
A node does the same steps with its own private key. If the tag does not check out, the layer was not made for it and the cell is dropped. Every hop strips 77 bytes of header and 16 bytes of tag plus the base64 overhead of the inner cell, which is why the cell shrinks on the way.
import { peel } from "./secant.mjs";
const { next, body } = await peel(me, cell);
// next: the address of the next hop, or "web" if you are the exit
// body: the cell for the next hop, or the request itselfWhy a straight line
Picking linked nodes that lie along one line, instead of any four nodes, keeps the route short in real distance and makes the entry and exit far apart. A line that bends back on itself tends to put entry and exit in the same neighbourhood, which is exactly what a watcher wants.
route() tries 400 random walks and keeps the straightest one that is long enough.Replies
In version 0.3 the reply travels back along the same line, hop by hop, as plain bytes over each connection. Use https so the reply is encrypted between the site and you. Layered replies are planned for 0.4.