dilithium-py
A pure python implementation of ML-DSA (FIPS 204)
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-pyuv
uv add dilithium-pypoetry
poetry add dilithium-pyInstalling 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
Tags
More Cryptography packages
Certifi provides Mozilla's curated collection…
copyleft · top 100 on PyPI
cryptographycryptography provides cryptographic recipes and…
permissive · top 100 on PyPI
rsaPure-Python RSA encryption, decryption,…
permissive · top 1,000 on PyPI
pyOpenSSLpyOpenSSL wraps OpenSSL's SSL/TLS functionality…
permissive · top 1,000 on PyPI
azure-identityProvides Microsoft Entra ID token-based…
unclear · top 1,000 on PyPI
PyNaClPyNaCl provides Python bindings to libsodium…
permissive · top 1,000 on PyPI
SLH-DSAPure Python implementation of the SLH-DSA…
copyleft · top 15,000 on PyPI
pqcryptoProvides Python bindings to post-quantum…
permissive · top 15,000 on PyPI
pysodiumPysodium is a Python wrapper around libsodium…
permissive · top 15,000 on PyPI
pycryptodomexPyCryptodomex provides low-level cryptographic…
permissive · top 1,000 on PyPI
pure25519Pure-Python implementation of Curve25519 and…
permissive · top 15,000 on PyPI
ed25519-blake2b-forkProvides Python bindings to Ed25519 digital…
permissive · top 15,000 on PyPI
securesystemslibSecuresystemslib provides a cryptography…
permissive · top 5,000 on PyPI
josepyImplements the JOSE (JSON Object Signing and…
permissive · top 5,000 on PyPI
endesiveEndesive signs and verifies digital signatures…
unclear · top 15,000 on PyPI
lightdsaLightDSA provides digital signature generation…
permissive · top 15,000 on PyPI