In this article, we break down everything that relates to blockchain hashing, and what this has to do with cryptocurrencies like *Bitcoin*. First, we’ll look at what blockchain is and what are some blockchain applications. Following this, we’ll unpack some of the intricacies of hashing algorithms.

Blockchain technology is not necessarily monetary by its creation. To paraphrase Vitalik Buterin, the essence of blockchain is “informational and processual.” Blockchain technology could actually be used in a myriad of ways. Bitcoin is simply an effective application of the technology.

### What is a Blockchain?

A blockchain is a linked list of transactions. This list contains data and a *hash pointer *to the previous block in the blockchain. A given blockchain functions based on the verification of a *hash *and *digital signatures*.

In a nutshell, hashing is a way for the blockchain to confirm its current state. Whereas the digital signature is necessary so transactions happen only once by the address owner.

## Hashing as a Vital System

Cryptocurrencies like Bitcoin and Ethereum, primarily rely on two computational processes: *hashing *and *blockchain technology*. It’s the revolutionary application of these technologies that is making decentralized currency and peer-to-peer transactions secure and increasingly appealing.

In a blockchain, the hash of a previous block in a sequence is a tamper-proof sequence. Because as a function of the design, a hash is very sensitive. So, to change any variable of any one of the hashes in a given block would cause a domino effect. Subsequently, it would alter all of the previous transactions in the block. Blockchain hashes are *deterministic *because the input data will produce the same result each time.

### How Bitcoin’s Algorithm Sets it Apart

Blockchain technology is not unique to cryptocurrencies, it is a technology that is common in many electronic transactions. However, Bitcoin’s algorithm has applied hashing and blockchain by relying on the participation of autonomous networks. All these networks take part in the production and confirmation of *hash transactions*. Hash transactions reach approval by way of *proof-of-work. *Additionally there are checks against the mutual consensus of the participating networks.

Once a transaction reaches approval, it joins the public ledger along with other approved transactions. With blockchain technology, currencies are secure when they are decentralized and peer-to-peer. To be sure, blockchain is not always a decentralized entity, as third parties such as banks and credit card companies utilize this technology as well.

### The Benefits of a Public Ledger

Simply put, blockchain is* *a *public decentralized ledger*. The benefit of such a system is that it has great potential to be monitored by multiple beneficent networks, rather than rely exclusively on a trusted third party and centralized currencies.

At its best, blockchain technology applied to cryptocurrency makes a reduction of corruption within both decentralized *and *centralized currencies possible. This is because it relies on a fellowship of participation, rather than resting solely on traditional financial institutions. Bitcoin is simply an example of a cryptocurrency that trades on the technology of hashing and blockchain, with the central goal of establishing a modern decentralized cryptocurrency.

### The Example of Stone Rai

Critical to the legitimacy of a cryptocurrency is the public ledger that blockchain relies on. Here is a fun example of a long lasting but obscure currency the Stone Rai. The Stone Rai is a longstanding currency of the Micronesian island of Yap. *Rai *are large doughnut-like stones that represent wealth as well as the exchange of wealth.

But it was not only valuable to have the 3.5 meter stone in your possession, but the record of the transactions themselves are also equally valuable. Historical records indicate that during the transportation of these large stones they would get lost at sea. However, this did not diminish the value of the stone, nor did it necessarily void the value of exchange, because the *record *of the transaction was just as valuable. And given the Rai’s mutually accepted value by the Yap, the physical object did not need to be present in order to maintain is fiat value.

### When Bitcoin Mining Ends

Similarly, with Bitcoin and cryptocurrencies, without the ability for networks to express consensus in the public ledger, a cryptocurrency has no value. Bitcoin, like gold, is a limited resource. The system is currently designed to yield 21 million Bitcoins by 2040. Bitcoin mining will cease once all of the hashes have been mined. At the point of capacity, the currency will only be usable and tradable for its exchange value. At present, as Bitcoin mining continues, it will become more and more scarce and thus more valuable.

So, in order for a decentralized currency like Bitcoin to work, it not only depends on the reliability of the blockchain, it also relies on users possessing an equilibrium of rationality, self-interest, and altruism. That is to say, that given the investment and computational power necessary for mining Bitcoin, there needs to be a future value. However, the system’s reliability also depends on an established harmony between the needs of the individual and the health of the system to align. Therefore networks need to cooperate and collaborate in order for the system to thrive.

**Adding to the Blockchain**

In order to add to the blockchain, miners must solve for what is called the *target hash*. Meeting or solving a hash uses an algorithm that relies on the data from the blockheader. Each block contains a blockheader with the number of the block, a timestamp of the transaction as well as the hash of the previous block which contains the *nonce*.

