box). That is still
secure against today’s computers, but X25519 is an elliptic-curve scheme, and a large enough quantum
computer running Shor’s algorithm breaks it. An attacker doesn’t need that computer today: they can
copy the ciphertexts now and decrypt them later (“harvest now, decrypt later”). For files that live in
source control, that is exactly the threat model.
Starting with @orion-js/env@4.5.1, new env files use hybrid post-quantum encryption.
How values are encrypted
Each value is encrypted with a fresh X-Wing key encapsulation. X-Wing combines ML-KEM-768 (the NIST-standardized post-quantum KEM, FIPS 203) with X25519. The resulting 32-byte shared secret is used as an AES-256-GCM key.@noble/post-quantum, an
audited, dependency-free JavaScript library. It is bundled into the package, so @orion-js/env works the
same from require() and import on Node.js 22, 24 and 26 and on Bun.
What changes in the file
Post-quantum files haveversion: '2.0', and keys and values are prefixed with pq1::
pq1: followed by 32 bytes in base64), so it fits in
ORION_ENV_SECRET_KEY or a secret manager exactly like before. Encrypted values are bigger: about
1.5 KB each, because every value carries its own ML-KEM ciphertext.
Migrating an existing file
Old files keep working: Orion Env still readsversion: '1.0' files with their old secret key. To
upgrade one, run:
migrate decrypts every value with the current key, generates a new post-quantum keypair,
re-encrypts everything, and checks that every value decrypts back to the original before it writes the file.
It then prints the new secret key.
ORION_ENV_SECRET_KEY together. That includes keys stored inside a secret manager through
readFromSecret. If you use the wrong kind of key, the error tells you which one it expected:
migrate on a file that is already post-quantum rotates its keypair, which is also the
recommended way to rotate keys from now on.
A migration does not erase history. Old ciphertexts remain in git, encrypted with the old key. If
someone may already have collected them, rotate the underlying credentials (database passwords, API
keys) as well, not only the encryption.
Summary
orion-env initcreates post-quantum files.orion-env addkeeps working on both kinds of files, and warns when the file is still legacy.orion-env migrateupgrades legacy files and rotates keys on post-quantum ones.- Applications don’t need code changes:
envandloadEnv()read both formats.