Algebra + Modular + Prime = Crypto
Back TR HOME ABOUT MY BLOG

Algebra + Modular + Prime = Crypto


Every ingredient has a job

Elliptic curve cryptography looks like a random pile of math until you notice that every piece is there for a reason. Algebra, a curve, modular arithmetic, and a prime each fix one specific problem. Together they build something none of them could do alone.

Remember that viral 2016 video where a guy combines a pen with some fruit and proudly gets something new and ridiculous? Crypto works the same way. Combine two ingredients, get a new thing, combine again, and at the end you have a lock nobody can pick.

Here's the recipe, one ingredient at a time.

Ingredient 1: Algebra writes the rules of the game

Algebra's job is to say what "combining" is allowed to mean. A structure is just a set of things plus one way to combine two of them. Each level of the ladder adds exactly one new rule:

  1. Magma: combining always stays inside the set (closure).
  2. Semigroup: parentheses don't matter, so (a∗b)∗c = a∗(b∗c).
  3. Monoid: there's a "do nothing" element.
  4. Group: every move can be undone.
  5. Abelian group: order doesn't matter, so a∗b = b∗a.
  6. Cyclic group: one single element, repeated, builds everything.

Crypto wants the very down of the ladder: a cyclic group. Keep that in mind, because every other ingredient exists to help build one.

Ingredient 2: The elliptic curve supplies the combining move

We need a set of points and a way to add two of them. An elliptic curve, y² = x³ + ax + b, gives us both, and that x³ is no accident.

A straight line crosses a degree-3 curve exactly three times. So two points go in, and exactly one new point comes out. A circle (degree 2) would give no new point, and a degree-4 curve would give two, with no way to choose.

The rule: draw a line through P and Q, find the third point, then flip it over the x-axis. Why flip? Without it, no point can act as "do nothing," and you're stuck at the magma level. The flip turns the point at infinity, O, into the zero of the group.

Quick check on y² = x³ + 1:

Adding a point to itself works the same way, using the tangent line at that point. Algebra + curve = a group of points.

Ingredient 3: Modular arithmetic makes it finite and exact

Real numbers have two problems for computers: there are infinitely many, and they get rounded. Working mod p fixes both. Every number wraps around like a clock, so everything stays a whole number from 0 to p − 1.

The curve y² = x³ + 3 mod 23 stops being a smooth line and becomes a scattered cloud of 23 points, plus O, for 24 in total. The addition formulas don't change at all; they're just done mod 23.

Here's the bonus: finite means cycles. Keep adding a point to itself in a finite group, and you must eventually land back on O. Take P = (1, 2):

Multiple

Point

1P

(1, 2)

2P

(0, 16)

3P

(11, 0)

4P

(0, 7)

5P

(1, 21)

6P

O

So modular arithmetic doesn't create cycles directly. It creates finiteness, and finiteness forces cycles.

Ingredient 4: The prime makes division possible

The slope formula divides, and mod p there's no ordinary division. Instead, you multiply by an inverse: the number that gives 1. Mod 23, the inverse of 6 is 4, because 6 × 4 = 24 ≡ 1.

Every nonzero number has an inverse only when p is prime. Try mod 24 instead, and 6 has no inverse at all, so the slope formula simply crashes.

Modular + prime = a field: a number world where +, −, ×, and ÷ all work. That's exactly what the curve formulas need to survive.

Plot twist: there's a second prime. Crypto also wants the group of points it uses to have a prime number of elements. A group with a prime number of elements is always cyclic, and every point except O generates the whole thing.

The grand combo: easy one way, impossible the other

Put it all together. Pick a public starting point G and a secret number n. Your public key is nG: the point G added to itself n times.

Going forward is fast. Double-and-add reaches nG in a few hundred steps, even when n is around 2²⁵⁶.

Going backward is the lock. Given G and nG, there's no known shortcut to find n, because the points jump around the grid with no pattern to follow. This is the elliptic curve discrete logarithm problem.

One last treat: the map n ↦ nG is a homomorphism, since (a + b)G = aG + bG. Adding secret numbers matches adding public points. That's what lets fancier tools, like zero-knowledge proofs, do math on numbers they never get to see.

Cheat sheet

Ingredient

Its job

What breaks without it

Algebra (group rules)

Defines what "combining" must obey

No guarantees the math behaves

Cubic curve

2 points in, exactly 1 point out

No clear answer for P + Q

The flip

Makes O the "do nothing" point

Stuck at a magma

Modular arithmetic

Finite and exact, which forces cycles

Infinite points and rounding errors

Prime p

Every nonzero number has an inverse

Slope division crashes

Prime group size

Cyclic, every point a generator

Easier to attack

So: algebra + modular, then discrete math + prime. Nothing in this recipe is decoration. Every ingredient is there because something breaks without it.