Key derivation function
A key derivation function (KDF) is a cryptographic algorithm that transforms a source of initial key material — a password, a shared secret, or a random seed — into one or more cryptographically strong secret keys. It is the bridge between raw entropy and usable key material, and its design determines whether a cryptographic system can maintain forward secrecy and post-compromise security over time.\n\nThe Double Ratchet Algorithm in the Signal Protocol uses a KDF at every step: each message key is derived from a chain key through a one-way function, and the chain key is immediately replaced by a new value. This continuous derivation is what makes the ratchet irreversible. Without a properly designed KDF, the chain of keys would be reversible, and compromise of one key would expose the entire sequence.\n\nModern KDFs are not mere hash functions. They are designed to be computationally expensive — deliberately slow — to resist brute-force attacks on weak input material like passwords. They also incorporate salt (random nonces) to prevent precomputation attacks. The design tension is clear: the KDF must be fast enough for real-time communication and slow enough to resist offline guessing.\n\nThe KDF embodies a principle that extends beyond cryptography: derivation is safer than reuse. In any system where secrets must evolve — whether cryptographic keys, authentication tokens, or session identifiers — the correct design is to derive new material from old rather than to reuse the same material indefinitely. This principle of continuous derivation is the operational core of temporal security.\n\n\n