Multiplicative Inverse Using The Extended Euclid's Algorithm

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Finding the multiplicative inverse using the extended Euclid’s algorithm

For example: Find the inverse of e = 17 for RSA where p = 101 and q = 199

Calculate t = (101 - 1)*(199 - 1) = 19800

So the inverse d should satisfy the following: e*d mod t = 1.

Substituting, 17 * d mod 19800 = 1

Finding d using the extended Euclid’s algorithm.

Setup a table as shown below, the U & V values are always setup in this way.

Row Quotient Remainder U V


0 - 19800 0 1
1 - 17 1 0
2
3
4
5

Start to fill in the empty spaces.


19800 / 17 → 1164 times, remainder 12 (see where to put values below)

Row Quotient Remainder U V


0 - 19800 0 1
1 - 17 1 0
2 1164 12
3
4
5

To get the values under U & V, follow this pattern:


(a) (b) (c) (d)
0 - (1164 * 1) = -1164

In other words, 0 – (1164 * 1) = -1164.

Row Quotient Remainder U V


0 - 19800 0 (a) 1
1 - 17 1 (c) 0
2 1164 (b) 12 -1164 (d)
3
4
5
Do the same for the V value.

Row Quotient Remainder U V


0 - 19800 0 1 (a)
1 - 17 1 0 (c)
2 1164 (b) 12 -1164 1 (d)
3
4
5

That is, 1 – (1164 * 0) = 1.

Continue for the remainder of the table.


For each row as you go down, use the next values of U & V to do your calculations.
E.g. if the last calculation used row 0, the next calculation uses row 1 and so on.

Row Quotient Remainder U V


0 - 19800 0 1
1 - 17 1 0
2 1164 12 -1164 1
3 1 5 1165 -1
4 2 2 -3494 3
5 2 1 8153 -7

When the remainder gets to 1, the calculation is complete (last row).


The value highlighted above is the inverse of e.

CHECK: 17 * 8153 mod 19800 = 1

You might also like