Verify a detached ML-DSA-65 signature in Rust
Verify a release manifest using a separate public key and signature. Then change a byte and try a different key to see what the verifier rejects.
Prerequisites and commands
Install Rust and Cargo. The archive pins fips204 0.4.6 and includes Cargo.lock. Cargo may download dependencies on the first run. Run the commands in the extracted ml-dsa-verify folder.
Download the runnable source (ZIP)Archive checksum (SHA-256)
77e48505fcf9980af2dfbfa70cfe4de6b5c83c2fc92e49c7df37365b02f04a7b
cargo test --locked
cargo run --locked -- fixture demo
cargo run --locked -- verify demo/public.key demo/release.txt demo/release.sig
cargo run --locked -- verify demo/public.key demo/tampered.txt demo/release.sig
cargo run --locked -- verify demo/other.key demo/release.txt demo/release.sigWhat the tests show
The fixture command generates ephemeral keys and signs release.txt. It saves the raw public key and detached signature, leaving the secret key in memory for the duration of the fixture command. The verify command receives three files and uses the context evidentchain-release-demo-v1. The original message and the tampered copy differ by one byte.
- Original file, original key, original signature → VALID, exit 0.
- One changed byte or a different public key → INVALID, exit 1.
- Wrong key or signature length → ERROR, exit 2. Cargo tests also exercise a flipped signature byte.
If your result differs
Use a new directory name if demo already exists. An editor may change LF to CRLF, add a UTF-8 BOM, or add a newline. Compare the raw bytes and check the context before investigating the cryptographic library. This example expects a 1,952-byte public key and a 3,309-byte signature.
Scope and limits
Verification authenticates the bytes against the supplied key. For a real release, obtain the publisher’s public key or its fingerprint through a trusted channel. The signed text in this fixture names an artifact but contains no digest of its contents. This exercise covers the Rust library API and file handling. It makes no claim about node interoperability or FIPS certification.
Sources and further reading
From verification to participation
Try an exercise, follow updates, or see what tPQC is used for and how checkout works.