Blockchain core technology

Blockchain Core Technologies

Learning Objectives

  • Understand the underlying core technologies of blockchain: Hash Function, Merkle Tree, Digital Signature, Encryption Technology
  • Master the principles and classifications of mainstream consensus mechanisms
  • Understand the operating principles and overall architecture of blocks
  • Recognize the characteristics and application scenarios of consortium blockchains

Prerequisites

  • Basic computer science concepts (data structures, algorithms)
  • Preliminary understanding of cryptography (optional)
  • Have read 01-Web3 Overview and Vision

I. Hash Function

1.1 What is a Hash Function?

A Hash Function is a mathematical function that maps an input of arbitrary length to a fixed-length output. The output result is called a Hash Value or Digest.

输入(任意长度) → 哈希函数 → 输出(固定长度)

For example:

SHA-256("Hello") → 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969
SHA-256("Hello!") → 334d016f755cd6dc58c53a86e183882f8ec14f52fb05345887c8a5edd42c87b7

Just one extra exclamation mark, and the output is completely different—this is the avalanche effect of hash functions.

1.2 Characteristics of Hash Functions

Characteristic Description
Easy to compute forwards Given an input, the hash value can be calculated quickly
Difficult to derive backwards Given a hash value, it's almost impossible to reverse-engineer the original input
Collision resistance It's very difficult to find two different inputs that produce the same hash value
Determinism The same input always produces the same output
Avalanche effect A tiny change in the input leads to a significant change in the output

1.3 Common Hash Algorithms

MD5:
- Output length 128 bits (32 hexadecimal characters)
- Fast computation speed, but security has been compromised
- Currently only used for non-security scenarios like file integrity verification

SHA-256:
- Output length 256 bits (64 hexadecimal characters)
- Hash algorithm adopted by Bitcoin
- High security, not yet compromised
- The most widely used hash algorithm in the blockchain field

Hash functions are widely used in blockchain: block hashes, transaction hashes, Merkle trees, Proof of Work (mining), etc., all rely on hash functions.


II. Merkle Tree and Merkle Proof

2.1 What is a Merkle Tree?

A Merkle Tree is a tree-like data structure where each leaf node is the hash of a data block, and each non-leaf node is a combined hash of its child node hashes.

          Root Hash
         /         \
      Hash01       Hash23
      /    \       /    \
   Hash0  Hash1  Hash2  Hash3
     |      |      |      |
   Data0  Data1  Data2  Data3
  • Leaf Nodes: Hashes of original data
  • Intermediate Nodes: Hashes of concatenated child hashes
  • Root Node (Merkle Root): The "fingerprint" of the entire tree, representing a digest of all data

2.2 Merkle Proof

A Merkle Proof is used to efficiently verify whether a specific piece of data is included in a Merkle tree, without needing to download all data.

Merkle Proof

Verification Process:

Suppose we want to verify if Data1 is in the tree:
1. Provide the hash of Data1, Hash1
2. Provide the sibling node Hash0
3. Calculate Hash01 = Hash(Hash0 + Hash1)
4. Provide the sibling node Hash23
5. Calculate Root = Hash(Hash01 + Hash23)
6. Compare the calculated result with the known Merkle Root; if they match, verification is successful

Advantages:
- Verifying a single piece of data only requires O(log n) hash values, not O(n) all data
- This allows light nodes (SPV nodes) to verify transactions without storing the entire blockchain


III. Digital Signature

Digital signatures are a core technology for identity verification and transaction authorization in blockchain.

Digital Signature

3.1 Basic Principle

Digital signatures are based on asymmetric encryption (public-key cryptography) and involve a pair of keys:

  • Private Key: Known only to the holder, used for signing
  • Public Key: Publicly available, anyone can use it to verify a signature

3.2 Signing and Verification Process

Signing Process (Sender):
1. Calculate the hash value of the original data
2. Encrypt the hash value with the private key to generate a digital signature
3. Send the original data and digital signature together

Verification Process (Receiver):
1. Decrypt the digital signature with the sender's public key to obtain hash value A
2. Calculate the hash value of the received original data to obtain hash value B
3. Compare A and B; if they match, verification is successful

3.3 Role in Blockchain

  • Identity Verification: Proves that the transaction was indeed initiated by the private key holder
  • Tamper-proofing: If transaction content is modified, signature verification will fail
  • Non-repudiation: The signer cannot deny transactions they have signed

In blockchain, your private key is your identity. The common saying "Not your keys, not your coins" emphasizes the importance of private keys.


IV. Encryption Technology

Encryption Technology

