This is the documentation for version 0.5. Read this page for version 0.6, the latest.
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.
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 mirror#
- Fork grantstamp/grantstamp-mirror.
- In your fork, open the Actions tab and enable workflows.
- Open Settings, then Pages, and set Source to GitHub Actions.
- Open Actions, pick
grantstamp-mirror, and click Run workflow. -
Check your mirror:
pip install grantstamp grantstamp audit --from https://<you>.github.io/grantstamp-mirror
A witness#
- Fork grantstamp/grantstamp-witness.
- In your fork, open the Actions tab and enable workflows.
-
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.keyIt prints one line that starts with that name. The line is public. Keep it.
-
In your fork, open Settings, then Secrets and variables, then Actions. Add a secret named
GRANTSTAMP_WITNESS_KEYwith the contents ofwitness.key. Then delete the file. - Open Actions, pick
grantstamp-witness, and click Run workflow. It should end with "cosigned ... entries". - Pick a timer.
A fork never copies secrets or state. Your witness starts with its own key and an empty history.
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.
- Repository access: only your fork.
- Permissions: Actions, set to Read and write.
- Note the expiry date. When the token expires, the timer stops.
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. 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>"
- The log key is the
logline at registry.grantstamp.io/v1/log/policy. - The program makes one pass every 5 minutes until you stop it. Change that with
--every. - It writes
witness-state.jsonbeside the key. Back up both. A witness that loses its state can no longer prove it never signed a fork.
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:
- A public address. Forward a port on your router to this machine, or use a tunnel service.
- A stable name. A domain name, or an address that does not change.
- HTTPS. Put a web server or a tunnel in front that holds a certificate.
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.
- A mirror. Send its address to contact@grantstamp.io.
- A witness. Send the public line that
keygenprinted. Until the registry lists your witness, it does not keep your cosignatures. That is expected. Your witness still checks the log on every pass.
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#
- Your witness fails with "rewrote history". Do not delete its state. That failure is the witness doing its job. Write to security@grantstamp.io, and say so in public if you get no answer.
- Your mirror's audit fails. Run it again. If it still fails, the registry served something that does not add up. Write to the same address.
- A trigger fails with "refused the token". The token has expired. Make a new one and run
grantstamp trigger --set-token.
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:
- A mirror. Check it with
grantstamp audit --from <address>. Then add the address toGRANTSTAMP_LOG_MIRRORS, separated from the others by commas. - A witness. Add
witness <short name> <their public line>toGRANTSTAMP_WITNESS_POLICY. Start with a quorum that any one witness can meet, for examplegroup either any github <short name>andquorum either. Then one late witness cannot block checks. - Then pin the new list. Run
curl -s https://registry.grantstamp.io/v1/log/policy > src/grantstamp/logs/registry.grantstamp.io_log.policy, commit it and release. Clients trust a new witness only from that release on.
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.5, licensed CC BY 4.0.