← Back to section · Tutorials & Labs

Project: A Software Update Package Verifier with ML-DSA Signatures

Design a signed manifest for software update packages: the publisher signs the manifest with ML-DSA-65, and the client verifies the signature first, then checks every file hash — installation only proceeds when both channels pass.

Published 22 November 2026 · 6 min read · PQ Frontier

Project: A Software Update Package Verifier with ML-DSA Signatures
AI-generated site artwork
Video explainer · Code examples and hands-on projects

Software updates are among the highest-stakes applications of digital signatures: hijack the update channel and an attacker can push a poisoned “genuine” build to every user. This project builds a minimal but structurally correct update package verifier. The publisher packs several files together with a manifest that lists each file name and its SHA-256 hash, then signs the manifest with ML-DSA-65. The client first verifies the signature, then re-checks every file against the manifest hashes, and only releases the files into the target directory when both steps pass. Small as it is, it demonstrates the full trust skeleton of real update systems, from OS patches to app stores. The boundary up front: this is a teaching implementation. The verification key is distributed by manually copying it, and there is no revocation, timestamping, or rollback protection, so it must not be used for real software distribution; in production use TUF (The Update Framework) or the signed update mechanisms built into each operating system.

Goal and Architecture

The project has two scripts. pack.py runs on the publisher side: it walks the release directory, computes the SHA-256 of each file, writes a JSON manifest of file names and hashes, and produces the update package directory together with a signature over the manifest. verify_install.py runs on the client: it reads the manifest and signature from the package, verifies the signature with a pre-provisioned ML-DSA public key, then recomputes each file’s hash and compares it against the manifest. Only if everything matches does it copy files into the install directory; any failure aborts immediately and removes any partially released files.

Before writing code, state the threat model — who exactly this verifier defends against. It defends against tampering along the distribution path: a compromised mirror server, a man-in-the-middle swapping the download in transit, a poisoned content-delivery cache. These attacks share one property: the attacker can change any byte in the package but does not hold the publisher’s private key. It does not defend against compromise of the publisher itself (once the private key leaks, the signature mechanism fails wholesale and only revocation and key rotation can help), nor against users who bypass verification to install packages of unknown origin. Writing these two “does not defend” items in the open is not pessimism; it gives every later design trade-off its reference point — why verification must precede extraction, and why the public key must be distributed out of band, are both answered by the threat model.

One design trade-off matters here: why not sign every file individually? Because signature operations are expensive and signatures are not small (an ML-DSA-65 signature is 3309 bytes); signing file by file is both slow and bloating. The manifest pattern converges trust onto a single point: the signature protects one small manifest file, while the bulk data is checked with far cheaper hashes. That is also why the manifest must contain each file’s hash and not just its name — the manifest is the sole carrier of trust, and the completeness of its fields determines the strength of the whole system.

Walking Through the Core Code

The only dependency is oqs: pip install oqs. Manifest construction and signing on the publisher side:

import oqs, hashlib, json, pathlib

SIG_ALG = "ML-DSA-65"

def build_manifest(folder: pathlib.Path) -> bytes:
    entries = []
    for p in sorted(folder.rglob("*")):
        if p.is_file():
            entries.append({
                "path": p.relative_to(folder).as_posix(),
                "sha256": hashlib.sha256(p.read_bytes()).hexdigest(),
            })
    return json.dumps({"files": entries}, sort_keys=True).encode()

with oqs.Signature(SIG_ALG) as signer:
    public_key = signer.generate_keypair()
    secret_key = signer.export_secret_key()
    manifest = build_manifest(pathlib.Path("release"))
    signature = signer.sign(manifest)

Client verification is a symmetric three lines: construct an oqs.Signature(SIG_ALG) object and call verify(manifest_bytes, signature, public_key), which returns a boolean. Three places are easy to get wrong. First, what is signed is the manifest’s canonical byte string: JSON serialization must be byte-identical on both ends. This project uses sort_keys=True and fixes UTF-8 encoding; the client must feed the exact bytes read from the package into verify and must never re-serialize its own JSON to verify — a single field-order or whitespace difference guarantees failure. Second, verify returning False is a normal return value, not an exception; the code must check it explicitly and abort, never treating “we called verify” as “verification passed”. Third, the public key is not part of the update package: it must be pre-distributed with the software itself or through a trusted channel. If the key travelled with the package, an attacker could replace the entire package including the key and still pass — the verifier answers “was this package released by whoever holds the private key”, while the authenticity of the public key is a separate problem that only out-of-band distribution can solve.

Running and Verifying

Run at least four acceptance experiments. First, the happy path: publish a package with three files, the client verifies it, files are released intact, and every hash matches. Second, tamper with a file: change one byte of a packaged file and the manifest hash check must fail and abort installation. Third, tamper with the manifest: change a file name inside the manifest without touching the files, and signature verification must fail — proving the signature genuinely covers the manifest. Fourth, the wrong key: substitute a non-matching public key and verification must fail. The four experiments guard four trust links respectively — file integrity, manifest integrity, signature authenticity, and key correspondence. Miss any one of them and the verifier is merely a good feeling.

Exercises

One: add a version number and release-time field to the manifest, and make the client reject packages whose version is lower than the installed one — the seed of rollback protection. Think about how an attacker uses “push an old, validly signed but vulnerable version” against you. Two: upgrade the flat manifest to a Merkle tree — the manifest stores only the root hash, each file carries a Merkle proof, and discuss what that saves when the file count reaches a hundred thousand. Three: swap ML-DSA-65 for SLH-DSA-SHA2-128s and measure the change in package size and verification time, understanding why firmware update scenarios nevertheless favour the conservative hash-based signature. Four, the advanced one: design a dual-signature scheme where ML-DSA and Ed25519 sign the same manifest and the client requires both to pass; spell out which class of risk it defends against and what it costs.

Summary

The skeleton of this verifier — a manifest converging trust, a signature protecting the manifest, hashes protecting the files, and the public key distributed out of band — is the skeleton of every real update system. Writing it once, attacking it once (the four tampering experiments), and extending it once will teach you more about “what should a signature actually sign” than ten introductory articles. The boundary, restated: a teaching implementation without revocation, timestamping, or professional audit; for real distribution, use a mature framework such as TUF.

Tags: ML-DSASoftware UpdatesDigital Signaturesliboqs