Skip to main content

mldsa-mu

A small Python library for generating external μ (mu) values as specified by ML-DSA (FIPS 204).

This library is intended for use in systems that need to compute μ outside of a full ML-DSA signing implementation (for example: KMS-style services, HSM adapters, or test tooling).


What is μ?

In ML-DSA, the value μ is defined as:

μ = SHAKE256(tr || M', 64)

where:

  • tr = SHAKE256(public_key, 64)
  • M' = 0x00 || len(context) || context || message

This library implements exactly that construction.


Features

  • Deterministic μ generation per FIPS 204
  • Supports optional domain-separation context
  • Utilities for extracting raw public keys from (base64) PKIX / SPKI encodings

Installation

pip install mldsa-mu

Usage

Example: generate μ from a raw public key

from mldsa_mu import generate

public_key = b"\x01" * 64
message = b"hello world"

mu = generate(public_key, message)
print(mu)

Example: generate μ with a domain-separation context

from mldsa_mu import generate

public_key = b"\x02" * 64
message = b"important message"
context = b"my-protocol-v1"

mu = generate(public_key, message, context=context)
print(mu)

Example: extract raw public key from DER-encoded PKIX (SPKI) and generate μ

from mldsa_mu import generate, public_key_from_pkix

with open("public_key.spki.der", "rb") as f:
    spki_der = f.read()

public_key = public_key_from_pkix(spki_der)

mu = generate(public_key, b"hello world")
print(mu)

Example: extract raw public key from base64-encoded PKIX (SPKI)

from mldsa_mu import generate, public_key_from_pkix_b64

spki_b64 = (
    "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A..."
)

public_key = public_key_from_pkix_b64(spki_b64)

mu = generate(public_key, b"hello world")
print(mu)

Development

Create (and remove if needed) the Hatch dev environment.

hatch env remove dev
hatch env create dev

Run tests: hatch run dev:fmt

Run code linting: hatch run dev:pytest

Run code type checking: hatch run dev:typing

License

mldsa-mu is distributed under the terms of the MIT license.


Python written by humans. English written by AI.

Metadata

Release files for mldsa-mu 1.0.0

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-mu 1.0.0
File Size Uploaded Provenance Actions
mldsa_mu-1.0.0.tar.gz 3.5 kB Without provenance Details for mldsa_mu-1.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 8.5 kB

Release files / mldsa_mu-1.0.0.tar.gz

Download URL mldsa_mu-1.0.0.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a860c057023e50990607aa164a1f9a9f1cc2c55cad6efd30382f58dd0271ad89
BLAKE2b-256 checksum
How to use checksums
8221c78c9ebd3025f623f3c21cc920ec01ac5b8143c474ad0dbf70fe18ddfe52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.2 cpython/3.14.2 HTTPX/0.28.1

Release files / mldsa_mu-1.0.0-py3-none-any.whl

Download URL mldsa_mu-1.0.0-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d0e6f5534744bbdaac9c2d91297a3ef92d559328e82dd9cca7708e8e3e762eb1
BLAKE2b-256 checksum
How to use checksums
d6647364810b0a3edafdddd48cf3b86597f68d836cfc9850d76b9ca48ef38c0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.2 cpython/3.14.2 HTTPX/0.28.1

Security for mldsa-mu 1.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.0 This release

2 release files No 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