比特币技术 — 网络与共识层
15 min read

第11讲 网络安全

Chapter 11: Network Security and Attack Defense

status author date difficulty

💡 Imagine a village vault with no banks, no police, no government protection, yet safely storing hundreds of billions of dollars worth of wealth. This sounds crazy? But Bitcoin has done exactly that. This chapter explains in the simplest way how this "unguarded vault" defends against thieves from around the world.

Recommended exchange for buying BTC / ETH / USDT: Binance Registration Link

Table of Contents

Introduction: How Can an Unguarded Vault Be So Secure?

Imagine this scenario:

  • There's a village vault storing hundreds of billions of dollars worth of wealth
  • The vault has no guards, no walls, and is open 24/7
  • Thieves from around the world know the vault's location
  • But for 16 years, not a single thief has successfully stolen even a penny

This sounds like a fantasy, but this is the true story of the Bitcoin network.

💡 Think About It

Before learning about Bitcoin security, consider:

  • If you were managing a village vault but have no guards or police, how would you protect it?
  • Why is sometimes "no central authority" safer than having a "strong central authority"?
  • What kind of security system can allow thieves to know the location of the vault but prevent them from breaking in?

Security Philosophy: The Village's Defense Wisdom

Traditional Protection vs Bitcoin Protection

Traditional Banking (Hiring Guards Model):

Your Money → Bank Vault → Guards Watching → Trust Guards Won't Be Greedy
              ↑           ↑
          Single Point   Can Be Bribed
          of Failure

It's like hiring the strongest guards to watch the vault, but what if the guards are bribed?

Bitcoin (Village Collective Defense Model):

Your Money → Mathematical Lock → 13,000 Village Supervisors → Math Cannot Lie
              ↑                  ↑
          Cannot Crack      Cannot Bribe Everyone

It's like making everyone in the village voluntary supervisors, and using mathematics to ensure rules.

Four Principles of Village Defense

🔍 Don't Trust, Verify first

  • Traditional: When old Wang says the vault is safe, everyone believes it.
  • Bitcoin: Everyone can check every record of the vault.

🏘️ No Village Chief, everyone is equal

  • Traditional: Village chief decides who can access the vault.
  • Bitcoin: Mathematics decides, no one can change the rules.

📖 Open Books, Transparent accounting

  • Traditional: Only the bank knows the accounts.
  • Bitcoin: Everyone can see the complete ledger.

💰 Honesty is rewarded, cheating will result in loss

  • Traditional: Villagers rely on moral constraints.
  • Bitcoin: The cost of cheating far exceeds the benefit of being honest.

Common Attacks: The Thieves' Playbook

Even with Bitcoin's tight defenses, clever thieves still come up with various crooked schemes. Let's look at these tactics and how the village responds.

1. 51% Attack: Wanting to Be a "Fake Village Chief"

Attack Idea: If I can impersonate more than half of the villagers in the village, can I control the vault?

Real Analogy: It's like trying to impersonate 6,501 villagers in a village of 13,000 people to control village decisions.

Why is this almost impossible?

  1. Too Expensive: Need to spend billions of dollars on equipment.
  2. Nowhere to Hide: Concentrated computing power will be detected immediately.
  3. Not Worth It: Successful attack would cause Bitcoin value to crash, making the attacker's investment worthless.

💰 How much does it cost to become a "fake village chief"?

Imagine you want to buy more than half of the "voting rights" in a village:

  • We need to buy millions of the world's most expensive mining machines.
  • The cost is approximately $5 billion (equivalent to the value of 10 Huawei companies).
  • The annual electricity cost is $600 million (equivalent to the total electricity consumption of Switzerland).

Most importantly: Even if you spend so much money and succeed in the attack, the price of Bitcoin will plummet due to the loss of trust, and your investment will be completely wiped out.

Real Analogy: It's like spending 5 million to buy explosives to blow up a bank vault, only to have all the money destroyed, yielding a net loss.

Village Defense Mechanisms:

  • 🌍 Global Distribution: Miners are scattered worldwide, hence cannot be centrally controlled.
  • 💸 Economic Rationality: Attack cost far exceeds possible benefits.
  • 👀 Real-time Monitoring: Abnormal hash power concentration is immediately detected.
  • 🔄 Self-healing: Even if temporarily successful, the network will automatically recover.

2. Double Spending Attack: The desire to "buy two things for the price of one".

Attack Idea: Can I use the same banknote to buy both A and B?

