Overview of Blockchain

Burakcan Ekici
12 min readSep 20, 2020

In this story, we will take a look at Blockchain fundamentals and the concepts and ideas stand behind the Blockchain. Beyond traditional database systems such as centralized or distributed databases, we will look at which common or different features the Blockchain has, and the innovative technological improvement that the Blockchain provides with ensuring the agreement between all participants while working on an untrusted environment and without a central authority.

The followings are the benefits of Blockchain that make the innovative technological improvement I mentioned above;

  • Pseudonymous, cryptographic identities allow for accountability.
  • Consensus protocols, to make democratic decisions in an untrusted environment that not controlled by any authority.
  • Immutable, all ledgers are public and any change can be detected easily so the truth of each ledger is provided.
  • Uncensorable, cannot be controlled by any third party or central authority.
  • Distributed, no central point of failure in the network.

Blockchain

Blockchain is literally just a chain of blocks. Technically, it is a structure that keeps the blocks, which contains digital information securely, by linking together like a chain. The chain is assumed as a growing list of records that are linked using cryptography.

The chain structure consisted of blocks seems like the image below. Each block is chained to the previous block by keeping the previous block information.

So, let’s consider where the first block is chained to, which is Genesis Block. The Genesis Block corresponds to Block #0 in the image below. In the Bitcoin environment, the first block of Bitcoin ever mined named Genesis Block and it created by Satoshi Nakamoto. It describes the Bitcoin trading system and its prototype, That’s why it apart from regular blocks that keep transactions.

The Blockchain Structure

The following items consist of a block;

  • Block Header It refers hash of the current block id. When any miner validates a block and wants to publish it, they announce this value. If a block with this ID is accepted, this block will be the last block on the blockchain and a new block will chain end of this.
  • Previous Block Hash It refers hash of the previous block id.
  • Nonce It is an arbitrary number used only once in the cryptographic communication. It is a 32-bit number. It is a dummy field to mining. Each miner starting at 0 as a nonce, keep increasing the nonce value until they validate PoW condition to mine a block and make a profit.
  • Merkle Root It is the root of a kind of tree structure that contains all transactions in the block. Each transaction is assumed as a node and each node hashed with its sibling and this circumstance continues until reaching the root.
The Merkle Root Structure

The tree structure at the right side of the image above shows how the root effects when any change is made in a transaction. Since we hash each level, any change in a transaction continues to the root element and it detects easily. Therefore, the immutability of transactions can be provided.

The following contexts make blockchain special and distinguish it from traditional systems;

1.Shared Ledger:

The biggest idea behind blockchain is keeping thousands of the same records in more than one place securely as a kind of distributed system, which is distributed ledgers. All nodes, which have a copy of the ledger, create a network by bringing together and each node connects to every single node in the network directly.

The difference between Distributed Databases and Ledgers

The image above shows the difference between traditional systems and what the blockchain proposed;

  • Centralized Databases: one central entity handles all requests and data processing.
  • Distributed Databases: a group of nodes that trust each other and cooperate to maintain a consistent overall view of the system.
  • Distributed Ledgers: a group of nodes that do not fully trust each other. The nodes must implement some form of consensus protocol to have a consistent view of the system.

As you see, the Distributed Ledgers and Distributed Databases are not the same things. The main difference is the trusted environment that not fully in the Distributed Ledgers (Therefore, the consensus algorithms help to have consistency in the system).

If any failure happens in any node, the network can keep working without any cut. Since each node should keep the latest secure copy of the ledger, the other nodes can keep working and, after fixing the failure, the troubled node can take the latest copy from any other nodes.

2.Permission:

Blockchains divide as public (permissionless) and private (permissioned) according to whether it requires permission to join the network and participate in the consensus. It can not be said that one is better than the other. Both types of blockchain address different problems and offer different solutions. Therefore, before determining which one will be used, we should describe the problems we are facing and figure which one offers the best solution out.

  • The permissioned governed by the organization, that’s why it has its own consensus method and offers more customizability on the blockchain.
  • The permissionless opens to all who want to join the network. Therefore it should provide a more trusted environment. Also, it is slower and harder to scale.
Permissioned vs. Permissionless Blockchain

3.Cryptography:

The main concern that should be handled is preventing the double-spending problem (which is the risk that a digital currency can be spent twice. The blockchain network is manipulated by reproduced digital information and it causes a potential problem).

Double Spending; Basically, it is successfully spending the same value more than once. Bitcoin, although being a digital currency, solves the problem of being copied and getting spent twice. Double Spending attack can happen as;

