0

I m looking an easy way to compute inverse modulo of some numbers. I had this example(made from RSA computation) pick p = 7 and q =11 i calculate the $\phi$ = 60 and n= p*q = 77.

I chose an e = 7 I need to find the inverse multiplicative in this way

$7^{-1} $mod 60

I used this type of simple computation

60 = 8 (7) +4

7= 1(4) +3

4 = 1(3) +1

after computing the inverse

1= 4- 1(3)

= 4 - 1(7 -1(4))

= 2(4) - 1(7)

= 2(60 -8(7)) -1(7)

= 2(60) -17(7)

and 2(60) mod 60 = 0

so I have just -17(7) that should be an inverse modulo of 7 mod 60, but something didn't work.


If I use 11 for calculating the inverse of 11mod 60 in the same way

60= 5(11)+5

11 = 2(5) +1

so

1= 11-2(5)

= 11 -2(60-5(11))

= 11(11) -2(60)

and in this case, 11 is right, is the inverse of 11mod 60.

I didn't understand why I m wronging in the first case. Someone can clarify to me why happened this?

I know that I should use different method of calculating inverse, but I need to compute in fast and easy way this stuff, I m not a very mathematic expert.

theantomc
  • 101
  • 2
    You showed in the first case that$$7^{-1}\equiv-17\equiv43\pmod{60}$$ – Peter Foreman May 01 '20 at 10:25
  • I aspect that my output in the $ 2(60) -17(7) $will be $2(60) -43(7)$... as in second case that i got $11(11)- 2(60)$ @PeterForeman – theantomc May 01 '20 at 10:59
  • 1
    It's called the Euclidean algorithm. You go backwards. But I can never remember how to do it. –  May 01 '20 at 11:07
  • You've just forgotten the minus sign on the 17, that's all! The method is fine. – Matthew Towers May 01 '20 at 11:13
  • See https://math.stackexchange.com/questions/85830/how-to-use-the-extended-euclidean-algorithm-manually – Ege Erdil May 01 '20 at 11:18
  • I think that minus sign give me some problem in the calculation. Because for 11 I got a positive sign and no problem to determine where is the inverse. I miss something on equality give by Peter @MatthewTowers – theantomc May 01 '20 at 17:00
  • Maybe the key is do 60-17 that give me 43. And after i can say that 43 is the inverse. – theantomc May 01 '20 at 17:04
  • 1
    No, what you did is really correct, there's no problem in the calculation. Peter points out that if you want a positive residue you can swap $-17$ for $60-17=43$ because they are the same mod 60. When you use this method sometimes you will get positive inverses and sometimes negative, but you can easily convert to a positive one by Peter's suggestion. – Matthew Towers May 01 '20 at 17:53
  • ok thank i got :) – theantomc May 01 '20 at 18:01

0 Answers0