Skip to content

Search docs

Jump between documentation pages.

Browse docs

Post-quantum readiness

DaloyJS has no encryption or key exchange of its own, so the urgent part of a post-quantum migration is your runtime's TLS. The part the framework owns is token signatures, and jwk() and createJwtVerifier() verify ML-DSA tokens when you list the algorithm.

What quantum attacks affect

A large quantum computer breaks today's public-key algorithms: RSA, ECDSA, EdDSA and Diffie-Hellman key exchange. Symmetric cryptography and hash functions are not affected in the same way. That splits the framework into three layers.

Where public-key cryptography appears
TLS key exchangeOwned by the runtime and the platform, not by DaloyJS
Node / OpenSSLBunDenoWorkersyour proxy
Token and message signaturesOwned by DaloyJS. ML-DSA is available for JWTs when listed
jwk()createJwtVerifier()createJwtSigner()http-signatures
Symmetric keys and hashesNot affected. Nothing to migrate
session() HMACwebhook HMACHS256 tokensscrypt passwordscursor signing
Recorded traffic can be decrypted later, so key exchange is the urgent layer. A signature only has to hold until the token expires.
AreaWhat DaloyJS usesAffectedWhat to do
TLSWhatever the runtime negotiatesYes, and it is urgentKeep the runtime current and check the key exchange
jwk(), createJwtVerifier()RS, PS, ES, EdDSA, and ML-DSA when listedYes, laterList an ML-DSA algorithm once your issuer publishes such keys
http-signaturesEd25519, ECDSA, RSA, HMACYes, laterNothing yet. That module has no post-quantum algorithm
session(), cursors, webhooksHMAC-SHA-256NoNothing
passwordHash()scryptNoNothing
clientCertAuth()The certificate your CA issuedDecided by your CAFollow your CA's migration

TLS is the urgent part

DaloyJS does not configure TLS groups. The Node adapter, fetchGuard() and plain fetch() all use the runtime's defaults, so the fix for recorded-traffic attacks is a runtime that offers the hybrid group X25519MLKEM768 and a peer that accepts it.

Check what your deployment negotiates instead of trusting a version number:

scripts/check-tls.tsts
import tls from "node:tls";

const host = "api.example.com";
const socket = tls.connect({ host, port: 443, servername: host }, () => {
  console.log(socket.getProtocol(), socket.getEphemeralKeyInfo());
  // TLSv1.3 { type: 'TLSGroup', name: 'X25519MLKEM768' }
  socket.end();
});

If the name is X25519 or a P-256 curve, one side does not offer the hybrid group. Update the runtime first: DaloyJS supports every Node 24 release, but an older 24 patch release may not offer the hybrid group by default. Then check the proxy or load balancer in front of the app, because it terminates TLS for your clients.

ML-DSA tokens

ML-DSA is the NIST post-quantum signature standard (FIPS 204). RFC 9964 registers it for JWTs as ML-DSA-44, ML-DSA-65 and ML-DSA-87, with keys published as kty: "AKP" JSON Web Keys.

Nothing accepts these algorithms by default. A verifier takes them only when its allowlist names them, the same rule as every other algorithm:

src/build-app.tsts
import { App, jwk } from "@daloyjs/core";

app.use(jwk({
  jwks: "https://login.example.com/.well-known/jwks.json",
  algorithms: ["ES256", "ML-DSA-65"],
  issuer: "https://login.example.com/",
  audience: "books-api",
}));

Listing both lets the issuer move at its own pace: classical tokens keep verifying, and ML-DSA tokens verify as soon as the JWKS carries an ML-DSA key. Remove the classical algorithm once the issuer has stopped signing with it.

With a key you hold yourself, pass the public JWK or a CryptoKey:

src/verify.tsts
import { createJwtVerifier, type AkpJsonWebKey } from "@daloyjs/core";

const publicKey: AkpJsonWebKey = {
  kty: "AKP",
  alg: "ML-DSA-65",
  pub: process.env.TOKEN_PUBLIC_KEY!, // base64url of the raw ML-DSA public key
};

const verifier = createJwtVerifier({
  algorithms: ["ML-DSA-65"],
  key: publicKey,
  issuer: "https://tokens.internal.example/",
  audience: "books-api",
});

Runtime support

ML-DSA runs through WebCrypto, so @daloyjs/core still has no runtime dependency. The runtime must implement it. Check before you list the algorithm:

ts
const supported = (SubtleCrypto as { supports?: (op: string, alg: string) => boolean })
  .supports?.("verify", "ML-DSA-65") ?? false;

On a runtime without ML-DSA the verifier rejects the token with unsupported_alg, and jwk() answers 401. It never falls back to another algorithm.

What the verifier checks

  • The token's alg must be in the allowlist. ML-DSA-65 in the list does not accept ML-DSA-44 or ML-DSA-87.
  • The JWK must be kty: "AKP" and its alg must equal the token's algorithm. RFC 9964 makes alg mandatory on these keys, and the AKP key type is shared with other algorithms, so this is what ties a key to ML-DSA and to one parameter set.
  • pub must have the exact length for the parameter set, so a key relabelled as a different set is refused before it is used.
  • A verification key must not carry priv. A JWKS that publishes a private seed is rejected instead of quietly used.
  • HS* next to a JWK source is still refused at construction, and alg: "none" is still refused everywhere.
CodeMeaning
alg_not_allowedThe token's algorithm is not in the allowlist
key_algorithm_mismatchThe key's alg is missing or names a different algorithm
invalid_keyNot an AKP key, wrong pub length, a priv on a verification key, or the runtime refused it
unsupported_algThe runtime's WebCrypto has no ML-DSA
invalid_signatureThe signature does not verify

Token size

ML-DSA signatures are large. Plan for it before you switch.

AlgorithmPublic keySignatureSignature in a token
ES25665 bytes64 bytes86 characters
ML-DSA-441,312 bytes2,420 bytes3,227 characters
ML-DSA-651,952 bytes3,309 bytes4,412 characters
ML-DSA-872,592 bytes4,627 bytes6,170 characters
  • Cookies: browsers cap a cookie near 4 KB, so an ML-DSA token does not fit in one. Send it in the Authorization header, or keep a session cookie and hold the token server-side.
  • Header limits: the Node adapter accepts 16 KiB of headers by default (maxHeaderBytes), which fits every parameter set. Many proxies cap a single header line at 8 KB; an ML-DSA-87 token with large claims gets close to that.
  • JWKS size: jwk() caps a fetched key set at 1 MiB, which is room for hundreds of ML-DSA keys.

Signing

createJwtSigner() accepts the same three algorithms, with a CryptoKey or an AkpJsonWebKey whose priv is the 32-byte seed. Minting tokens is authorization-server work, so the boundary described in the security API reference applies here too.

A migration order that works

  1. Fix TLS first

    Update the runtime, run the check above against production, and confirm the proxy in front of the app offers the hybrid group.

  2. List where you verify public-key signatures

    Search for jwk( and createJwtVerifier( and note each issuer.

  3. Add the ML-DSA algorithm next to the classical one

    Do this when an issuer announces post-quantum keys, after checking that the runtime supports ML-DSA.

  4. Check sizes on the path the token takes

    Cookies, proxy header limits, and any gateway that logs or stores tokens.

  5. Remove the classical algorithm

    Take it out of the allowlist once the issuer has stopped signing with it.

Edit this page on GitHub

Last updated