Unit 1: Number Theory-I
1. The Integers and Divisibility
Number theory forms the mathematical cornerstone of modern cryptography, public-key encryption, and hashing algorithms. The domain of study is the set of integers .
1.1 Definition of Divisibility
Let with . We say that divides (written as ) if there exists an integer such that:
- If divides , then is called a factor or divisor of , and is called a multiple of .
- If does not divide , we write .
- Example: because . Conversely, because no integer satisfies .
1.2 Fundamental Properties of Divisibility
For all integers :
| Theorem / Property | Formal Statement | Mathematical Consequence |
|---|---|---|
| Reflexivity | for all . | Any non-zero integer divides itself (). |
| Transitivity | If and , then . | Divisibility chains preserve factors. |
| Linearity (Linear Combinations) | If and , then for any integers . | If divides two numbers, it divides any integer linear combination of them. |
| Multiplication Property | If , then for any integer . | Multiples inherit divisors. |
| Zero Divisibility | for every non-zero integer . | ; zero is divisible by every non-zero integer. |
| Boundedness | If and , then $ | a |
| Antisymmetry | If and , then . | Mutual divisors in differ at most by sign. |
2. The Division Algorithm
Despite its historical name, the Division Algorithm is a foundational theorem that guarantees the existence and uniqueness of quotients and remainders.
2.1 Formal Statement
Let (the dividend) and (a positive integer divisor). Then there exist unique integers (the quotient) and (the remainder) such that:
CODEDividend (a) = Divisor (d) * Quotient (q) + Remainder (r) [-------------------------] [-----------] Multiple of d 0 <= r < d
2.2 The Strict Constraint on the Remainder
The remainder must strictly satisfy . It can never be negative, and it must be strictly less than the divisor.
2.3 Division with Negative Dividends
When is negative, careful application of is mandatory:
- Example 1: Divide by .
Here, and . Note that writing is mathematically invalid under the Division Algorithm because . - Example 2: Divide by .
3. Modular Arithmetic and Congruence
Modular arithmetic studies the arithmetic of remainders, forming the bedrock of cryptographic ciphers like RSA and Diffie-Hellman.
3.1 Definition of Congruence
Let be a positive integer called the modulus. Two integers and are said to be congruent modulo (written ) if divides their difference:
Equivalent Characterization:
if and only if and leave the exact same remainder when divided by :
Examples:
- because , and .
- because , and .
3.2 Equivalence Relation and Residue Classes
Congruence modulo is an equivalence relation satisfying:
- Reflexive: since .
- Symmetric: If , then .
- Transitive: If and , then .
It partitions into exactly disjoint residue classes modulo :
Where each class represents all integers leaving remainder when divided by .
3.3 Algebraic Compatibility with Addition and Multiplication
If and , then:
- Addition Compatibility:
- Multiplication Compatibility:
- Exponentiation Compatibility:
3.4 Failure of General Cancellation
Unlike standard arithmetic over , cancellation does not hold generally in modular arithmetic:
Counterexample: (since ), but canceling the gives , which is false!
The Correct Cancellation Rule:
If (i.e., and are coprime), then can be cancelled safely:
4. Representations of Integers and Base Expansions
4.1 Base- Expansion Theorem
Let be an integer greater than 1 (the base or radix). Any positive integer can be uniquely expressed in the base- positional system as:
Where:
- is a non-negative integer.
- Each digit satisfies .
- The leading coefficient .
- Notation: .
4.2 Algorithm for Base Conversion
To convert a decimal integer to base :
- Divide by to get quotient and remainder .
- Divide by to get and remainder .
- Repeat until quotient becomes . The remainders read in reverse order (bottom-up) form the base- representation.
4.3 Common Cryptographic Number Bases
| Base Name | Radix () | Permitted Digits | Practical Computer Science Application |
|---|---|---|---|
| Binary | Low-level hardware logic, bitwise XOR ciphers | ||
| Octal | Unix file permissions (chmod 755) | ||
| Decimal | Human standard positional arithmetic | ||
| Hexadecimal | Memory addresses, cryptographic hashes (MD5, SHA-256) |
Hexadecimal letter values: .
4.4 Fast Conversion Shortcuts: Binary Octal Hexadecimal
Because and , conversion between binary and octal/hexadecimal requires zero arithmetic:
- Binary to Octal: Partition binary bits into groups of 3 bits starting from the right (pad with leading zeros on left if needed), then replace each 3-bit group with its octal digit.
- .
- Binary to Hexadecimal: Partition binary bits into groups of 4 bits starting from the right, then replace each 4-bit group with its hexadecimal character.
- .
- Hexadecimal to Binary: Expand each hex digit into its corresponding 4-bit nibble.
- .
5. Modular Exponentiation and Fast Algorithms
In modern cryptosystems (such as RSA and Diffie-Hellman ), numbers often have 2048 or 4096 bits. Calculating directly produces astronomical numbers exceeding the atoms in the observable universe.
5.1 Square-and-Multiply (Repeated Squaring) Algorithm
To compute efficiently:
- Express the exponent in binary form: .
- Initialize result and base power .
- For each bit from to :
- If bit , update .
- Square the base power: .
- Return .
Time Complexity: Requires at most modular multiplications ( runtime), making computations feasible in milliseconds even for 4096-bit exponents.
Common Pitfalls & Anti-Patterns
- Negative Remainders: Writing instead of . The remainder must strictly satisfy .
- Illegal Cancellation in Modulo: Assuming . In truth, , so .
- Misgrouping Bits for Base Conversion: Grouping from left to right instead of right to left when converting binary to octal or hex causes catastrophic padding errors.
- Dividing in Modular Arithmetic: Division by is undefined unless an explicit modular multiplicative inverse exists (which requires ).
Exam Tips & High-Yield Formulas
- Division Algorithm: , with .
- Congruence: .
- Cancellation Rule: .
- Base Groupings: Binary to Octal = groups of 3 bits; Binary to Hex = groups of 4 bits (grouped from right to left).
- Linearity: If and , then for any integers .
Quick Revision Summary
- Divisibility: requires . Divisibility is reflexive, transitive, and linear.
- Division Algorithm: Uniquely breaks any integer into with strictly non-negative remainder .
- Modulo System: Partitions integers into equivalence classes. Addition and multiplication are preserved; cancellation requires coprimality.
- Base Expansions: Encodes integers into radix . Powers of 2 () permit direct 3-bit and 4-bit regrouping.
- Fast Exponentiation: Square-and-multiply evaluates in logarithmic time by exploiting binary expansion.