liveBook · Manning

Public key cryptography

As explained in Hacking Cryptography

Public-key cryptography is cryptography based on paired public and private keys, allowing operations such as encryption or signature verification with a public key while restricting the corresponding inverse operation to the private-key holder.

Public-key cryptography uses related keypairs instead of one shared secret. Anyone may publish a public key, while its matching private key remains secret. A sender encrypts to the recipient’s public key; only the private-key holder can decrypt. The same asymmetric foundation also supports digital signatures, where verification is public but forgery is intended to be infeasible. section 8.0 section 8.1

Alice and Bob exchange a message

Alice generates a keypair and publishes her public key. Bob encrypts his plaintext with that public key and sends the ciphertext over an insecure channel. An eavesdropper can obtain the public key and ciphertext, but decryption requires Alice’s private key. The lock-and-key analogy captures the division: the public key is the lock, and the private key is the matching physical key. section 8.1

The security goal depends on trapdoor one-way functions: reversing the operation should be hard without the trapdoor key. Classical systems commonly rely on the difficulty of integer factorization or the discrete logarithm problem. Engineering details matter: weak randomness has caused RSA keys to share primes, deterministic textbook RSA requires probabilistic padding, and small private exponents enable attacks. section 8.3 section 8.5

Practical rules follow directly from the failure modes:

  • Keep private keys secret; publishing the corresponding public keys is compatible with confidentiality. section 8.1
  • Use probabilistic padding rather than deterministic textbook RSA. section 8.5
  • Use reliable randomness and test RSA public moduli with batch GCD to find shared factors. section 8.5
Figure 8.2 Alice and Bob communicating using asymmetric encryption
figure

A sequence diagram makes the public-key exchange, insecure channel, and private-key decryption roles concrete. section 8.1

How Hacking Cryptography covers it

How deep it goes
Explains keypair workflows, trapdoor foundations, RSA failures, and defenses, while deferring detailed digital-signature treatment.
Examples
Uses Alice–Bob message exchange, lock-and-key intuition, shared-prime RSA keys, batch GCD detection, padding, and small-exponent attacks.
What it assumes
Assumes familiarity with symmetric ciphers and secret-key exchange, then establishes keypairs and trapdoor functions explicitly.
What you can do after
Apply it via public-key encryption while recognizing weak randomness, deterministic RSA, shared factors, and small private exponents.
How it connects
Connects symmetric-key cryptography, digital signatures, trapdoor functions, RSA, integer factorization, discrete logarithms, and quantum computing.

Also explained in

Compare how 5 books explain public key cryptography →

Related concepts

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