Calculating the difference of the factors of a semiprime

102 Views Asked by At

Let there be a semiprime $N=p q$ where $p$ and $q$ are prime numbers.

If the value of $N$ is given, is there any way to calculate the value of $(p-q)$. If not exactly then approximately ?

Update : Anyway of calculating the upper bound and lower bound in which $p-q$ will lie ?

Thanks

2

There are 2 best solutions below

5
On

If $pq$ and $p-q$ are known, then so is $(p+q)^2=(p-q)^2+4pq$, and hence so is $p+q$. Therefore determining $p-q$ is equivalent to determining $p$ and $q$.

0
On

Lower bounds on $|p-q|$ are equivalent to ruling out the existence of factorizations with $p$ and $q$ close together.

Fermat factorization (assuming $N$ is odd, but the question is trivial if $N$ is an even semiprime) looks for solutions to $N = x^2 - y^2$, since any factorization $N=pq$ corresponds to $x= \frac{p+q}{2}, y = \frac{p-q}{2}$. It's easy to see that making $p-q$ small is equivalent to making $x$ as small as possible. So you can step through possible values of $x$ (starting with $\lceil\sqrt{N}\rceil$), which gives lower bounds for $x$ and in turn lower bounds for $y$. These aren't very strong bounds but they are initially better (for the same amount of effort) than trial division counting down from $\lfloor\sqrt{n}\rfloor$. See example at https://en.wikipedia.org/wiki/Fermat%27s_factorization_method#Fermat.27s_and_trial_division

Upper bounds on $|p-q|$ are equivalent to ruling out small prime divisors of $N$. This is literally trial division, but it can also be done (albeit probabilistically in most cases that I know of) by using more advanced factoring methods such as Pollard rho or ECM which perform well when there is a small prime divisor.