In this article, we will talk about:
Hash and Hash Functions
Blocks
Blockchains
Decentralization
Today’s article will aim to answer a simple question:
“What is the blockchain?”
Hash and Hash Functions
The basic starting point for understanding blockchains is hash and hash functions. For context, a hash is simply a unique fixed-length string meant to identify a piece of data. The hashes are built by inputting the data into something called a “hash function”.
In this example above, we are using a SHA256 hash function to create the hash for the string “Uncommon Cents”. Each string or number will contain its own specific hash.
This way the data becomes encrypted. If you look at the example below, you can see that simply changing the capitalization of the letters in “Uncommon Cents” changes the hash.
Blocks
Blocks take hash functions one step further by incorporating block number and nonce (number used only once) into the equation. Instead of using just a single piece of data (the string “Uncommon Cents”), it now uses three different variables (string, block number, nonce).
Miners on the blockchain network are tasked with searching for the hash that can encrypt this information. The requirement in this scenario is that the hash must contain “0000” as its first 4 digits.
Validators/miners on the network solve a series of brute force mathematical problems to find the correct hash. In doing so, they are rewarded with a percentage of the fees from the network. This is essentially how Bitcoin or Ethereum mining works.
The hash above meets the requirement of having “0000” at the beginning. We have now successfully mined for the hash and secured the network.
Blockchains
Blockchains are exactly what they sound like - a series of blocks.
One thing to consider here is that the hash corresponding to the previous block is also encrypted into the next block. This way, the blockchain is able to create a “ledger” of transactions one after another.
If even a single block here doesn’t meet the requirement of the hash, the following blocks after it becomes invalidated. Since the hash for block #2 did not have “0000” in front of it, block #3 also runs into the same issue.
This is a unique feature of the blockchain, known as immutability. No one can go back and change any block without invalidating the entire network, embedding a form of censorship resistance in the technology.
Decentralization
Decentralization sits at the core of many blockchain projects, including Bitcoin and Ethereum. In a decentralized network, there are many validators who are operating in parallel to secure the network.
Here, Peer A and Peer B are both responsible for maintaining the integrity of this blockchain. When there are discrepancies between the two, we can look at Peer C’s network to determine which one is the malicious actor.
The bad actor can be kicked out and the network can continue to function as it would. Democracy is, therefore, a crucial component of the blockchain. However, it also opens up some potential vulnerabilities. For example, many small networks are prone to a 51% attack where one actor controls 51% of the mining activity.
Conclusion
At Uncommon Cents, we do deep dives into specific blockchain projects every single week. Come follow the journey as we embark on the future.
To play around with hash, hash functions, and blocks, check out Blockchain Demo.