Learn the Math

Deep dive into the four fundamental mathematical concepts that power modern cryptography and blockchain technology.

01

Modular Arithmetic

The foundation of modern cryptography

? What is Modular Arithmetic?

Modular arithmetic is like clock math. When the hour hand goes past 12, it wraps back to 1. In math terms, we're working with remainders after division. This simple concept is the foundation of nearly all modern encryption.

a mod n = remainder when a is divided by n

For example: 17 mod 5 = 2 (because 17 ÷ 5 = 3 remainder 2)

Key Properties

  • Addition: (a + b) mod n = ((a mod n) + (b mod n)) mod n
  • Multiplication: (a × b) mod n = ((a mod n) × (b mod n)) mod n
  • Exponentiation: Used in RSA encryption for secure key generation
  • One-way function: Easy to compute forward, nearly impossible to reverse

Try It Yourself

Modular Arithmetic Calculator

17 mod 5 = 2

Blockchain Application

In Bitcoin, modular arithmetic is used in ECDSA (Elliptic Curve Digital Signature Algorithm) to create and verify digital signatures. Every transaction you make is secured by these calculations.

02

Prime Numbers

The atoms of mathematics

? What are Prime Numbers?

A prime number is a natural number greater than 1 that can only be divided evenly by 1 and itself. These seemingly simple numbers are the building blocks of all integers and form the foundation of cryptographic security.

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31...

The beauty of primes: every integer greater than 1 can be uniquely expressed as a product of prime numbers (Fundamental Theorem of Arithmetic).

Why Primes Matter in Cryptography

  • RSA Encryption: Uses the product of two large primes (1024+ bits each)
  • One-way trap: Multiplying primes is easy; factoring their product is extremely hard
  • Key generation: Your private keys depend on prime number properties
  • Security guarantee: No known efficient algorithm can factor large semiprimes

Try It Yourself

Prime Number Checker

97 is PRIME

Blockchain Application

While Bitcoin uses elliptic curves (not RSA), prime numbers are still crucial. The secp256k1 curve used by Bitcoin is defined over a prime field with a 256-bit prime number.

03

Discrete Logarithms

The one-way function

? What are Discrete Logarithms?

A discrete logarithm is the inverse of modular exponentiation. If g^x mod p = h, then x is the discrete logarithm of h to the base g, modulo p. The magic: computing g^x mod p is easy, but finding x from the result is incredibly hard.

Given g, p, and h: find x where g^x mod p = h

This asymmetry (easy one way, hard the other) is what makes public-key cryptography possible.

The Diffie-Hellman Key Exchange

  • Step 1: Alice and Bob agree on public values g and p
  • Step 2: Alice picks secret a, sends g^a mod p to Bob
  • Step 3: Bob picks secret b, sends g^b mod p to Alice
  • Step 4: Both compute (g^ab mod p) - the shared secret!

Even if an attacker sees all public communication, they cannot compute the shared secret without solving the discrete log problem.

Try It Yourself

Modular Exponentiation Calculator

5^3 mod 23 = 10

Blockchain Application

The discrete log problem on elliptic curves (ECDLP) is what secures your Bitcoin wallet. Your private key is essentially a secret exponent, and your public key is the result of elliptic curve multiplication - easy to compute, impossible to reverse.

04

Elliptic Curves

The modern standard

? What are Elliptic Curves?

An elliptic curve is a special type of curve defined by the equation y² = x³ + ax + b. When we combine this with modular arithmetic over a prime field, we get Elliptic Curve Cryptography (ECC) - the backbone of Bitcoin and Ethereum.

y² = x³ + ax + b (mod p)

ECC provides the same security as RSA with much smaller key sizes: a 256-bit ECC key ≈ 3072-bit RSA key.

Point Operations on Curves

  • Point Addition: Given two points P and Q, we can compute P + Q geometrically
  • Point Doubling: Computing P + P = 2P using the tangent line
  • Scalar Multiplication: Computing kP by repeated doubling and adding
  • ECDLP: Given P and Q = kP, finding k is computationally infeasible

secp256k1: Bitcoin's Curve

Bitcoin uses a specific elliptic curve called secp256k1, defined by:

y² = x³ + 7 (mod p)

Where p is a massive 256-bit prime. Your Bitcoin private key is a random 256-bit number k, and your public key is the point K = k × G, where G is the generator point.

Blockchain Application

Every Bitcoin address is derived from an elliptic curve public key. When you sign a transaction, you prove ownership of the private key without revealing it - this is the magic of ECDSA (Elliptic Curve Digital Signature Algorithm).