Repository navigation
Ledger Signing and Publication
This page covers what kingresd adds on top of the kingres_ledger extension (see Ledger): signing keys, signed checkpoints of tile logs, the aggregate digest and the publication that an auditor reads. The design is in ledger-phase7.md. Read the status section at the end for what is built and what is not.
The database alone cannot prove its own integrity. kingresd therefore reads the chain of every shard group, builds Merkle logs from it, signs their checkpoints with keys that live in files outside the database and serves the result on a listener of its own. A third party fetches those files with The Verifier and checks them against a trust file that it obtained outside the cluster.
- A chain log has one leaf per block of one chain. An aggregate log has one leaf per aggregation round of one database.
- A checkpoint is a signed note (C2SP
signed-note,tlog-checkpoint,tlog-tiles; RFC 6962 and RFC 9162; Ed25519 only) that states the size and root of one log. - The leader keeps a transparency log for every chain and an aggregate log for every database in the system database, signs their checkpoints and stores the tiles. The job
ledger.roundruns on the manager leader, and a round runs for each database with a ledger everypublication.intervalSeconds. - A log never gets a smaller tree and never a second root for a size.
- A follower never signs. A leader that loses its term cannot write (a term guard on every write).
The aggregate digest of a database is the checkpoint of its aggregate log. Each leaf lists, for every chain of the database (at most 512), a flag byte (stale, retired, diverged), the chain id, epoch, height, block hash and the root of the chain log. Because the checkpoint commits to every leaf, it commits to the head of every shard group's chain at each recorded round, and a consistency proof shows that no earlier round was changed. LedgerDigest.aggregateHash is the hex of that root and aggregateSize is the size. A group that cannot be read is marked stale and the digest says complete: false; it is never skipped as complete.
- Keys are Ed25519. The private key is a file under
--ledger-keys-dir(default<data-dir>/ledger/keys), mode 0600, optionally sealed with a passphrase file (--ledger-key-passphrase-file). Without a passphrase file, key files are in clear text, like the certificate authority key, andkingresdlogs a warning. - The leader and the servers that run shard group 0 hold the key files, so a new leader can sign.
- Key lifecycle tasks (one at a time, cluster-wide):
ledger.key.create,ledger.key.rotate,ledger.key.retire,ledger.key.revoke,ledger.key.distribute. Every change is published as a signed event (key-added,key-retired,key-revoked) underevents/. - A retired key is bound to a maximum tree size (
max_tree_size), so what it signed stays valid and what it signs later is refused. - Set
ledger-key-passphrase-file(mode 0600, one line) so that the key files are sealed at rest. Back up the private keys and the passphrase file apart from each other and from the data. - REST operations:
getLedgerSettings,updateLedgerSettings,getLedgerSigning,createLedgerSigningKey,retireLedgerSigningKey,revokeLedgerSigningKey,getLedgerTrustFile(the REST contract has 37 ledger operations in all). The alertledgerSignerUnavailableis raised when the key set is damaged, differs from the published trust file or a key file is missing.
The listener is off by default. Enable it with --ledger-publication-listen (host:port), and with --ledger-publication-tls-cert and --ledger-publication-tls-key together for TLS (without them it is plain HTTP and the console warns). It serves GET and HEAD for this layout and nothing else, with no authentication (the files are public by design):
keyring.json the trust file
logs.json the logs and their state
events/<number> signed key events
c/<chain_id>/e<epoch>/ checkpoint, tile/<L>/<N>, tile/entries/<N>
a/<aggregate_id>/ checkpoint, tiles, anchors/<size>/<target>.json
Tiles, bundles and events are immutable and cacheable; the checkpoint and keyring.json are cached for 5 seconds. The listener limits concurrent requests (200) and requests per client address. REST operations: getLedgerPublication, getLedgerAggregate, listLedgerAggregates, generateLedgerDigest, createLedgerBundle, getLedgerBundle. A bundle is the same layout restricted to the logs and sizes asked for, with a bundle.json.
If the head of a chain goes below what was published, or a published block changes, the log is stopped (diverged) and the critical alert ledgerChainDiverged is raised. Nothing is signed over it and nothing repairs it automatically; an operator acknowledges it with acknowledgeLedgerDivergence. The acknowledgement (a typed confirmation and a reason) closes the old log with the signed event epoch-closed and starts a new epoch whose log is built from block 0. A dropped database or a removed server ends its chains with a signed chain-retired event, so an auditor can tell a deletion (retired, with an event) from a rollback (diverged, with an alert). A database that disappears without dropDatabase is treated as vanished after 30 minutes of every group saying so, with an alert first.
A restore of the system database from an older backup must not make the publisher sign a second root for a published size. Every holder of the key files keeps a record, published.json, of the highest size and root of every log and the last event (mode 0600, checksummed, no secrets). Every round compares the database with the record. A database that is behind it signs nothing and raises the critical alert ledgerSignerUnavailable with the subject published-state. The leader spreads the record to the other holders. Not covered: when every copy of the record is lost or older than the publication, only a mirror or an auditor that holds a later checkpoint shows the restore.
The way back to signing after a real restore is a decision of the operator (ADR 0025). The alert says what was published, what the database holds, and a confirmation of sixteen hexadecimal digits. After checking that the database really was restored and that no newer backup exists, restart every kingresd, and on the host of the manager leader write the confirmation and a reason (up to 200 printable ASCII characters, on a second line) into <ledger-keys-dir>/accept-restore. The leader makes its record what the database holds, one generation higher, keeps the old record as published.json.before-restore-<generation>, and publishes the signed event restore-acknowledged before it signs anything else. The logs fork against a mirror that holds the old checkpoints; the event is the public statement of that. There is no REST operation for this, and the lost rows of the aggregate log and the events are not recovered (no importer is built).
The trust file (trust.json) holds the origin prefix, the public signing keys with their validity (not_before, not_after, revoked, max_tree_size) and the roots of time-stamp authorities. The operator creates it once from the console (getLedgerTrustFile), copies it to the auditor and to a safe place outside the cluster, and compares the key fingerprint on paper or by voice. kingres-verify trust init makes a trust file from a key that you obtained yourself, and trust follow follows key events from the publication.
The Ledger page of the web console has pages for signing keys, anchoring and client keys, and dialogs for bundles, the acknowledgement of a diverged chain and the audit of the publication. See Web Console.
-
Bundles.
createLedgerBundlestarts the taskledger.bundle.create; the bundle is the layout of the publication restricted to the logs and sizes asked for, the events, the key ring, and, if asked, evidence files and proofs. It is kept for 24 hours on the manager leader that built it. -
Client keys and signature policy. Every shard group has its own registry; registering or revoking a client key and setting a table's signature policy run on every server.
upgradeLedgerExtensionrunsALTER EXTENSION kingres_ledger UPDATEon every server (the extension must be 0.3 in every group). -
Audit of the publication.
startLedgerVerificationtakeschecks:chain(always) andpublication(every tile and entry bundle of the database's stored logs against the root of the latest checkpoint, and the stored note against its size and root; on demand). In release 0.2.0 the checkanchorsis not built and answers 422unsupported_operation, and a scheduled audit of the publication is not built either. Both are built in release 0.2.1 (phase 18, task 1, contract 0.36.0): the checkanchorsverifies every anchor record on the server and stores a report (ok,failedorincomplete, never "ok" for something not checked), and the scheduled audit (every 24 hours by default) re-reads every log, compares every block of the database with the published leaf and keeps a high-water mark per log. It raisesledgerPublicationAltered(critical, sticky until an administrator acknowledges it withacknowledgeLedgerPublicationAlteration),ledgerPublicationBehindandledgerPublicationUnreadable. Details: Ledger Anchoring. It is the server checking itself; the independent check is The Verifier.
Phase 7 is built (signing keys, the collector and the publication, anchoring, bundles, client keys, the aggregate digest, the verifier), except step 24, which is not in the first release: an external signer command for the ledger, publication mirrors (to a directory or an object store), and the anchor probe from another server. The leader signs with its own key files, and you mirror the publication with your own tools. The first release, 0.1.0, is being prepared.
What is not built or not proven, matching the changelog and the limitations of the first release:
- In release 0.2.0 the check
anchorsof a ledger verification and a scheduled audit of the publication are not built; they are built in release 0.2.1 (see above). What they do not prove is in Limitations and Known Issues. - RFC 3161 and OpenTimestamps anchoring were tested against local fakes only (Ledger Anchoring).
- No multi-node ledger with consensus and no global snapshot (phase 8, in design, not built): there is one chain per shard group, and the aggregate digest commits to the head of every chain.
- When every copy of the record of what was published is lost, only a mirror or an auditor shows a restore of the system database.
- A database can be dropped with its ledger by every role that has the privileges of its owner; publication and anchoring are what make it visible.
- The signing key's passphrase and the private keys must be backed up by you, apart from each other.
See Control Plane and REST API, Configuration and Security Model.
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/docs/design/ledger-phase7.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/control-plane/README.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/api/openapi.yaml
- https://github.com/KingresDB/Kingres/blob/kingres-18/contrib/kingres_ledger/README.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/README.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/docs/guide/operator-guide.md (sections 7 and 8)
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/docs/guide/limitations.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/docs/adr/0025-restore-of-the-system-database-is-accepted-by-an-operator.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/docs/reviews/2026-11-18-kingresd-ledger-signing-keys.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/docs/reviews/2026-11-19-kingresd-ledger-collector-and-publication.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/docs/reviews/2026-11-20-kingresd-anchoring-wiring-and-publication-fixes.md
KingresDB's own code is licensed under AGPL-3.0-only. PostgreSQL code keeps the PostgreSQL License. Copyright of the project's own code: RooyeKhat Media Co. KingresDB is derived from PostgreSQL and is not endorsed by the PostgreSQL project. Repository | Licence | COPYRIGHT
KingresDB
1. Product
- Product Overview and Features
- Status and Roadmap
- User Guide
- Administrator Guide
- REST API Reference
- Web Console
- Command Line Client
- Extensions
- Limitations and Known Issues
- Release Notes
Features in detail
- Sharding
- Sharding Query Pushdown
- Sharding Table Lifecycle
- High Availability
- Ledger
- Ledger Signing and Publication
- Ledger Anchoring
- The Verifier
- Analytics Extensions
Administration
- Cluster Setup
- Servers Databases and Roles
- Rebalancing
- Configuration
- Memory and Warm-up
- Control Plane and REST API
- Upgrades
2. Architecture (arc42)
- Architecture
- Architecture Introduction and Goals
- Architecture Constraints
- Architecture System Context
- Architecture Containers
- Architecture Components
- Architecture Runtime Views Sharding
- Architecture Runtime Views Availability and Ledger
- Architecture Deployment
- Architecture Crosscutting Concepts
- Security Model
- Architecture Decisions
- Architecture Quality Requirements
- Architecture Risks and Technical Debt
- Enterprise Architecture
3. Data architecture
- Data Architecture
- Data Model Sharding
- Data Model Ledger
- Data Model System Database
- Data Model Analytics
- Data Lifecycle
- Backup Restore and PITR
- Data Security
- Data Quality and Integrity
4. Development
- Building from Source
- Development and Testing
- Repository Layout
- Coding Standards
- Branching and Synchronisation
- Testing Strategy
- Review Process
- Release Process
- Contributing
5. Operations