Docs / Start

Quick start

Download two files, start three nodes on your own machine and send a real request through all of them. Node 20 or newer, nothing to install.

$SECANTsoonChartBuy $SECANT

What you need

  • Node.js 20 or newer. Check with node -v.
  • A terminal and about two minutes.
  • Nothing else. secant.mjs has 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.mjs

Start 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 9103

Each 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.com

On 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}
NOTEOn one machine all three nodes are you, so nothing is hidden yet. The point is to see the layers work. Spread the nodes across machines you do not control together and the line starts to mean something.

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);

Where next