Skip to content

An LLM wrote this crypto library's assembly, then Lean proved it

Maintainers behind pyca/cryptography released Verified Garbage, an experimental library whose assembly and formal proofs were both written by LLMs, humans only reviewing the specifications.

Maintainers behind pyca/cryptography, the library many Python tools rely on for TLS and crypto primitives, published Verified Garbage on 28 November. It reimplements every algorithm pyca/cryptography uses, including ML-KEM, ML-DSA, X25519, ECDH, ECDSA, RSA PKCS#1, RSA PSS, AES-GCM, ChaCha20Poly1305, SHA256 and HMAC-SHA256, in hand-written assembly for x86, x86-64, ARMv7, ARM64, PPC64le and RISCV64, with each implementation formally proved against a Lean specification.

Both the assembly and the Lean specifications were written by LLMs. Humans only reviewed the specifications, which the authors call the trusted computing base. The proofs check two things: that the assembly matches its specification, and that its instruction trace never depends on secret inputs, so there’s no data-dependent timing to leak a key through. It ships as two Rust crates, verified-garbage and rustls-verified-garbage, the second a drop-in rustls TLS provider.

Why it matters: this inverts the usual approach to trusting AI-written code. Rather than a human reviewing LLM output line by line, the authors let an LLM write the actual attack surface and used mechanical proof to pin down the properties that matter for crypto correctness and constant-time behaviour. If you write Rust and care about verified constant-time primitives, it’s worth watching.

The caveat: the authors call this an experiment, not a replacement for pyca/cryptography’s OpenSSL backend. The human-reviewed Lean specifications, not the LLM-written assembly, are still the part you have to trust.

Share

Related reading

More from The Wire

All briefs