Skip to main content

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.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mldsa-1.0.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mldsa-1.0.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file mldsa-1.0.0.tar.gz.

File metadata

  • Download URL: mldsa-1.0.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for mldsa-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9c830c6b94e60c5c2fce4cda1a30a7a1f849989eb1c48aa371935bb7cabd517c
MD5 8fb8f8fb84c0955af0fb5a2a21922400
BLAKE2b-256 2a55170f6ff5cf719357ca815dd88dc264d36550b8692116e798de17bfb0091d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mldsa-1.0.0.tar.gz:

Publisher: publish-to-pypi.yml on FiloSottile/mldsa-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mldsa-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: mldsa-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for mldsa-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd618fa0dd2597c7cf10ef5b2dcef8a89344176dd88670db035d57e9e00a33de
MD5 914476520d61d90bfa35e7e7f9b877ac
BLAKE2b-256 c51f7488bd5e58506d8004609392b7cd51c84aad561951987b3d88000effbac7

See more details on using hashes here.

Provenance

The following attestation bundles were made for mldsa-1.0.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on FiloSottile/mldsa-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page