* Attack 51%: This attack happens through hash power weakness. If somehow an attacker captures and control 51% of the hash power of the network, it can happen.

“Hash Power” means the computational power that verifies transactions an blocks. If an attacker can control it, any transaction can be reversed by them and make a private blockchain which everyone will consider as real. But so far, no such attack has happened because controlling 51% of the network is highly cost intensive.

* Race Attack: When an attacker sends the same coin in rapid succession to two different addresses, the obvious outcome is that only one of them will get included. Now, if you as a merchant doesn’t wait for confirmations of payment, then in a case like this, there’s a 50% chance you got the double spent coin.

To prevent double spending problem, the transaction should be confirmed by taking from uncommitted transactions pool. The timestamp information is used to apply confirmation. All transaction announced and kept publically. Therefore, double spending attack can be detected from the timestamp information because the timestamp information proves that all the data in the hash couldn’t have been created after hash was published.

The followings are the most important concepts to use to prevent the double-spending problem by determining whether the related transaction belongs to who it sends really;

  • Digital Signatures (Digital signatures rely on public-key encryption and in bitcoin and other blockchains, digital signatures are mainly used in the transaction process as a way to sign the transactions and prove their ownership, without having to reveal their private key).
  • Hashing (Hashing is the process of sending data through a hash function to produce a specific, essentially unique hash of a fixed length. Hashing has Preimage Resistance which means finding the value that we have hashed is computationally difficult to find from the hashed value. It has also Collison Resistance which means computing the same hashed value from two or more separate inputs is impossible. Besides, It is deterministic because a given input will always have the same output, quick, and uses Avalanche Effect any single change even in a character affects the output significantly).

4.Consensus:

Every time someone sends money, a transaction message is passed around to all miners who want to help maintain the ledger with a math-based voting process. Each of these people keeps a personal copy of the ledger (peer-to-peer network) and updates it whenever they receive a new transaction with a valid signature. Since some differences, which are caused by delays and frauds, can happen during this operation occurs, people who aim to gain profit in the network need to decide which version they use. To deal with these problems each of these people works on their version of the ledger. The first person who solved it announces their solution, then everyone updates their version.

Similar indecision comes to mind when a new miner joins to network for the first time and requires to take a copy of the ledgers; whose copy should be preferred?

Since the blockchain offers the network without any central authority, how to provide the agreement between the participant of the network become important. Without consensus, transactions fall apart and not saved to the blockchain. Several consensus methods are described such as; Proof of Work (PoW) which requires network users to resolve a complex mathematical puzzle with the goal to validate a transaction and create a new block, Proof of Stake (PoS) which selects the creator of the next block based on several stakes related factors, and etc.

Proof of Work is a solution to the Byzantine Generals’ Problem and also an example of the Byzantine Consensus Algorithm. It is the validation part, Miners continuously compete to solve a very computationally difficult problem are; Easy to verify, Hard to compute.

Byzantine Generals’ Problem; Generals stationed around a city are trying to coordinate an attack. If they want to be success, they all do the same thing they select although existince of treators in network. (without centralized authority, nodes in network try to reach a consensus they don’t look whether it true, at distributed systems that hold dishonest node)

Historicaly, emperor wants to send what he thinks to their commander and send messengers to commanders (send several messengers to each commander). Then commanders share what emperor wants to each other. Commanders accept and do what message says if the greater of the messengers bring same message.

To solve BGP, Byzantine Fault Tolerance was created. This method determines what the system should move at various signals and distributed systems. There are some rules about this method;

* 2/3 of the system must be honest.

* Each node must do what message that is send by greater of the system contains.

* Main goal is do something together without doubt even it is not true.

To prevent these indecision circumstances, the PoW concept is used to make consensus in the blockchain network. All miners try to find a valid nonce to mine their blocks through solving math problems to vote or validate. It causes each vote to have a cost in computing power. Therefore, making to manipulate the majority of users with numbers of people at the number of times on vote is ineffective. Also, there is no mathematical tricks or shortcuts to solving faster. It exactly depends on all computing power you have.

The speed of solving the nonce value and the time required to mining a block never keeps the same. It may changes according to the computational power the miners have or another possible reasons. Miners gain a profit when they broadcasted a new block and a big part of this profit consists of the Block Reward which is a constant value and sends to the miner automatically. By the block numbers in the chain is increasing, this Block Reward will decrease continuously, which means the miners get less than 12,5 BTC that were paid at the beginning. This circumstance directly affects the interest of the miners. Therefore, the following information is used to keep the interest at a specific level;

