liveBook · Manning

Public-private key pair

As explained in Software Security for Developers

A public-private key pair is a mathematically related pair of asymmetric cryptographic keys in which the private key signs data and the public key verifies it.

A public-private key pair is two mathematically related asymmetric cryptographic keys. The public key can be shared; the private key must remain secret. The pair supports encryption and digital signatures without distributing one shared secret to every service. section 6.2 section 6.3.3

Use each half for its intended operation:

  • Encrypt with the public key and decrypt with the matching private key; only the private-key holder can recover the plaintext. section 6.2
  • Sign with the private key and verify with the matching public key; verification establishes integrity and authenticates the signer. section 6.3.3
  • Give each service its own pair, store private keys securely, and share public keys through a mechanism that prevents tampering or impersonation. section 6.2 section 6.6
  • Replace the entire pair after private-key compromise; sharing only a public key does not compromise the system's secrecy. section 6.2

Warehouse and payment services

A warehouse service encrypts refund data with the payment service's public key. The payment service decrypts it with its matching private key. For authentication instead, the warehouse signs request data with its private key, and the payment service verifies the signature with the warehouse's public key. section 6.4 section 16.2.3

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.
figure

Use the key-pair diagram to compare the shared public key, protected private key, mathematical relationship, and resulting trust boundary. section 6.2

How Software Security for Developers covers it

How deep it goes
Explains key roles, compromise response, certificates, and Java or OpenSSL generation, but defers mathematical proofs and protocol internals.
Examples
Uses Java RSA services, OpenSSL Ed25519 files, X.509 certificate issuance, signed service requests, and hardware-key login challenges.
What it assumes
Assumes basic application and command-line skills while teaching public-key sharing, private-key secrecy, signatures, certificates, and compromise response from zero.
What you can do after
Build it from scratch using Java or OpenSSL, then apply it to encryption, signature verification, certificates, and service requests.
How it connects
Connects asymmetric cryptography with encryption, digital signatures, digital certificates, hybrid encryption, TLS, WebAuthn, and service authentication.

Also explained in

Compare how 6 books explain public-private key pair →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Software Security for Developers. The section links point to the parts of the book it draws on.