Passer au contenu

Bitcoin accepté au paiement  |  Expédié depuis Laval, QC, Canada  |  Soutien expert depuis 2016

Modular Arithmetic

Network & Protocol

Definition

Modular arithmetic is a system in which numbers wrap around upon reaching a fixed value called the modulus, exactly the way a 12-hour clock returns to 1 after 12. Two integers are congruent modulo m when their difference is divisible by m, written a ≡ b (mod m), and the expression b mod m denotes the unique remainder r with 0 ≤ r < m. This wrap-around arithmetic is the bedrock beneath every elliptic-curve operation in Bitcoin: every signature your node verifies, every public key your wallet derives, is computed inside a finite, modular world.

Clock arithmetic, formalized

If it is 9 o'clock and you add 8 hours, the answer is 1 o'clock rather than 17, because 17 is congruent to 5 modulo 12 on a 12-hour dial. What makes the idea powerful is that congruence is compatible with addition, subtraction, and multiplication: you can reduce intermediate results at any point in a calculation without changing the final answer. That property is what keeps 256-bit elliptic-curve computations from ballooning into unbounded integers — hardware and software can reduce after every step and stay inside fixed-width words. It is also why modular code maps so cleanly onto silicon: a reduction modulo a well-chosen prime compiles down to a handful of additions and shifts, which is one reason Bitcoin's curve arithmetic is fast even on modest hardware.

Prime moduli, inverses, and finite fields

Division is where the modulus choice matters. When the modulus p is prime, every non-zero value has a multiplicative inverse, so division becomes possible and the integers modulo p form a finite field. This is precisely the setting elliptic curves require: secp256k1 performs all of its coordinate arithmetic modulo the 256-bit prime 2256 − 232 − 977, a value chosen partly because reduction against it is cheap. A second modulus matters just as much: the curve's group order n, the prime number of points on the curve. Private keys, nonces, and signature values in both ECDSA and Schnorr signatures live modulo n, and mixing up the two moduli is a classic implementation bug.

Why the wrap-around makes cryptography possible

Modular arithmetic gives cryptographers something rare: operations that are easy to perform but appear practically impossible to reverse. Exponentiation modulo a prime is fast, but recovering the exponent — the discrete logarithm — has no known efficient solution, and the elliptic-curve version of that asymmetry is the entire basis of Bitcoin key security. The discrete logarithm problem is hard exactly because the answers live in a finite, wrap-around world with no notion of "getting closer": there is no smooth gradient an attacker can follow from a public key back to its private key. The same structure underpins RSA and Diffie–Hellman outside Bitcoin.

Where a miner and node operator meets it

You touch modular arithmetic more often than you might think. Difficulty retargeting, key derivation paths, and Schnorr's linear signature equation s = k + e·d (mod n) all reduce modulo fixed constants. Even SHA-256, the hash your ASIC computes trillions of times per second, is built from 32-bit additions that are themselves modular — addition modulo 232, which is why the algorithm's adders wrap instead of overflowing. For the sovereign operator, the payoff of grasping this topic is confidence: curve coordinates never overflow, signatures verify deterministically on any honest implementation, and the security of your keys rests on well-studied mathematics rather than on trust in any vendor. The wrap-around world is small enough to compute in and vast enough — roughly 2256 values — that brute force is off the table for every adversary on Earth.

In Simple Terms

Modular arithmetic is a system in which numbers wrap around upon reaching a fixed value called the modulus, exactly the way a 12-hour clock returns…

Explore the Full Glossary

Browse all Bitcoin mining terms from A to Z. Whether you are a beginner or expert, deepen your understanding of the mining ecosystem.

Glossaire du minage

ASIC Miner Database

Compare 500+ miners with real-time profitability data, home mining scores, and detailed specs.

Comparer les mineurs