Question: Part 2 ( encryption and decryption ) . Now it's time to put all your hard work to use. The encryption and decryption processes are
Part encryption and decryption Now it's time to put all your hard work to use. The encryption and decryption processes are identical, except that they involve different encryptiondecryption keys. Write a program rsa.java that takes in one command line arguments the name of the encryption key reads in a decimal string from standard input, and applies the RSA function to the message. It should work as follows. In real applications, you might want to send an ASCII text message instead of a decimal integer; however, you are only responsible for handling decimal inputs.
RSA function. The key step is to implement the RSA function aka modular exponentiation: given three extended precision integers the basethe exponent and the modulus compute modn. You will implement this as the function xPrsa in
A natural way to compute is to set ; then multiply it by times; then set xmodn. This method suffers from two serious performance bugs.
First, observe that if the inputs and are digit decimal integers, then the intermediate result could contain as many as digits. To see the great importance of this, observe that if is the intermediate result could consume a terrabyte of memory!
The second problem is that repeating anything times will be slow. If is even moderately large say decimal digits it will take centuries to execute, even on the fastest supercomputer.
We use two ideas to overcome the above obstacles. First, the following mathematical identity is useful to keep the intermediate numbers small.
xymodn
Second, we use the technique of divideandconquer or repeated squaring. We incorporate both ideas into the following pseudocode. This allows us to perform modular exponentiation in a reasonable amount of time when an appropriate base case is added
mod
mod
odd
return
Note here that the division is integer division, and each of the intermediate computations is performed using extended precision arithmetic. The exponentiation computation is naturally implemented using recursion. As above, if and are Ndigit numbers, then the intermediate results in this function will never have more than digits. However, since could be digits long, the intermediate results in the mod division function might be as many as digits. This explains why we allocate digit.
Extra credit. Write a program that compute two large pseudorandom prime numbers and of a specified number of digits. Compute and select a small integer that is relatively prime with Use these to generate a public key and its companion secret key
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
