Search code examples
algorithmencryptionidempotent

Idempotent decryption routine/algorithm


Is there a simple decryption algorithm that is idempotent? Something like this:

decrypt(encrypt(x)) ===  x  === decrypt(decrypt(decrypt(encrypt(x))))

Solution

  • Suppose decrypt is a function f and encrypt is a function g. Hence, we have f(g(x)) = x and f(f(f(g(x)))) = x. Hence, we have f(f(x)) = x, and then f(f(x)) = f(g(x)) = x. If the result of the decryption function will be a bijective functio, we can conclude that f(x) = g(x), and then g(g(x)) = x. Also, if we suppose g(x) is bijective, it means f is inverse of g. Therefore, g(x) = x!

    Also, if we don't have the bijective assumption for the function g (which is not too far!), from g(g(x)) = x, we find that for all input x the function maps the value of g(x) to itself. Hence, g(x) = x by the definition.