## What is a Nonce?

The nonce is a “number only used once.” In a Bitcoin block, this is a 32-bit (4-byte) numerical string. The value of the nonce is adjusted as miners mine. That means that the hash of the block will be less than or equal to the current target of the network. This iterative calculation requires time and resources. Proof-of-work is therefore the proof that the block has the correct nonce value. Without this proof, the block cannot be confirmed.

## What is a Genesis Block?

The *Genesis Block* is the first transaction in the block that starts a new electronic transaction (or coin in the case of Bitcoin). A crucial function of the blockchain is that it relies on hash pointers which contain the address of the previous block, as well as the hash of the new data. Each block is similar to a sequence of chain links. Where each link is connected to the other via the previous link.

Blocks, however, are connected to the previous block using a *pointer*. A pointer does not store the actual hash value, but “points” to an address of variables. Data from the previous blocks are hashed (or encrypted) into a new unique series of letters and numbers of a fixed length.

Continuing, the nonce has a *high min-entropy* because the variables are chosen from a large distribution. This also means that the nonce is a randomly generated string. High min-entropy means that there is a low likelihood of randomly generating the hash. The nonce is then added to a hashed block, thus a miner is only successful if they meet the target hash, at which point the nonce is added to a hashed block.

## PoW and Hashing

In order for new blocks to be accepted to an extent blockchain, a *proof-of-work* must be generated. The proof-of-work is composed of letters and numbers fixed according to the desired outcome. This is expressed by the double SHA-256 hashing algorithm.

That means that once the target hash has been obtained, then the block is accepted into the public ledger by the consensus of other participating networks.

Because the blockchain only contains those transactions that have been validated, this prevents fraudulent transactions being added to the chain, or the problem of double-spending by reusing the same transaction twice.

## The True Importance of Blockchain Tech

This is why cryptocurrencies like Bitcoin depends on the features of blockchain technology. Using a block of hashes in an interdependent sequence replaces the need for a trusted third party. However, by using blockchain, a publicly published list of transactions functions as the guarantor. This is done through the public system of participation that represents a vouchsafe for its own authenticity. Or more correctly, this guarantee happens by virtue of the individual networks of the established blockchain.

So in this sense, a blockchain like Bitcoin, is self-guaranteeing, because there are multiple networks continuously approving the transactions. The Bitcoin blockchain is thus a public ledger composed of data blocks. These digital blocks have been successfully hashed and are now a perminant part of the list of transactions. All transactions on the ledger have been mutually approved by independent networks.

**What is Hash and Hashing?**

A hashing algorithm is a computational function that condenses input data into a fixed size, the result of which is the output called a *hash *or a *hash value*. Hashes are used to identify, compare or run calculations against files and strings of data. Typically, the program first computes a hash and then compares the values to the original files.

If you didn’t love doing in math in school, that is ok, because while hashing relies on some pretty crazy Alan Turing-*esque* computations, a computer program does the all the math for you. So all you need to remember from math class are the basics of exponents and probability functions.

### Example of Blockchain Hashing

An example of hashing is what functions as a digital signature on a piece of software so that it is available for download. To do this you need a hash of the script of the program you want to download. You also need an actual digital signature, which also gets hashed.

Once the input data is hashed the software is encrypted. And once the software is encrypted it can be downloaded. So, when someone downloads software, the browser needs to decrypt the file and check the two unique hash values. The browser then runs the same hash function, using the same algorithm and hashes both the file and the signature again. If the browser successfully produces the same hash value, it can confirm that both the signature and the file are authentic and that have not been altered.

### The Meaning of Deterministic in Hash Values

Hash values are *deterministic *and respond to the parameters of the given variables of the algorithm. So, the reason hashing is so important for cryptocurrencies is that the same sequence will never be reproduced with a different data set as the input. That means no two hashes can be the same.

The resultant hash of the input of data and is both unique and irreversible. For example, an input of “123” will always have the same output. If it didn’t, and it came up with a different output every time it was hashed, then there would be no consistency or validity to the process. It would also mean that your programs would never speak the same language and therefore could not run the code. The hash used for Bitcoin is a 65-digit-hexadecimal number -which I will explain shortly.

**Digital Signatures**

Hashing also requires the use of unique digital signatures. For example, SSL certificates (SSL/TLS Protocol) have a role in what makes possible secure data transmission from one device to another. Digital signatures bind a key to a dataset. SSL signatures are encrypted authentication received data. SSL Certificates, therefore, need to match a specific public key to the intended transaction -kind of like a lock and key.

