Hash Functions
A cryptographic hash function is a function, which can be denoted as H, that has the following properties:
It takes in inputs of arbitrary size (meaning that they can be nearly any size and the size does not matter in practice).
It produces an output of some fixed size.
It is efficiently computable, meaning given any input it is fast to compute the output.
It is pre-image resistant. This means that given a hash h it is hard to find an input x such that H(x) = h.
It is collision resistant. This means that it is hard to find two different inputs x and y such that H(x) = H(y).
The most used hash function today is SHA256, and this is what Bitcoin uses. SHA256 hashes are usually encoded and expressed as a string containing 64 alphanumeric characters, such as the string 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 (the hex encoding of the SHA256 hash of “hello”).
The Bitcoin White Paper defines a coin as “a chain of digital signatures”. An owner transfers a coin by “digitally signing” a “hash” of the previous transaction involving the coin and the public key of the next owner. Because the hash used in a transaction includes both the previous transaction involving the coin and the public key of the next owner, the hash embeds the history of expenditure of that coin.