What you need
- Node.js 20 or newer. Check with
node -v. - A terminal and about two minutes.
- Nothing else.
secant.mjshas no dependencies and uses the WebCrypto built into Node and every modern browser.
Get the files
The library and the two small programs around it are served from this site. Save the library as secant.mjs so Node reads it as a module.
mkdir secant && cd secant
curl -o secant.mjs {{ORIGIN}}/lib/secant.js
curl -o node.mjs {{ORIGIN}}/lib/node.mjs
curl -o send.mjs {{ORIGIN}}/lib/send.mjsmkdir secant; cd secant
iwr {{ORIGIN}}/lib/secant.js -OutFile secant.mjs
iwr {{ORIGIN}}/lib/node.mjs -OutFile node.mjs
iwr {{ORIGIN}}/lib/send.mjs -OutFile send.mjsStart three nodes
Open three terminals, or put the first two in the background. Each node makes its own key pair the first time it starts and keeps it in ~/.secant.
node node.mjs --port 9101 &
node node.mjs --port 9102 &
node node.mjs --port 9103Each one prints a node.identity line with its id, then node.ready.
Send a request
Give send.mjs the line of nodes and an address. It fetches each node’s public key, seals three layers and hands the cell to the first node.
node send.mjs --via http://localhost:9101,http://localhost:9102,http://localhost:9103 https://example.comOn stderr you get the route and the size of the cell. On stdout you get the page. In the node logs you can watch the cell shrink at every hop as one layer comes off:
{"ev":"cell.relay","in":631,"out":371,"to":"http://localhost:9102"}
{"ev":"cell.relay","in":371,"out":177,"to":"http://localhost:9103"}
{"ev":"cell.exit","in":177,"host":"example.com","status":200,"out":577}Or try it in the browser
The same library runs on a page. The secant.js page has live blocks that boot 48 nodes in your tab, cut a line across them and show what every hop saw.
import { mesh, boot, route, cross } from "{{ORIGIN}}/lib/secant.js";
const m = await boot(mesh(48));
const path = route(m, { hops: 4 });
const { trace, delivered } = await cross(m, path, "GET https://example.com");
console.table(trace);<script type="module">
import { mesh, boot, route, cross } from "{{ORIGIN}}/lib/secant.js";
const m = await boot(mesh(48));
const r = await cross(m, route(m), "hello from the other side of the circle");
document.body.textContent = r.delivered;
</script>Where next
- Run a node for real, on a machine other people can reach.
- Private routes explains the layers byte by byte.
- Threat model says plainly what this does not protect.