What is a blockchain? And why it is so secure?

Abir Hassini
6 min readNov 15, 2022

You have surely heard about “Blockchain” the technology that runs Bitcoin, so what is blockchain?

As the name indicates, a blockchain is a chain of blocks in which each block contains data and a reference to the previous one in the list. The data contained in a block can be anything (in the case of a cryptocurrency, the data stored in a block is usually a list of transactions).

This technique was originally described in 1991 by a group of researchers to timestamp digital documents so that it’s impossible to backdate them or to tamper with them.

This technology was unused until it was adopted by Satoshi Nakamoto in 2009 (whose true identity is still unknown) to create the digital cryptocurrency Bitcoin. Blockchain provided the answer to digital trust because it records important pieces of information in a public space and doesn’t allow anyone to remove them. It’s transparent, time-stamped, and decentralized.

Because of the power of this technology, many entrepreneurs started to realize around 2014 that it could be used for more than cryptocurrency, and they decided to invest in and explore how blockchain could alter many different kinds of operations and impact supply chains, healthcare, insurance, transportation, voting, contract management, and more…

Since the Blockchain is used in different areas and by different institutions, it might be secure, so what makes this technology secure?

Well, first, Blockchain is not unbreakable. It is hard to hack or corrupt, and we will see how.

What makes a blockchain so secure?

As said, once some data has been recorded inside a blockchain, it becomes very difficult to change it. To understand the POC, let’s take a closer look at a block:

Each block contains some data, the hash of the block, and the hash of the previous block.

1 - A block contains data that depends on the type of blockchain. For example, the bitcoin blockchain stores different details about a transaction like a sender, receiver, and the number of coins….

2 - A block also has a hash (we can consider a hash as a fingerprint). It identifies a block and its contents, and it’s always unique.

Once a block is created, the hash is calculated using a hash function.

Changing something inside the block will cause the hash to change, which means it no longer identifies the same block. We use often this technique to detect changes.

3 - The third element inside each block is the hash of the previous block, and this effectively creates a chain of blocks which makes a blockchain so secure.

As you can see, the first block cannot point to previous blocks since it’s the first one. We call this block “The genesis block”.

If we tried to change the data inside a block, for example, ”the second block”, this will cause a hash for that block changes as well, which will make the all following blocks invalid because they no longer point to a valid hash of the previous block. So changing a single block will impact all the following blocks and make them invalid.

After understanding the concept of a blockchain, the question now is: how a hash can be calculated?

Well, each hash of a block is calculated by using certain aspects of cryptography such as “Secure Hash Algorithms” also known as SHA, which is a family of cryptographic functions designed to keep data secured. This algorithm works by transforming the data using a hash function: an algorithm that consists of bitwise operations on the input string, modular additions, and compression functions, to a fixed-size string output that looks completely different than the original.

Furthermore, the SHA algorithm is designed to be a one-way function, meaning that once the inputs are transformed into their respective hash values, it’s impossible to transform them back into the original data. To better understand this concept, here is the following example:

· Given m as an input, it is easy to calculate h by using a hash function H, such as h=H(m).

· Given h, it is difficult to calculate m such that H(m)=h

· Given m, it is difficult to find m’ such as H(m)= H(m’) otherwise we will have a COLLISION

(We can also use the hash to check if large files have been modified by comparing a recalculated hash with a hash stored, it can be determined whether change took place.)

There are a few algorithms of interest such as SHA-2 & SHA-3, and each one of these was successively designed with stronger encryption in response to hacker attacks. Hence, SHA-0 is obsolete due to the widely exposed vulnerabilities, and the same thing for SHA-1, cryptographers modified it to produce SHA-2, which consists of not one but two hash functions known as SHA-256 and SHA-512, using 32- and 64-bit words, respectively.

— Is it enough to use hashing for the security of a blockchain?

— How about trying to tamper with a block and recalculate all the hashes of other blocks to make our blockchain valid again?

Well, using hashes is not enough to prevent tampering since computers these days are faster and can calculate hundreds of thousands of hashes per second. So to mitigate this, blockchains have something called proof–of–work to make them more secure: It’s a mechanism that slows down the creation of new blocks. This technique makes it very hard to tamper with the blocks because if you tamper with one block, you’ll need to recalculate the proof of work for all the following blocks. So the security of a blockchain comes from using hashes and the proof-of-work mechanism.

There is another way that makes blockchains more secure is by being distributed, so instead of using a central entity to manage the chain, blockchains use a “peer-to-peer network” in which every node of that network has a copy of the blockchain, and when someone joins this network, he also gets the full copy of the blockchain, hence blocks that are tampered with will be rejected by other nodes in the network. So to successfully tamper with a Blockchain you’ll need to taper with all blocks on the chain, redo the proof of work for each block and take control of more than 50% of the peer-to-peer network. Only then will your tampered block become accepted by everyone else, and this is almost impossible to do!

--

--

Abir Hassini

I'm a Software Engineer & ML enthusiast. I find immense joy in crafting articles on Medium