Apex › Cryptography

Finding a factor by accident (Pollard’s rho)

Miller–Rabin says a number is composite; Pollard’s rho produces the factor — in about n^(1/4) steps, no divisor list. Iterate f(x) = x² + c mod n; if p is a hidden factor, the sequence taken mod p cycles after ~√p steps (birthday paradox), tracing the Greek letter ρ. When two terms collide mod p but not mod n, gcd(x_i − x_j, n) = p. Floyd’s tortoise-and-hare finds the collision in O(√p) time and O(1) memory. Verified in node: finds a true factor of many composites including a 19-digit semiprime, factor·cofactor = n, and iterations track √p. Step the walk and watch the gcd jump from 1 to a factor.

More in Cryptography