NextPrime[n_] := n /; PrimeQ[n];
NextPrime[n_] := NextPrime[n + 1];

GoodPrime[e_, n_] := n /; ((GCD[n - 1, e] === 1) && PrimeQ[n]);
GoodPrime[e_, n_] := GoodPrime[3,NextPrime[n+1]];

MakeKey[e_, p_, q_] := 
{ 
	{e, p*q} , 
	Mod[ ExtendedGCD[e, (p-1)(q-1)][[2,1]], (p-1)(q-1) ]
};


