RS256 and ES256 are broken by Shor's algorithm on a quantum computer. @pq-jwt/core replaces them with NIST-standardized ML-DSA and SLH-DSA — plus Express middleware, hybrid migration, and full JOSE.
RS256 relies on integer factorization. ES256 relies on elliptic curve discrete log. Shor's algorithm (1994) solves both in polynomial time on a quantum computer.
If you've used jsonwebtoken before, you already know how to use pq-jwt. Same sign / verify / decode pattern. Typed errors. Full TypeScript.
import { generateKeyPair, sign, verify } from '@pq-jwt/core'; // Generate once — store in your secrets manager const { publicKey, secretKey } = generateKeyPair('ML-DSA-65'); // Sign a token — identical to jsonwebtoken API const token = sign( { sub: 'user_42', role: 'admin', org: 'acme' }, secretKey, { algorithm: 'ML-DSA-65', // NIST FIPS 204 expiresIn: '1h', notBefore: '0s', // v1.0.6 issuer: 'auth.myapp.com', audience: 'api.myapp.com', } ); // Verify — throws TypedError on failure const { payload } = verify(token, publicKey, { issuer: 'auth.myapp.com', audience: 'api.myapp.com', clockTolerance: 10, // distributed system clock skew }); console.log(payload.sub); // 'user_42' console.log(payload.role); // 'admin'
import { verify, importKey, TokenExpiredError, SignatureError, InvalidTokenError, } from '@pq-jwt/core'; const PK = importKey(process.env.PQ_PUBLIC_KEY!); export function pqAuth(req, res, next) { const token = req.headers.authorization?.slice(7); if (!token) return res.status(401).json({ error: 'Missing token' }); try { const { payload } = verify(token, PK, { issuer: 'auth.myapp.com', clockTolerance: 10, }); req.user = payload; next(); } catch (e) { if (e instanceof TokenExpiredError) return res.status(401).json({ error: 'Expired' }); if (e instanceof SignatureError) return res.status(403).json({ error: 'Invalid' }); res.status(400).json({ error: e.message }); } }
Four packages under the PQ-JWT ecosystem — from low-level JWT signing to Express APIs, hybrid classical→PQ migration for frontends, and a complete post-quantum JOSE stack.
npm install @pq-jwt/corepqAuth() with typed errors, role guards, and custom token extractors — wire PQ auth into Node APIs in minutes.npm install @pq-jwt/expressnpm install @pq-jwt/hybridnpm install @pq-jose/joseAfter a 7-year open competition, NIST selected and standardized these algorithms in August 2024. The NSA mandates them for all national security systems by 2030.
Post-quantum tokens are larger. Signing is slower. These are real trade-offs — documented clearly so you can make the right architectural decisions.
| Algorithm | Sign | Verify | Token Size | Quantum Safe |
|---|---|---|---|---|
| ECDSA-P256 (ES256) | < 1ms | < 1ms | ~0.5 KB | ✗ Broken |
| RSA-2048 (RS256) | < 2ms | < 1ms | ~0.5 KB | ✗ Broken |
| ML-DSA-44 | 8.1ms | 2.1ms | ~3.5 KB | ✓ FIPS 204 |
| ML-DSA-65 default | 10.7ms | 2.9ms | ~4.5 KB | ✓ FIPS 204 |
| ML-DSA-87 | 11.1ms | 4.8ms | ~6.2 KB | ✓ FIPS 204 |
| SLH-DSA-SHA2-128s | 5,373ms | 5.8ms | ~10.8 KB | ✓ FIPS 205 |
The threat is not immediate. The migration pressure is. Start evaluating tooling now so you're not rushing in 2027.
MIT license. JavaScript, TypeScript & Node.js. Express ready. Built on audited cryptography. Maintained by Sachin Ruhil.