InterviewStack.io LogoInterviewStack.io

Number Theory for Cryptography Questions

Comprehensive mastery of the number theoretic and algebraic foundations that underpin modern cryptography. Core topics include modular arithmetic and modular exponentiation, prime number theory and primality testing, integer factorization problems, the discrete logarithm problem in multiplicative groups, quadratic residues and Legendre and Jacobi symbols, Euler theorem, group theory, ring theory, finite fields, and elliptic curve groups. Candidates should be able to apply these concepts to analyze and explain public key systems such as Rivest Shamir Adleman, Diffie Hellman key exchange, ElGamal, and elliptic curve cryptography, and to show why security reduces to the hardness of integer factorization or discrete logarithm in the appropriate group. The scope covers algorithmic tools and their practical complexity including the extended Euclidean algorithm, fast modular exponentiation, Chinese remainder theorem, Miller Rabin and deterministic primality tests, trial division, Pollard rho and Pollard p minus one factorization methods, elliptic curve method for factorization, quadratic sieve, general number field sieve, baby step giant step, Pollard rho for discrete logarithm, and index calculus approaches. Candidates should be comfortable solving representative problems by hand or with small code examples such as computing modular inverses, performing modular exponentiation, applying the Chinese remainder theorem, solving small discrete logarithm instances, and reasoning about how algorithmic advances translate into concrete key size and security recommendations.

MediumTechnical
73 practiced
Describe the AKS primality test at a high level: what core idea makes it polynomial-time, the role of polynomial congruences, and its worst-case complexity. Then compare AKS to Miller-Rabin in practice and explain scenarios where AKS might be chosen despite slower real-world performance.
MediumTechnical
106 practiced
Explain Tonelli-Shanks algorithm for computing square roots modulo an odd prime p. Then use Tonelli-Shanks to compute a square root of 5 modulo 41 (i.e., find x such that x^2 ≡ 5 mod 41) and verify your answer. Show the decomposition p-1 = q * 2^s and all intermediate steps.
EasyTechnical
118 practiced
Explain the Miller-Rabin probabilistic primality test step by step. Then perform one Miller-Rabin iteration on n = 21 using base a = 2: decompose n-1 = 2^s * d, compute a^d mod n and successive squarings, and show whether this base detects compositeness. Finally, explain why Miller-Rabin is stronger than a simple Fermat test.
HardTechnical
59 practiced
Provide a rigorous proof sketch of correctness for the Tonelli-Shanks algorithm for computing square roots modulo an odd prime p. Explain the role of the decomposition p-1 = q * 2^s, how the algorithm finds a 2-adic square root in the subgroup of order 2^s, and analyze its runtime in terms of modular multiplications and expected number of loop iterations.
HardTechnical
83 practiced
Provide a formal reduction argument: under what assumptions can an algorithm that recovers RSA plaintexts or private exponents be used to factor the RSA modulus N? Present the standard reduction that shows how a decryption or signing oracle can be converted into a factoring procedure, and discuss practical caveats where the reduction may not hold (e.g., with randomized padding or limited oracle access).

Unlock Full Question Bank

Get access to hundreds of Number Theory for Cryptography interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.