← Complete problem index

PROJECT EULER · #0182

RSA Encryption

Statement only · SolvedOriginal problem ↗

The RSA encryption is based on the following procedure:

Generate two distinct primes p and q.
Compute n=pq and ϕ=(p1)(q1).
Find an integer e, 1<e<ϕ, such that gcd(e,ϕ)=1.

A message in this system is a number in the interval [0,n1].
A text to be encrypted is then somehow converted to messages (numbers in the interval [0,n1]).
To encrypt the text, for each message, m, c=memodn is calculated.

To decrypt the text, the following procedure is needed: calculate d such that ed=1modϕ, then for each encrypted message, c, calculate m=cdmodn.

There exist values of e and m such that memodn=m.
We call messages m for which memodn=m unconcealed messages.

An issue when choosing e is that there should not be too many unconcealed messages.
For instance, let p=19 and q=37.
Then n=1937=703 and ϕ=1836=648.
If we choose e=181, then, although gcd(181,648)=1 it turns out that all possible messages m (0mn1) are unconcealed when calculating memodn.
For any valid choice of e there exist some unconcealed messages.
It's important that the number of unconcealed messages is at a minimum.

Choose p=1009 and q=3643.
Find the sum of all values of e, 1<e<ϕ(1009,3643) and gcd(e,ϕ)=1, so that the number of unconcealed messages for this value of e is at a minimum.

Write-up coming later

The complete problem is available here. An approach, code, and answer will be added later.