Docs / Guides

Hybrid TLS

tls configures Node and Go TLS to prefer the hybrid X25519MLKEM768 key exchange, so traffic recorded today cannot be decrypted later.

01Server and client

import https from 'node:https';
import nodeTls from 'node:tls';
import { tls } from 'pqlock';

https.createServer(tls.serverOptions({ key, cert }), app).listen(443);

const socket = nodeTls.connect(tls.clientConfig({ host: 'api.example', port: 443 }));
socket.on('secureConnect', () => console.log(tls.negotiatedGroup(socket)));   // "X25519MLKEM768"
import pqtls "github.com/Motiontic/pqs/packages/go/tls"

srvCfg, err := pqtls.ServerOptions(&tls.Config{Certificates: certs}, pqtls.Options{})
cliCfg, err := pqtls.ClientConfig(&tls.Config{ServerName: "api.example"}, pqtls.Options{})

conn, err := tls.Dial("tcp", "api.example:443", cliCfg)
log.Println(pqtls.NegotiatedGroup(conn.ConnectionState()))

The group list puts X25519MLKEM768 first and keeps X25519 as a fallback for clients that do not support it yet. negotiatedGroup shows which one a connection used, so the share of fallback connections can be tracked during migration.

Python

The Python tls module is not implemented in v0.1.0. Python services can use hybrid TLS through a proxy or load balancer that supports X25519MLKEM768.

02What hybrid TLS covers

Hybrid key exchange protects confidentiality in transit against harvest-now-decrypt-later. Certificates are still classical in v0.1; post-quantum certificates depend on the wider PKI and are tracked in the CBOM by pql scan.

pqlock v0.1.0 · unaudited preview · source of truth: spec/