Skip to content

The Verifier

Mohammad Rasoul Kazemi edited this page Nov 28, 2026 · 9 revisions

The Verifier

kingres-verify is a standalone command-line verifier for the ledger (see Ledger). It checks digests, inclusion proofs, exported block headers, signed checkpoints, tile logs, aggregate digests, bundles, client signatures and anchors without trusting the database. An auditor runs it on their own machine with files obtained earlier. It is an independent second implementation of hash format version 1, written from the documentation, and it is checked against fixtures from a real server. It has a reproducible build and a release script that produces signed checksums.

It uses the Go standard library only (no third-party modules), so that an auditor can read all of it and build it with one command.

Build

cd kingres/verifier
go build -o kingres-verify ./cmd/kingres-verify

Go 1.27.3 or later. go test ./... needs no database.

Releases, and how to get a verifier that does not come from the cluster

An auditor must not run a verifier that came from the cluster it checks. Two ways give one that does not depend on the operator, and both end in the same check.

  • From the source, at the release tag (preferred). Clone the repository on your own machine, check out the tag, and build with scripts/build-one.sh <GOOS> <GOARCH> <VERSION> <OUTPUT>, which holds all the flags (CGO_ENABLED=0, -trimpath, no build id, fixed micro-architecture levels, no other Go release fetched). There is no third-party module, so the build depends on the Go release only, and the same source and Go release give the same bytes on any machine. Compare sha256sum of the result with the line of SHA256SUMS. scripts/repro-check.sh builds twice in different places and requires the same bytes.
  • From the release files. A release is the binaries (kingres-verify-linux-amd64, -linux-arm64, -darwin-arm64, -windows-amd64.exe), SHA256SUMS, RELEASE (the version, the commit, its date and the Go release) and SHA256SUMS.note, a signed note over SHA256SUMS made with the release key below. They are made by scripts/release.sh from a clean checkout whose HEAD is exactly the tag. The first release, 0.1.0, was published on 2026-11-28, and its verifier files are attached to the GitHub release kingres-0.1.0-pg18 (the verifier is cut with --tag kingres-<version>-pg18, so the release of kingres-0.1.0-pg19 does not carry them). On the release page the sums and the note are named kingres-verify-SHA256SUMS and kingres-verify-SHA256SUMS.note, because a release page has one name for each file and the product's own SHA256SUMS is there too; give them to --sums and --note under those names. In the next release of the verifier, scripts/release.sh writes them under those names itself, and the sums of the product's packages and images (kingres-SHA256SUMS with kingres-SHA256SUMS.note) are signed with the same key and checked with the same command (Installing and Packaging). The command streams each file and refuses one over 1 GiB. The verifier was not released again with 0.1.1: its files stay on the release page of kingres-0.1.0-pg18. The product checksums of 0.1.1 (kingres-SHA256SUMS and kingres-SHA256SUMS.note) are checked with kingres-verify release verify, but with a verifier built from kingres-18 after 2026-11-28: the verifier of 0.1.0 refuses file names with a + and files over 256 MiB, so it cannot check the packages and images. Check the files before you run anything, with a verifier you already trust (a build of your own, or one from an earlier release), and with the key from this page or the repository README, not from the place you downloaded the files from. The command kingres-verify release verify is shown in the next section. It prints VERIFIED only when the note is signed by that key, its text is the sums file, and every binary has the SHA-256 of its line. It cannot show that a release is the newest one: compare the version with the project's announcement. The Debian package also installs a copy of kingres-verify as a convenience; that copy is not an independent verifier.

The release key

The release files of kingres-verify (the binaries, RELEASE and SHA256SUMS) are signed: SHA256SUMS.note is a signed note over SHA256SUMS, made with the project's release key. The key is Ed25519, key name kingres-verify-release, held by the project owner:

public key:  bbwi8vQotQ8amSyMOM70mk1Q+JSSD2gmbBDxnYiTma0=
key string:  kingres-verify-release+dc5771ec+AW28IvL0KLUPGpksjDjO9JpNUPiUkg9oJmwQ8Z2Ik5mt
fingerprint: 81ac03cf18cf327bcdb757473e71851ec1d8c19eb6d6a8f33a08cb2574bcffd5

Check the files before you run anything, with a verifier you already trust (a build of your own, or one from an earlier release):

kingres-verify release verify --sums SHA256SUMS --note SHA256SUMS.note \
    --key kingres-verify-release+dc5771ec+AW28IvL0KLUPGpksjDjO9JpNUPiUkg9oJmwQ8Z2Ik5mt \
    --binary kingres-verify-linux-amd64

The line you want is VERIFIED. The same values are printed in kingres/verifier/README.md ("The release key"); do not trust a key that is not in both places. The key has no expiry date; if it is ever replaced, the new key is announced on this page and in the README before a release is signed with it.

What it can and cannot prove

It verifies what is in the files you give it, nothing else.

  • The digest must be obtained and kept outside the control of the database. A digest read from the database you are checking proves nothing.
  • A proof shows that an entry with a given row_hash and table_id is in the ledger. To learn that a row you hold is in the ledger, recompute its row hash from your own data (row-hash) and give it to proof --row-hash with --table-id.
  • It does not prove that a row was not changed later in the table, that no other rows exist, or anything about transactions not yet in a block covered by a digest.
  • Block times are the server's clock; they are evidence only against an external anchor.
  • checkpoint without --state shows that a checkpoint is signed by a key you trust, not that it is the latest one.

