skillfed

dilithium-py

A pure python implementation of ML-DSA (FIPS 204)

dilithium-py v1.4.0 156.5K downloads/30d#10,781 on PyPI128
Permissive license MIT Active released

What it is and what it does

This package provides a pure-Python implementation of ML-DSA (the NIST standardized version of Dilithium from FIPS 204) and the original CRYSTALS-Dilithium specification. It exposes three core functions: keygen() to generate keypairs, sign() to create signatures, and verify() to validate them. The implementation passes all known test vectors (KATs) for both ML-DSA and Dilithium v3.1.

The package is explicitly designed for educational purposes and learning about post-quantum lattice-based cryptography. The code is not constant-time and not optimized for performance; instead, it prioritizes readability and close correspondence with the published specifications. The disclaimer is unambiguous: do not use this for actual cryptographic applications. It includes optional support for the xoflib package for better performance with XOF operations, and uses pycryptodome for AES256 CTR DRBG if deterministic randomness is needed.

Use it for:

  • Learning how ML-DSA and Dilithium work by reading well-commented, specification-aligned code
  • Experimenting with post-quantum signature schemes in a controlled, educational environment
  • Comparing the differences between the original Dilithium v3.1 and the standardized ML-DSA
  • Testing interoperability with ML-DSA implementations by validating against official KAT vectors
  • Prototyping quantum-resistant signature workflows before deploying production systems

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

A pure-Python implementation of ML-DSA (FIPS 204) and CRYSTALS-Dilithium post-quantum digital signature algorithms for educational study and experimentation.

Yes, if your goal is learning or experimentation with post-quantum cryptography. The implementation is actively maintained, has no runtime dependencies, and passes all official test vectors. However, do not install for production cryptographic use—the package explicitly warns against this and is not designed to resist side-channel attacks. For production ML-DSA, use a hardened C or Rust implementation.

Install

dilithium-py on PyPI

pip

pip install dilithium-py

uv

uv add dilithium-py

poetry

poetry add dilithium-py

Installing dilithium-py

Before you install

Low install friction with no runtime dependencies. Active maintenance (last commit 2026-06-09) and recent releases. Suitable for learning and experimentation.

License in practice

MIT license (permissive). You may use, modify, and distribute freely with minimal restrictions.

Quickstart

pip install dilithium-py

from dilithium_py.ml_dsa import ML_DSA_44

pk, sk = ML_DSA_44.keygen()
msg = b"Your message"
sig = ML_DSA_44.sign(sk, msg)
assert ML_DSA_44.verify(pk, msg, sig)

Requires Python 3.9 or later. Not suitable for production cryptographic applications—use only for learning and experimentation.

Verify before relying

  • Whether pycryptodome is an optional or required runtime dependency for deterministic CSRNG use
  • Whether xoflib is required or optional for production-grade performance
  • Actual performance characteristics in real-world scenarios beyond the benchmarks shown

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 240 days since the last release
Last repo commit
First released
Downloads 156,519/month — #10,781 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: dilithium_py-1.4.0-py3-none-any.whl

Programming Language :: Python :: 3Topic :: Security :: Cryptography

Tags

post-quantum cryptographyML-DSA signaturedilithium implementationNIST FIPS 204lattice-based signaturesquantum-resistant signingeducational cryptography
post-quantumeducationallattice-crypto

More Cryptography packages