Post-quantum key exchange (ML-KEM-768, FIPS 203)

Your API data is naked the moment TLS ends

HTTPS protects your data in transit — and does it perfectly. But the instant TLS terminates, the JSON body lies in plaintext across your logs, databases, CDN, proxies, and every third-party hop. Nen keeps it encrypted the whole way. One line of code. Same TLS you already trust.

What you write
Live Editable
fetch("/api/claims", {
  method: "POST",
  body:
});
What your CDN, logs & proxies see
{ "patient_id": "ptn_8821", "ssn": "412-55-9087", "diagnosis": "Type 2 Diabetes", "balance_due": 1840.00 }
Plaintext visible. TLS protected it in transit, but it terminates at the edge. This payload now sits entirely readable in your logs, your CDN, and every proxy.
x-nen-session: sid_3f9a… x-nen-nonce: ezNym8Y9V5Ox1gg3 x-nen-signature: aFaFzhXwqGYywYNCIKF1eJnMFw6zfgaa0wZM5CNSgcoR body: aFaFzhXwqGYywYNCIKF1eJnMFw6zfgaa0wZM5CNS gcoRD7ZgdZrJEE/1P3uq3RxD8zRivMs6WeIpMPSH SBaueTrvxxRX4l0r64ENRJ9MOPuBSQHbdHK16AtU n2Qu9IBEENlaKuKFC0ibNXWi7wZBigkxXeBj5mns b/J1+Hv+gQSHCg==
End-to-End Ciphertext. ChaCha20-Poly1305 over an ML-KEM-768 shared secret. Only the terminal API endpoint you trust can read this.
Edit the body — it's your data. Toggle above to watch it disappear from the wire.
$npxcreate-nen-app
The gap nobody guards

TLS did its job. Then it handed off your plaintext.

TLS encrypts the channel and stops at termination — the load balancer, the CDN edge, the serverless runtime. From there your payload travels in the clear. This isn't a flaw in TLS; it's simply where TLS's job ends. It's where Nen's begins.

Logs & observability
Request and response bodies captured in your logging pipeline stay ciphertext — never plaintext PII, PHI, or prompts sitting in a log index.
Databases & queues
Payloads you choose not to decrypt come to rest as ciphertext — and because the key exchange is ML-KEM, they stay safe against harvest-now-decrypt-later.
Proxies & third-party hops
Intermediaries — your CDN, edge, load balancer, internal proxies, and forwarders — see only base64 ciphertext, not the data inside.

You already wrote 90% of this

Swap fetch for nenFetch on the client. Wrap your route with withNen on the server. The handshake, key rotation, HMAC, and replay protection happen underneath. About ten lines, start to finish.

Client
import { nenFetch } from "@withnen/client";

const res = await nenFetch("/api/claims", {
  method: "POST",
  body: JSON.stringify(claim),
});
// payload encrypted before it leaves the tab
Server
import { withNen } from "@withnen/server";

export const POST = withNen(async (req, body) => {
  // body is already decrypted + verified
  return { ok: true };
});
// payload decrypted and ready for processing
Drop-in fetch replacement Mandatory per-request HMAC Encrypted SSE streaming Redis / edge sessions
Where the trust boundary actually sits

No overclaims. Ever.

A security engineer will find any exaggeration in thirty seconds — so we draw the line ourselves.

Everything between the two Nen endpoints sees only ciphertext. The two endpoints hold plaintext — by necessity, because someone has to read the data. The product's value is letting you choose where those endpoints are, pushing the trust boundary inward past the CDN, edge, load balancer, logs, and proxies — down to the specific code that genuinely needs the plaintext.

Browser
CDN / Edge
Proxy / Logs
Your API
TLS (Channel Encrypted)
TLS
TLS
Nen (Payload Ciphertext E2E)

What we will never claim: “even a compromised server sees only ciphertext.” The terminating server decrypts — that is the point of the middleware. See the full threat model for what Nen does and does not protect against.

Under the hood

What that one line actually does

Behind nenFetch is a full post-quantum handshake: an ML-KEM key encapsulation, an optional ML-DSA identity signature, and a derived ChaCha20-Poly1305 session. Run it step by step — change the payload, change the security level, and watch the ciphertext change with it.

Cryptographic Dashboard
Interactive Post-Quantum Key Exchange & Payload Encryption
Click Start to run demo 👇
Client Edge
Awaiting Key Generation
Nen Middleware
Awaiting Handshake
nen-engine.log
Performance & Scale

Designed for the edge.Built to be ignored.

Post-quantum cryptography sounds slow. We made it invisible. Nen sustains thousands of encrypted requests with sub-millisecond crypto overhead.

