Modular exponentiation Confusion

  • Thread starter Siksissk
  • Start date
  • Tags
    Confusion
In summary, the conversation discusses the implementation of a Modular exponentiation encryption method, specifically focusing on the decryption method. The most popular method, the RSA algorithm, involves choosing two prime numbers, p and q, and computing m = pq. Then, φ(m) is calculated and e is chosen so that gcd(e,φ(m)) = 1. This allows for the selection of a unique d for decryption. An example using small numbers is given to demonstrate the process.
  • #1
Siksissk
8
0
Hi all,

First off, not sure which forum maybe the most relevent, hopefully this one is the most suited?

I do not have much of a background in maths, so bare with me.

I am trying to implement a Modular exponentiation encryption method, I am using
http://en.wikipedia.org/wiki/Modular_exponentiation

the encryption I am happy with, but what I am stuck on is the decryption method.

Can anyone point me to a good bit of text, that explains the method in simple terms.

Thank you.

P.S. apologies if this belongs in the comp science forums.
 
Mathematics news on Phys.org
  • #2
ok, so what you are doing is creating an encryption c, by taking the original message b, and computing be (mod m).

in this case, e can be thought of as "the encryption key", and the reduction mod m keeps the encryption c = be in a manageable range. we want to choose e and m in such a way that we can also uniquely "decrypt" c, by taking:

cd = b (mod m), for some "decryption" (private) key d. so we need 3 integers, e,d and m that makes this all work out. the most popular method (RSA algorithm) does it this way:

1. choose 2 prime numbers, p and q. we are going to use m = pq (the idea being that even if m is known (public information), p and q are quite difficult to recover).

2. compute φ(m) = φ(p)φ(q) = (p-1)(q-1). this is sensitive information, as knowing either p or q, would allow the other to be calculated quickly, thus revealing φ(m). conversely, if φ(m) were to be discovered, it is possible to calculate p and q in terms of m and φ(m).

3. choose e so that gcd(e,φ(m)) = 1. this is critical, because it is what allows us to devise the decryption key d. often, e is chosen to be a small prime, such as 3 (most of the numbers < m = pq will be co-prime to φ(m), so it's likely 3 will be. in the rare cases where it's not, 7 or 13 also make good choices).

now if gcd(e,φ(m)) = 1, there is always a unique d such that de = 1 (mod φ(m)). obviously, d must be kept secret (private key).

then cd (mod m) = (be)d (mod m) = bde (mod m) = b(1 + kφ(m)) (mod m)

= (b)(bφ(m))k (mod m)

= b(1k) (mod m) = b (mod m).

this is because the group of units mod m, has φ(m) elements, and any group element raised to the order of the group gives the identity, and the identity of the group of units mod m is 1 (mod m). we chose e to be in this group of units, and this allows us to pick d = e-1 (mod m).

to give an unrealistically small example, let p = 3, q = 7. so we are going to work mod 21.

now φ(21) = φ(3)φ(7) = 12. so our choices of e are limited to numbers relatively prime to 12. 11 works. so let's say our original message is "12".

our encrypted message is (12)11 mod 21 = 3.

to decrypt this message, we need to know d. as we saw above d = 11-1 (mod 12). although one can use the euclidean algorithm to compute d, since 12 is so small, it is quicker to use trial-and-error (showing why larger primes p and q should be used). in this case, 11 is its own inverse (mod 12) (11*11 = 121 = 1 (mod 12)).

so, decrypting, we take 311 (mod 21), which gives us back 12.
 

FAQ: Modular exponentiation Confusion

What is modular exponentiation?

Modular exponentiation is a mathematical operation that involves finding the remainder when a number is raised to a power and divided by a given modulus. It is commonly used in cryptography and computer science.

How is modular exponentiation different from regular exponentiation?

Modular exponentiation involves finding the remainder when dividing by a modulus, while regular exponentiation involves finding the full result of the exponentiation operation. This makes modular exponentiation useful for dealing with large numbers and for preserving the privacy of the exponentiation operation.

What is the purpose of modular exponentiation in cryptography?

Modular exponentiation is used in cryptography to securely encrypt and decrypt messages. It is also used in key exchange protocols to securely share secret keys between two parties.

Can you provide an example of modular exponentiation?

For example, if we have the numbers 5, 3, and 7, the modular exponentiation operation would be 5^3 mod 7. This would result in a remainder of 6, as 5^3 = 125 and when divided by 7, the remainder is 6.

What are some common sources of confusion when working with modular exponentiation?

Some common sources of confusion with modular exponentiation include understanding the concept of a modulus, properly handling negative exponents, and choosing appropriate values for the base, exponent, and modulus to ensure the result is within a desired range.

Similar threads

Replies
1
Views
686
Replies
0
Views
1K
Replies
1
Views
1K
Replies
4
Views
3K
Replies
10
Views
2K
Replies
6
Views
3K
Replies
2
Views
2K
Back
Top