* Difficulty; a representation of the expected number of computations required to find a block (difficulty value represents finding hash hardness level). The mining difficulty changes at every 2016th block.

* Target; It calculates from difficulty so it depends on calculation power of miners. This target number is value that start with several zero. (With increasing difficulty level, the target value are increased each time when difficulty re-calculated at every 2016th block).

A specific time to need to mine the last 2016 blocks is determined to realize that whether it needs to be changed; If the previous 2016 blocks have been mined earlier than the time determined , the difficulty is re-calculated and it will be raised. Otherwise, If the mining previous 2016 blocks require more than the time determined before, the difficulty is re-calculated and it will be decreased.

In mining, the goal is to find a hash below a target number as find proper nonce value because the Merkle root and the prevBlockHash are constant, and the only changeable variable is nonce. If this condition is true, your block is accepted and it is proof-of-work. The miner who finds nonce first, get the block reward and all transaction fee in this block.

Bitcoin

Bitcoin’s pseudonymous creator Satoshi Nakamoto referred to it as “a new electronic cash system that’s fully peer-to-peer, with no trusted third party.”. The Bitcoin protocol is built on the blockchain.

The following principles define the Bitcoin process;

  1. Download the entire Bitcoin blockchain: miners require to download the entire blockchain and keep it up to date.
  2. Verify incoming transactions: miners collect and verify a group of uncommitted transactions according to their transaction fees.
  3. Create a block: miners create a block and put verified transactions into this block with previous block hash and other metadata information.
  4. Find a valid nonce: miners try to be the first who finds a valid nonce through solving the mathematical equation (depends on the computing power they have). Since PoW is used to make consensus in the Bitcoin network, finding a valid nonce value to broadcast the block is essential for the Bitcoin network.
  5. Broadcast your block: the first miner who finds the nonce value has a right to broadcast the block that contains all transactions they have validated. The Peer-to-peer network concept provides the miner broadcast the block to each participant in the network and prevents any problem related to broadcasting.
  6. Profit: When the miner mines any block, the miner deserves a profit that consists of the block award and the total fee inside the block they have broadcasted. It calculated as; MINING_REVENUE = BLOCK_REWARD + TX_FEES. Here, BLOCK_REWARD is a constant payment, and TX_FEES is the total of fees that belong to transactions verified in the current block.

Wallet

In the blockchain environment, not every client is a miner. Some people don’t have to entire blockchain, it may be possible that there are some people just want to buy/send their bitcoin.

Bitcoin transfer made between accounts by using information called to address. Using the bitcoin address ensures that the owner of the bitcoins remain anonymous because it prevents knowing who owns the relevant account. The bitcoin address is generated from the public-key via several hashing algorithms SHA256 and RIDEMP160, and then the hashed public-key puts into Base58 Check Encode and the bitcoin address is generated.

Bitcoin Address Generation

We won’t go beyond that in this story but if you want to look into how to generate a Bitcoin address from a public key practically, you look at my other story. Also, it mentions the conversion that seems in the image above in more detail.

One person may have multiple private-key and bitcoin addresses, so they need somewhere to keep their keys, and addresses are named as Wallet. A wallet can do;

  • Keep track of your private key
  • Store, send & receive, and list transactions
  • Maybe some other related fancy functionality

Wallets can be classified according to whether it is connected to the internet;

  • Hot: It is connected to the internet which provides access to cryptocurrency quickly. Also, it is free and easy to use. Smartphone apps (Mycelium Online), web-wallets (coinbase.com)
  • Cold: It is not connected to the internet which causes accessing cryptocurrency not as quick as hot wallets and expensiveness but it is the most secure option. Paper Wallets (bitaddress.org), Hardware Wallets (Ledger)

As same as public vs. private blockchain, it can not be said that one is better than the other. Both types of wallet address different problems and offer different solutions.

If the owner prefers long-term keeping the bitcoin they have, cold wallets offer a better solution than hot wallets because what you have kept in hot wallets open to the internet and the attacks that come with. Also, trusting a third party to keep our assets brings a concern about their reliability. On the other hand, cold wallets just need physical protection.

Otherwise, in short-term keeping, it is not easy to transfer or exchange the bitcoins we have in cold wallets because we need to make some configuration to access our assets that kept in cold wallets at each time we will use.

Of course, there are more concepts that lie behind the blockchain than we talked about, but in this story, we tried to guide someone who is new to blockchain technology and wants to be familiar with the concepts proposed with blockchain.

--

--