Skip to content
Optimal Lab

Security · interactive

Digital signatures

Alice signs a hash of her message with her private key. Anyone with her public key can check it. This uses real RSA maths with tiny numbers so you can follow it; real keys are thousands of bits.

Signing (Alice)

“Pay Bob $10”

signature = hash^d mod n

= 938

Received by Bob

“Pay Bob $10”

signature 938

Bob hashes the message

1244

signature^e mod n (Alice's public key)

938^17 mod 3233 = 1244

1244 = 1244: valid signature

Alice's public key: n = 3233, e = 17. Her private d = 2753 never leaves her.

Alice's public key turns the signature back into the hash of the message. They match: Alice sent it, and it wasn't changed.

Scenario

Step 3 of 4

  1. 1

    Hash the message

    A fixed-size fingerprint. Change one character and the hash changes completely.

    SHA-256(message)

  2. 2

    Sign with the private key

    Only the holder of the private key can produce a value that the public key maps back to the hash.

    Signing isn't encrypting: the message stays readable.

  3. 3

    Verify with the public key

    Anyone can check: recompute the hash, apply the public key to the signature, compare.

    Proves who signed and that nothing changed.

  4. 4

    Trust the key itself

    A signature only proves which key signed. Certificates (TLS), key servers or pinned keys tie the key to a real identity.

    Modern choices: Ed25519, ECDSA, RSA-PSS.

In production

Tools and technologies

Signatures secure TLS, software updates and tokens.

Not tied to one language — use these names when you search docs or design a system.