Digital Signatures and Public-Key Infrastructure

A public key lets anyone encrypt to you and verify your signatures — but it raises a new question: how do you know a public key really belongs to who it claims? If an attacker can substitute their own public key for the bank's, all the cryptography in the world protects your connection to the attacker. Solving "whose key is this?" is what certificates, certificate authorities, and chains of trust exist for — the plumbing that makes public keys into verifiable identities.

The previous post showed that signing with a private key and verifying with the public key proves authenticity. This post goes deeper on digital signatures and the crucial problem they raise: how do you trust that a public key belongs to the right entity? The answer is PKI (Public-Key Infrastructure) — certificates, certificate authorities, and chains of trust. This machinery is what makes HTTPS, code signing, and secure identity actually work.

Digital signatures

A digital signature proves that a message came from the holder of a specific private key and hasn’t been altered. It works by combining hashing (integrity) with asymmetric crypto (authenticity):

Signatures give the strongest combination — integrity, authenticity, and non-repudiation — which is why they’re used for software distribution (verify a download came from the real vendor), documents, blockchain transactions, and, centrally, certificates. Standard signature algorithms are RSA signatures, ECDSA, and EdDSA (Ed25519) — the elliptic-curve ones preferred for efficiency. As always, use vetted libraries. The key distinction from a MAC (previous topic): a signature uses a private key (asymmetric), so it gives non-repudiation and anyone can verify with the public key; a MAC uses a shared key, so only key-holders verify and there’s no non-repudiation.

The trust problem: whose key is this?

Signatures and public-key encryption both assume you have the right public key. But that assumption hides the central problem of public-key crypto: how do you know a public key actually belongs to who it claims?

Consider connecting to your bank. The bank sends its public key; you use it to establish a secure connection. But what if an attacker intercepts and substitutes their own public key? You’d establish a perfectly secure, encrypted connection — to the attacker (a man-in-the-middle). The cryptography works flawlessly and you’re still compromised, because you trusted the wrong key. Encryption to the wrong party is worthless.

So the hard problem isn’t the math of signatures or encryption — it’s binding a public key to a real-world identity in a way you can trust. You need some way to be confident that “this public key really belongs to yourbank.com,” even though you’ve never met the bank and are talking over a network an attacker may control. This is exactly what PKI solves, through certificates and a chain of trust.

Certificates and certificate authorities

A digital certificate binds a public key to an identity, vouched for by a trusted third party:

This is the core mechanism: instead of trusting a bare public key, you trust a certificate that a CA has signed, binding the key to an identity. The MITM attack fails because the attacker can’t produce a certificate for yourbank.com signed by a trusted CA — they don’t control the domain, so no CA will issue them one, and they can’t forge the CA’s signature. But this just moves the question: how do you trust the CA?

Chains of trust and root CAs

You trust a CA’s signature only if you have the CA’s authentic public key — which is the same “whose key is this?” problem one level up. PKI resolves it with a chain of trust anchored in root CAs:

Chain of trust:
   Root CA (pre-trusted in your OS/browser)
      └─ signs → Intermediate CA
                    └─ signs → yourbank.com's certificate (leaf)
   Verify each signature up the chain to a trusted root → trust the leaf's key

This is how your browser decides a site’s certificate is legitimate: it validates the chain up to a trusted root, checks the certificate isn’t expired, matches the domain, and hasn’t been revoked. If all pass, the padlock appears; if not, you get a certificate warning. The chain of trust turns a handful of pre-trusted roots into the ability to verify millions of identities.

PKI in practice, and its limits

PKI is what makes secure identity work at internet scale, and as an engineer you interact with it constantly:

Digital signatures give integrity, authenticity, and non-repudiation; PKI uses them to solve “whose key is this?” — binding public keys to identities via CA-signed certificates validated through a chain of trust up to pre-installed roots. This is the identity foundation of the secure web. Next: TLS — how signatures, certificates, key exchange, and symmetric encryption all come together in the protocol securing nearly every connection you make.

Key takeaways

Further reading

Sources & References

Certificate format and PKI