This is one article in a collection of 52 articles published weekly throughout 2023 on the basics of Bitcoin. The series is intended for people unfamiliar with Bitcoin or people wishing to enhance their understanding of the fundamentals that underpin the technology. Please contact us, if you have any questions or comments.
As discussed in our previous publication, a block is mined (i.e. created) approximately every 10 minutes. A mathematical formula is used to determine who successfully mines the next block using a concept known as proof-of-work. The proof-of-work concept ensures that a certain amount of computation power is expended before the next block is created. The proof-of-work system the Bitcoin protocol uses is important to grasp so one can conceptualize the security of the Bitcoin protocol despite being completely decentralized. While there are several different types of proof-of-work systems, Bitcoin miners essentially enter guesses (known as a nonce) to see if they can come up with the right criteria to successfully mine the next block. To understand bitcoin mining it is essential to know the basics of hash functions and hexadecimal numbers.
A hash function is a computer program which transforms any kind of data of any length to a fixed number of characters. There are many different hashing algorithms that have been created. However, the Bitcoin protocol uses the hashing algorithm known as Secure Hash Algorithm 256 (SHA256). Technically the Bitcoin protocol uses double SHA256 which means data is put into the hash function two times. SHA256 provides a fixed length output of 64 characters using only the hexadecimal numbers. The hexadecimal number system, which includes 16 characters 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, and f, is frequently used in computer science because it allows 4 bits of data to be used efficiently which is always one of the paramount goals for programming.
A useful hash function has the following five characteristics:
- The hash function creates a hash value on any length of data quickly;
- The hash function is deterministic. This means the hash function always creates the same hash value (output) for the same input;
- The hash function is pseudorandom. This means the hash value returned should change unpredictably when the input of data is changed, even if the change is slight. However, a hash function is only pseudorandom because an identical entry should always produce the same hash value (i.e. it is deterministic);
- The hash function is preimage resistant. This means the input cannot be calculated or determined based on the hash value. In other words, the hash function only works in one direction from input to output. Under no circumstances should a person or even the strongest super computer be able to determine the input of a useful hash function from the hash value; and
- The hash function is collision resistant. This means there is only one input that creates a hash value. If there are two inputs that create the same hash value, the hash function is not collision resistant.
SHA256 has many applications outside of Bitcoin and has continually met the five criteria discussed above. We encourage our readers to play around with the SHA256 algorithm which can be found in this link. Our next publication will explore how these tools are used to determine which miner successfully mines the next block on the Bitcoin blockchain (or time chain as Satoshi originally called it).