Encryption technologies used in blockchain are mainly divided into two categories:

4.1 Symmetric Encryption

  • Encryption and decryption use the same key
  • Advantages: Fast computation speed
  • Disadvantages: Key distribution is difficult—how to securely transmit the key to the other party?
  • Common algorithms: AES, DES, 3DES

4.2 Asymmetric Encryption

  • Encryption and decryption use different keys (public key for encryption, private key for decryption)
  • Advantages: Solves the key distribution problem, public keys can be public
  • Disadvantages: Slower computation speed than symmetric encryption
  • Common algorithms: RSA, ECC (Elliptic Curve Cryptography)

Blockchain primarily uses Elliptic Curve Cryptography (ECC), especially the secp256k1 curve (adopted by both Bitcoin and Ethereum). Compared to RSA, ECC offers shorter keys and faster computation at the same security level, making it very suitable for resource-constrained scenarios.


V. Consensus Mechanisms

Consensus mechanisms are the core of blockchain, solving a fundamental problem: in the absence of a centralized authority, how to enable all nodes to agree on data?

Mainstream consensus mechanisms can be divided into two major categories based on whether they are "write-then-consensus" or "consensus-then-write".

5.1 Write-then-Consensus

These mechanisms first allow nodes to propose blocks, and then the network confirms their legitimacy.

POW (Proof of Work):
- Nodes compete for the right to record transactions by expending computing power to solve mathematical puzzles
- The node that first solves the puzzle gains block creation rights and rewards
- Representative project: Bitcoin
- Advantages: Security verified for over a decade, high degree of decentralization
- Disadvantages: Huge energy consumption, slow transaction confirmation

POS (Proof of Stake):
- Nodes compete for the right to record transactions based on the amount and duration of staked tokens
- The more tokens staked, the higher the probability of gaining block creation rights
- Representative project: Ethereum 2.0
- Advantages: Low energy consumption, high efficiency
- Disadvantages: May lead to "the rich get richer"

DPOS (Delegated Proof of Stake):
- Token holders vote to elect a certain number of "delegates" (supernodes) to take turns creating blocks
- Representative project: EOS
- Advantages: Fast transaction speed, high throughput
- Disadvantages: Reduced decentralization, prone to oligarchy

POX (Hybrid Proof):
- Combines the advantages of POW and POS
- Different consensus methods are used for different stages or functions
- Attempts to strike a balance between security, decentralization, and performance

5.2 Consensus-then-Write

These mechanisms first allow nodes to reach consensus on block content, and then write the block to the chain.

PBFT (Practical Byzantine Fault Tolerance):
- Nodes reach consensus through multiple rounds of voting
- Can tolerate up to 1/3 malicious nodes
- Advantages: Strong transaction finality (irreversible once confirmed), low latency
- Disadvantages: Communication overhead increases sharply with the number of nodes, not suitable for large-scale public chains

Chained-BFT:
- An improved version of PBFT, pipelining the consensus process
- Each round of voting also serves as a confirmation for the previous round
- Reduces communication complexity and increases throughput
- Representative project: Diem (formerly Libra)

Tower-BFT:
- Uses time as an auxiliary means for consensus
- After a node votes for a block, it must wait a certain period before changing its vote
- Waiting time increases exponentially with voting rounds, making historical blocks increasingly difficult to overturn
- Representative project: Solana


VI. Block Operating Principles

Block Operating Principles

The basic structure of a block includes:

6.1 Block Header

Field Description
Previous Block Hash Points to the previous block, forming a chain structure
Timestamp Time of block creation
Merkle Root Merkle tree root hash of all transactions in this block
Difficulty Target Mining difficulty in POW (POW chains only)
Nonce Random number tried by miners (POW chains only)

6.2 Block Body

  • Contains all transaction records within this block
  • Transactions are organized into a Merkle tree, with the root hash stored in the block header

6.3 Operating Flow

  1. Users initiate transactions, sign them with their private key, and broadcast them to the network
  2. Nodes receive transactions and place them into the transaction pool (Mempool)
  3. Block-producing nodes select transactions from the transaction pool and package them into a block
  4. 4. Confirm the legitimacy of the block through a consensus mechanism
    5. The confirmed block is appended to the chain, and transactions officially take effect
    6. All nodes synchronize to the latest state

Blocks are linked end-to-end by the "previous block hash," forming an immutable chain. If data in a historical block is tampered with, its hash value will change, invalidating the "previous block hash" of all subsequent blocks—an attacker would have to recalculate the hashes of all subsequent blocks, which is almost computationally impossible.


