If $x^2\equiv y^2\mod n$, does $\gcd(x-y,n)$ divide $n$?

66 Views Asked by At

If $x^2\equiv y^2\mod n$, does $\gcd(x-y,n)$ divide $n$?

EDIT: I should really be asking if $\gcd(x-y,n)$ is neither $n$ nor $1$, since it will always divide $n$.

I know $n$ must divide $x^2-y^2$, but in my cryptology course we have been using a square factoring algorithm where we look at the prime factorization of numbers with small prime factors in order to find some $x\ne \pm y$ such that $x^2\equiv y^2\mod n$.

1

There are 1 best solutions below

0
On BEST ANSWER

The greatest common divisor of two numbers is a divisor of each of those, so $\gcd(n,a)$ is a divisor of $n$ for any number $a$.

The point of what you are doing is the following: you are trying to factor $n$, or at least find a proper nontrivial divisor (that is a divisor $d$ such that $1\neq d\neq n$.

If $x^2\equiv y^2\pmod{n}$, then since $n$ divides $x^2-y^2=(x-y)(x+y)$. If in addition $x\not\equiv y\pmod{n}$ and $x\not\equiv -y\pmod{n}$, then $n$ does not divide $x-y$ nor $x+y$. That means that $\gcd(n,x-y)\neq n$ and $\gcd(n,x+y)\neq n$. If $p$ is a prime factor of $n$, then $p\mid (x-y)(x+y)$, and since $p$ is prime, if it divides a product then it divides one for the factors, so you will have either $p\mid x-y$ or $p\mid x+y$. And that means that $p\mid \gcd(n,x-y)$ or $p\mid \gcd(n,x+y)$. And that will mean that $\gcd(n,x-y)$ (or $\gcd(n,x+y)$) will not equal $1$. So you will "detect" a nontrivial factor of $n$ with either $\gcd(n,x-y)$ or with $\gcd(n,x+y)$, provided that $x^2\equiv y^2\pmod{n}$ and $x\not\equiv \pm y\pmod{n}$. This is the heart of Fermat's factorization method.