kingres_ledger
kingres · Tamper-evident ledger tables with hash chains, digests and inclusion proofs.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 102353 | kingres_ledger | kingres | 0.3 | SEC | AGPL-3.0-only | C |
PostgreSQL · 18, 19
Usage
Sources:
kingres_ledger 0.3 records changes in hash chains and Merkle blocks for append-only or updatable ledger tables. It detects tampering only when compared with a previously trusted digest kept outside the database; an internally consistent rewritten chain is not proof of integrity.
Enable a ledger
The reviewed KingresDB source supports PostgreSQL 18 and 19 branches. Preload and restart; the extension owner must remain a superuser. Creating SQL objects without preload is insufficient for enabling a ledger. The following example permanently enables append-only mode.
Verification and privileges
kingres.ledger_enable(relation, 'updatable') instead creates history for changed/deleted row versions. Enabling is irreversible and the mode cannot later be switched. Protected tables cannot be dropped or truncated through ordinary administration. Explicit execution grants are needed for administrative APIs and the caller must own the table. History access is separate from the base table’s RLS and column privileges.
kingres.ledger_inclusion_proof and kingres.ledger_verify_proof verify row membership. Export the result of kingres.ledger_generate_digest() to independent trusted storage: the copy recorded inside the database is not a trust anchor. New kingres.ledger_head, kingres.ledger_blocks_entries and kingres.ledger_block_preimage functions expose publication inputs; full external signing and anchoring are separate components.
Maintenance boundary
There is an unprotected interval until committed rows enter a block and its digest leaves the database. Privileged catalog/file edits and disabled guards remain outside the protection boundary. Upgrade from 0.2 by deploying the matching library, restarting and applying ALTER EXTENSION kingres_ledger UPDATE TO '0.3'; the supplied migration preserves existing blocks and proofs.
Distribution 0.2.1: Anchor Checks
The control plane now accepts anchors in startLedgerVerification, and schedules publication audits that compare stored blocks with published leaves. Unreachable stores, missing trust material and unfinished anchors produce incomplete results, not success. Audit progress survives leader changes; detected publication alteration remains an alert until acknowledged.
These server-side checks are not independent verification. Keep the auditor’s trust material outside the server and use kingres-verify anchors for that separate check. The release has not completed tests against real external authorities. SQL extension version remains 0.3.