0

I need an efficient formula of some kind that will allow one to figure out the original message(msg) with regards to the following formula: C = msg^e mod N. If a user is provided with C, e and N, is there an efficient way to calculate msg? In this example, C is the ciphertext, e is the public key and N is a public modulus.

I have done some research on what modular arithmetic is all about and looked over some detailed explanations, however, no articles have shown me how to figure out a problem such as this.

James Foster
  • 71
  • 1
  • 7
  • It seems that you are trying to break RSA. Here some attacks on RSA [Twenty Years of Attacks on the RSA Cryptosystem](https://crypto.stanford.edu/~dabo/papers/RSA-survey.pdf) – kelalaka May 21 '19 at 11:19

1 Answers1

0

Modulus is a non-reversible operation. At best, you know that msg ^ e = C + k*N, and need to determine the value of k.

Consider the following simple case:

e = 2
N = 10
msg =  1 | C = 1  'Note1
msg =  2 | C = 4  'Note2
msg =  3 | C = 9  'Note3
msg =  4 | C = 6  'Note4
msg =  5 | C = 5
msg =  6 | C = 6  'Note4
msg =  7 | C = 9  'Note3
msg =  8 | C = 4  'Note2
msg =  9 | C = 1  'Note1
msg = 10 | C = 0

Line Graph showing the results of the above table

It should immediately be obvious that if C = 6, this could mean that Msg = 6 or that Msg = 4 (Or Msg = 24, et cetera, ad infinitum) with no way to tell the difference without more information.

However, given the same msg for different known values of e and N, then you can narrow down the possibilities like so:

e = 3
N = 10
Msg =  1 | C = 1
Msg =  2 | C = 8
Msg =  3 | C = 7
Msg =  4 | C = 4  'We can now see that this
Msg =  5 | C = 5
Msg =  6 | C = 6  'Is different from this
Msg =  7 | C = 3
Msg =  8 | C = 2
Msg =  9 | C = 9
Msg = 10 | C = 0
Chronocidal
  • 6,827
  • 1
  • 12
  • 26
  • I understand your point. In my task I was only provided with a single key (e), a single public modulus (N) and an example of a cipher text(c), so unless I was given more examples, I cannot figure out my original message (msg) ? – James Foster May 21 '19 at 07:45
  • @JamesFoster Correct - you can work out *possibilities* - in the example above, for `C=6, e=2, N=10` we know that `msg=√(6+10k)`, so `√6`, `√16`, `√26`, `√36`, et cetera. We can discard non-integer roots (e.g. , `√6` and `√26`) and then have to work out which of the others it is. If your plain text is an ASCII encoded string, then it is just a case of testing each case for "is this valid", and testing each **valid** case for "does this make sense" – Chronocidal May 21 '19 at 07:55
  • @JamesFoster e.g. "Test" as Ascii bytes / hex is `54 65 73 74`. In decimal, that is `1415934836` - since `1415934836² = 2004871459798346896`, this means that mod-10 `C = 6` and `k = 200487145979834689` - when we test the previous value of `k=200487145979834688` we would get `msg="Tesj"` instead. Obviously, larger values of `N` would make this easier to calculate (if `N=1000000` then `C=834689` and `k` is a mere `200487145979`). – Chronocidal May 21 '19 at 07:58
  • Alright, I think I understand what you are saying. Thank you, much appreciated – James Foster May 21 '19 at 08:54