# Chapter 5

Hash Functions

A *hash function* is a function that takes as input an arbitrarily long string of bits (or bytes) and produces a fixed-size result. A typical use of a hash function is digital signatures. Given a message *m*, you could sign the message itself. However, the public-key operations of most digital signature schemes are fairly expensive in computational terms. So instead of signing *m* itself, you apply a hash function *h* and sign *h*(*m*) instead. The result of *h* is typically between 128 and 1024 bits, compared to multiple thousands or millions of bits for the message *m* itself. Signing *h*(*m*) is therefore much faster than signing *m* directly. For this construction to be secure, it must be infeasible to construct two messages *m*_{1} and *m*_{2} that hash to the same value. We'll discuss the details of the security properties of hash functions below.

Hash functions are sometimes called *message digest* functions, and the hash result is also known as the *digest*, or the *fingerprint*. We...