SSL/TLS uses asymmetric encryption which makes secure key exchanges possible. The security of this transfer relies on two keys. A public key used for encryption, and a private key for the recipient’s decryption. Digital signatures are very sensitive, and small changes result in a very different hash generation.

**SHA-256**

Presently SHA-256 is the most secure hashing function. This function expresses the possible combinations or values that results from the given input data. SHA stands for *Secure Hashing Function*, and 256 expresses the numerical quantity of the fixed bit length. This means that the target is correct 256 bit, and as mentioned, Bitcoin uses a 65-hexadecimal hash value.

Using the SHA-256 function makes it (nearly) impossible to duplicate a hash. That’s because there are just too many combinations to try and process. Therefore, a significant amount of computational work is required. So much so that Bitcoins are no longer mined with personal computers. Presently, to mine, you need to rely on Application-Specific Integrated Circuits or ASICs. Achieving this target has a probability of 2^256. If you remember your exponents, you will deduce this is an incredibly difficult variable to hit.

Furthermore, using this hash function means that such a hash is intentionally computationally impractical to reverse. The intentional result is that requires it a random or *brute-force* method to solve for the input.

#### A Case in Point

Consider the following, if I have 1 six-sided dice, I have a 1 in 6 chance of rolling a 6. However, the more sides my dice has (say 256 sides), the more my chances of rolling a 6 decrease. That’s 1 in 256, which is still better than your odds of using brute-force on an extent hash.

A *hash rate* is then the speed at which hashing operations take place during the mining process. If the hash rate gets too high and miners solve the target has too quickly, this increases the potential for a collision. When that happens, the difficulty of the hash needs adjusting accordingly. For example, at present, a Bitcoin is mined/hashed about every 10 minutes.

**Collision Resistance**

Due to the complexity and sensitivity of SHA-256, reversing the hash sequence in an effort to find the original input data is basically impossible. The difficulty of meeting SHA-256 means that this hash is extremely secure because it is“collision resistant.” Collision resistance expresses the likelihood of two different networks solving the same hash at the same chance is minuscule.

Therefore, given the possible permutations of SHA-256, the probability of a collision is negligible. Below is a comparison of two different hash outcomes. The first only uses the single hash function (SHA-1), while the second uses the double hash function (SHA-256). And as you can see, the double hash function produces a much more complicated hash and as a consequence is far more collision resistant.

Here are a few examples of other cryptographic hash functions and when collision resistance broke, and it will become evident why SHA-256 is currently the favored hash:

- MD 5: It produces a 128-bit hash.
- Collision resistance was broken after ~2^21 hashes.

- SHA 1: Produces a 160-bit hash.
- Collision resistance broke after ~2^61 hashes.

- SHA 256: Produces a 256-bit hash.
- This is currently being used by Bitcoin.

- Keccak-256: Produces a 256-bit hash.
- Currently used by Ethereum.

**Merkle Tree and Merkle Roots**

