7.1 Number theory background and classical factoring

3 min readjuly 23, 2024

Number theory forms the backbone of many cryptographic systems. It deals with properties of integers, , and . These concepts are crucial for understanding how modern encryption works and why certain mathematical problems are hard to solve.

Number theory's applications in cryptography rely on the difficulty of certain mathematical operations. For instance, while multiplying large prime numbers is easy, factoring their product is computationally challenging. This asymmetry forms the basis of widely used encryption methods like RSA.

Number Theory Fundamentals

Fundamentals of number theory

Top images from around the web for Fundamentals of number theory
Top images from around the web for Fundamentals of number theory
  • Modular arithmetic performs arithmetic operations on integers within a fixed range or modulus (nn)
    • Addition: (a+b)modn=((amodn)+(bmodn))modn(a + b) \bmod n = ((a \bmod n) + (b \bmod n)) \bmod n (5 + 7 ≡ 2 (mod 10))
    • Multiplication: (a×b)modn=((amodn)×(bmodn))modn(a \times b) \bmod n = ((a \bmod n) \times (b \bmod n)) \bmod n (3 × 4 ≡ 2 (mod 10))
  • relation ab(modn)a \equiv b \pmod{n} holds if and only if nn divides (ab)(a - b)
    • Congruence classes are sets of integers that have the same remainder when divided by nn (2, 7, 12 are in the same congruence class modulo 5)
  • states that for coprime integers aa and nn, aϕ(n)1(modn)a^{\phi(n)} \equiv 1 \pmod{n}
    • ϕ(n)\phi(n) is , counting the number of positive integers up to nn that are coprime to nn (ϕ(12)=4\phi(12) = 4 since 1, 5, 7, 11 are coprime to 12)
  • is a special case of Euler's theorem
    • If pp is prime and aa is not divisible by pp, then ap11(modp)a^{p-1} \equiv 1 \pmod{p} (361(mod7)3^6 \equiv 1 \pmod{7})

Complexity of factoring algorithms

  • Factoring decomposes a composite number into its prime factors (60 = 2 × 2 × 3 × 5)
  • Classical factoring algorithms have limitations due to the believed hardness of factoring large numbers
    • divides the number by primes up to its square root with time complexity O(n)O(\sqrt{n})
    • uses a sequence of numbers to find a factor with average time complexity O(n1/4)O(n^{1/4})
    • finds smooth numbers to create a congruence of squares with time complexity O(e(logn)1/2(loglogn)1/2)O(e^{(\log n)^{1/2}(\log \log n)^{1/2}})
  • Best known classical algorithms have subexponential time complexity, which is exponential with respect to the number of digits in the input (factoring a 2048-bit number is much harder than factoring a 1024-bit number)

Factoring vs RSA cryptosystem

  • RSA cryptosystem is a public-key cryptosystem based on the difficulty of factoring large numbers
    • Key generation:
      1. Choose two large prime numbers pp and qq
      2. Compute n=pqn = pq and ϕ(n)=(p1)(q1)\phi(n) = (p-1)(q-1)
      3. Select public exponent ee coprime to ϕ(n)\phi(n)
      4. Compute private exponent dd such that ed1(modϕ(n))ed \equiv 1 \pmod{\phi(n)}
    • Encryption: cme(modn)c \equiv m^e \pmod{n}
    • Decryption: mcd(modn)m \equiv c^d \pmod{n}
  • The security of RSA relies on the difficulty of factoring large numbers
    • If an attacker can factor nn, they can compute ϕ(n)\phi(n) and derive the private key dd

