# How do I create a secure encryption scheme using addition?

You have a 4 number long PIN code with each number ranging from 0 to 9 which you wish to encrypt. You are then given a random 4 digit number ranging from 0 to 9999, which when added to the original PIN should give out a perfectly secure encrypted number.

Now clearly, just adding the two numbers would give an uneven distribution (a Gaussian curve), as if for example the PIN was 0000 and the random number was 0001, you can rest assured that the original PIN is either 0000 or 0001, while if both integers add up to 9999, there are 19998 possible outcomes.

So my initial thought was that applying the mod of 10000 (because there are 10000 possible combinations) to the sum should ensue an even distribution, making this encryption scheme perfectly secure. Now I honestly really don't know how to prove this, but my main question is how can you convert this somewhat meaningless number back to the original PIN? Is this actually (maybe not effective) perfectly secure? The point of this exercise is that the two users only have common knowledge of the random number, so I don't think any modulus exponent tricks are accessible.

• Smells like homeworks to me. :/ Fist advice : simplify your scheme. I.e. think each digit separately => consider a only 1 number long PIN code. Second hint : if a + b = c, if you know b and c, how do you find a (it works with mod too)? – Biv Apr 4 '16 at 16:37
• 3rd and last hint, you do not need exponents. Your scheme is perfectly secure as is (using the modulus). You just need to prove it. And yes here comes the probabilities... – Biv Apr 4 '16 at 16:44
• Have you considered carry-less addition of the individual digits? This would be comparable to exclusive-or in base-2. – user9070 Apr 4 '16 at 18:13
• @AndresStadelmann Well, its not that they are not welcomed, it is just that 1. it is rarely useful to someone else. 2. If we give the answer you won't learn anything and it will sap the work of a teacher. :) So the best you could expect is some advices or hint. However is the question is not too specific, asking won't hurt. And no you don't need to remove it. In a worse case scenario, it will get down voted/closed and will get removed automatically in some months. – Biv Apr 4 '16 at 18:33
• Our usual policy concerning homework is that you document your efforts and depending on how far you have come we'll usually guide you towards the correct result or fix flaws in your thought process which allows you to come to the solution yourself, which is a) more satisfying for you and b) more effective as a means of learning. – SEJPM Apr 4 '16 at 19:24

Your idea of addition modulo 10000 is correct. The correctness follows from the fact that $\mathbb{Z}_{10000} = \{0, 1, \dots, 9999\}$ equipped with addition modulo $10000$ forms a (finite) group.
Let $m \in \mathbb{Z}_{10000}$ denotes a PIN code. Now choose a uniformly random element $r \in \mathbb{Z}_{10000}$ and define $c = m + r \bmod 10000$. It is easily seen that $c$ is a uniformly random element in $\mathbb{Z}_{10000}$.
• Your answer does not fit the constraints of its question: the message is 4 digit long, hence yes it is perfectly secure. "each digit together" $\mapsto$ far too informal: Lets say that you have 1234, if you add each digit together you get 10. I'm pretty convinced this is not what you want to say. :) – Biv Apr 5 '16 at 11:45