DIGITAL SIGNATURE ALGORITHM (DSA)

Parameters: prime p, prime q such that q divides (p-1), g = h^((p-1)/q) mod p.
Private key x (0 < x < q). Public key y = g^x mod p.
H = hash of the message (SHA-1 here, reduced mod q).

Signing (random k, 0 < k < q):
    r = (g^k mod p) mod q
    s = k^-1 * (H + x*r) mod q
    signature = (r, s)

Verifying:
    w  = s^-1 mod q
    u1 = H * w mod q
    u2 = r * w mod q
    v  = ((g^u1 * y^u2) mod p) mod q
    signature is valid if v = r

Steps:
1. Generate parameters and keys.
2. Hash the message.
3. Sign with the private key to get (r, s).
4. Verify with the public key, v must be equal to r.

(Small numbers for demo only, real DSA uses 2048 bit p and 256 bit q.)
