One-Way Functions and Pseudorandom Generators
Learning Objectives
- Explain why perfect secrecy forces keys as long as messages, and how computational security relaxes it by limiting the adversary to efficient algorithms and negligible success.
- Define one-way functions and give standard candidates, and explain why their existence would imply P NP.
- Define computational indistinguishability and pseudorandom generators, and build a one-bit-stretch generator from a one-way permutation and a hard-core predicate.
- Write a security proof by reduction: show that a stream cipher built from a pseudorandom generator is secure if the generator is.
Context & Motivation
software-distributed/security-cryptography proved that the one-time pad achieves perfect secrecy, a ciphertext reveals nothing at all about the message, and Shannon showed this requires a truly random key at least as long as all the messages ever sent with it. That is impractical: nobody pre-shares a terabyte of key to send a terabyte of data. The same discipline then used block ciphers, hash functions, RSA, and Diffie-Hellman, whose security was argued from experience: decades of cryptanalysis have not broken them.
Modern theoretical cryptography, developed by Goldwasser, Micali, Blum, Yao, and others in the 1980s and taught in MIT's 6.875 and Barak's Harvard CS127, replaces "nobody has broken it" with reductions: a scheme is proved secure by showing that any efficient attack on it would yield an efficient algorithm for a problem assumed to be hard. The minimal such assumption is the existence of one-way functions. From them alone one can build pseudorandom generators, pseudorandom functions, private-key encryption, message authentication, digital signatures, and commitments, which is why one-way functions are the foundation on which the rest rests.
Core Theory
Computational security
Two relaxations make short keys possible. The adversary is efficient, a probabilistic polynomial-time (PPT) algorithm in the security parameter (roughly the key length). And it may succeed, but only with negligible probability: a function is negligible if it is eventually smaller than for every constant , like . Negligible success cannot be amplified to noticeable by polynomially many repetitions.
One-way functions
A function is one-way if:
- it is computable in polynomial time, and
- for every PPT algorithm , is negligible.
Inverting means finding any preimage, not necessarily . Standard candidates: multiplication of two random -bit primes (inverting is factoring), modular exponentiation (inverting is the discrete logarithm), and subset sum. If P = NP, no one-way function exists, since checking a candidate preimage is in P and so finding one would be in NP. Proving one-way functions exist would therefore prove P NP, so all of cryptography rests on an unproven assumption, and the goal is to make that assumption as weak as possible.
Indistinguishability and pseudorandom generators
Two distributions and are computationally indistinguishable if for every PPT distinguisher ,
A pseudorandom generator (PRG) is a polynomial-time with whose output on a uniformly random seed is computationally indistinguishable from uniform on . The output cannot be truly random, since there are only outputs among strings, but no efficient test can tell. Yao showed an equivalent criterion: is a PRG if and only if no efficient algorithm predicts its next output bit from the previous ones with probability noticeably above .
From one-way permutations to a PRG
A hard-core predicate of is a bit computable from but unpredictable from : no PPT algorithm guesses from with probability noticeably above . Goldreich and Levin (1989) proved that every one-way function has one, in a slightly modified form: for , the inner product is hard-core.
If is a one-way permutation with hard-core bit , then
stretches bits to . The first bits are uniformly random because is a permutation of a uniform , and the last bit is unpredictable from them by the hard-core property. Iterating (Blum-Micali: output , replace by , repeat) stretches to any polynomial length. Håstad, Impagliazzo, Levin, and Luby (1999) showed PRGs can be built from any one-way function, and conversely every PRG is itself a one-way function. So PRGs exist exactly when one-way functions do.
Using a PRG: a stream cipher and its proof
Encrypt with , a one-time pad whose pad is generated from a short key. Theorem: if is a PRG, no PPT adversary can distinguish encryptions of two messages of its choice with more than negligible advantage.
Proof by reduction. Suppose adversary distinguishes with advantage . Build a distinguisher for : given a string (either or truly uniform), runs , gets , picks a random bit , gives the ciphertext , and outputs 1 if guesses correctly. If , this is exactly the real encryption game, so wins with probability . If is uniform, is a true one-time pad and wins with probability exactly . So distinguishes from uniform with advantage , which must be negligible. Every security proof in this style has the same shape: an attack on the scheme becomes an attack on the assumption.
Worked Examples
Example 1: breaking a bad generator
Problem: A proposed generator outputs , stretching bits to . Show it is not a PRG.
Trace: Distinguisher : output 1 if the last bit of equals the parity of the first bits. On , outputs 1 with probability 1. On a uniform string, the last bit is independent of the rest, so outputs 1 with probability . The advantage is , far from negligible. Stretching alone is not enough: the extra bit must be unpredictable, which is exactly what a hard-core predicate of a one-way permutation provides and a parity of visible bits does not.
Example 2: key reuse destroys the stream cipher
Problem: A system encrypts two messages with the same key: and . What does an eavesdropper learn, and which step of the security proof fails?
Resolution: , independent of the key. If one message is known or guessable (a protocol header, a common file format), the other is recovered directly; even without that, statistics of natural language often reveal both. The proof covered a single encryption: it used the pad once, as in the one-time pad. Encrypting many messages securely requires fresh randomness per message, for example a pseudorandom function evaluated at a random nonce, which is how standard modes such as counter mode work. This exact mistake has broken real systems, including WEP Wi-Fi encryption.
Common Misconceptions & Pitfalls
- "Pseudorandom means statistically random." A PRG's output fails some tests, for instance testing whether the string is in the image of , but those tests take exponential time. Pseudorandomness is relative to efficient observers.
- "Hash functions are one-way functions, so they are PRGs." Cryptographic hashes are designed to be one-way and collision-resistant, but their security is heuristic, and one-wayness alone does not make an output pseudorandom. Constructions need the specific properties their proofs assume.
- "A security proof means the system is secure." It means the system is as secure as the assumption, in the model the proof considered. Side channels, key reuse, and implementation bugs are outside the model and break proved schemes in practice.
Summary
Perfect secrecy needs keys as long as the data, so modern cryptography limits adversaries to efficient algorithms and negligible success probability. One-way functions, easy to compute but hard to invert on random inputs, are the minimal assumption; their existence would imply P NP. A pseudorandom generator stretches a short seed into output no efficient distinguisher can tell from uniform; from a one-way permutation and a hard-core bit, stretches by one bit and iteration stretches further, and PRGs exist exactly when one-way functions do. Security of a PRG-based stream cipher follows by reduction, turning any attack on the cipher into a distinguisher for the generator. The next concept looks at a specific hardness assumption chosen to survive quantum computers.