All on the Line · Mathematics
The math behind your credit card was invented in 1954. The math protecting it has never been broken. Both use arithmetic you never learned.
Number theory and cryptography
19 May 2026
12 minutes

Every number you were taught in school lived on a line. It stretched right without end into positives and left without end into negatives, and every integer (…, −3, −2, −1, 0, 1, 2, 3, …), every fraction (a/b, where a and b are integers and b ≠ 0), every irrational number (those that cannot be written as simple fractions, and their decimals never repeat or end, like π or √2) had exactly one home on that line, one fixed position that never changed. Two plus two moved you four steps to the right of zero and landed on four, and four was always four, and the line was the whole story. What no teacher mentioned is that the line is just one arithmetic structure among many that is used for counting. More modern mathematics also works in other arithmetic structures like modulo n — or modular — arithmetic, where the line closes into a circle, where numbers wrap at a fixed boundary, and where two plus two can equal one without any rule being broken.
The simplest version of this alternative numerical system is already tattooed on our daily life. A 12-hour clock face runs from 1 to 12, and when the hour hand passes 12, it does not go to 13, it returns to 1. In arithmetic modulo n, every number is rewritten as the sum of two parts: a multiple of n, which drops out of the equation, and a remainder that falls inside the finite set {0, 1, 2, …, n−1}. That remainder is the number. Everything else is discarded. So the clock is arithmetic modulo 12. If you start work at 9 o’clock and work for 9 hours, you don’t finish at 18 o’clock but at 6 o’clock. Because when you divide 18 by 12, 12 goes in once and 6 is left over — that leftover is the remainder, and in modular arithmetic, that remainder is the answer:
9 + 9 = 18, and since 18 = 12 + 6, and 12 is zero in this system, 9 + 9 ≡ 6 (mod 12)
The entire infinite number line now collapses into a cycle of twelve positions, and addition inside that cycle always produces an answer that falls within the finite set expressed before.
Edward Frenkel, professor of mathematics at the University of California, Berkeley and one of the clearest writers bridging the gap between advanced mathematics and general understanding, devoted a chapter of his book Love and Math to what he called magic numbers — the surprising properties that emerge when arithmetic closes into these finite cycles, properties that turn out to run far deeper than any clock face suggests. On the number line, 6 and 18 are twelve positions apart. In arithmetic modulo 12, they are the same number. What matters is not the number itself but the remainder it leaves after division. That principle — which feels like a curiosity when you first encounter it on a clock face — turns out to be the entry point into one of the richest areas of modern mathematics, and the mechanism that protects every electronic financial transaction you have ever made. The student who was taught that 2 + 2 = 4 was taught something true about one mathematical universe. There are others.1
Hans Peter Luhn was a prolific inventor at IBM — he held over eighty patents by the time he died in 1964, covering everything from information retrieval systems to the first practical implementation of the KWIC index, the keyword-in-context search method that prefigured how computers would eventually organize information. In 1954 he turned his attention to a narrower problem: how do you validate a long numerical identifier entered by hand, when human hands make mistakes and no central database can be consulted in real time? A single transposed digit — 47 entered as 74 — somewhere in a credit card sequence, for example, could be invisible on inspection but would route a transaction incorrectly or reject it outright. Luhn needed a way to let the number itself reveal whether it had been corrupted, without any external reference.
The solution he designed runs entirely on modular arithmetic. Take the 16-digit card number 4532 0151 1283 0366. The rightmost digit — 6 — is the check digit, kept as is. Starting from the second digit from the right and moving left, double every second digit. If the result of doubling is a two-digit number, add its digits together to reduce it back to a single digit. Sum all the resulting digits together with the untouched ones. If the total is divisible by 10 — if the sum is zero modulo 10 — the number is valid. For our credit card number, the sum is 50, and 50 ≡ 0 (mod 10). The number passes.2 Card networks subsequently built their numbering systems around this algorithm — the check digit at the rightmost position of every card number is calculated from the preceding digits specifically to make the whole sequence pass the Luhn check. The 16-digit number on your card is not an arbitrary identifier. It is a mathematical object engineered to satisfy a modular arithmetic condition.
What Luhn built into every card number is a remainder — a modular residue that valid numbers carry inside themselves and that a single accidental error almost always destroys. The card network does not store your number and compare it against a record. It performs a calculation and checks what is left over after division by ten. If the remainder is zero, the number has the right shape. If it is anything else, something is wrong. The entire check runs in the payment terminal before any communication with your bank, your card network, or anyone else. It has been running without modification in every major card network since Luhn filed his patent, and it extends well beyond credit cards — the IMEI number that uniquely identifies your mobile phone, the National Provider Identifier used across the entire US healthcare system, and several other large-scale identification systems all embed the same Luhn residue for the same reason. A piece of modular arithmetic from 1954 sits at the base of systems that collectively process hundreds of billions of identifiers every year.
The Luhn algorithm catches errors, not frauds. It is an error-detection tool, not a security tool, and anyone who understands how it works can generate numbers that pass it. A number that clears the Luhn check is structurally valid but offers no protection against interception — the underlying card data, whether transmitted directly or as a token, still requires encryption to be secure in transit. Validating the structure of a number and hiding its contents are two different problems, and the second one is orders of magnitude harder. Solving it required not just modular arithmetic but a specific property of prime numbers that three researchers at MIT formalized into a working encryption system in the late 1970s.
In 1977, three researchers at the Massachusetts Institute of Technology — Ron Rivest, Adi Shamir, and Leonard Adleman — published a paper describing an encryption system built entirely on a single mathematical observation: multiplying two numbers together is fast, but working backwards from the product to recover the two numbers that produced it is, at sufficient scale, effectively impossible. The system took their initials: RSA. It became the foundation of encrypted digital communication, and it runs underneath every secure transaction on the internet today.
RSA operates inside a modular cycle — the same remainder logic from the clock and the Luhn check, now applied at a different scale. Where the clock runs on a cycle of 12 positions and the Luhn check runs on a cycle of 10, RSA runs on a cycle of n positions {0, 1, 2, …, n−1}, where n is a number hundreds of digits long. Every encryption and decryption operation performs arithmetic inside that cycle — numbers are multiplied, raised to large powers, and reduced to their remainder modulo n, exactly as 18 was reduced to 6 modulo 12 on the clock face. The remainder is the answer. Everything outside the cycle drops out.
With small numbers, the factoring problem is simple enough. Take 15 and you immediately recover its factors, 3 and 5. Take 3,233 and you can still recover 61 and 53 without much effort. But as the scale increases, the problem of working backwards from a product changes character entirely. Finding the factors of a number that is hundreds of digits long has no known efficient solution on any classical computer — meaning any machine that exists or is projected to exist outside the realm of quantum computing. The best available algorithm, the General Number Field Sieve, would require computational effort exceeding 1060 operations to factor a standard RSA key.3 To put that number in context: a computer performing one billion operations per second — which is roughly what a modern processor does — would need 1051 seconds to complete the task. The age of the universe is approximately 4.3 × 1017 seconds, meaning the computation would outlast roughly 1033 universes.4 The multiplication that produced the key ran in microseconds.
The modulus n in RSA is never prime — it is always the product of two primes, and that specific structure is what makes the encryption lock work. Inside the cycle of n positions, not every number has a multiplicative inverse — a partner that brings the result back to 1 under multiplication. The numbers that do are precisely those that share no common factor with n.5 Because n is the product of two primes p and q, the only numbers in the cycle that share a common factor with n are the multiples of p and the multiples of q — a small and countable fraction of the cycle. Every other number has a partner. Counting exactly how many numbers have a partner gives a quantity called φ(n) — pronounced phi of n — which equals (p−1)(q−1).6 That quantity is what builds the relationship between the public and private keys in RSA. The key holder knows p and q, computes φ(n) in seconds, and uses it to construct the lock. An adversary who only knows n cannot compute φ(n) without first factoring n into p and q — which is the problem the previous paragraph just established is unreachable at scale. The product is public. The primes are secret. That asymmetry is the lock.
To see it working, take p = 61 and q = 53 — small enough to follow, structurally identical to a real key. Their product is n = 3,233, and φ(n) = (61−1)(53−1) = 60 × 52 = 3,120. Choose a public exponent e = 17 — a prime smaller than φ(n) that shares no common factor with it, which guarantees its multiplicative inverse exists inside the cycle. The private exponent d is the multiplicative inverse of 17 in arithmetic modulo 3,120 — the number satisfying 17 × d ≡ 1 (mod 3,120), which is d = 2,753.7 To encrypt the message m = 65 — an integer between 1 and 3,232 that shares no common factor with n — compute 65##INLINE46## = 6517 ≡ 2,790 (mod 3,233). To decrypt, compute 2,790##INLINE47## = 2,7902753 ≡ 65 (mod 3,233).8 The public key — (e, n) = (17, 3,233) — is shared openly. The private key — (d, n) = (2,753, 3,233) — is kept secret. An adversary who intercepts 2,790 and wants to reverse the operation must first factor 3,233 into 61 and 53. With small numbers like these, that takes a second. With an RSA key at real scale, it cannot be done.
The security of RSA is not a theorem. It is a bet — an extremely well-supported bet, backed by decades of failed attempts by the most capable mathematical minds working on the problem — that no efficient classical algorithm for factoring large numbers exists. A quantum computer running an algorithm developed by Peter Shor in 1994 could break RSA efficiently in principle — the mathematics is proven correct — but the hardware capable of running it at the scale required to factor a real RSA key does not yet exist. When Anthropic’s Claude Mythos model demonstrated in 2025 the ability to autonomously exploit vulnerabilities in the encryption protocols protecting banking communications, it did so by finding flaws in how the mathematics is implemented in software — not by breaking the mathematics itself. The mathematical foundation described in this essay has not been touched.9
From the clock on the wall to the Luhn check in every payment terminal to the cryptographic locks — of which RSA is the most foundational — protecting every electronic financial transaction, the same principle runs through all of it: modular arithmetic — the remainder inside the cycle. The number line taught in school is the arithmetic structure with the most ubiquitous practical uses — counting and measuring. It is also just one structure among many. A parallel mathematical universe exists where numbers wrap, where two plus two can equal one, and where the security of digital financial transactions rests on problems that look, at small scale, embarrassingly simple: take a number and find its factors. At the key sizes the financial system currently operates, that instruction has never been completed.
— Carlos E. Mora
I wake up, I build, I repeat. No guarantees.
I work like it’s all on the line, because it is.
Family is the only true legacy.
Your name is your currency, and it must be earned daily.
1.Take modulo 3. The cycle has three positions: 0, 1, and 2. The number 3 maps to 0 because it divides evenly by 3. The number 4 maps to 1 because it leaves remainder 1 after division by 3: 2 + 2 = 4, and since 4 = 3 + 1, and 3 is zero in this system, 2 + 2 ≡ 1 (mod 3). That remainder is what modular arithmetic treats as the number itself.
2.Full Luhn calculation for 4532 0151 1283 0366. The rightmost digit 6 is the check digit and is kept as is. Starting from the second digit from the right, every second digit is doubled; if the result is two digits, its digits are summed. Resulting digits from right: 6, 6→12→3, 3, 0→0, 3, 8→16→7, 2, 1→2, 1, 5→10→1, 1, 0→0, 2, 3→6, 5, 4→8. Sum: 6+3+3+0+3+7+2+2+1+1+1+0+2+6+5+8 = 50, and 50 ≡ 0 (mod 10). Valid. The algorithm detects all single-digit errors and approximately 98% of adjacent transposition errors. The cases it misses are those where both digits in the transposed pair produce the same value after doubling, which occurs for a small number of specific digit pairs. The algorithm offers no protection against deliberate fraud — it was designed exclusively to catch accidental input errors.
3.A 2,048-bit number is a number that requires 2,048 binary digits — a 0 or a 1 — to represent, which corresponds to a whole number roughly 617 digits long. That is the size of the modulus n in a standard RSA key. The current NIST (National Institute of Standards and Technology) recommendation is 2,048 bits minimum, with 3,072 bits recommended for security beyond 2030. For the mathematically inclined, the complexity of the General Number Field Sieve for a b-bit number is roughly O(exp((64/9·b)1/3·(log b)2/3)), which for b = 2,048 yields the 1060 estimate.
4.A computer performing one billion operations per second would need 1051 seconds to complete the task — calculated as 1060 operations divided by 109 operations per second. And since the age of the universe is 4.3 × 1017 seconds, then 1051 ÷ (4.3 × 1017) = (1051 ÷ 1017) ÷ 4.3 = 1034 ÷ 4.3 ≈ 2.3 × 1033, meaning that it would take roughly 1033 universes to factor a standard RSA key.
5.The technical term for a number’s partner under multiplication is its multiplicative inverse. In an arithmetic modular system built on a prime p, every integer from 1 to p−1 has a multiplicative inverse — a partner that when multiplied by it produces 1 (mod p). In modulo 7, for example: 3 × 5 = 15 = 14 + 1 ≡ 1 (mod 7), so 3 and 5 are partners. 2 × 4 = 8 = 7 + 1 ≡ 1 (mod 7), so 2 and 4 are partners. 1 × 1 ≡ 1 (mod 7) and 6 × 6 = 36 = 35 + 1 ≡ 1 (mod 7), so 1 and 6 pair with themselves. Every number has a partner when the modulus is prime. When the modulus is not prime, some numbers share a common factor with it, meaning their multiples will never produce remainder 1 — the partner does not exist for them. In modulo 6, for example, the number 4 shares the common factor 2 with the modulus 6. Every multiple of 4, when reduced by 6, leaves an even remainder, and since 1 is odd, remainder 1 is unreachable. The numbers inside a cycle that do have multiplicative inverses are precisely those that share no common factor with the modulus. When the modulus is prime, that condition is satisfied by every number in the cycle, because a prime number shares no common factor with any integer smaller than itself other than 1.
6.The quantity φ(n) is called Euler’s totient function, named after the Swiss mathematician Leonhard Euler who developed it in the 18th century. For n = p × q with p and q distinct primes, φ(n) = (p−1)(q−1). To see why, consider n = 3,233 = 61 × 53. The cycle runs from 1 to 3,232. The multiples of 61 that fall inside the cycle are 61, 122, 183, … up to 61 × 52 = 3,172 — exactly 52 of them, which is q−1. The multiples of 53 that fall inside the cycle are 53, 106, 159, … up to 53 × 60 = 3,180 — exactly 60 of them, which is p−1. The number 3,233 itself equals n and is zero in the cycle, so it does not count. Every number that is a multiple of either 61 or 53 lacks a multiplicative inverse. Every other number in the cycle has one. The total count of numbers with a multiplicative inverse is therefore 3,232 − 52 − 60 = 3,120, which equals (61−1)(53−1) = 60 × 52 = 3,120. That is φ(n), and it is the quantity RSA uses to build the relationship between the public and private keys.
7.The method for finding d is called the extended Euclidean algorithm, named after Euclid — the Greek mathematician who lived around 300 BC and described the original algorithm for finding the greatest common divisor of two numbers in his work Elements. The extended version goes further: it finds the multiplicative inverse of a number in a modular system. To find d such that 17 × d ≡ 1 (mod 3,120): the algorithm yields d = 2,753. Verification: 17 × 2,753 = 46,801 = 15 × 3,120 + 1, so 17 × 2,753 ≡ 1 (mod 3,120). The choice of e = 17 satisfies all three conditions — it is prime, smaller than φ(n) = 3,120, and shares no common factor with 3,120. In real RSA implementations the most common value of e is 65,537 — a prime chosen because it is large enough for security and has a binary representation that makes modular exponentiation computationally efficient.
8.The correctness of RSA decryption follows from Euler’s theorem: for any m with gcd(m,n) = 1 — meaning m and n share no common factor other than 1 — mφ(##INLINE45##) ≡ 1 (mod n). For m = 65 and n = 3,233: since 65 = 5 × 13 and 3,233 = 61 × 53, the two numbers share no common factor other than 1, so the condition is satisfied. Since e × d = 17 × 2,753 = 46,801 = 15 × 3,120 + 1, we have m(##INLINE52## × ##INLINE53##) ≡ m (mod n). The computations 6517 ≡ 2,790 (mod 3,233) and 2,7902753 ≡ 65 (mod 3,233) can be verified with any standard computing environment. In practice the condition gcd(m,n) = 1 is almost always satisfied automatically, because n is the product of two very large primes and the chance that a real message number is a multiple of either prime is negligibly small.
9.NIST finalized its first post-quantum cryptographic standards in August 2024. The primary standards are FIPS 203 (ML-KEM, for key encapsulation), FIPS 204 (ML-DSA, for digital signatures), and FIPS 205 (SLH-DSA, for stateless hash-based signatures), all based on mathematical problems believed to be hard for both classical and quantum computers. The push toward these standards was accelerated by two converging pressures: the theoretical threat of quantum computers running Shor’s algorithm at scale, and the practical demonstration that the implementation layer of encryption protocols is already under active attack by AI systems capable of autonomously exploiting software vulnerabilities. The engineering layer built on top of RSA is the current battlefield. The mathematical foundation described in this essay has not been touched.
The arithmetic in these essays is the arithmetic the practice runs on a mandate.
Discuss a mandate →