As blocks are added to an increasing blockchain, there is a need to reclaim storage space; this is the role of the Merkle Tree. Rather than store the entire transaction, only the root of the hash is stored (the Merkle Root. This means that it is still possible to verify the blockchain without sorting through all of the data.

Verification processes are therefore simplified by following a branch. The branch links transactions to the block it was time-stamped in, but not the complete transaction itself (as these take up a lot of space). Instead, the check is to ensure that the previous network node accepted the transaction. This continually affirms its reliability. And so subsequent blocks are added to the chain and the value can be traded on.

How is this done? The Merkle Root summarizes all of the data in the related transactions and is stored in the block header. Just as we saw is the case for hashes, if a single detail in any of the transactions is altered, so is the Merkle Root. Using a Merkle tree makes testing a to see if a specific transaction is included in the set or not much more efficient then going through all of the blocks in the chain.

### The Creation of Merkle Trees

Merkle trees originate by repeatedly hashing pairs of nodes until there is only one hash left. This hash is the Root Hash, or the Merkle Root. Each leaf node is a hash of transactional data, and each non-leaf node is a hash of its previous hashes. Merkle trees are binary and therefore require an even number of leaf nodes. If the number of transactions is odd, the last hash will become a duplicate once to create an even number of leaf nodes.

I will borrow an example from Shaan Ray. Here are four transactions in a block: A, B, C, and D. Each are hashed. Then, the hash stored in each leaf node, the result is Hash A, B, C, and D. Consecutive pairs of leaf nodes are then summarized in a parent node. This is done by hashing Hash A and Hash B, resulting in Hash AB, and separately hashing Hash C and Hash D. The result of this is resulting in Hash CD. The two hashes (Hash AB and Hash CD) are then hashed again to produce the Root Hash (the Merkle Root).

**Conclusion and Review **

For some, cryptocurrencies may seem too ephemeral to trust, but the basic idea of currency like Bitcoin relies on typical monetary practices of a fiat system. In fact, currently, similar monetary systems are used frequently. Many transactions and bank balances rely on data rather than the physical presence of hard currency (like gold).

A crucial difference in the application of blockchain in terms of cryptocurrencies is that typically an exchange of currency requires a third party as guarantor. This would similar to a bank or credit card company. However, the application of blockchain technology in cryptocurrencies is disrupting the need for a third party, as well as making non-cash peer-to-peer transactions more secure and desirable.

Here is what you should take away from this article, *What is Blockchain Hashing?*:

## Blockchain Technology

- Blockchain as a public ledger: With individual networks, transactions are hashed and added to a public record. Participating networks maintain and thus approve the record. The blockchain ledger is essential in order to maintain validity as a currency. Additionally, it makes the reliability of decentralized cryptocurrencies possible.
- Adding blocks to the blockchain: To add to the blockchain, miners mine for the target hash. This relies on data from the blockheader. Each blockheader contains versions of the number of the block, a timestamp of the transaction and the hash of the previous block, which contains the nonce.
- Proof-of-work: Once the target-hash has been solved, it also produces proof-of-work. This is related to the SHA-256 and the current level of difficulty for solving it.
- Nonce: The nonce is a “number only used once,” in a Bitcoin block is a 32-bit (4-byte). The value of the nonce is adjusted by miners. So the hash of the block will be less than or equal to the current target of the network.

## Blockchain Hashing

#### Hash Algorithms

Hash algorithms are computational functions. The process condenses input data into a fixed size, the resulting is an output that is a hash or a hash value. Hashes identify, compare or run calculations against files and strings of data. When attempting to add to an extent blockchain, the program must solve for the target-hash in order for it to reach acceptance as a new block.

- Hashes are deterministic and pre-image resistant:
- Deterministic: the outcome of a particular set of data input will always have the same result. This makes it possible to keep track of transactions and nearly impossible to recreate the input from the output data (or pre-image resistant).

- SHA-256:
- This produces a 256-bit hash. Given that data is so large, that there are too many possible outcomes to compare hashes to and attempt to solve backward. So if one wanted to try to solve for a target hash, this they would need to begin with a random hash a sequence -then test it against the target hash – this would take a nearly incalculable amount of times.
- Collision Resistance: SHA-256 is collision resistant because of the large amount of data, so arriving the same target-hash at the same time is nearly impossible. This is also a result of using a target with high min-entropy.

#### Merkle Trees and Roots

The Merkle Root summarizes all of the data in the related transactions. That that summary is stored in the block header. Just as we saw with hashes, alter a single detail in any of the transactions; the Merkle Root is altered. Using a Merkle Tree makes ensuring that a specific transaction is included in a set efficient. Rather than going through all of the blocks, you just check the root.

#### Computational Functions

,Hash algorithms are computational functions. The process condenses input data into a fixed size. This results in an output called a hash or a hash value. Hashes are used to identify, compare and run calculations against files and strings of data. When adding to an extent blockchain, the program must solve for the target-hash. In order for the new block to be accepted, you must solve the target-hash.

#### Features of Hashes

- Deterministic: the outcome of a particular set of data input will always have the same result. This makes it possible to keep track of transactions. It also makes it nearly impossible to recreate the input from the output data (or pre-image resistant).
- SHA-256:
- This produces a 256-bit hash. Given that data is so large, that there are too many possible outcomes to compare hashes to and attempt to solve backward. So if one wanted to try to solve for a target hash, they would need to begin with a random hash sequence. Then test it against the target hash. This would take a nearly incalculable amount of time.
- Collision Resistance: SHA-256 is collision resistant because of the large amount of data, so arriving the same target-hash at the same time is nearly impossible. This is also a result of using a target with high min-entropy.

- Merkel Trees and Merkel Roots:
- The Merkle Root summarizes all of the data in the relevant transactions and stores in the block header. Just as we saw with hashes, if a single detail in any of the transactions changes, so goes the Merkle Root. Using a Merkle Tree makes testing for specific transactions more efficient. Much more so than going through all of the blocks.

####

SHA-256:

- This produces a 256-bit hash. Given that data is so large, there are too many possible outcomes to compare hashes to; this makes solving backward nearly impossible. So if one wanted to try to solve for a target hash, they would need to begin with a random hash sequence, then test it against the target hash. This would take a nearly incalculable amount of time.
- Collision Resistance: SHA-256 is collision resistant because of the large amount of data. So arriving at the same target-hash at the same time is nearly impossible. This is also a result of using a target with high min-entropy.