Funded by the European Union. Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or the National Agency. Neither the European Union nor National Agency can be held responsible for them.

Basic components: blocks, cryptographic hashing, decentralization

How Does a Blockchain Work? 

  • Each transaction or data entry, known as a "block," is securely linked to the previous one through cryptographic hashing, creating a continuous and tamper-resistant chain of information. 
  • Because there is no way to change a block, the only trust needed is at the point where a user or program enters data. This aspect reduces the need for trusted third parties, which are usually auditors or other humans that add costs and make mistakes. 

A blockchain consists of programs called scripts that conduct the tasks you usually would in a database: Entering and accessing information and saving and storing it somewhere. A blockchain is distributed, which means multiple copies are saved on many machines, and they must all match for it to be valid. 

The blockchain collects transaction information and enters it into a block, like a cell in a spreadsheet containing information. Once it is full, the information is run through an encryption algorithm, which creates a hexadecimal number called the hash

Figure 1 How the blockchain works (Source: https://www.geeksforgeeks.org/how-does-the-blockchain-work/

The transaction process in a blockchain can be summarized as follows: 

  1. Facilitating a transaction
  2. Verification of transaction
  3. Formation of a new block
  4. Consensus Algorithm
  5. Addition of the new block to the blockchain
  6. Transaction complete

The hash is then entered into the following block header and encrypted with the other information in the block. This creates a series of blocks that are chained together.

Transactions follow a specific process, depending on the blockchain they are taking place on. For example, on Bitcoin's blockchain, if you initiate a transaction using your cryptocurrency wallet—the application that provides an interface for the blockchain—it starts a sequence of events.

  1. Facilitating a transaction: A new transaction enters the blockchain network. All the information that needs to be transmitted is doubly encrypted using public and private keys.
  2. Verification of transaction: The transaction is then transmitted to the network of peer-to-peer computers distributed across the world. All the nodes on the network will check for the validity of the transaction like if a sufficient balance is available for carrying out the transaction.
  3. Formation of a new block: In a typical blockchain network there are many nodes and many transactions get verified at a time. Once the transaction is verified and declared a legitimate transaction, it will be added to the mempool.  All the verified transactions at a particular node form a mempool and such multiple mempools form a block.
  4. Consensus Algorithm:  The nodes that form a block will try to add the block to the blockchain network to make it permanent. But if every node is allowed to add blocks in this manner then it will disrupt the working of the blockchain network.
  5. Addition of the new block to the blockchain: After the newly created block has got its hash value and is authenticated, now it is ready to be added to the blockchain. In every block, there is a hash value of the previous block and that is how the blocks are cryptographically linked to each other to form a blockchain. A new block gets added to the open end of the blockchain.
  6. Transaction complete: As soon as the block is added to the blockchain the transaction is completed and the details of this transaction are permanently stored in the blockchain. Anyone can fetch the details of the transaction and confirm the transaction.

Comparison to traditional databases

The traditional databases are centralized, mutable, and optimized for high-speed data processing, while blockchains are decentralized, immutable, and focused on providing trust and transparency through consensus mechanisms. The choice between the two depends on the specific needs of a given application.

  • Centralization vs. Decentralization
  • Data Structure
  • Access Control
  • Consensus Mechanism
  • Immutable vs. Mutable Data
  • Transaction Speed and Scalability
  • Use Cases

Centralization vs. Decentralization

Traditional Databases: Traditional databases are centralized systems where a single entity (e.g., a company or organization) has control over the database. They rely on a central server or a cluster of servers to manage and store data. 

Blockchain: Blockchains are decentralized networks where data is distributed across multiple nodes (computers) in a network. There is no central authority or single point of control, making them resistant to censorship and tampering.

Centralized

All nodes are connected under a single authority.

Decentralized

No single authority server controls the nodes, they all have individual entity.

Distributed

Every node is independent and interconnected with each other.

Transaction in distributed network

Transaction is recorded in a node and copied to each other.

A hash function is a mathematical function that converts input value into another compressed value. The input to the hash function is of arbitrary length but output is always of fixed length.

Hash functions are extremely useful and appear in almost all information security applications.

Unique output of hash function

SHA1 is not enough in this time

Pre-Image resistance

This property means that it should be computationally hard to reverse a hash function.

In other words, if a hash function h produced a hash value z, then it should be a difficult process to find any input value x that hashes to z.

This property protects against an attacker who only has a hash value and is trying to find the input.

Collision Resistance

This property means it should be hard to find two different inputs of any length that result in the same hash. This property is also referred to as collision free hash function.

In other words, for a hash function h, it is hard to find any two different inputs x and y such that h(x) = h(y).

Since, hash function is compressing function with fixed hash length, it is impossible for a hash function not to have collisions. This property of collision free only confirms that these collisions should be hard to find.

This property makes it very difficult for an attacker to find two input values with the same hash.

Also, if a hash function is collision-resistant then it is second pre-image resistant.

Blockchain

Block = data + hash of previous block + hash

Chain = chain between blocks

Proof of Work

Proof of work (PoW) is a form of cryptographic proof in which one party (the prover) proves to others (the verifiers) that a certain amount of a specific computational effort has been expended.

Verifiers can subsequently confirm this expenditure with minimal effort on their part.

Proof of stake

Proof-of-stake (PoS) protocols are a class of consensus mechanisms for blockchains that work by selecting validators in proportion to their quantity of holdings in the associated cryptocurrency.

This is done to avoid the computational cost of proof-of-work (POW) schemes.

The 3 levels of blockchain

  1. Blockchain 1.0: The origin of the modern blockchain
  2. Blockchain 2.0: Smart contracts
  3. Blockchain 3:0: Decentralized enterprise level application

Comparison to traditional databases

Data Structure

Traditional Databases: Traditional databases use tables to organize data in a structured manner, typically following a predefined schema.

Blockchain: Blockchains use a ledger structure where data is organized into blocks, and each block contains a list of transactions or data entries. The structure is typically less rigid, allowing for more flexibility in data types and formats.

Access Control

Traditional Databases: Access control is managed by a centralized authority, and permissions can be granted or revoked for various users or roles. 

Blockchain: Access control is often managed through cryptographic keys. Users have control over their private keys, allowing them to interact with the blockchain without relying on a central authority. Public blockchains are typically permissionless, while private blockchains may have varying levels of access control. 

Consensus Mechanism

Traditional Databases: Traditional databases do not rely on a consensus mechanism among multiple parties. They assume that the data stored in the database is accurate. 

Blockchain: Blockchains use consensus mechanisms (e.g., Proof of Work, Proof of Stake) to validate and agree on the state of the ledger. This ensures that all participants in the network have a shared and agreed-upon view of the data. 

Immutable vs. Mutable Data

Traditional Databases: Data in traditional databases can be modified or deleted by authorized users with the necessary permissions. 

Blockchain: Once data is recorded on the blockchain, it is typically immutable and resistant to alteration. This immutability is a core feature of blockchain technology. 

Transaction Speed and Scalability

Traditional Databases: Traditional databases are often optimized for high transaction speeds and can scale easily by adding more servers or resources. 

Blockchain: Public blockchains, especially those using Proof of Work, can have slower transaction processing speeds and scalability challenges. However, various solutions and technologies are being developed to improve blockchain scalability. 

Use Cases

Traditional Databases: Traditional databases are well-suited for applications that require high throughput, low latency, and centralized control, such as banking systems and e-commerce platforms. 

Blockchain: Blockchains are best suited for applications requiring decentralization, trust, transparency, and security, such as cryptocurrencies, supply chain tracking, voting systems, and smart contracts. 

How does a blockchain work – Simply Explained [6:00]

Blockchain Basics & Cryptography

© 2024 Blockchain for Agri Food Edu. All rights reserved.
menuchevron-down