PQLOCK
POST QUANTUM
LOCK · v0.1

The Post
Quantum Lock

pqlock: hybrid post-quantum encryption and signatures

Two locks guard every key.

An attacker has to break both to read the data.

One API in TypeScript, Python and Go.

Envelope overhead1,195 bytes AlgorithmsML-KEM-768 + X25519
An isometric cube made of two stacked locks, ML-KEM-768 below and X25519 above, meeting at one shared secret. Rays from the cube seal cells in a grid of data below it.
sealedplaintext
Keywords

Hybrid KEM

ML-KEM-768 and X25519 combined into one 32-byte secret (X-Wing).

Fail closed

Any tampered byte gives one error and zero plaintext.

Validated engines

OpenSSL 3.5, pyca/cryptography and the Go standard library do the math.

00
FILM · 58 S
The launch film

Stolen today.
Read in ten years.

58 seconds, narrated. The bytes, the tampered envelope and the scan results on screen come from the PQL spec vectors and the uc8 migration use case.
01
WHY NOW
Harvest now, decrypt later

Data stolen today
is read in the 2030s

RSA and elliptic-curve keys protect almost every login, database field, backup and software update. A large enough quantum computer breaks them. Traffic recorded now can be decrypted then, so anything that must stay secret for ten years needs post-quantum protection today.

2024NIST publishes FIPS 203 (ML-KEM), 204 (ML-DSA) and 205 (SLH-DSA).
2026Industry joint statement on post-quantum migration. TLS stacks ship X25519MLKEM768.
2030NIST IR 8547: RSA and ECC at 112-bit security deprecated.
2035RSA and ECC disallowed for US federal systems.
02
SEAL
How it works

One call seals.
Two locks protect it.

seal(publicKeys, data) runs a hybrid key exchange, derives a fresh key bound to the envelope header, encrypts with AES-256-GCM and adds a key commitment. Developers never pick an algorithm unless they want to.

Seal pipeline: the recipient public key goes into X-Wing, where ML-KEM-768 and X25519 each produce a secret that SHA3-256 combines into 32 bytes. HKDF-SHA256 derives a data key and a commitment. AES-256-GCM encrypts the plaintext. The output is a PQL1 envelope.
PQL-DEFAULT. X-Wing hybrid KEM (Connolly, Schwabe, Westerbaan) → HKDF-SHA256 over the header hash → AES-256-GCM with the header as associated data → 32-byte commitment.
Open

Seven checks.
One error.

Opening checks the envelope in a fixed order before a single byte of plaintext is released. A wrong key, a truncated envelope, a flipped bit or a rewritten suite id all raise the same error, with no partial output and no hint about which check failed.

  1. No downgrade.The suite is read from the bytes and must match the key. There is no negotiation.
  2. Commitment before decryption.A ciphertext cannot be crafted to open under two different keys.
  3. Tag before release.Plaintext leaves the SDK only after AES-GCM verifies.
Seven gates in order: length, magic and version, suite, key id, decapsulation, commitment, GCM tag. Every gate fails into a single error with no plaintext; only after the last gate is plaintext returned.
03
WIRE FORMAT
Anatomy of an envelope

Every byte
has a job

A PQL1 envelope describes itself: suite, recipient key and KEM ciphertext travel with the data. That is what makes rotation and algorithm changes possible without re-architecting. The same bytes come out of all three SDKs.

Exploded isometric stack of the PQL1 envelope fields: magic 4 bytes, version 1, suite id 2, key id 8, KEM ciphertext 1120, nonce 12, AEAD ciphertext plus 16-byte tag, commitment 32. The header fields are bound both as associated data and through the key schedule.
Header bound twice: as AES-GCM associated data and through the HKDF key schedule. Text form for TEXT columns and JSON: pql1. + base64url, no padding.
04
SIGN
Signatures

Two signatures,
both required

sign(keys, message) produces a composite signature: ML-DSA-65 and Ed25519 over the same prepared message. Verification passes only if both halves verify, so a forger has to break a lattice scheme and an elliptic curve at the same time.

  1. Release signing.Detached .pqlsig files, checked by installers.
  2. Login tokens.JOSE tokens signed with ML-DSA, plus a short reference mode for cookies.
  3. Webhooks and agent tool calls.Signed payloads with an audit log that can be verified later.
The message is prepared with a prefix, label, context and SHA-512 hash, then signed by ML-DSA-65 (3309 bytes) and Ed25519 (64 bytes). The halves are joined into a PQLG signature. Verify requires both to be valid.
SuiteSealSignUse it for
PQL-DEFAULTX-Wing: ML-KEM-768 + X25519ML-DSA-65 + Ed25519Most applications. Hybrid, compact, fast.
PQL-HIGHML-KEM-1024 + P-384ML-DSA-87 + P-384Long-lived secrets and higher security margins.
PQL-CNSAML-KEM-1024ML-DSA-87, SHA-384CNSA 2.0 alignment for national-security workloads.
PQL-LEGACYImports RSA and ECC keys read-only. Never seals or signs.Migration: read old data, write new data.
05
FEATURES
What ships in the box

Built for teams that
are not cryptographers

F.01

Hybrid by default

