liveBook · Manning

Private key

As explained in Hacking Cryptography

A private key is the secret member of an asymmetric key pair used for operations such as decryption or signature generation.

A private key is the secret half of an asymmetric keypair. Its matching public key may be published or sent over an insecure channel; secrecy of the private half is what preserves the security property the pair is meant to provide. In public-key encryption, anyone can encrypt to a recipient’s public key, but only the holder of the corresponding private key can decrypt the ciphertext. The lock-and-key analogy is useful: distribute the lock freely, but retain the unique physical key. section 8.1

This split addresses the key-distribution problem of symmetric encryption. A symmetric secret must already be shared with every intended participant, whereas a public key can travel openly. A private key must never travel alongside its public counterpart: an eavesdropper with only public information cannot decrypt ciphertext intended for the keypair holder. section 8.1 section 8.5

Private-key operations depend on the cryptosystem. In classic Diffie–Hellman key exchange, each participant chooses a secret integer as a private key and publishes a value derived from it. Each combines the other participant’s public key with their own private key to reach the same shared secret. Recovering that private value from the public value requires solving the discrete logarithm problem. section 8.3.1

Diffie–Hellman with a small group

With p = 13 and generator g = 7, Alice chooses private key a = 3 and publishes A = 7³ mod 13 = 5. Bob chooses b = 9 and publishes B = 7⁹ mod 13 = 8. Alice computes Bᵃ mod p = 8³ mod 13 = 5; Bob computes Aᵇ mod p = 5⁹ mod 13 = 5. The public values are exchanged, while a and b remain secret. section 8.3.1

RSA makes the private component explicit as d. Key generation chooses primes p and q, computes n = pq and φ(n) = (p − 1)(q − 1), selects a public exponent e, then calculates d as e’s multiplicative inverse modulo φ(n). The public key is (n, e), while d is stored secretly. Encryption computes c = mᵉ mod n; decryption computes m = cᵈ mod n. The underlying difficulty is deriving secret factorization-related information from the public modulus. section 8.3.2 section 8.5

Equation 8.9
\[\begin{aligned} \begin{aligned} \text{PubKey}_{\text{Alice}} &= (n, e) \\ \text{PrivKey}_{\text{Alice}} &= (d) \end{aligned} \label{equation:alice-rsa-keypair} \end{aligned}\]

The RSA keypair form separates publishable values n and e from the secret exponent d. section 8.3.2

A private key also enables asymmetric message authenticity. A signer uses it to generate a signature; a verifier uses the corresponding public key and receives only a yes/no result. Unlike a shared-secret MAC, verification does not give verifiers the secret needed to create valid signatures. section 9.1

Treat private-key handling as a security boundary:

  • Keep the private portion secret; publishing the public portion is expected, but exposing its counterpart defeats the asymmetric separation. section 8.1
  • Generate key material with reliable randomness. Poor random-number generation or hardware faults can cause RSA keys to share primes, making vulnerable keys discoverable from public moduli. section 8.5
  • Avoid small RSA private exponents, and use probabilistic padding rather than deterministic textbook RSA encryption. section 8.5

How Hacking Cryptography covers it

How deep it goes
Works through private exponents in Diffie–Hellman and RSA, while deferring the proof that RSA decryption works.
Examples
Calculates a shared secret using private integers 3 and 9 modulo 13 and constructs an RSA exponent d from selected primes.
What it assumes
Introduces keypair roles directly, then uses modular arithmetic, prime factorization, Euler’s phi function, and multiplicative inverses for implementations.
What you can do after
Evaluate/understand how secrecy of a private key supports decryption, key exchange, and signature authenticity.
How it connects
Connects asymmetric cryptography with public keys, Diffie–Hellman key exchange, RSA, discrete logarithms, integer factorization, and digital signatures.

Also explained in

Compare how 13 books explain private key →

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.