VII. Consortium Blockchain

7.1 What is a Consortium Blockchain?

A Consortium Blockchain is a form of blockchain that lies between public and private blockchains. It is jointly maintained by multiple known organizations, and only authorized nodes can participate in consensus and read/write data.

7.2 Characteristics of Consortium Blockchains

Characteristic Description
Partially Decentralized Managed jointly by multiple consortium members, rather than being fully open or controlled by a single entity
Strong Controllability Node admission requires approval, and network behavior can be regulated
Data Not Public by Default Data is only visible to consortium members, supporting privacy protection
Fast Transaction Speed Limited number of nodes that trust each other, consensus efficiency is much higher than public chains

7.3 Consortium Blockchain vs. Public Blockchain

Dimension Public Chain Consortium Chain
Participants Anyone Authorized Organizations
Degree of Decentralization High Medium
Transaction Speed Slower (BTC ~7 TPS) Faster (up to thousands of TPS)
Privacy Data Public Data Controllable
Typical Scenarios Cryptocurrency, DeFi Enterprise Collaboration, Government Affairs

VIII. Application Scenarios

Blockchain technology (especially consortium blockchains) has been implemented in various fields:

8.1 Product Traceability

  • Every step of a product, from raw materials to the end consumer, is recorded on the chain
  • Consumers can scan a code to view the complete circulation path
  • Data is immutable, effectively preventing counterfeiting
  • Typical cases: Food safety traceability, luxury goods anti-counterfeiting, drug tracking

8.2 Public Welfare and Charity

  • Every donation's destination is recorded on the chain, making it open and transparent
  • Donors can track fund flows in real-time
  • Resolves the trust crisis in traditional charity
  • Prevents misappropriation of funds and opaque operations

8.3 Supply Chain Finance

  • The credit of core enterprises can be transmitted to upstream and downstream SMEs through blockchain
  • Accounts receivable can be confirmed and circulated on the chain
  • Financial institutions provide financing to SMEs based on on-chain data
  • Reduces information asymmetry and improves financing efficiency

8.4 Mutual Insurance

  • Insurance rules are written into smart contracts, making claim conditions transparent
  • Claims are automatically triggered when conditions are met, without manual review
  • Participants jointly manage the fund pool
  • Reduces operating costs and moral hazard

IX. Overall Architecture

The overall architecture of a blockchain system is typically divided into the following layers:

Overall Architecture

Layer Description
Application Layer DApp, Smart Contracts, User Interface
Contract Layer Smart Contract Engine, Virtual Machine (EVM, etc.)
Consensus Layer Consensus Algorithms (POW, POS, PBFT, etc.)
Network Layer P2P Network, Node Communication, Data Broadcast
Data Layer Block Structure, Chained Storage, Merkle Tree, Digital Signature

Each layer assumes specific responsibilities, collectively forming a complete blockchain system.

Overall Architecture Details


X. Baidu XuperChain

Baidu XuperChain is a blockchain underlying technology independently developed by Baidu, and one of the more representative consortium blockchain platforms in China.

Main Features

  • Independent Intellectual Property: Core technologies are entirely self-developed, with multiple patents
  • High Performance: Single chain can reach tens of thousands of TPS, meeting large-scale commercial demands
  • Flexible Consensus: Supports pluggable consensus mechanisms, allowing selection of PBFT, DPOS, etc., based on scenarios
  • Smart Contracts: Supports multi-language contract development such as Solidity and C++
  • Privacy Protection: Built-in multiple privacy computing solutions
  • Open Source and Open: Core code is open source, lowering the entry barrier for enterprises

XuperChain has been implemented in government affairs, judiciary, healthcare, finance, and other fields, making it one of the important choices for enterprise-level blockchain solutions in China.


Summary

This article introduced the core technology stack of blockchain: hash functions ensure data integrity, Merkle trees enable efficient verification, digital signatures ensure identity authentication, encryption technology protects data privacy, and consensus mechanisms solve trust issues in decentralized environments. These technologies collectively form the technical foundation of blockchain. Consortium blockchains apply these technologies to enterprise collaboration scenarios, generating practical value in areas such as product traceability, public welfare and charity, and supply chain finance.

Previous: 01-Web3 Overview and Vision
Next: 03-Smart Contracts and Solidity Basics (To be continued)

主题测试文章,只做测试使用。发布者:Walker,转转请注明出处:https://walker-learn.xyz/archives/7479

(0)
Walker的头像Walker
上一篇 5 days ago
下一篇 4 days ago

Related Posts

EN
简体中文 繁體中文 English