step1 method
Sets p and q variables. Makes them different prime numbers and generates the necessary data for the next step.
Implementation
List<int> step1({
required int p,
required int q,
}){
//TODO: Problem may have to do with p and q not beign turned into prime when they are not prime. Find alternative to renaming the parameters name
//Make the numbers prime if they are not and save them internally
_pValue = p;
_qValue = q;
if(_pValue!.isPrime() == false){
_pValue = OptimusPrime.primeAfter(_pValue!);
}
if(_qValue!.isPrime() == false){
_qValue = OptimusPrime.primeAfter(_qValue!);
}
//Make sure that p and q are not the same
if(_pValue == _qValue){
_qValue = OptimusPrime.primeAfter(_qValue!);
}
//Calculate N
_N = _pValue! * _qValue!;
//Calculate Φ(N)
_phi = (_pValue! - 1) * (_qValue! - 1);
//Empty the possible e list
_possibleE = [];
//Find and save possible values for e
for(int i = 2; i < phi!; i++){
if(i.coprimeWith(phi!) && i.coprimeWith(N!)){
_possibleE.add(i);
}
}
//Return the possible values for e
return _possibleE;
}