Modular Arithmetic
Before we look at the code in the RSA program example, let's first understand a bit more about modular arithmetic. Modular arithmetic is used in many cryptographic systems, including RSA, DSA, and SSL. The algebraic structure that is used is referred to as Zn , which is the set of nonnegative integers modulo n. Zn consists of the set {0, 1, 2, …, n – 1} along with operators defined for addition and multiplication. Note that Zn is integer arithmetic on a finite circle, not an infinite number line. Zn is sometimes referred to as clock arithmetic, since a twelve hour clock implies Z12 arithmetic.
For example, Z12 would be the set of numbers from 0 to 11, with addition defined much like regular addition, but any result over 11 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access