Sign a message with your private key, let anyone verify it with your public key. Learn it, compute it, and test yourself — all here.
A digital signature proves who sent a message and that it wasn't tampered with. It is the mirror image of encryption: you sign with your private key, and anyone can verify with your public key.
ElGamal signatures (Taher ElGamal, 1985) are built on the same hard problem as Diffie–Hellman: the discrete logarithm problem. The scheme is the ancestor of the modern DSA standard.
Secret. Only the owner can produce a valid signature.
Published. Anyone can check a signature, nobody can forge one.
| Encryption | Signature | |
|---|---|---|
| Goal | secrecy | authenticity + integrity |
| Sender uses | recipient's public key | own private key |
| Receiver uses | own private key | sender's public key |
| Output | ciphertext | signature (r, s) |
In signing, the message itself is usually sent in the clear — the signature travels alongside it as a proof of origin.
Given g, p and y = gˣ mod p, it is easy to compute y but believed infeasible to recover the exponent x (the discrete logarithm) when p is large. Without x, an attacker cannot construct the value s that makes the verification equation balance.
1 < x < p−1.y = gˣ mod p.gcd(k, p−1) = 1.m.From the signing equation, s·k ≡ m − x·r (mod p−1), so m ≡ x·r + k·s (mod p−1). By Fermat's little theorem, exponents of g can be taken modulo p−1, therefore:
| Symbol | Role | Computed as | Secret? |
|---|---|---|---|
| p, g | domain params | chosen | public |
| x | private key | chosen | secret |
| y | public key | gˣ mod p | public |
| k | ephemeral key | random, gcd(k,p−1)=1 | secret |
| r | signature part 1 | gᵏ mod p | public |
| s | signature part 2 | (m−x·r)·k⁻¹ mod(p−1) | public |
Sign the message m = 7 with prime p = 23, generator g = 5, private key x = 6, and ephemeral key k = 3.
Both sides match, so the verifier accepts the signature as authentic.
Try changing any single value (say m = 8) in the Calculator tab — verification will fail, showing how the signature binds to the exact message.