0
$\begingroup$

In RSA cryptosystem to encrypt or decrypt a message we have to convert strings like $$C = 987^{937} mod\ 2537$$ or $$M= 461^{937}mod\ 2537$$

we have to solve it doing binary expansion of $937 = 2^9+2^8+2^7+2^5+2^3+1$

and then $$M =( 461^{512}*461^{256}*461^{128}*461^{32}*461^8*461)mod\ 2537$$ this takes another process called $Modular\ Exponentiation$ to solve this. This takes a long time, is there any way to solve this faster?

  • 0
    Are you using [exponentiation by squaring](https://en.wikipedia.org/wiki/Exponentiation_by_squaring)?2017-02-03
  • 2
    RSA is viewed as a slow way to encrypt/decrypt data, so is often used just to exchange keys for a faster algorithm. The numbers used practically are *much* larger than you show, but are handled by computer so the computations are fast in human terms.2017-02-03
  • 0
    @RossMillikan thanks, but i'm trying to prepare for my exam and this process is taking a long time . Is there any other way?2017-02-03
  • 0
    @Joffan yeah, i'm using Exponentiation by squaring2017-02-03
  • 0
    @Joffan i'm preparing for my exam, i've to do it by my hand not in computer2017-02-03

1 Answers 1

2

How I do exponentiation by squaring for $M= 461^{937}\bmod\ 2537$:

The calculation to make is: $(\!(\!(\!(\!(\!(\!(\!(\!(\!(461)^2\cdot 461)^2\cdot 461)^2)^2\cdot 461)^2)^2\cdot 461)^2)^2)^2\cdot 461)$, all operations undertaken $\bmod 2537$, which is driven by the binary structure of $937$, $1110101001$.

Calculate largest power of $2$ less than or equal to the exponent $937$, which is $2^9=512$. Then the layout for the process, stepping through the binary digits of the exponent, is:

\begin{array}{c|c} 2^k & \text{square prev} &\text{inc?} & \text{value}& \text{remaining exp} \\ \hline 512 & 1 & \checkmark & 1\cdot 461 \equiv 461 & 937-512 = 425\\ 256 & 461^2 \equiv 1950 & \checkmark & 1950\cdot461 \equiv 852 & 425-256 = 169\\ 128 & 852^2 \equiv 322 & \checkmark & 322\cdot 461 \equiv 1296 & 169-128 = 41\\ 64 & 1296^2\equiv 122 & \times & 122& 41\\ 32 & 122^2 \equiv 2199 & \checkmark & 2199\cdot 461 \equiv 1476 & 41-32 = 9\\ 16 & 1476^2\equiv 1830 & \times & 1830& 9\\ 8 & 1830^2 \equiv 60 & \checkmark & 60\cdot 461 \equiv 2290 & 9-8=1\\ 4 & 2290^2\equiv 121& \times & 121& 1\\ 2 & 121^2\equiv 1956& \times & 1956& 1\\ 1 & 1956^2\equiv 140 & \checkmark & 140\cdot 461 \equiv \fbox{1115} & 1-1 = 0\\ \end{array}

all calculations undertaken $\bmod 2537$ . The decision on whether to multiply by $461$ ("inc?") is based on whether the remaining exponent is greater than or equal to the current power of $2$ (equivalently, the value of the corresponding binary digit). The process finishes on the line where the power of $2$ reaches $1$.

Admittedly if done strictly by hand the 14 operations here will not be that quick, but there really isn't a more efficient method. With a desk calculator this should be reasonable.

  • 0
    that's a well organized way.. thanks2017-02-03