Question: Write own large prime number generator. Write PYTHON 3 CODE which implements the function GenerateRSAPrime. This function takes as input the integer k, the size
Write own large prime number generator. Write PYTHON 3 CODE which implements the function GenerateRSAPrime. This function takes as input the integer k, the size of the desired prime in bits. The output should be p, a random prime value between l and u. The main idea for GenerateRSAPrime is to first pick a random number in the range, then test if that random number is prime, and repeat until a prime value has been selected. Furthermore, verify that the prime number is NOT equal to 1 modulo 3 or 1 modulo 5.
You may use the random module to generate your random values since this is not a secure implementation.
Pseudocode is as follows:
Check for a sensible range
assert 32 k 64
Commute maximum number of attempts
r 100 * k
repeat
r r - 1
assert r > 0
Choose n randomly as a k bit number
n 2^(k-1),...,2^k -1
Continue trying until we find a value satisfying:
(n mod 3) 1 and (n mod 5) 1 and n is prime
return n
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