Real Analogy: It's like using the same $100 bill to buy things at a convenience store and at the neighboring pharmacy, then finding a way to cancel one of the transactions.

Attack Script:

🎭 Three-Act Play: "Double Spending"

Act 1: Li Si's Wishful Thinking
Li Si has 1 Bitcoin and wants to get Wang Wu's goods for free

Act 2: Simultaneous Action
Li Si sends 1 BTC to Wang Wu to buy goods (Transaction A)
Li Si simultaneously sends 1 BTC to himself (Transaction B)

Act 3: Truth Revealed
If Li Si controls enough computing power:
- Let Transaction B be confirmed, Transaction A be cancelled
- Get goods, keep money in pocket
- Wang Wu loses everything

Why is this hard to pull off?

🛡️ Village Double Flower Protection System

Bitcoin uses "confirmation count" to prevent double-spending, much like locking transactions:

The Story of Locking the Safe:

  • 🔓 0 locks: They could be picked at any time (buying coffee is a risky business).
  • 🔒 1 lock: It requires some skill to pick (relatively safe for small purchases).
  • 🔒🔒🔒 3 locks: Only professional thieves can handle this (online shopping is safe enough).
  • 🔒🔒🔒🔒🔒🔒 6 locks: Almost impossible to pick (you can buy a car or a house with peace of mind).

The protection principle is very simple:

  • Each additional lock doubles the difficulty of picking the lock.
  • 6 locks = 6 blocks need to be rewritten = almost impossible.
  • The longer the time frame, the higher the cost for attackers.

Practical Protection Strategies:

  • Buying Coffee: 0 confirmations is OK (a $5 loss is acceptable).
  • 🛒 Online Shopping: Wait for 1-3 confirmations (a few minutes to half hour).
  • 🏠 Buying a house: Wait 6+ days for confirmations (about 1 hour, to be safe).
  • 🏢 Large Transactions: Wait 10+ confirmations (2 hours, absolutely safe).

3. Eclipse Attack: "Isolating Villagers"

Attack Idea: If I can isolate a villager and only let them hear fake news, can I deceive them?

Real Analogy: Like surrounding someone's house and only delivering fake newspapers, making them think the outside world is different from reality.

How it Works:

Normal Situation:
Target Node ↔ Honest Node A ↔ Real Network
           ↔ Honest Node B ↔ Real Network
           ↔ Honest Node C ↔ Real Network

Eclipse Attack:
Target Node ↔ Malicious Node 1 ↔ Fake Blockchain
           ↔ Malicious Node 2 ↔ Fake Blockchain
           ↔ Malicious Node 3 ↔ Fake Blockchain
(Completely isolated, seeing false information)

Village Defense Mechanisms:

  • 🌍 Connection Diversity: Connect to nodes from different regions.
  • 🔄 Address Randomization: Regularly change connected nodes.
  • Checkpoints: Verify blockchain state through multiple channels.

4. Sybil Attack: "Creating Fake Villagers"

Attack Idea: If I create many fake identities, can I influence the village?

Attack Methods:

  • Control a large number of IP addresses.
  • Running a large number of malicious nodes.
  • Attempting to influence the node's connection choices.

Defense Measures:

  • 🔨 Proof of Work: Creating a block requires actual computational cost.
  • 🚫 Connection Limits: Limits the number of connections from the same subnet.
  • 🔍 Behavior Analysis: Identify and block nodes exhibiting abnormal behavior.

5. Network layer attacks

BGP hijacking: hijacking traffic at the Internet routing layer.

python
python
Normal routing: Your node → ISP → Bitcoin network
Hijacking: Your node → ISP → Attacker → Fake network

DNS attack: hijacking DNS seed servers.

  • Returns the IP address of the malicious node.
  • Connect the new node to the fake network.

Protection Plan:

  • Multiple DNS Seeds: 9 independent DNS servers.
  • Hardcoded Nodes: Trusted node addresses built into the client.
  • Encrypted connection: BIP 324 provides end-to-end encryption.

###Protection mechanism

##Multi-layer protection system

bash
bash
Application Layer: Wallet security, private key management  
Protocol Layer: Digital signatures, hash verification  
Network Layer: P2P encryption, connection diversity  
Consensus Layer: Proof of Work, economic incentives  
Physical Layer: Hardware security, geographic distribution

Defense Mechanisms: The Village's Security System

1. Cryptographic Verification

