🏡 index : quine-global/quorum.git

# Running a rebuilder

A rebuilder builds a project's release from its source, on their own
machine, and signs the hashes of what came out. When enough rebuilders that
a user trusts got the same hashes, quorum lets the user run the file. Your
signature says one thing: *I built this release from its published source,
and these are the bytes I got.* It doesn't vouch for the code being good.

What makes it worth something is that you're independent: your own machine,
your own key, nobody else's build. Two rebuilders run by one person or one
company count as one.

## What you need

- A Linux machine (x86_64) with [Nix](https://nixos.org/download/) and
  flakes. Builds run in Nix's sandbox; a release of Hyper takes some 10 GB
  of disk and 4 GB of memory, twice its build time (below), and network to
  fetch sources.
- A key, made once and kept to yourself:

  ```
  nix run github:quine-global/quorum#cosign -- generate-key-pair --output-key-prefix ~/rebuilder/<you>
  ```

  `<you>.key` is the secret (encrypted with the password you give it);
  `<you>.pub` is what you publish. Pick a name (`<you>`) that people will
  know you by: lower case, no spaces.
- A clone of the feed, [quine-global/attestations](https://github.com/quine-global/attestations).

## For each release

```
nix run github:quine-global/quorum#rebuild -- \
    --project hyper --release 4.0.1 \
    --flake github:quine-global/hyper/v4.0.1#windows \
    --name <you> --key ~/rebuilder/<you>.key --feed ~/attestations
```

It:

1. builds the release from that tag with Nix;
2. builds it **again** (`nix build --rebuild`) and stops unless both are
   bit for bit the same. This also makes sure the result is your machine's
   own and not something Nix fetched from a binary cache;
3. prints the files' SHA-256 and writes what you're vouching for (`quorum
   statement`: the files, their hashes, the release);
4. signs it with your key (cosign), into
   `hyper/4.0.1/<you>/attestation.sigstore.json` in the feed. cosign runs
   with an empty signing config, so nothing goes to Sigstore's public log.

Compare the printed hashes with the project's `SHA256SUMS` before you
publish: if they differ, that's worth an issue, not an attestation.

Then open a pull request to the feed with that file. The first time, add
your public key as `hyper/builder-keys/<you>.pem` (it's `<you>.pub`) and say
where people can check its fingerprint independently (your website, a
signed message, in person): users pin rebuilders by that fingerprint.

```
quorum trust -p hyper add <you>     # what users run; it shows your fingerprint
```

Only `--flake` references to a tag or commit of the published repository
make sense: a local checkout may hold changes nobody else can rebuild.

## The log

The feed's maintainers log every attestation in the project's transparency
log (`hyper/log`, Tessera's format, cosigned by witnesses), so a rebuilder
can't sign one hash for most people and another for a target. You don't need
to do anything for that. (The maintainers run the same command with
`--log-key`, and `--witness-policy` for the witnesses.)

## Keys

- Lost or leaked key: say so in an issue on the feed and add a new key
  under a new name (`<you>-2`). Users have to pin the new one by hand; that
  is the point.
- The key is encrypted with your password, and cosign asks for it when it
  signs (or reads `COSIGN_PASSWORD`). The build machine holds the key while
  it signs; signing on another machine isn't supported yet.