Question: [ BBS algorithm ] Implement the methods in BBS . java. class BBS { / * the numerical components of the BBS algorithm * /

[BBS algorithm] Implement the methods in BBS.java.
class BBS
{
/* the numerical components of the BBS algorithm */
int p, q, n, s, X;
/* Check that the p and q values are appropriate for the BBS algorithm.
* If either one is not appropriate, throw an exception with a meaningful
* message. Otherwise, compute and assign the values of n, s, and X_0(the
* latter is stored in X).
* Must produce the EXACT output shown in the handout, such as:
* Setting up BBS with p =7 and q =199
* n =1393
* s =696
*/
BBS(int p, int q) throws Exception
{
System.out.println("Setting up BBS with p ="+ p +" and q ="+ q);
/* To be completed (you MUST keep the line above)*/
}// constructor
/* return the largest integer less than or equal to n/2 that is
* relatively prime to n.
*/
private int chooseS()
{
/* To be completed */
return -1; /* Delete this line in your submission */
}// chooseS method
/* use the BBS algorithm to update X and return the next random
* bit (with true representing a 1 bit and false representing a 0
* bit.
*/
boolean getNextRandomBit()
{
/* To be completed */
return false; /* Delete this line in your submission */
}// getNextRandomBit method
/* use the BBS algorithm to return the next random integer value;
* to keep values small, the 20 most significant bits must be equal
* to 0; the remaining bits are produced by BBS from most to least
* significant (i.e., from left to right)
*/
int getRandomInt()
{
/* To be completed */
return -1; /* Delete this line in your submission */
}// getRandomInt method
/* This method is used for testing.
* Do NOT modify it.
*/
public static void main(String[] args) throws Exception
{
if (args.length !=2)
{
System.out.println("Usage: java BBS

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!