Asymmetric Cryptography: The Math of Sovereignty
Web3 security is built on the bedrock of Asymmetric (Public-Key) Cryptography. Unlike symmetric systems where one key performs both encryption and decryption, asymmetric systems use a mathematically linked pair: a Private Key and a Public Key.
The Elliptic Curve Digital Signature Algorithm (ECDSA)
Most modern blockchains, including Bitcoin and Ethereum, utilize the secp256k1 elliptic curve.
The Equation
The curve follows the Weierstrass form:
y^2 = x^3 + 7 pmod p
Where p is a large prime number:
p = 2^{256} - 2^{32} - 2^9 - 2^8 - 2^7 - 2^6 - 2^4 - 1
Key Generation Lifecycle
- The Private Key (k): A 256-bit integer chosen uniformly at random in the range
[1, n-1], wherenis the order of the curve. - The Public Key (P): A point on the curve calculated as
P = k * G, whereGis a predefined generator point. - Point Addition & Scalar Multiplication: The "multiplication" here is not standard integer multiplication but repeated elliptic curve point addition, which is a one-way function.
Hashing: The Fingerprint of Data
Hashing is a one-way function that maps input data of any size to a fixed-size bit string.
Keccak-256 vs. SHA-3
Ethereum uses Keccak-256. While often confused with SHA-3, Keccak-256 is the version of the algorithm before it was finalized by NIST as SHA-3. The padding rules are slightly different, leading to different hash outputs for the same input.
Properties of Cryptographic Hashes
- Pre-image Resistance: Given
H, it's infeasible to findmsuch thathash(m) = H. - Second Pre-image Resistance: Given
m1, it's infeasible to findm2such thathash(m1) = hash(m2). - Collision Resistance: It's infeasible to find any two messages
m1andm2such thathash(m1) = hash(m2).
🛠 Tactical Activity: ECDSA Key derivation Simulation
Objective: Visualize the derivation of a public key from a private key.
- Use an ECDSA playground tool (like BitAddress or a Python script).
- Input a private key (hex):
0x1. - Observe: The public key point
(x, y). - Input a private key:
0x2. - Observe: Is the new point just "double" the old one in a linear sense? No, the point "jumps" across the curve according to the point-addition rules.