Post-Quantum ML-DSA Signatures in Go 1.27: How crypto/mldsa and TLS 1.3 Work and Why They Stay Off by DefaultNote · digest for November 22
Symbolic composition of post-quantum cryptography in Go 1.27 featuring a secure TLS 1.3 channel and the lattice-based ML-DSA algorithm
Note3 sections≈ 5 min

Post-Quantum ML-DSA Signatures in Go 1.27: How crypto/mldsa and TLS 1.3 Work and Why They Stay Off by Default

One top-level post-quantum signature in Go 1.27 takes over four kilobytes—more than three standard Ethernet packets compared to tiny Ed25519. In August 2026, the Go team added ML-DSA post-quantum signatures straight into the standard library, yet simply recompiling your service changes nothing in your TLS traffic.

And that's a good thing. If the compiler silently switched handshakes to the new algorithm, older clients would immediately fail to connect.

Why Add Signatures When Post-Quantum Key Exchange Already Exists

Post-quantum cryptography covers algorithms designed to resist Shor's algorithm on future quantum computers. Go already had ML-KEM key exchange, and version 1.27 adds MLKEM1024 for Config.CurvePreferences.

ML-KEM and ML-DSA solve different threats, though. ML-KEM protects captured traffic from being decrypted years later. ML-DSA signatures, standardized in NIST FIPS 204, prove a server's identity right now so an attacker can't forge an X.509 certificate (the server's digital ID holding its key and CA signature) during the handshake.

What Landed in the Standard Library

The update touches four packages. The centerpiece is crypto/mldsa with FIPS 204 key generation, signing, and verification. crypto/x509 now understands ML-DSA keys and signatures in certificates. crypto/tls adds three SignatureScheme values for TLS 1.3 handshakes: tls.MLDSA44, tls.MLDSA65, and tls.MLDSA87. Finally, crypto gains the crypto.MLDSAMu constant for External μ ML-DSA signing mode.

The private key *mldsa.PrivateKey implements the standard crypto.Signer interface:

package main

import (
    "crypto/mldsa"
    "fmt"
    "log"
)

func main() {
    // Generate ML-DSA-65 keys (baseline NIST level)
    sk, err := mldsa.GenerateKey(mldsa.MLDSA65())
    if err != nil {
        log.Fatal(err)
    }
    msg := []byte("post-quantum signature in Go 1.27")
    // Context (up to 255 bytes) separates signature domains
    opts := &mldsa.Options{Context: "demo-tls-service"}

    sig, err := sk.Sign(nil, msg, opts)
    if err != nil {
        log.Fatal(err)
    }
    pub := sk.PublicKey().Bytes()
    pk, err := mldsa.NewPublicKey(mldsa.MLDSA65(), pub)
    if err != nil {
        log.Fatal(err)
    }
    if err := mldsa.Verify(pk, msg, sig, opts); err != nil {
        log.Fatal("invalid signature:", err)
    }
    fmt.Printf("OK: pub=%dB, sig=%dB\n", len(pub), len(sig))
}

The Context string in mldsa.Options must match during signing and verification, preventing a signature from one protocol from being replayed in another. Here is the size cost of quantum resistance in bytes:

AlgorithmSecurity LevelPublic KeySignatureKey Seed
Ed25519Classic (~128-bit)32 B64 B32 B
MLDSA44NIST Category 2 (~128-bit)1,312 B2,420 B32 B
MLDSA65NIST Category 3 (~192-bit)1,952 B3,309 B32 B
MLDSA87NIST Category 5 (~256-bit)2,592 B4,627 B32 B

The Certificate and CertificateVerify handshake messages grow noticeably heavier. MLDSA65 is treated as the baseline choice, while MLDSA87 targets CNSA 2.0 compliance.

Why Services Don't Switch Automatically and How to Roll Out Safely

Rebuilding on Go 1.27 leaves your existing ECDSA/RSA certificates untouched. To turn on ML-DSA, you need TLS 1.3, new X.509 certificates, and support on both ends. Using GetCertificate lets you roll it out smoothly without breaking legacy clients:

func buildTLSConfig(pqCert, classicCert tls.Certificate) *tls.Config {
    return &tls.Config{
        // ML-DSA only works over TLS 1.3
        MinVersion: tls.VersionTLS13,
        GetCertificate: func(
            hello *tls.ClientHelloInfo,
        ) (*tls.Certificate, error) {
            // Serve ML-DSA to clients advertising it in ClientHello
            if slices.Contains(hello.SignatureSchemes, tls.MLDSA65) {
                return &pqCert, nil
            }
            return &classicCert, nil
        },
    }
}

Modern Go 1.27 clients will advertise tls.MLDSA65 and receive the post-quantum certificate, while older clients connect smoothly with the classic key.

What to Check Before Testing ML-DSA

  • Connections are restricted to TLS 1.3 (MinVersion: tls.VersionTLS13).
  • X.509 certificates with ML-DSA keys have been issued.
  • The peer (client or proxy) supports MLDSA44, MLDSA65, or MLDSA87.
  • Network limits can handle larger handshake packets.

Right now, ML-DSA in Go 1.27 is great for internal mTLS links where you control both sides, or for getting ready for NIST and CNSA 2.0 without third-party libraries. On public HTTPS sites, there's no rush yet: mainstream browsers and public CAs haven't adopted these trust chains.

Want a deep diveVotes help us choose what to break down in detail. This material has 0 votes.
Sources · 4