I have the values for p, q, n and e and would like to calculate the private key d. How can I do this, could someone give me the example C# code ? I am using a BigInteger class to represent the values for p, q, n and e so I assume d will be a BigInteger as well.
I have the values for p , q , n and e and would
Share
The short way is to compute the inverse of e modulo (p-1)*(q-1). Actually you only need the least common multiple of p-1 and q-1, but this will not buy you much (yes, there are several possible values for d, this is normal, they are all equivalent).
If your
BigIntegerclass has a modular inverse method, then this will be easy: just call it. Otherwise, you will have to compute it yourself, using the extended Euclidean algorithm (this is whatBigIntegerclasses tend to use to compute modular inverses).