Modular exponentiation Confusion

  • Thread starter Thread starter Siksissk
  • Start date Start date
  • Tags Tags
    Confusion
AI Thread Summary
The discussion centers on implementing modular exponentiation for encryption and the challenges faced in decryption. The user seeks clarification on the decryption process after successfully encrypting a message using the formula c = b^e (mod m). Key concepts include selecting prime numbers p and q to compute m, determining φ(m), and ensuring e is coprime to φ(m) to find the decryption key d. An example illustrates the process with small primes, showing how to encrypt and decrypt a message effectively. The thread emphasizes the importance of understanding the relationship between the encryption and decryption keys in modular arithmetic.
Siksissk
Messages
8
Reaction score
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
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.
 
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Suppose ,instead of the usual x,y coordinate system with an I basis vector along the x -axis and a corresponding j basis vector along the y-axis we instead have a different pair of basis vectors ,call them e and f along their respective axes. I have seen that this is an important subject in maths My question is what physical applications does such a model apply to? I am asking here because I have devoted quite a lot of time in the past to understanding convectors and the dual...

Similar threads

Replies
8
Views
164
Replies
3
Views
3K
Replies
6
Views
3K
Replies
5
Views
2K
Replies
2
Views
3K
Back
Top