ZEQ · SDKzeqstate.com

Run it on a server

One machine per systemd instance (or per container), one system user per machine, one port per machine. The code is shared and read-only. TLS ends at a terminator in front.

systemd

As root, with the signed release in /opt/zeq:

install -d -m 755 /opt/zeq && cp -r zeq.py manifest.json plugins spectrum /opt/zeq/
python3 /opt/zeq/zeq.py > /opt/zeq/proved.txt          # proved once as root: the boot record beside the file is the one production trusts
useradd --system --home-dir /srv/zeq/ana --shell /usr/sbin/nologin zeq-ana
install -d -o zeq-ana -m 700 /srv/zeq/ana
install -d -m 711 /etc/zeq
install -o zeq-ana -g zeq-ana -m 600 /dev/null /etc/zeq/ana.pin   # then write the PIN into it
printf 'ZEQ_ISSUER_ZID=ZEQ7...\nZEQ_PORT=8801\nZEQ_TRUSTED_PROXIES=127.0.0.1\nZEQ_PUBLIC_HOST=example.org\n' > /etc/zeq/ana.env
cp deploy/zeq@.service /etc/systemd/system/ && systemctl daemon-reload
systemctl enable --now zeq@ana

The terminator (nginx)

server {
    listen 443 ssl;
    server_name example.org;
    ssl_certificate     /etc/letsencrypt/live/example.org/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem;
    client_max_body_size 2m;

    location / {
        proxy_pass http://127.0.0.1:8801;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_buffering off;              # /pulse streams one event per Zeqond
        proxy_read_timeout 1h;
    }
}

Two settings are required behind a terminator:

Working with it

cat /srv/zeq/ana/machine.owner.key                                          # the owner's key
cd /srv/zeq/ana && sudo -u zeq-ana -H env ZEQ_PIN_FILE=/etc/zeq/ana.pin \
     python3 /opt/zeq/zeq.py --key issue laptop read 30                     # a key for one holder
journalctl -u zeq@ana

Health, metrics, logs

RouteAccessWhat it gives
GET /healthpublic{"status": "ok", "version": "…", "api": 1}; use GET (the machine does not answer HEAD)
GET /metricsread keyPrometheus text: requests by route and status, uptime, log rows, live keys

ZEQ_ACCESS_LOG=json writes one JSON line per request to stderr. A key is named by its holder or its first characters, never in full.

Backups and upgrades

Settings

SettingWhat it does
ZEQ_ISSUER_ZIDthe publisher's ZID, pinned
ZEQ_PORT, ZEQ_BINDthe port, and the address plain HTTP listens on (127.0.0.1 by default)
ZEQ_PUBLIC_HOST, ZEQ_TRUSTED_PROXIESthe site's name, and the terminators whose X-Forwarded-For is read
ZEQ_ORIGINSbrowser origins allowed to call the API
ZEQ_RATE_LIMITrequests per 60 s per address (default 120)
ZEQ_WEBHOOKan address each sealed answer is posted to, signed
ZEQ_NAME, ZEQ_ANCHORa name stated at birth, and the foundation ZID the machine anchors to at birth
ZEQ_MODULESthe modules to plug in (all by default)
ZEQ_PRODUCTION1: refuse to boot unless every file is exactly the publisher's