Every default key pairs a post-quantum algorithm with a classical one. Security holds if either survives.

F.02

Three SDKs, same bytes

TypeScript, Python and Go agree byte for byte: 148 spec vectors and 54 of 54 cross-language pairs pass.

F.03

Keysets and rotation

One primary key, older keys kept for opening. Rotate without re-encrypting everything at once.

F.04

Crypto-agility

Change suites in pql.policy.yaml, not in application code. New algorithms slot into the same envelope.

F.05

Misuse-resistant

Secrets never print in logs, open never returns partial data, and empty or oversized inputs are refused.

F.06

No homemade math

pqlock only composes primitives from OpenSSL 3.5, pyca/cryptography and the Go standard library.

F.07

pql scan + CBOM

Finds RSA, ECDSA and ECDH across code, configs and certificates, and writes a CycloneDX 1.7 inventory.

F.08

Hard size limitsin review

One spec sets a maximum for every untrusted input, enforced the same way in every SDK and the CLI.

F.09

FIPS modein review

A strict switch that requires the engine's FIPS 140-3 mode and refuses anything outside the validated module.

06
USE CASES
Eight real applications, tested end to end

Everywhere RSA
and ECC run today

Each use case is a working app in the repository. Every change is deployed and run against all eight, including real PostgreSQL and S3-compatible storage.

UC.01

Login tokens

A Node service issues post-quantum tokens. A Python API verifies them.

tokens.issue · tokens.check
UC.02

Database fields

A Go service seals card numbers and PII into Postgres columns, bound to table, column and row.

seal_batch
UC.03

Backups

A Python worker streams large backups into object storage, sealed in chunks.

stream
UC.04

Release signing

CI signs artifacts. A Node installer refuses anything without a valid .pqlsig.

pql sign · sign.verify
UC.05

Webhooks

A Go sender signs webhooks. A Python receiver verifies them and rejects replays.

webhooks
UC.06

Hybrid TLS

A Node server and a Go client agree on X25519MLKEM768, and the connection proves it.

tls
UC.07

AI agent tool calls

A Python agent signs every tool call. Node tools verify it and append to a tamper-evident audit log.

sign · audit
UC.08

Migration

Scan a legacy Node app, inventory its RSA and ECDSA, and swap to pqlock step by step.

pql scan · legacy · rotate
pql scan reads a repository, flags RS256 JWTs, RSA-2048 certificates, ECDHE P-256 TLS and ECDSA signing, then writes a CycloneDX 1.7 CBOM and fails CI while vulnerable crypto remains.
Start with an inventory. pql scan --fail-on-vulnerable . exits 3 while quantum-vulnerable crypto remains, so CI tracks the migration.
07
DOCS
Quickstart

Five minutes
to post-quantum

// npm install pqlock   (Node 26+, OpenSSL 3.5+)
import { keyset, seal, sign } from 'pqlock';

const keys = keyset.create('seal');            // PQL-DEFAULT
const pub  = keyset.toPublic(keys);

const text = seal.toText(seal.seal(pub, Buffer.from('card 4242…')));
// "pql1.…"  store it in any TEXT column
const data = seal.open(keys, text);          // or PQLOpenError

const signer = keyset.create('sign');
const sig = sign.sign(signer, Buffer.from('release v0.1.0'));
sign.verify(keyset.toPublic(signer), Buffer.from('release v0.1.0'), sig);
# pip install pqlock   (Python 3.12+, cryptography 47+)
from pqlock import keyset, seal, sign

keys = keyset.create("seal")                 # PQL-DEFAULT
pub  = keyset.public(keys)

text = seal.to_text(seal.seal(b"card 4242…", pub))   # data first, keys last
data = seal.open(text, keys)                    # or OpenError

signer = keyset.create("sign")
sig = sign.sign(b"release v0.1.0", signer)
sign.verify(b"release v0.1.0", sig, keyset.public(signer))
// go get github.com/Motiontic/pqs/packages/go   (Go 1.27+)
keys, _ := keyset.Create(keyset.Seal)            // PQL-DEFAULT
pub := keyset.Public(keys)

env, _ := seal.Seal(pub, []byte("card 4242…"))
text := seal.Encode(env)                          // "pql1.…"
data, err := seal.OpenText(keys, text)            // err on any tamper

// stronger suite, one option
keyset.Create(keyset.Seal, keyset.WithSuite(keyset.SuiteHigh))
# inventory every RSA / ECC use in a repo
pql scan --format json -o scan.json .
pql cbom -o cbom.json .                     # CycloneDX 1.7
pql scan --fail-on-vulnerable .             # CI gate: exit 3

# set the suite for the whole app
echo "suite: PQL-HIGH" > pql.policy.yaml
08
STATUS
Honest status

Preview, tested,
not yet audited

pqlock v0.1.0 is a preview. Every change is fuzzed, checked against NIST ACVP vectors, timing-tested on its own compare and parse paths and reviewed independently, but an external cryptographic audit has not happened yet. An audit is required before v1.0.

Report

Security issues go to security@motiontic.com, not to public issues. The license is Apache-2.0.

pqlock.motiontic.com

Lock it before
someone records it

Motiontic builds pqlock and helps enterprise teams plan and ship post-quantum migrations.