Entropy คืออะไร? Randomness เบื้องหลัง Crypto Security
สารบัญ
ทุก cryptocurrency wallet เริ่มจาก random number ไม่ใช่ password ที่คุณเลือก ไม่ใช่ pattern ที่คุณ design แต่เป็น raw randomness ที่ดึงจากโลก physical Randomness นี้เรียกว่า entropy และเป็น single most important factor ที่กำหนดว่า crypto assets ของคุณ secure หรือ vulnerable
ถ้า entropy เบื้องหลัง wallet แข็งแกร่ง attacker ต้อง search combinations มากกว่า atoms ใน observable universe ถ้า entropy อ่อน funds ของคุณถูกขโมยได้ในวินาที ไม่มี middle ground
Entropy ที่ Define ไว้¶
ใน cryptography entropy วัด unpredictability ของ data Quantify เป็น bits หนึ่ง bit entropy เป็น single binary choice สอง bits ให้สี่ possible outcomes สาม bits ให้แปด
Formula ตรงไปตรงมา: n bits entropy produce 2^n possible values
Entropy ใน crypto context ไม่ใช่ metaphor แต่เป็น specific, measurable quantity of randomness ที่ feed เข้า deterministic algorithms เพื่อ produce seed phrase, private keys และ addresses ทุกอย่างหลัง initial entropy เป็น mathematically derived Entropy เท่านั้นที่ต้อง genuinely random
128 Bits vs 256 Bits¶
BIP39 standard support สอง entropy lengths หลัก:
128 bits (12-word seed phrase)¶
- Produce 2^128 possible seed phrases
- 340,282,366,920,938,463,463,374,607,431,768,211,456 combinations
- ประมาณ 3.4 x 10^38
256 bits (24-word seed phrase)¶
- Produce 2^256 possible seed phrases
- ราว 1.16 x 10^77 combinations
- มากกว่า atoms ที่ประมาณใน observable universe
ทั้งสอง levels ถือว่า secure ต่อ technology ปัจจุบัน Detailed comparison ดู How Fast Can a Seed Phrase Be Brute-Forced?
Entropy bits กับ word count มี simple rule: ทุก 11 bits entropy map ไปยังหนึ่งคำจาก BIP39 word list (2,048 คำ, 2^11 = 2,048) 12-word phrase encode 128 bits entropy plus 4 bits checksum Full breakdown อ่านใน BIP39 Explained
Sources of Randomness: Hardware RNG และ Web Crypto API¶
Pseudorandom vs. Cryptographically Secure¶
Standard programming random function (เช่น JavaScript Math.random()) เป็น pseudorandom ใช้ mathematical formula produce numbers ที่ดูเหมือน random แต่เป็น deterministic ทั้งหมด Catastrophically ไม่เหมาะสำหรับ generate cryptocurrency keys
Cryptographically secure random number generators (CSPRNGs) แก้ปัญหาด้วยการ incorporate genuine physical randomness จาก hardware sources
Hardware Random Number Generators¶
Modern CPUs มี dedicated hardware random number generators:
- Intel RDRAND/RDSEED: ใช้ thermal noise ใน silicon circuits
- ARM TrustZone TRNG: Hardware-level random bit generation
- OS-level entropy pools: Linux
/dev/urandom, Windows CryptGenRandom, macOS SecRandomCopyBytes
Web Crypto API¶
สำหรับ browser-based tools Web Crypto API ให้ access ไปยัง OS cryptographic random number generator ผ่าน crypto.getRandomValues()
SafeSeed ใช้ Web Crypto API สำหรับทุก key generation เมื่อใช้ Bitcoin Seed Phrase Generator หรือ Ethereum Seed Phrase Generator entropy source จาก crypto.getRandomValues()
Math.random() กับ crypto.getRandomValues() เป็น fundamentally different systems Math.random() มี roughly 52 bits internal state crypto.getRandomValues() ไม่มี weakness นี้
จาก Entropy สู่ Seed Phrase¶
Journey จาก raw entropy สู่ seed phrase follow precise, deterministic path ตาม BIP39 specification:
Step 1: Generate random bytes¶
CSPRNG produce 16 bytes (128 bits) หรือ 32 bytes (256 bits) random data
Step 2: Compute checksum¶
SHA-256 hash ของ entropy compute แล้ว first 4 bits (128-bit entropy) หรือ 8 bits (256-bit entropy) append เป็น checksum
Step 3: Split เป็น 11-bit groups¶
Combined entropy + checksum bits divide เป็น groups ของ 11 bits
Step 4: Map ไปยัง words¶
ทุก 11-bit value (0-2047) ใช้เป็น index ใน BIP39 word list ผลลัพธ์คือ mnemonic phrase
Step 5: Derive seed¶
Mnemonic phrase pass ผ่าน PBKDF2-HMAC-SHA512 2,048 iterations produce 512-bit seed จากนั้น HD wallet tree derive ตาม BIP44 derivation paths
ทุก step หลัง step 1 เป็น deterministic 128 bits entropy เดียวกันจะ produce 12 คำเดียวกัน seed เดียวกัน addresses เดียวกันเสมอ
เมื่อ Weak Entropy นำไปสู่ Funds ถูกขโมย¶
Android SecureRandom vulnerability (2013)¶
สิงหาคม 2013 flaw ใน Android SecureRandom ถูกค้นพบ Java cryptography library ไม่ seed random number generator อย่างถูกต้อง ทำให้บาง Bitcoin wallets generate private keys ที่มี entropy ไม่เพียงพอ Attackers ขโมย bitcoins จาก affected wallets
Blockchain Bandit (predictable keys)¶
Security researcher Adrian Bednarek document กรณี attackers systematically scan Ethereum blockchain หา addresses ที่ derive จาก weak private keys Keys เช่น 0x0000...0001 ถูกใช้โดยคนที่ไม่เข้าใจ entropy Automated bots monitor addresses เหล่านี้และขโมย funds ภายในวินาที
Brain wallet attacks¶
Brain wallets --- ที่ private key derive จาก memorized passphrase --- ถูก compromised ซ้ำแล้วซ้ำเล่าเพราะ human-chosen phrases มี entropy น้อยกว่าที่คนคิดมาก
บทเรียนร่วม: cryptographic algorithms (SHA-256, secp256k1, ECDSA) ไม่ broken Entropy ที่ feed เข้าไม่เพียงพอ
Test Entropy Quality¶
NIST SP 800-22¶
NIST publish statistical tests สำหรับ randomness --- frequency tests, runs tests, matrix rank tests
Dieharder test suite¶
Extended randomness tests set ที่ push generators harder กว่า NIST suite
Practical verification¶
สำหรับ end users verification ที่ practical ที่สุดคือ ensure ว่าใช้ well-audited tool ที่ rely บน crypto.getRandomValues() อย่าพยายามเพิ่ม "randomness" ด้วยตัวเอง ดู Are Online Seed Generators Safe?
Entropy กับ Security Posture ของคุณ¶
การเข้าใจ entropy เปลี่ยนวิธีคิดเกี่ยวกับ crypto security 12-word seed phrase ไม่ใช่แค่ convenient backup mechanism แต่เป็น human-readable encoding ของ random number ที่ใหญ่จนจักรวาลไม่มี energy พอ search ทุก possibilities
เมื่อเลือก tools:
- Verify entropy source: Tool ควรใช้
crypto.getRandomValues(),/dev/urandomหรือ equivalent hardware-backed randomness - Avoid custom entropy: อย่าเลือกคำเอง อย่า roll dice ด้วย biased method
- ใช้ established standards: BIP39 battle-tested ตั้งแต่ 2013 Tools ที่ follow BIP39 เช่น Solana Seed Phrase Generator บน SafeSeed inherit decade of security review
- Generate offline เมื่อเป็นไปได้: ดู How to Generate a Bitcoin Seed Phrase Offline
Entropy invisible คุณไม่สามารถเห็น สัมผัส หรือ verify จาก output ได้ Seed phrase จาก weak entropy ดูเหมือนกับที่ generate จาก strong entropy ทุกประการ วิธีเดียวที่ ensure security คือ trust process: ใช้ audited, open-source tools ที่ draw จาก hardware-backed random number generators