MODULE 1 OF 5CADET

Asymmetric Cryptography: The Math of Sovereignty

~2 MIN READWeb3 Foundation & Cryptography

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

  1. The Private Key (k): A 256-bit integer chosen uniformly at random in the range [1, n-1], where n is the order of the curve.
  2. The Public Key (P): A point on the curve calculated as P = k * G, where G is a predefined generator point.
  3. 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 find m such that hash(m) = H.
  • Second Pre-image Resistance: Given m1, it's infeasible to find m2 such that hash(m1) = hash(m2).
  • Collision Resistance: It's infeasible to find any two messages m1 and m2 such that hash(m1) = hash(m2).

🛠 Tactical Activity: ECDSA Key derivation Simulation

Objective: Visualize the derivation of a public key from a private key.

  1. Use an ECDSA playground tool (like BitAddress or a Python script).
  2. Input a private key (hex): 0x1.
  3. Observe: The public key point (x, y).
  4. Input a private key: 0x2.
  5. 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.