Proving Who Signed It and That It Wasn't Changed

Encryption keeps data secret; digital signatures keep data authentic. A signature proves three things at once: the message came from the claimed sender (authenticity), it has not been altered since it was signed (integrity), and the sender cannot deny sending it (non-repudiation). Signing is the flip side of encryption: instead of hiding the content, you attach a mathematical proof of authorship to it.

How a Signature Works

The trick is the key pair. With asymmetric crypto, a public key decrypts what the private key encrypts — so the private key's identity is the missile: if you hold Bob's public key and a message decrypts, that message must have been produced by Bob's private key. Signing inverts it: Alice creates a digest of her message (hashing lesson), encrypts that digest with her private key, and ships message-plaintext-plus-signature. The receiver decrypts the digest with Alice's public key and recomputes the hash. If the decrypted digest matches the freshly computed one, the message is authentic and unmodified.

from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives import hashes

private = ec.generate_private_key(ec.SECP256R1())
public = private.public_key()
sig = private.sign(b"message", ec.ECDSA(hashes.SHA256()))
public.verify(sig, b"message", ec.ECDSA(hashes.SHA256()))  # OK

Note you sign a hash, not the whole message, much like encryption uses hybrid schemes — the expensive math runs on a small digest while the payload rides along in the open.

PKI: The Trust Registry

Signatures answer "who signed this?" but only within a web of who you already trust. The Public Key Infrastructure (PKI) builds that web: a Certificate Authority (CA) signs certificates that bind a public key to an identity (a domain or a person). When your browser accepts https://example.com, it walks the chain: leaf certificate → intermediate → root that is hardcoded in your browser's trust store. The security property is scalable trust: you trust a handful of roots, each CA decides whom to sign, and every site leans on that decision. The whole ladder — the signing, the hashing, the certificates, the revocation — is the X.509 ecosystem, and it is the reason a stolen private key or a rogue CA is such a serious event: it lets someone forge "Bob" to everyone.

Signing Is Used Everywhere

Programs shipped unsigned will warn "the developer is not verified"; code signing proves a binary is exactly what its developer published and not a trojanized copy. Email signingDKIM and S/MIME — reduces phishing by letting mail servers verify the sender domain. Git and package managers use signatures to guard against a compromised repository or a tampered dependency (the supply-chain lesson). In each case the pattern is identical: artifact + signature + someone's trusted public key = trust.

Revocation and the Lifetime of Trust

A signature is a statement about a moment: the key was valid and the sender was that key's owner. When a key leaks, the whole trust falls apart, so infrastructure must be able to say "this cert is no longer valid before expiry". That is what CRLs (revocation lists) and OCSP (real-time status checks) do in the TLS lesson. Modern practice shortens cert lifetimes (Let's Encrypt's 90-day rotation) so the number of secrets needing special revocation shrinks. The security review question remains: who can issue for this identity, and what happens the moment that issuer is compromised? — answering it is the whole discipline of public key trust.