# Finding small-length RSA private key

I was wondering if there is an algorithm to derive $$p$$ and $$q$$ or is it simply trial and error?

Consider the following RSA crypto-system with public key $$(437,13)$$. Since the numbers are so small, it is possible to break the crypto-system and determine the private key. What is the value of the two primes $$p,\,q$$ with $$n=p\times q$$ used in the key generation.

Hint: You may ignore the value $$13$$ in your computations.

The answer is $$23$$ and $$19$$ but I was wondering if there is an algorithm for it?

Thanks!

• I rolled back the edit to the question. It's crucial to the answer that the numbers are small, and questions shouldn't be edited in a way that makes answers invalid. – David Richerby Dec 8 '18 at 21:12

Of course there’s an algorithm for it. Trial division is an algorithm, a very straightforward one.

Divide the odd target number by 3, 5, 7, and 11 to see if they are factors.

Then beginning with the number 11, increment with the values of 2,4,2,4,6,2,6,4,2,4,6,6,2,6,4,2,6,4,6,8,4,2,4,2,4,8,6,4,6,2,4,6,2,6,6,4,2,4,6,2,6,4,2,4,2,10,2,10 as continuing and repeating .

Finally, divide the odd target number by each incremented number to see if one of them is a factor. Continue dividing by the incremented numbers up to the square root of the target number if no factors are previously found.

One note, I found the increments that produce a sequence of odd numbers with multiples of 3, 5, and 7 removed just by working logically with a sequence of odd numbers. However, the increments can also be determined using Wheel Factorization formulas. But I think it is faster to increment with 48 hard-coded array values than to compute.

• You should probably explain that your sequence consists of the gaps between the small primes. You might have well started it with an extra 2,2,4. – Yuval Filmus Dec 9 '18 at 1:14
• The increments produce a sequence of odd numbers with multiples of 3, 5, and 7 removed. The sequence does contain all the forward prime numbers but also contains composite numbers. Use of the number sequence in factoring reduces the number of required divisions and is a major increase in performance – S Spring Dec 9 '18 at 1:54
• That would be a good thing to explain in your answer, though I think you can assume that $n$ is the product of two primes. – Yuval Filmus Dec 9 '18 at 1:56
• The sequence of odd numbers with multiples of 3, 5, and 7 removed, is very little computational overhead in exchange for the increase in performance. Developing all prime numbers for the factoring operation would be much more computational overhead. – S Spring Dec 9 '18 at 2:07
• You can explain all of this in your answer. – Yuval Filmus Dec 9 '18 at 2:08