Blockchain

By Maurizio Farina | Posted on November 2017 |

The rise of criptovalutes has made known to everyone the technology that guarantees their applicability, security and consistency of transactions: Blockchain.
This short post is to describe what Blockchain is and why it will probably survive the success or failure of the cryptocurrencies.

What is a Blockchain?

The easy description: The Blockchain is software technology that allows multiple hosts to manage a public ledger where all transactions are recorded; once information is entered it cannot be manipulated and not owned by few parts. A full copy of a Blockchain contains every transaction ever executed. With this information is possible to know all transactions at any point in history.

Financial transactions, for example, are shared by many counterparts; this avoids having the monopoly of banks or government institutions. Blockchain is at the heart of the BitCoin revolution as well as other cryptomonets.

a simple rough example about how a Blockchain may look like: Simple Blockchain

A block contains four pieces of information: a summary of included transactions, a time stamp, the Proof of Work that went into creating the secure block and a reference to the previous block. The only exeception is for the first block of the chain called the genesis block (generally hardcoded into the software and numbered as Block 0) that doesn't contain the reference to the previous block.

Starting from the genesis block, the sequence of blocks is chronologically guaranteed because the block created does not know the hash of the previous block.

Same for modifying the block when is already inserted into the chain. Modifying the block, then changing the chain, would require the generation of subsequent blocks.

The number of transactions in a block depend on when the block is closed.

Components of the Blockchain:

  • Shared public ledger
  • P2P Network
  • Cryptography

Hash Algorithm

BitCoin uses the SHA-256 to generate "random" numbers. The random numbers generated require a predictable amount of CPU to be verified. Generating a new SHA-256 hash with a value below the current target solves a block and earns you some coins.

The Blockchain is broadcast to all nodes on the networking using a flood protocol.

What is the role of miners?

Mining is the process of adding transaction records to the public registry and generating hash code to use for the new blocks.

The blocks are linked together using the hash reference to the previous block. Blocks generally require numerous independent confirmations and the Blockchain require to build new blocks to improve low latency.

Miners use their servers to process transactions in exchange for fees. Miners resources needs to be efficient which means buy graphics cards and computer hardware.

How new blocks are generated?

The individual blocks must contain an hash in the header. The mining activity consists to find a SHA-256 hash beginning with '000' considering possible numbers coded using 256bit (very huge number).

When a new hash is find the 256bit number used have to be compared with a target number shared with all nodes; if the new number is lower it became the new target number and a new block is generated.

The maximum target used by SHA256 mining devices is:

1
0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

What happens when two blocks are generated within a few seconds?

Blockchain forks

The previousHash attribute in each block ensures that there is only one valid path from block to genesis block; but when two blocks are generated in a few seconds it may happen that two blocks have the same reference to the same parent block.

In this case there is a fork on the Blockchain.

Blockchain Fork

How are the forks managed?

All transactions in the shorter chain are added to the transaction pool and will be included in another block.

All blocks in the shorter chain are eliminated and the reward will not be present in the longest chain.

Personal Considerations

The Blockchain, from functional perspective, means "a public ledger" that anyone can check; so the challenge is not only in cryptocurrency but finding new uses unleash this potential.

Few examples:

  • Identity management
  • Managing contracts
  • Content Management
  • or anything that benefits from a public ledger system

References

URL Description
Genesis Block Code An old version of Bitcoin. Useful to understand all hardcoded values in the genesis block
Bitcoin wiki a wiki around Bitcoin technology and topics