Applications of modular arithmetic

  • Modular exponentiation efficiently computes abmodna^b \bmod n using repeated squaring
    • Example: Compute 3100mod173^{100} \bmod 17 by repeatedly squaring 3 and reducing modulo 17
  • Solving linear congruences finds solutions to equations of the form axb(modn)ax \equiv b \pmod{n}
    • Use the extended Euclidean algorithm to find the modular multiplicative inverse of aa modulo nn
    • Example: Solve 3x4(mod7)3x \equiv 4 \pmod{7} by finding the inverse of 3 modulo 7 and multiplying both sides
  • solves a system of simultaneous linear congruences
    • Example: Find xx such that x2(mod3)x \equiv 2 \pmod{3}, x3(mod5)x \equiv 3 \pmod{5}, and x2(mod7)x \equiv 2 \pmod{7} by combining the congruences using their pairwise coprime moduli

Key Terms to Review (21)

BQP - Bounded-error Quantum Polynomial Time: BQP refers to the class of decision problems that can be efficiently solved by a quantum computer with a high probability of correctness in polynomial time. Essentially, it allows quantum algorithms to outperform classical algorithms for specific problems, providing a framework for understanding the power of quantum computation in relation to traditional computational models.
Chinese Remainder Theorem: The Chinese Remainder Theorem (CRT) is a mathematical principle that provides a way to solve systems of simultaneous congruences with different moduli. It states that if the moduli are pairwise coprime, then there exists a unique solution modulo the product of these moduli. This theorem is especially useful in number theory and classical factoring, as it helps simplify complex problems into manageable parts by breaking them down into smaller, easier-to-solve congruences.
Classical bits: Classical bits are the fundamental units of information in classical computing, represented as either a 0 or a 1. They serve as the building blocks for all types of data processing and are critical in understanding how traditional algorithms operate, especially when exploring concepts such as number theory and factoring.
Composite numbers: Composite numbers are positive integers that have at least one positive divisor other than one and themselves. This means that composite numbers can be divided evenly by numbers other than just 1 and the number itself, which distinguishes them from prime numbers, which only have two distinct positive divisors. Understanding composite numbers is essential in number theory and plays a significant role in classical factoring, where identifying the factors of a number is crucial for various applications.
Congruence: Congruence refers to a relationship between two numbers indicating that they give the same remainder when divided by a certain modulus. This concept is fundamental in number theory and plays a critical role in classical factoring techniques, especially when dealing with the properties of integers and their divisibility. Understanding congruence helps in simplifying calculations and proving various properties related to prime numbers and modular arithmetic.
Divisibility: Divisibility refers to the ability of one integer to be divided by another integer without leaving a remainder. This concept is foundational in number theory, as it lays the groundwork for understanding prime numbers, factors, and the process of classical factoring. Recognizing whether a number is divisible by another helps in determining its factors and plays a crucial role in various mathematical algorithms, especially in factoring large integers.
Euler's Theorem: Euler's Theorem states that if 'a' and 'n' are coprime integers, then it holds that $$a^{\phi(n)} \equiv 1 \ (mod \ n)$$, where $$\phi(n)$$ is Euler's totient function, which counts the positive integers up to 'n' that are relatively prime to 'n'. This theorem is a significant result in number theory and plays a crucial role in classical factoring algorithms as well as the foundations of modern cryptography.
Euler's Totient Function: Euler's Totient Function, denoted as \( \phi(n) \), counts the number of positive integers up to a given integer \( n \) that are relatively prime to \( n \). This function plays a crucial role in number theory, particularly in classical factoring and the study of the multiplicative structure of integers, since it helps in determining the properties of numbers and their divisors.
Fermat's Little Theorem: Fermat's Little Theorem states that if $p$ is a prime number and $a$ is an integer not divisible by $p$, then $$a^{p-1} \equiv 1 \mod p$$. This theorem is a crucial principle in number theory, particularly in the context of primality testing and classical factoring methods, as it provides a foundation for understanding the properties of numbers in modular arithmetic.
Greatest common divisor: The greatest common divisor (GCD) is the largest positive integer that divides two or more integers without leaving a remainder. It plays a crucial role in number theory, particularly in understanding the properties of integers and their factors, which is foundational for classical factoring techniques. The GCD is essential for simplifying fractions, solving Diophantine equations, and has applications in various algorithms, including those used in cryptography.
Modular arithmetic: Modular arithmetic is a system of arithmetic for integers, where numbers wrap around after reaching a certain value known as the modulus. It’s similar to the way a clock resets to zero after reaching 12, which makes it particularly useful in number theory and classical factoring. This concept plays a crucial role in various algorithms, especially those related to cryptography and solving equations in finite fields.
P vs NP Problem: The P vs NP problem is a major unsolved question in computer science that asks whether every problem whose solution can be verified quickly (in polynomial time) can also be solved quickly (also in polynomial time). This problem connects deeply to concepts of computational complexity, particularly in relation to algorithms used in number theory and classical factoring, where determining factors of large numbers efficiently is crucial for cryptography and secure communications.
Pollard's rho algorithm: Pollard's rho algorithm is a probabilistic method used for integer factorization, particularly effective for finding small factors of large composite numbers. It uses a combination of randomization and mathematical properties of numbers to identify factors efficiently, making it an important tool in the field of number theory and classical factoring.
Prime numbers: Prime numbers are natural numbers greater than 1 that cannot be formed by multiplying two smaller natural numbers. They are the building blocks of the integers, as every integer greater than 1 can be expressed uniquely as a product of prime numbers, which is known as its prime factorization. This uniqueness and the distribution of prime numbers play a crucial role in various areas of mathematics, including number theory and classical factoring.
Public Key Cryptography: Public key cryptography is a cryptographic system that uses a pair of keys—one public and one private—for secure communication. The public key can be shared openly, while the private key is kept secret by the owner. This method relies on mathematical problems, particularly from number theory, making it fundamentally secure and enabling functionalities such as digital signatures and secure data exchange.
Quadratic Sieve: The quadratic sieve is a factorization algorithm that efficiently finds the prime factors of large composite numbers. It relies on the principle of finding smooth numbers, which are integers that can be factored entirely over a small set of primes. This method is particularly effective for numbers with up to about 100 digits, making it one of the fastest classical factoring techniques used in number theory.
Quantum Bits (Qubits): Quantum bits, or qubits, are the fundamental units of quantum information, analogous to classical bits but with unique quantum properties that allow them to exist in multiple states simultaneously. This characteristic of superposition enables qubits to perform complex calculations at a scale unattainable by classical bits. The ability of qubits to also exhibit entanglement further enhances their computational power, making them essential in various areas such as cryptography, optimization, and machine learning.
Quantum supremacy: Quantum supremacy refers to the point at which a quantum computer can perform a calculation that is practically impossible for any classical computer to complete within a reasonable timeframe. This milestone highlights the potential of quantum computing to tackle complex problems beyond the reach of traditional computing technologies, signaling a major shift in computational capabilities.
RSA Encryption: RSA encryption is a widely used public key cryptographic system that enables secure data transmission and digital signatures. It relies on the mathematical properties of prime numbers and modular arithmetic, making it difficult for unauthorized parties to decipher encrypted messages without the appropriate key. RSA stands as a cornerstone in modern security protocols, emphasizing the importance of number theory and factoring large integers in both classical and quantum contexts.
Shor's Algorithm: Shor's Algorithm is a quantum algorithm designed to efficiently factor large integers, which is fundamentally important for breaking widely used cryptographic systems. It demonstrates the power of quantum computing by outperforming the best-known classical algorithms for factoring, making it a pivotal example in the quest to understand the potential of quantum technologies.
Trial Division: Trial division is a straightforward algorithm used to determine whether a given integer is prime by dividing it by all integers up to its square root. This method checks for factors of the number and is foundational in number theory, especially in classical factoring techniques. The simplicity of trial division makes it an intuitive approach for understanding more complex algorithms and plays a crucial role in establishing the properties of numbers.
© 2024 Fiveable Inc. All rights reserved.
AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.