Skip to content

pg_postquantum

AlohaDB ML-KEM, ML-DSA and hybrid encryption functions

alohadb · AlohaDB ML-KEM, ML-DSA and hybrid encryption functions

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
102492pg_postquantumalohadb1.0SECMITC

PostgreSQL · 18

Usage

Sources:

pg_postquantum 1.0 exposes ML-KEM encapsulation, ML-DSA signatures and public-key encryption in AlohaDB 21.10.0, based on PostgreSQL 18. Its cryptographic implementation requires OpenSSL 3.5 or later. Stock PostgreSQL portability is not established.

Enable and Encrypt

The extension is trusted and relocatable: a role with database CREATE privilege can install it once the server files are present. It needs no preload or restart.

CREATE EXTENSION pg_postquantum;
SELECT pq_available();
WITH keys AS MATERIALIZED (
    SELECT * FROM pq_kem_keypair()
), encrypted AS MATERIALIZED (
    SELECT private_key, pq_encrypt('example message'::text, public_key) AS envelope
    FROM keys
)
SELECT pq_decrypt_text(envelope, private_key) FROM encrypted;

The example keeps an ephemeral key within one statement. Protect real private keys separately; avoid exposing them in SQL logs or broadly readable tables. Availability depends on the server’s OpenSSL algorithms, not just successful extension installation.

Function Index

  • pq_kem_keypair, pq_kem_encapsulate and pq_kem_decapsulate create keys and agree a shared secret. The default is X25519-ML-KEM-768; raw KEM also supports ML-KEM-512, ML-KEM-768 and ML-KEM-1024.
  • pq_sign_keypair, pq_sign and pq_verify create and verify signatures. The default is ML-DSA-65, with ML-DSA-44 and ML-DSA-87 alternatives.
  • pq_public_key derives a public key from a private key and explicit algorithm.
  • pq_encrypt, pq_decrypt and pq_decrypt_text combine encapsulation with AES-256-GCM. The encryption envelope supports the default hybrid and ML-KEM-768/1024, not every raw-KEM option.

Use the same algorithm and key encoding at both ends. Keys are raw encodings; hybrid keys concatenate the ML-KEM and X25519 portions. Text helpers use UTF-8, while binary functions use bytea.

Maintenance and Security Boundary

The PQE1 envelope includes the scheme, KEM ciphertext, nonce, encrypted data and authentication tag. Preserve compatible decryptors and keys when migrating data or backups. An extension installation does not supply key lifecycle management, authorization, protocol authentication or a certification of application compliance.

Keep the AlohaDB extension and OpenSSL libraries aligned. Validate round trips, tampered inputs and recovery with the exact deployed build before entrusting persistent data to this preview module.

Table reader