hello friends welcome to engineering code and today we are going to learn about the calculation of d in rsa algorithm so it is one of the toughest thing we calculate in the algorithm so it is the also the main part so one of my subscribers requested me to explain this in English so here we are so it will be given in the question the value of P Q and E and we have to calculate D so there are total three steps two step actually the first one is we have to calculate phi n so as we know that phi n is equal to the product of p minus 1 and q minus 1 so we will put the values of p and q in this equation so we will get 5 minus 1 is 4 and the line minus 1 is 10 so phi n will be 40 now the second step is we know that D multiplied by is congruent to 1 mod 5n. So we will put all the values here. So 3 into d is congruent to 1 mod 40. Now the value of 5n here is 40. We will simultaneously write the values here. The table of 5n.
So 40, 1, 4, 40, then 80, then 120 and this will continue. And side by side we have to add 1 in each number. So we will get here 41, 80 plus 1 is 81, 120 plus 1 is 121. Now we have to compare these values with this value, E value.
If E completely divides this value, any of the given value, then we will take this value. So here 81 is completely divisible by 3. So if we will put this here. we will get 1 as the modulus value so we have to make this equation equivalent to 81 so what will the number which will multiply so that this equation will be equivalent to 81 so 27 is the number if we will multiply here then it will be 81 so we will multiply this equation with 81 sorry 27 so it will be 81 27 into 3 will be 81 and here it will be 27 and mod 40 will remains same now if we will take 40 into 2 the modulus of 81 we will get 1 as a reminder when this value of when the product value with the d will be 1 then this value will be equal to d so this is very simple concept and it is just a two step process now we will again take another example let's p equal to 3 q is equal to 11 and e is equal to 7 so here also we have to calculate d so the first step is same we have to calculate the phi n value it will be 3 minus 1 2 and 11 minus 1 10 so it will be 20 now the step 2 we will put all the value which are given and we will get this equation d into 7 is congruent to 1 more 20 now as i told you told you earlier that we have to write the table of the 5 ins side by side so it will be for 20 40 60 and dot dot continue the same process and also we will add one in each number to get the other number so here it will be 21 40 plus 1 will be 41 60 plus 1 will be 61 now we will take that value which is completely divisible by the value of e which is 7 so if you will take 21 it will be completely divisible by 7 so we have to make this equation equivalent to 21 so what will we have to do we will have to multiply it with 3 so when we will multiply it with 3 it will be 21 and it will be 3 and mod 20 will remain same now if we will take the modulus of 21 mod 20 then it will be 1 whenever we will get 1 here the process is complete and this value will be equal to the value of D so here D is equal to 3 so this is a very simple process and because of this we are not able to calculate the whole process in RSA algorithm so that's it thank you so much