Don't Let the Cat Out!Trapdoor functions and their importance in security
Functions! I’m sure you have heard this concept in many ways: math,
programming, economics, etc. And they all can be reduced to the same
basic thing: something that takes some inputs and produces some outputs.
Math is the case here, however, there is a lot to add to that short
definition, specially when we apply it to computer security, because
despite you might be unaware, your security totally depend on a special
kind of functions called
Trapdoors.  Let’s
talk about trapdoor functions and how they save you from "letting the
When we talk about inputs producing an output we usually talk about the reverse process: given the outputs deduce the inputs, this is really useful in many applications… but not in security! knowing an input from an output is a serious problem, you will see why.
Trapdoor is essentially something taking an input and producing an
output, but it is extremely difficult to do the reverse process, this is
because to do so you need to know a "secret" called a private key and
you have to be the luckiest guy in all universes to guess it or to guess
P : Plain text data
Trapdoor is a function that encrypts with the properties:
E = f(P) (Easy to do)
Trapdoors are not the same as the well known hash functions, hash
functions are one-way functions as well, but they are not reversible by
any means, whereas
Trapdoors are reversible with the key. This is what
makes them fundamental for
Encryption of shared information.
Your lifesaving, precious data is always put in a
and transmitted and no one (except the possessor of the secret and the
luckiest guy in all universes) can figure out the data.
Symmetric and Asymmetric Encryption
When two ends have to exchange sensitive data, they must agree on the
key they both use, this is called
 where the same key is used to encrypt and to
decrypt. This key has to be transmitted first for agreement before any
other communication, but how can they prevent a third party sniffs and
retrieve the key? they use a type of
Asymmetric Encryption: It encrypts the data with one public key and decrypts it
with a different private key
Kp : Public key
The data is encrypted with
E = f(P,Kp)
And decrypted with
P = f-1(E,Kp)
Encryption is slow and it’s not commonly used in data
transmission. It’s only used between parties to agree on a shared key
that they use for
Symmetric Encryption which is the one used for large
data exchange as it’s faster. The shared key for
is transmitted over
Asymmetric Encryption so no attacker can retrieve
this symmetric key.
Rivest, Shamir, Adleman, also know as
 is the most common algorithm for
Asymmetric Encryption and it’s based on a
Trapdoor function called modular
E = PKP mod N
In this case knowing P from E is impossible, you need to know a secret KS in order to compute it.
RSA algorithm uses prime number arithmetics and modular exponentiation
to encrypt a message, the algorithm can be summarized like this :
Choose two prime numbers p and q.
Compute n = pq.
Compute Euler’s function ϕ = (p - 1)(q - 1). 
Choose a number e smaller and coprime  to ϕ.
Choose a number d such that (ed - 1) mod ϕ = 0, This is know as the modular multiplicative inverse, in other words, ed - 1 must be divisible entirely by ϕ.
(e,n) are the public key whereas (s,n) are the private key.
A message m is encrypted into c by
c = me mod n
And decrypted by
m = cd mod n
Thus, anyone can know the public key value e to encrypt but not the private key value d used to decrypt. What about n ? could not they use it to come up with d ? Yes, they can, they will just take tenths of years to do it as n is chosen to be a very big number, so breaking it into the prime factors p, q used to get e and therefore d, would take long enough that an attacker cannot crack the key.
AES (Advanced Encryption System)  algorithm,
is usually the chosen one for
Symmetric Encryption. This algorithm is
rather procedural than hard mathematical formula computation, it
basically encrypts a table of data in four steps:
SubBytes: Each value in a table is substituted by another using a table.
ShiftRows: Rows of the table are shifted by some offset.
MixColumns: Columns are mixed by a matrix operation.
AddRoundKey: The public key is performed over the table with an
All operations performed are reversible and they are made in order to eliminate or diffuse any possible pattern or relationship of the ciphered message to the original one and to the key that might hint an attack.
You can be sure your data is very well protected and that the
communication won’t be disclosed to any attacker thanks to a
of course, as computing power continues to develop, we might need to
create new traps, but now the assurance of your privacy on communication
is really high, so every time you browse your social networks, bank
accounts, etc; remember there is a
Trapdoor that won’t let any cat