A public key is the openly distributable member of a mathematically linked cryptographic key pair. Anyone may possess it; the matching private key remains secret. Public-key cryptography removes the need to distribute one shared secret to every service. section 6.2 section 6.5
A recipient’s public key encrypts data that only the matching private key can decrypt. The public key can also verify signatures created with that private key, but it cannot unlock encrypted data or create the corresponding signature. section 6.2 section 6.6
Use public keys at trust boundaries, while protecting the private-key operations they enable:
- Share a service’s public key so another service can encrypt communications for it. section 6.2
- Verify a digital signature on data or a service request to check integrity and authenticity. section 16.2.3
- Use certificates when distributing keys across an untrusted network; a certificate helps prove that a public key belongs to the claimed service and was not replaced in transit. section 6.2 section 9.3
- Replace the entire key pair if the matching private key is compromised; merely changing the public key does not restore trust. section 6.2
Warehouse and payment services
The warehouse service encrypts refunds.json with the payment service’s public key. The payment service decrypts the result with its private key. In a production design, the payment service can expose its public key through an endpoint while storing the private key securely, simplifying key rotation without sharing secret keys across services. section 6.4
Public-key encryption is usually reserved for keys or small payloads because RSA is computationally expensive and requires chunking for larger data. Hybrid encryption uses AES for content and the recipient’s RSA public key to wrap the AES key. section 6.3.2 section 6.6
Figure 6.3 A key pair, consisting of a private and a public key. The keys are numbers that are related by means of a mathematical equation. The private key works only with the public key in the same key pair, and the public key works only with the private key from the same key pair. The private key must be kept secret, but the public key can be shared with anyone, including friends, enemies, and hackers. Security in a public key cryptosystem depends on keeping private keys private.
Inspect the paired-key relationship: the public key may be shared with anyone, while security depends on keeping its matching private key secret. section 6.2