Every transaction undergoes rigorous security checks:

  • Digital Signature Verification — Confirms the sender's identity.
  • Hash Integrity — Prevents data from being tampered with.
  • Balance Check — Prevent overspending.
  • Double-spending detection — Prevents duplicate spending.
  • Script Verification — Ensures that transaction conditions are met.

2. Economic Incentive Mechanism

  • Earn rewards by mining honestly.
  • The attack caused enormous damage to the network.
  • Maintaining cybersecurity in the long term.

3. Network Decentralization

  • 15,000+ nodes worldwide.
  • No single point of failure.
  • Resisting state-level attacks.

Wallet Security: Protecting Your Personal Safe

Wallet Types and Security Levels

Wallet TypeSecurity LevelUse CaseSecurity Features
Hardware Wallet⭐⭐⭐⭐⭐Long-term storageOffline signing, most secure
Desktop Wallet⭐⭐⭐⭐Daily useLocal control, relatively secure
Mobile Wallet⭐⭐⭐Small paymentsConvenient use, medium security
Online Wallet⭐⭐Temporary useQuick and convenient, higher risk
ExchangeTrading onlyGood liquidity, highest risk

Wallet Security Best Practices

🔒 Seven Golden Rules:

  • 🔐 Use a hardware wallet to store large sums of money.
  • 📝 Secure backup of mnemonic phrases (offline storage).
  • 🔄 ** Regularly update your wallet software**.
  • 🌐 Use trusted full node connections.
  • 👥 Multi-signature is used for large transfers.
  • 🚫 Never screenshot or share your private key online.
  • ✅ ** Carefully verify the receiving address before transferring money.**

💎 Cold Storage Setup Guide:

  1. Purchase hardware wallets from well-known brands (Ledger / Trezor).
  2. Initialize the wallet in an offline environment.
  3. The mnemonic phrase was copied onto a metal plate.
  4. Testing the wallet recovery function.
  5. Store your mnemonic phrase in a secure physical location.

Multi-signature security

Multi-Signature (MultiSig): Team-based fund management

Multi-signature is like a company safe deposit box; it requires multiple people to use the key simultaneously to open it.

Example of a 2-of-3 multi-signature wallet:

bash
bash
👨 Alice  - Private Key 1
👩 Bob    - Private Key 2  
🏢 Company - Private Key 3

Spending condition: any 2 signatures are required

✅ Alice + Bob can spend
✅ Alice + Company can spend  
✅ Bob + Company can spend
❌ Alice alone cannot spend

Practical Application Scenarios:

  • Financial Management for Couples: 2-of-2, spending should only occur with the consent of both partners.
  • Family Savings: 2 of 3, parents + children, with the consent of either party.
  • Corporate Funding: 3-of-5, decided by a majority vote of the board of directors.

Node Security: Being a Responsible Villager

Node security operation

Basic security configuration:

bash
bash
# Firewall settings
sudo ufw allow 8333/tcp  # Bitcoin mainnet port
sudo ufw deny 22/tcp     # Disable SSH (if not necessary)

# Node configuration optimization
bitcoind -daemon \
  -maxconnections=20 \
  -bind=192.168.1.100 \
  -whitelist=192.168.1.0/24 \
  -bantime=86400

Monitoring and Maintenance:

  • Regularly check the geographical distribution of connected nodes.
  • Monitor for abnormal network traffic.
  • Keep the software version updated.
  • Back up your wallet and configuration files.

Network connection security 🌐 Connection characteristics of healthy nodes:

  • Geographical Distribution: Nodes connecting the 5 continents.
  • Protocol Version: Supports BIP 324 encryption.
  • Number of connections: 8 outbound + 15 inbound.
  • Anomaly Detection: Automatically disconnect malicious nodes.
  • Traffic Encryption: Enables the v2 transport protocol.

Real Cases: Learning from Hard Lessons

Successful attack cases

1. Mt.Gox (2014)

  • Loss: 744,408 BTC.
  • Reason: Internal management loopholes led to long-term theft.
  • Lesson learned: Don't keep large sums of money on exchanges.

2. Ethereum Classic 51% Attack (2020)

  • Loss: $1.1 million.
  • Method: Rent computing power for deep reorganization.
  • Impact: It exposed the security vulnerabilities of altcoins.

3. KuCoin Exchange (2020)

  • Loss: $280 million.
  • Reason: Private key leaked.
  • Response: Community collaboration to track and freeze funds.

