Run a mirror or a witness#

Grantstamp gets stronger with every mirror and witness that the project does not run. This page says what each one has to do, what it needs, and two ways to run it.

Who holds what Owner signs every stamp with a key only the owner holds stamp Registry puts writes in order in one public log, and signs it Witnesses cosign the log only when it extends what they saw before log head out, cosignature back Mirrors copy the log, the public records and the check map. Any plain web host will do. copy Agent, or you reads from any mirror and checks every byte data proof one, run by the project many, run by anyone A mirror can go silent. It cannot change, hide or add anything without being caught. The registry cannot show two histories. The witnesses would refuse to cosign.

What each one does#

Mirror Witness
The job, every few minutes Copy the public log, the listed stamps and the check map. Check every file. Serve the copy. Fetch the newest log head. Check that it extends the last one you signed. Sign it. Hand it back.
What it protects Availability. Checks keep working when the registry is slow or asleep. Integrity. The registry cannot show two histories.
Holds a secret No. Every file is public. Yes. A signing key that only you hold.
Trusted for Nothing. Every reader checks the copy. Not agreeing with the registry to sign a fork.

Run one or the other, not both from the same account. A witness that is also a host could hide its own host's misbehaviour.

What it needs#

Mirror Witness
Reachable from the internet Yes. Agents fetch its files. No. It only makes outgoing calls.
Runs on time Every 10 minutes or so. A stale mirror is skipped. Every 5 minutes or so. A check through mirrors refuses a cosignature older than 2 hours.
Disk and network Small. It grows with the log. Tiny.
Must never lose Nothing. It can be rebuilt. Its key and its state file.

Two ways to run one#

On GitHub On your own machine
Where the work runs In a GitHub workflow in your fork In the grantstamp program on your machine
Reachable address for a mirror GitHub Pages gives you one You provide one
Where a witness key lives In GitHub's secret store On your disk
What you keep running Only a timer The program itself
Good for Most people People who want no third party

On GitHub#

A fork runs the version of grantstamp pinned in its requirements.txt, and pip checks every file by hash. So the project cannot change what your fork runs. You take a new version when you choose, with Sync fork.

A mirror#

  1. Fork grantstamp/grantstamp-mirror.
  2. In your fork, open the Actions tab and enable workflows.
  3. Open Settings, then Pages, and set Source to GitHub Actions.
  4. Open Actions, pick grantstamp-mirror, and click Run workflow.
  5. Check your mirror:

    pip install grantstamp
    grantstamp audit --from https://<you>.github.io/grantstamp-mirror
    
  6. Pick a timer.

A witness#

  1. Fork grantstamp/grantstamp-witness.
  2. In your fork, open the Actions tab and enable workflows.
  3. On your own computer, make the key. The name is your fork's address.

    pip install grantstamp
    grantstamp witness keygen github.com/<you>/grantstamp-witness --out witness.key
    

    It prints one line that starts with that name. The line is public. Keep it.

  4. In your fork, open Settings, then Secrets and variables, then Actions. Add a secret named GRANTSTAMP_WITNESS_KEY with the contents of witness.key. Then delete the file.

  5. Open Actions, pick grantstamp-witness, and click Run workflow. It should end with "cosigned ... entries".
  6. Pick a timer.

A fork never copies secrets or state. Your witness starts with its own key and an empty history.

A registry on a free plan may rest between ticks, to stay within its plan. Then it is open only for a few minutes after each tick, on the hour and the half hour. grantstamp exits with code 75 when it finds the registry resting, and the workflow takes that as "next time", with a warning. So start your witness on the tick.

Pick a timer#

The workflow runs when something starts it. It does not keep time by itself. Pick one of these.

Timer Setup Stops when
Your machine's cron, set up by grantstamp One command Your machine is off
A hosted timer, such as a Cloudflare Worker About 10 minutes The service is down
GitHub's own scheduler Two lines in the workflow GitHub skips runs, sometimes for hours

All but the last need a GitHub token that can start the workflow and do nothing else.

Make the token. On GitHub, open Settings, then Developer settings, then Personal access tokens, then Fine-grained tokens.

Your machine's cron. This starts the workflow once, then every 5 minutes.

grantstamp trigger <you>/grantstamp-witness --install

It asks for the token once, without showing it, and keeps it in a file only you can read. The token is never written into cron. Use --every 600 for a mirror. Remove the schedule with --uninstall.

No cron on your machine? Leave this running in a terminal instead:

grantstamp trigger <you>/grantstamp-witness --every 300

A hosted timer. The folder integrations/join/timer holds a small Cloudflare Worker that does the same thing, on the hour and the half hour. Put your repositories in wrangler.toml, then:

npx wrangler secret put GITHUB_TOKEN
npx wrangler deploy

Any service that can send one web request on a schedule works as well. The request is in worker.js.

GitHub's own scheduler. In your fork's workflow file, remove the # in front of the two schedule lines. It costs nothing and needs no token. Use it as a backup beside another timer, not alone.

On your own machine#

No GitHub account and no token. You keep the program running, and for a mirror you provide the address.

A witness#

pip install grantstamp
grantstamp witness keygen <your-domain>/witness --out witness.key
grantstamp witness run https://registry.grantstamp.io --key witness.key --log "<the log key>"

A mirror#

pip install grantstamp
grantstamp mirror https://registry.grantstamp.io/log ./mirror --serve 8080

The program updates the folder every 10 minutes and serves it on port 8080.

That is not yet a mirror anyone can use. Agents must be able to reach it. You need all of these:

Already have a web server? Leave out --serve, use --every 600, and point the server at the folder.

Keep it running#

The program stops when you close the terminal or restart the machine. On Linux, a service keeps it up. Save this as ~/.config/systemd/user/grantstamp-witness.service, with your own paths:

[Unit]
Description=Grantstamp witness
After=network-online.target

[Service]
WorkingDirectory=%h/grantstamp-witness
ExecStart=%h/.local/bin/grantstamp witness run https://registry.grantstamp.io --key witness.key --log "<the log key>"
Restart=always
RestartSec=60

[Install]
WantedBy=default.target

Then run:

systemctl --user enable --now grantstamp-witness
loginctl enable-linger $USER

The second line keeps the service running when you are logged out.

Get listed#

Your mirror or witness works as soon as it runs. Agents use it only once the registry lists it.

What a witness promises#

It never cosigns a log that drops or changes anything it cosigned before. It saves its state before any cosignature leaves it, so a failed pass cannot be used to make it sign a different history.

If something looks wrong#

For the registry's operator#

The project follows this page too. Its own witness and mirrors are workflows on GitHub, started by a hosted timer, with GitHub's scheduler as a backup.

When someone sends you a mirror or a witness:

Raise the quorum to "all" only when the witnesses have shown they run on time.

Source of this page on GitHub. Documentation for Grantstamp 0.6, licensed CC BY 4.0.