Skip to main content

mldsa-py

pip install mldsa

This is a pure-Python production implementation of ML-DSA (FIPS 204) post-quantum signature verification.

It does not provide key or signature generation, because secrets can't be handled in constant-time in Python.

from mldsa import VerificationKey, VerificationError

vk = VerificationKey(verification_key_bytes)

try:
    vk.verify(signature, message)
except VerificationError:
    print("invalid signature!")

The parameter set (ML-DSA-44, ML-DSA-65, or ML-DSA-87) is inferred from the verification key size, or it can be specified explicitly.

from mldsa import ParameterSet, VerificationKey

vk = VerificationKey(verification_key_bytes, parameters=ParameterSet.ML_DSA_87)
vk.verify(signature, message, context=b"example.com/foo token")

The non-test code is a single-file module of less than 500 lines, with no dependencies.

It works with Python 3.8 and later.

mldsa-minimap-3col

Development

To run tests, use

uv run ruff check
uv run ruff format --check
uv run ty check
uv run pytest
go install github.com/FiloSottile/mostly-harmless/muzoo@latest
muzoo -mutations tests/testdata/mutations test -- uv run pytest -x

This project uses tests from Wycheproof.

To run benchmarks, use

uv run tests/bench_mldsa.py

The output is in the format of Go benchmarks, and matches the sub-benchmarks of BenchmarkVerify in crypto/mldsa, so the two can be compared with

go test -run=^$ -bench=BenchmarkVerify -cpu=1 -count=10 crypto/mldsa | tee go.txt
uv run tests/bench_mldsa.py -count=10 | tee py.txt
benchstat -ignore=goos,goarch,pkg,cpu go.txt py.txt

License

This work is marked CC0 1.0 Universal. To view a copy of this mark, visit creativecommons.org.

Alternatively, you may use this source code under the terms of the 0BSD license that can be found in the LICENSE file. In short, you can do whatever you want with this code.

Metadata

Release files for mldsa 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mldsa 1.0.1
File Size Uploaded Provenance Actions
mldsa-1.0.1.tar.gz 7.9 kB With provenance Details for mldsa-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mldsa 1.0.1
File Interpreter ABI Platform Actions
mldsa-1.0.1-py3-none-any.whl Python 3 none any Details for mldsa-1.0.1-py3-none-any.whl

Total release size: 16.9 kB

Release files / mldsa-1.0.1.tar.gz

Download URL mldsa-1.0.1.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
005a296d138448d9210a1f36bdc3190d30a19595f1bbf2b92aa537049d797a31
BLAKE2b-256 checksum
How to use checksums
029c252742c41fb96632e42d17ee790de522c628bc6b7124a3d1d9672950a3e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 26, 2026.

Transparency log

Release files / mldsa-1.0.1-py3-none-any.whl

Download URL mldsa-1.0.1-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cad0a75124c5a6f4c1efe0e013039e9b0a1a86a9bb8ec5a75d6cf71a45ce08f9
BLAKE2b-256 checksum
How to use checksums
ee1247c2ce5d1c133fbdb50d24c8fc10cd7a5f4000a6f57888565514051a97fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 26, 2026.

Transparency log

Security for mldsa 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mldsa-1.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page