ML-DSA (FIPS 204) post-quantum signature verification (pure Python, no dependencies)
Project description
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.
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mldsa-1.0.1.tar.gz.
File metadata
- Download URL: mldsa-1.0.1.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
005a296d138448d9210a1f36bdc3190d30a19595f1bbf2b92aa537049d797a31
|
|
| MD5 |
0e6b91df82e178666adce7f0c938df5d
|
|
| BLAKE2b-256 |
029c252742c41fb96632e42d17ee790de522c628bc6b7124a3d1d9672950a3e0
|
Provenance
The following attestation bundles were made for mldsa-1.0.1.tar.gz:
Publisher:
publish-to-pypi.yml on FiloSottile/mldsa-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mldsa-1.0.1.tar.gz -
Subject digest:
005a296d138448d9210a1f36bdc3190d30a19595f1bbf2b92aa537049d797a31 - Sigstore transparency entry: 2256118974
- Sigstore integration time:
-
Permalink:
FiloSottile/mldsa-py@b84df503a3cf57ede27f33a81185a63305579a95 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/FiloSottile
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@b84df503a3cf57ede27f33a81185a63305579a95 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mldsa-1.0.1-py3-none-any.whl.
File metadata
- Download URL: mldsa-1.0.1-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cad0a75124c5a6f4c1efe0e013039e9b0a1a86a9bb8ec5a75d6cf71a45ce08f9
|
|
| MD5 |
a4cf1ac172c8b44e35dbfd9f5e34c5da
|
|
| BLAKE2b-256 |
ee1247c2ce5d1c133fbdb50d24c8fc10cd7a5f4000a6f57888565514051a97fb
|
Provenance
The following attestation bundles were made for mldsa-1.0.1-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on FiloSottile/mldsa-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mldsa-1.0.1-py3-none-any.whl -
Subject digest:
cad0a75124c5a6f4c1efe0e013039e9b0a1a86a9bb8ec5a75d6cf71a45ce08f9 - Sigstore transparency entry: 2256118987
- Sigstore integration time:
-
Permalink:
FiloSottile/mldsa-py@b84df503a3cf57ede27f33a81185a63305579a95 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/FiloSottile
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@b84df503a3cf57ede27f33a81185a63305579a95 -
Trigger Event:
push
-
Statement type: