5 Things you must know as a BlockChain Developer

5 Things you must know as a BlockChain Developer

·

8 min read

This article is the part 1 of the series of five(5) parts that would attempt to explain the five(5) concepts of blockchain technology.

Before we go into each part that made up the concept, let us first understand what is blockchain and how it all came to be.

What is a Blockchain?

The goal of blockchain is to allow digital information to be recorded and distributed, but not edited. Blockchain technology was first outlined in 1991 by Stuart Haber and W. Scott Storneta, when their paper was published: How to timestamp a digital document, the two researchers wanted to implement a system where document timestamps could not be tampered with. But it wasn’t until almost two decades later, with the launch of Bitcoin in January 2009, by Sotashi Nakamoto, that blockchain had its first real-world application. However, they didn't necessarily coined or introduced the term blockchain but, their paper laid the foundation for what we have today as blockchain technology. The paper highlighted some of the concept behind blockchain.

According to wikipedia,

A blockchain, is originally a growing list of records, called blocks, that are linked using cryptography. Each block contains a cryptographic hash of the previous block, a timestamp, and transaction data .

Also, Investopedia brought another perspective that totally made sense to me in terms of really understanding the blockchain network:

Blockchain seems complicated, and it definitely can be, but its core concept is really quite simple. A blockchain is a type of database. One key difference between a typical database and a blockchain is the way the data is structured. A blockchain collects information together in groups, also known as blocks, that hold sets of information. Blocks have certain storage capacities and, when filled, are chained onto the previously filled block, forming a chain of data known as the “blockchain".

Another concept worth the time, is the blocks. Each node in the blockchain network has its data saved to the blocks that linked another node(block) along the chain. To understand the concept of blocks, you can take a look at this place and also from Andres github repo. However, we will talk more about blocks when we get to the mining part.

This is going to be a long read, so brace up;

There are five(5) concept to blockchain which will serve as our key takeaways:

  1. Hash Cryptography
  2. Immutable Ledgers
  3. Distributed P2P network
  4. Consensus Protocol
  5. Mining

So lets start with Hash Cryptography

TLDR;

The Five requirement of hash algorithms

  1. irreversible; it is has to be one-way.
  2. it is deterministic
  3. fast computation
  4. Avalanche Effect. this implies any change to the data used the hashing will change the hash value.
  5. it must withstand collision

    What is Hashing?

To understand why hashing knowledge is integral to blockchain, we should first understand how the chain are formed and what are the blocks that form those chains. What is a block, how does it form a chain with another block, what are the properties or characteristics of a block and what are the criteria for a block to form a link to previous or next block. We will first introduce secure hash algorithms as part of digital signature schemes and the derived properties a hash function is required to have from this context. SHA - Secure Hash Algorithm, was originally designed for this purpose, that is why a block hash value is computed using SHA256, each block is cryptographically linked to the previous block by matching the hash value of the previous block. That explains why the blockcahin network is considered highly secured. So each block has it own fingerprint and also references the fingerprint of the next block. if anything changes in any block it will also change the fingerprint of the block. if anybody tempers with the data of a block, then the fingerprint will no longer match and chain will be invalid.

To understand hashing, we first understand the concept behind it.

Understanding SHA256 Hash.

A Real life representation of a Hashing concept is a case where each person has a unique fingerprint and no two persons will have the same fingerprint. The possibility of two people having the same fingerprint is like 1:60,000,000, which is also very unlikely. it is a powerful concept used in identifying a person. the same principle can be used to identify say a document using SHA256 Hash. The Secure Hash Algorithm (SHA) was developed by the NIST in association with the NSA and first published in May 1993 as the Secure Hash Standard. It is used in Blockchain as the core principle behind the building block of blockchain. The SHA256 takes up 256 bits in memory and its 64 character long containing both letters and numbers, hence it is a hexadecimal that ranges from number 0 to 9 and letters from A to F inclusive.

Hashing is used in Blockchain to create a purely peer-to-peer version of electronic cash that would allow online payments to be sent directly from one party to another without going through a financial institution. Digital signatures provide part of the solution and that is what hash cryptography brought to the table. Hash function that produces the hash values are totally irreversible, they are one way, you cant take the result of a hash function and feed to another hash function to get the original values. They are also deterministic. If you take an input and feed into a hash function you should expect the same result each time. Hash codes are created by a hash function that turns digital information into a string of numbers and letters. If that information is edited in any way, the hash code changes as well.

A cryptographic hash function is a mathematical function used in cryptography: an algorithm that consists of bitwise operations, modular additions, and compression functions. Typical hash functions take inputs of variable lengths to return outputs of a fixed length. In the context of cryptocurrencies like bitcoin, the transactions are taken as input and run through a hashing algorithm which gives an output of a fixed length. Each output called the fingerprint is 64 character long and has the capacity to represent 256 bits in memory. You can imagine how huge the size of what it can contain but then cut down to a fixed length for every input.

Encoding of the Hash Function

Hash algorithms include thousands of logical operation on input bits. Hashing means generating a (hopefully) unique number that represents a value. In the case of each block in the blockchain, the block data known as the message which contains; the block version number, the current timestamp, the current difficulty target. (a threshold set to proof the eligibility of the block to be added to the blockchain network), hash of the previous block (digest or fingerprint), Nonce ( The nonce is an arbitrary string that is concatenated with the hash of the block), hash of the Merkle Root( used to cut down the time required to find out whether a particular transaction belongs in that block or not), the input is processed in parts of 512 bit for each bits that makes up the input, in this case the block data. Hashing requires processing the data from a block through a mathematical function, which results in an output of a fixed length. Using a fixed-length output increases security since anyone trying to decrypt the hash won’t be able to tell how long or short the input is simply by looking at the length of the output.

Hashing the word “hello” will produce an output that is the same length as the hash for “I am going to the store.”

Now, about the five requirements a hash algorithm must adhere to, In order to be an effective cryptographic tool, the hash function is desired to possess following properties

A hashing Algorithm must be irreversible

it should be infeasible to take the hash value of an input and decompress it to get the original input that was used to produce the hash value sometimes called the fingerprint or digest. The cornerstone of cryptographic security lies in the provision of pre-image resistance, which makes it hard and time-consuming for an attacker to find an original message, M, given the respective hash value, h(M). This security is provided by the nature of one-way functions, which is a key component of SHA. Pre-image resistance is necessary to ward off brute force attacks from powerful machines.

It is deterministic

it should be infeasible for two input to produce the same output. Given an input K that produces an output h(K), another input M, that produces an output h(M). it should be infeasible for h(K) to equal h(M). this security approach is called a second pre-image resistance. So if we take a document and hash it, it should produce the same output every time.

Fast computation

Before a block is added to the blockchain network is should be able to run a fast computation that can allow it accomplish a hash value below the blockchain algorithm. the cryptographic hash function, should execute fast, thus making it eligible to be part of the blockchain network.

Avalanche Effect.

This implies any change to the data used in the hashing will change the hash value. This is one of the fundamental feature that makes hash values unique. Any alteration to the input data will change the hash value. this contributes to the highly secure attribute of the blockchain.

It must withstand collision

A hash algorithm must withstand collision making it unfeasible for two input values to have the same hash value. just like for example in the case of fingerprint in humans, no two persons has the same fingerprint, though it could be possible but the possibility is like 1:60,000,000, that is a very rare case.

Conclusion

The cryptographic links that connect the blocks is what made blockchain possible with high level of security. The hash cryptography requirement is to add uniqueness to each data block and distributed among peers in the network. The hash also makes the distribution aware of each peer hash on the network. Cryptographic hash function is a fundamental building block in modern cryptography and is used for digital signature, message authentication, anomaly detection, pseudo-random number generator, password security, and so on.

You can find me on Twitter

Further Reading:

Stuart Haber and W. Scott Storneta: How to timestamp a digital document

Cryptography in Context