Successful protection cases

1. Bitcoin Network's Resistance to Attacks

  • It has been running for 16 years and has never been successfully attacked.
  • It withstood multiple attempts at a 51% attack.
  • The growth in network value proves its security.

2. BIP 324 Deployment (2024)

  • Encrypted communication is enabled across the entire network.
  • Significantly enhances privacy protection.
  • Prevent network layer eavesdropping attacks.

Future Challenges: Threats to the New Era

Quantum computing threat

Threat Analysis:

  • A sufficiently powerful quantum computer can crack ECDSA signatures.
  • Expected impact time: 10-20 years from now.
  • Scope of impact: All systems based on elliptic curve cryptography.

🛣️ Quantum Resistance Development Roadmap:

  • 📅 2025 - 2027 : Post-quantum cryptography research.
  • 📅 2028 - 2030 : Standardization of new signature algorithms.
  • 📅 2031 - 2035 : Bitcoin protocol upgrade.
  • 📅 2036+ : Fully Quantum Resistance Network.

Preparatory Measures:

  • Use one-time addresses to reduce exposure.
  • Pay attention to the NIST post-quantum cryptography standard.
  • Support the protocol upgrade proposal.

###Emerging threats AI-enhanced attacks:

  • Intelligent social engineering attacks.
  • Automated vulnerability discovery.
  • Large-scale network analysis.

Regulatory and compliance pressures:

  • Government-level internet censorship.
  • Mandatory identity authentication requirement.
  • Privacy restrictions.

Frequently Asked Questions

Q1: Is Bitcoin really secure? I hear people getting hacked often?

A: The Bitcoin network itself has never been successfully attacked in 16 years, but personal wallet security is another matter. It's like a bank vault being very secure, but you can still lose money if you drop your wallet in a taxi. Most "Bitcoin thefts" are due to poor wallet management or exchange hacks, not Bitcoin protocol issues.

Q2: What if all miners conspire to attack Bitcoin?

A: This is like asking "What if all banks conspire to steal customers' money?" Theoretically possible, but in reality:

  • Miners are distributed globally and cannot coordinate
  • Successful attack would crash Bitcoin value, miners would lose the most
  • Economic rationality determines cooperation is more beneficial than confrontation

Q3: What type of Bitcoin wallet should I choose?

A: Depends on your needs and amounts:

  • Small daily amounts: Mobile wallet (like Alipay feeling)
  • Medium amounts: Desktop wallet (like computer banking client)
  • Large storage: Hardware wallet (like a safe)
  • Remember the principle: Don't put all eggs in one basket

Q4: I heard quantum computers can break Bitcoin?

A: This is a long-term concern, not an immediate threat:

  • Truly threatening quantum computers need at least 10-20 more years
  • By then Bitcoin protocol will upgrade to quantum-resistant algorithms
  • Bitcoin is just one of many affected systems, the entire internet will upgrade
  • Using one-time addresses already reduces risk

Q5: What if governments ban Bitcoin?

A: Governments can ban usage, but technically cannot shut down the network:

  • Bitcoin nodes are distributed across 200+ countries
  • As difficult as banning mathematical formulas
  • Historically, multiple country bans haven't stopped Bitcoin development
  • Blockchain data will exist forever

Summary

Bitcoin network security is a multi-layered, comprehensive defense system:

🛡️ Security Advantages

  • Mathematical Guarantee: Cryptography provides theoretical security foundation.
  • Economic Incentives: Attack cost far exceeds benefits.
  • Decentralization: No single point of failure, globally distributed.
  • Transparency: All code and rules are publicly auditable.

🎯 Key Points

  • Personal Security: Use hardware wallets, backup seed phrases.
  • Node Security: Keep software updated, diversify connections.
  • Network Security: Support decentralization, participate in network verification.
  • Future Preparation: Monitor quantum threats, support protocol upgrades.

🌟 Security Philosophy

Bitcoin proves that pure mathematics can create trust, and cryptography can protect value. In this network, security doesn't rely on authoritative promises, but comes from mathematical certainty and economic rationality.

Every person using Bitcoin participates in this security experiment, and every verification strengthens this trustless network.

🔗 Security Tools: security_examples.py

📚 Further Learning: Check detailed security analysis in the knowledge base


Challenge Quiz

Complete 5 questions, you need to get all correct to unlock the next chapter

If this lesson was helpful, please consider supporting the author ☕

Support Author · Buy Me a Coffee