Exporting from a database

psql -X -At -c "SELECT kingres.ledger_generate_digest()" > digest.json
psql -X -At -c "SELECT kingres.ledger_inclusion_proof('app.accounts', kingres.ledger_row_hash(a.*)) FROM app.accounts a WHERE id = 1" > proof.json

Store the digest where the operators of the database cannot change it.

Commands

Command Purpose
proof verify an inclusion proof against a trusted digest: kingres-verify proof --proof proof.json --digest digest.json [--table-id N] [--row-hash HEX] [--op I|D|any]
row-hash compute the row hash from your own data: kingres-verify row-hash --table-id N --columns columns.json
digest-chain check that several digests of one chain are mutually consistent
blocks recompute the hashes of an export of block headers: blocks --blocks blocks.jsonl (--digest digest.json | --chain-id HEX)
trust init, trust show, trust follow make, inspect and follow the trust file
checkpoint verify one signed checkpoint of a chain or aggregate log; with --state it also proves from tiles that it extends the one you recorded
consistency check a consistency proof between two checkpoints
aggregate verify an aggregate digest
proof --bundle, bundle verify, bundle fetch verify or download a bundle of a publication
monitor poll a publication, keep the last checkpoint seen and detect a rollback or fork
attestation verify a client signature on a row against a digest or bundle
anchors verify the anchors of an aggregate checkpoint (WORM, RFC 3161, OpenTimestamps)
release verify check SHA256SUMS.note and the binaries of a verifier release against the release key
version, --help version and usage

A publication source (--source) can be a directory, a .tar.gz file or an https:// address (plain http:// only for loopback). Example from the README:

kingres-verify checkpoint --trust trust.json --log chain:<id>[:e<N>]|aggregate:<id> [--source DIR | --note FILE] [--state FILE]

Proofs are for one entry with the operation I (inserted) or D (removed). --op I or --op D makes the expected operation your explicit choice.

Worked example: is this row in the ledger

  1. On the server, export a digest and keep it outside the database: psql -X -At -c "SELECT kingres.ledger_generate_digest()" > digest.json.
  2. From your own copy of the row, build columns.json: one object per non-NULL column in column order, with name and send_hex (the hex of the type's binary send form; for example encode(int4send(id), 'hex') after SET client_encoding = 'UTF8'). The table id is SELECT table_id FROM kingres.ledger_table WHERE relid = 'app.accounts'::regclass.
  3. kingres-verify row-hash --table-id N --columns columns.json prints the row hash (64 hex characters).
  4. Later, export a proof from the server (kingres.ledger_inclusion_proof(...), see above) and run kingres-verify proof --proof proof.json --digest digest.json --table-id N --row-hash HEX --op I. A digest of the same block as the proof or later is needed; an older digest fails at the step chain-walk.

Exit status 0 and the word VERIFIED mean the entry is in the chain the digest commits to. The commands that read a publication or a bundle (checkpoint, consistency, aggregate, anchors, bundle verify, bundle fetch, monitor, attestation, trust follow) can also end with status 3, and only checkpoint --state can end with status 4.

Exit statuses

Status Meaning
0 everything that was asked for was verified
1 a verification failed, or a file has a form it must not have
2 usage or input error, or the result could not be written
3 incomplete: nothing failed, but something that was asked for could not be checked with the inputs and flags given (the publication does not contain it, or the source cannot be reached). Treat it as an alert, never as "probably fine": a publisher that hides a fork can withhold the tile that would show it.
4 a fork or rollback was found and the conflicting checkpoint could not be saved (only checkpoint --state)
5 only release verify: the signature and the hashes are genuine but the set was made by a dry run (a signed build that is not a release); --accept-dry-run gives 0

--json prints one JSON object instead of text, with the same status. Text from the inputs is escaped so that no input can forge a line of output. A standard output that is a closed descriptor is refused with status 2, so that a lost verdict is not taken for a success; a caller that gives the null device on purpose says so with KINGRES_VERIFY_NO_OUTPUT=1.

What it does not trust, and its stored state

  • It trusts only the trust file that you made from a key you obtained outside the cluster. A key that is revoked or outside its validity window is not used for new checkpoints. max_tree_size retires a key at a known size.
  • With --state FILE it keeps the last verified checkpoint so that a rollback or fork is found. The file holds only what was verified, the whole path of its directory must be private, and a lock stops two runs from writing at once.
  • Key events from the publication are verified under your trust file before they narrow it. A key revoked by a verified event vouches for nothing.
  • Anchors: the evidence file is the cluster's claim and nothing in it is believed. Each kind is checked from your inputs (--worm-url, the tsa_roots of your trust file, --btc-header HEIGHT:HEX). Without that input the result is status 3.

Status

The verifier is built (phase 7): digests, inclusion proofs, block headers, signed checkpoints and consistency proofs, tile logs, aggregates, bundles, client signatures, anchors, a monitor, the trust file with key events, and the release check. Its source is the standard library only, its build is reproducible, and the release files are signed with the release key above; the release 0.1.0 (2026-11-28) carries them. The RFC 3161 and OpenTimestamps checks of the verifier work from inputs that the auditor supplies, and the anchoring they check was tested against local fakes only (Ledger Anchoring). The custody of the release signing key is the project owner's decision. See Status and Roadmap and Ledger Signing and Publication.

Sources

Clone this wiki locally