Hash Function

A computer algorithm designed to take any arbitrary input of any length and produce a numeric derivative of that input, known as the data’s “hash”. These can be used to easily verify that the data has not been altered. If a single bit of the original data is changed and the hash algorithm is run, the hash will completely change. Because the hash is seemingly random, it is prohibitively difficult to try to produce a specific hash by changing the data which is being hashed. Bitcoin uses two cryptographic hash functions; SHA-256 , which produces a 256bit hash, and RIPEMD-160. SHA-256 is used almost exclusively in two round hashing (Hash256). RIPEMD-160 is only used in computing an address (see also Hash160 ). Scripts may use not only Hash 256 and Hash160, but also SHA-1, SHA-256 and RIPEMD-160.


Malone, J.A (2015). Glossary of Bitcoin Terms and Definitions. United States: Lulu Press, Inc

A hash function is a mathematical function with the following three properties:

  1. Its inputs can be any string of any size
  2. It produces a fixed-sized output. For the purpose of making the discussion in this chapter concrete, we will assume a 256-bit output size. However, our discussion holds true for any output size, as long as it is sufficiently large.
  3. It is efficiently computable. Intuitively this means that for a given input string, you can figure out what the output of the hash function is in a reasonable amount of time. More technically, computing the hash of an n-bit string should have a running time that is O(n).

These properties define a general hash function, one that could be used to build a data structure, such as a hash table.


Narayanan, Arvind, et al. (2017). Bitcoin and Cryptocurrency Technologies. United States: Princeton Press

Leave a Reply

Your email address will not be published. Required fields are marked *