Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

Sign a release manifest

A publisher signs a file containing release information. A user can check the file with the publisher’s verification key. Distribute that key through a trusted channel so the user can detect someone replacing both the file and its signature.

After setting up the Python environment, run this command from the repository root.

python docs/examples/sign.py
from quantaegis import MlDsa65, VerificationError

verify_key, signing_key = MlDsa65.keygen()
manifest = b"release=1.0"
context = b"release-manifest-v1"
signature = MlDsa65.sign(signing_key, manifest, ctx=context)

# Recipient
MlDsa65.verify(verify_key, manifest, signature, ctx=context)
print("Verified signature")

try:
    MlDsa65.verify(verify_key, b"release=2.0", signature, ctx=context)
except VerificationError:
    print("Rejected modified manifest")
else:
    raise AssertionError("Unexpected success with a different message")

The first verification succeeds. The next call verifies a different version number with the original signature and raises VerificationError. The context identifies the intended use of the signature. Both parties must use the same context and exactly the same message bytes. For files, read the content in binary mode to preserve encodings and line endings. Python API