Tool 7 of 8

Digital signatures

Alice signs with her private key. Anyone with her public key can check that the message comes from her and was not changed. Only Alice can produce the signature.

Your challengeFind three different ways to make a signature check fail, and explain why Bob can fake an HMAC tag from Alice but not her signature.
Visualise

Signing and verifying

Genuine ECDSA P-256 Simulated network
Message
→
HashingSHA-256
→
SigningAlice's private key
→
Signature
Alice
signer
Network Simulated
Bob
verifier

Conceptual view The browser's ECDSA operation computes the SHA-256 hash internally and signs it. The hash shown here is that same SHA-256 value, displayed so you can see the step.

Experiment

Signature lab

Genuine signing and verification Simulated network and attacker
Alice
signs
Network Simulated
Signature in transit
(nothing sent)
Mallory can…
Bob
verifies
Verify with

What happened

Experiment

Could Bob fake it? HMAC versus signature

Genuine

Bob wants to claim that Alice wrote: "Alice owes Bob €5 000". Let him try both mechanisms.

With HMAC (Tool 2)

Alice and Bob share one secret key. Bob computes the tag himself.

With a digital signature

Bob only has Alice's public key. He can only sign with his own private key.

Explain

Key ideas

Sign with the private key

Only Alice holds her private key, so only she can create a signature that matches her public key.

Verify with the public key

Anyone with Alice's public key can verify. No secret is needed to verify.

Hashing inside

The message is first hashed (Tool 1); the hash is signed. A changed message gives a different hash, so the signature no longer fits.

Integrity and authenticity

A valid signature shows the message was not changed and was signed with the private key belonging to that public key.

Different each time

ECDSA uses a fresh random number for each signature. Signing the same message twice gives two different signatures, and both are valid. This is not a bug.

Non-repudiation, with limits

Because only Alice has the private key, she cannot easily deny signing. But only if her key was not stolen, and only if we know the public key really is hers (Tool 8). Laws such as eIDAS add requirements for legally binding signatures.

Encrypting versus signing

Asymmetric encryption (Tool 4)Digital signature
GoalConfidentiality: only the recipient can readIntegrity and authenticity: who wrote it, unchanged
Sender usesThe recipient's public keyTheir own private key
Receiver usesTheir own private keyThe sender's public key
Message readable on the network?NoYes, a signature hides nothing

Common misconceptions

"A signed message is encrypted."
No. Everyone on the network can read it. To hide it too, you must also encrypt it.
"Signing means encrypting with the private key."
This old explanation only roughly fits RSA. Signing is its own operation; ECDSA, used here, cannot encrypt at all.
"A valid signature proves the content is true or safe."
It only proves who signed and that nothing changed. Malware signed with a stolen key still has a valid signature.
Apply

Where you meet digital signatures

Code signing

Windows shows the "verified publisher" of a program from its signature. Software updates are signed so that only the vendor can publish them.

HTTPS

The server signs the handshake, and Certificate Authorities sign certificates (Tool 8).

Signed documents

PDF signatures and e-ID cards (such as the Luxembourg eID or LuxTrust) create legally recognised electronic signatures.

E-mail and Git

S/MIME and PGP sign e-mails; developers sign Git commits so others know who really wrote them.

Challenges

1. Three ways to fail

In the lab, make the verification fail in three different ways. For each one, explain in one sentence what Bob can conclude.

Show answer
Changed message (content was modified), changed signature (signature corrupted or forged), wrong public key (not signed by the owner of that key). In each case Bob only knows "do not trust this"; he cannot tell exactly which happened.
2. The secret contract

Alice wants to send Bob a contract that only Bob can read, and that Bob can prove she signed. Which keys does she use?

Show answer
She signs with her own private key (authenticity), then encrypts for Bob with Bob's public key (confidentiality, in practice using hybrid encryption).
3. Whose key is it?

Mallory publishes a public key and claims it is Alice's. Bob verifies a message signed by Mallory with this key: valid! What went wrong?

Show answer
The signature is mathematically valid, but the public key is not Alice's. A signature is only as trustworthy as the link between the public key and the identity. Certificates create that link (Tool 8).

Continue the journey