v150 · Web Cryptography

ML-DSA signatures

Module-Lattice Digital Signature Algorithm (FIPS 204) is the post-quantum replacement for ECDSA/RSA signatures. Sign a message, verify it, then flip the tamper switch to prove a modified message fails verification. Larger parameter sets trade bigger signatures for higher security levels — see the real byte sizes below.

Pick a parameter set and sign the message.

Public key — via getPublicKey(privateKey)

Signature

Verification of the (possibly tampered) message

not verified

const alg = { name: "ML-DSA-65" };
const { privateKey, publicKey } =
  await crypto.subtle.generateKey(alg, true, ["sign", "verify"]);

// Derive the public key from the private key alone (new getPublicKey())
const derivedPub = await crypto.subtle.getPublicKey(privateKey, ["verify"]);

const message = new TextEncoder().encode("Transfer 100 credits…");
const signature = await crypto.subtle.sign(alg, privateKey, message);

const ok = await crypto.subtle.verify(alg, derivedPub, signature, message);
// ok === true; change one byte of `message` and verify() returns false

see also

implementation reference

Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