Hi, nice code

The prime numbers approach is a good idea, I also try it some time ago, but it only works as you said
if you have the right factors if no then the brute force approach of the prime numbers is also some exhaustive, we can try some small and common factors but those don't provide much speed, but if the prime factors aren't common then the probabilities of some prime number is factor of our key are very low probabilities.
IMHO this prime number approach is a nice as proof of concept but with some low success
I tried and tested similar approach a year ago. The best result I could achieve is O(N/4) complexity for a random number, so this is 4x better than bruteforce. But it's requires a lot of scalar multiplications, therefore optimized sequential key generation is still faster despite the higher complexity of O(N).