Sustained Throughput

Nen is highly optimized for concurrent workloads. Built-in session caching and efficient key derivation means the server scales effortlessly across thousands of active connections without sacrificing latency.

Peak Throughput
0
req/s
At concurrency 50 with 0% errors.
ML-KEM Handshake
0.0
ms
Initial key exchange latency.

Microsecond Overhead

By leveraging native bindings and optimized WebAssembly for ChaCha20-Poly1305, encrypting payloads takes fractions of a millisecond. Our wire format adds minimal base64 padding.

Crypto Engine
0.000
ms/op
To encrypt & decrypt a typical payload.
Wire Size Inflation
0.0
x
For a base64 encoded 1KB JSON structure.
PayloadPlaintextWire SizeOverheadp50 Latencyp99 Latency
1KB1.0 KB1.5 KB
1.437x
1.486 ms4.969 ms
10KB10.0 KB13.5 KB
1.344x
1.72 ms9.158 ms
100KB100.0 KB133.5 KB
1.334x
5.654 ms19.918 ms
500KB500.0 KB666.8 KB
1.334x
21.487 ms29.842 ms

Real-World Scenarios

We don't just benchmark simple loops. We evaluate Nen against demanding application patterns like session churn, connection bursts, and extended lifetime sessions to ensure stability.

Concurrent Handshakes

297.61hs/s

Sustained ML-KEM-768 handshakes per sec during peak burst (C=50).

Key Rotation

36.469ms

p50 latency to renegotiate keys mid-session while under load. Normal requests stayed at 25.943ms.

Long-Lived Sessions

-0.16ms drift

Negligible latency drift over 1.8s session (1000 reqs). Growth: 147.64MB.

Multi-User Burst

145.85req/s

Aggregate throughput when 100 distinct users simultaneously execute full CRUD lifecycles.

Session Churn

252.22sess/s

Sustained create/destroy cycles per second over 2540 sessions. 0 errors.

Measured on: darwin 25.5.0 • Node v25.2.0 10 CPUs • dev-server (single instance)
The wedge — Secure AI

Encrypt LLM prompts across your own stack

AI apps stream prompts, PHI, legal context, and financial records through many hops of your own infrastructure. Nen keeps prompts and streamed tokens as ciphertext from the user's browser to the one backend service you trust to call the model.

Honest scope: this hides prompts from your edge, logs, and proxies. It does not hide them from the model provider — they must decrypt to run inference.

See the Secure AI page
const ai = createSecureOpenAI({ /* ... */ });

const stream = ai.chat.completions.stream({
  messages,
});

// prompts and streamed tokens are E2E-encrypted
// from the browser to YOUR backend — your edge,
// CDN, logs, and proxies see only ciphertext.

Who reaches for this

Security and platform engineers at fintech, healthtech, and AI companies who just got a PQC-readiness or data-handling audit questionnaire — and need documentation and proof as much as code.

FinTech & Banking
Keep transaction payloads as ciphertext past TLS termination — through logs, proxies, and at-rest stores — so harvested ciphertext stays safe against future quantum decryption.
Healthcare
ePHI stays encrypted from the device to the one service that must read it, shrinking the plaintext-exposed surface your auditor asks about.
AI Platforms
Encrypt prompts and streamed responses across your own infrastructure with secure SSE streaming — a niche most PQC projects never reach.

Features

Post-quantum key exchange

ML-KEM-768 (FIPS 203) for the handshake and ML-DSA-65 (FIPS 204) for opt-in identity. Recorded ciphertext stays safe against harvest-now-decrypt-later.

Base64 wire format

The Wasm core outputs base64 directly — under 1.4x wire bloat versus raw, not the ~4.9x of number-array serialization.

Mandatory per-request HMAC

Every request is signed and verified with HMAC-SHA256 over METHOD, PATH, TIMESTAMP, and NONCE. HMAC is mandatory — the auth-downgrade bypass is closed.

Edge-ready sessions

Pluggable SessionStore with in-memory, Redis, and Upstash (REST, no TCP) backends — stateless horizontal scaling, including Edge runtimes like Workers and Vercel Edge.

Encrypted SSE streaming

nenStream encrypts each chunk with ChaCha20-Poly1305 and an XOR-counter nonce, decrypting tokens as they arrive.

Drop-in integration

withNen middleware and nenFetch client for Next.js App Router — about ten lines from npx create-nen-app to a working handshake.

Keep TLS. Add the part it can't reach.

The free SDK gives you the protection. The docs give you the proof your auditor wants. Both ship today.