pg_enquo
pg_enquo · PostgreSQL extension for encrypted query operations
Overview
PostgreSQL · 12, 13, 14, 15, 16, 17
Usage
Sources:
pg_enquo provides PostgreSQL types and operators for storing and comparing ciphertexts produced by an Enquo client library. Encryption and query-token construction happen in the application; the extension never receives the plaintext or encryption key as part of its normal query workflow.
Core Workflow
Create the extension and model columns with the encrypted counterpart of the required PostgreSQL type:
Generate storage ciphertexts and query ciphertexts with an official Enquo client library, then bind them as parameters rather than constructing ciphertext JSON in SQL:
The client must use the same root key, field identity, schema context, data type, and storage options for stored and query ciphertexts.
Supported Type Surface
enquo_bigintstores encrypted signed 64-bit integers and supports comparisons. Its documented default representation is roughly 500 bytes per value.enquo_datestores encrypted dates with years from-32768through32767and supports comparisons. Its documented default representation is roughly 250 bytes.enquo_textstores arbitrary UTF-8 text and supports equality/inequality. Its size starts around 110 bytes for an empty value and grows in encrypted blocks.- Client option
no_queryreduces storage when values never need querying, at the cost of removing query tokens.
Security Trade-offs
- Default security should be the baseline. Client option
enable_reduced_security_operationsadds deterministic/order information needed for indexes orORDER BY, but leaks equality and, for ordered types, the ordering of the column; this can enable inference attacks. enquo_bigintcan use B-tree or hash indexes and ordering only with the required reduced-security material.enquo_datesimilarly enables B-tree/order operations;enquo_textenables hash indexing. Match the index to the client storage options or operations will fail.- Ciphertext does not hide table shape, row count, nullness, access patterns, or query frequency. Define the threat model, rotate and back up root keys, and prevent logs/traces from recording plaintext before adopting the scheme.
- Version
0.0is an early interface. Pin the client library,enquo-core, extension build, schema field identities, and storage options as one compatibility unit; test restore, key loss, schema changes, re-encryption, index rebuilds, malformed ciphertext, and upgrades.