Attic › Computer science › Public-key cryptography

One-way mathematical functions make it impossible to calculate a private key from a public key

About One-way function

Because a public key and a private key work together, they have a mathematical connection. To keep the system safe, a computer makes the public key from the private key with a trapdoor function. This special calculation is easy to do in one direction, but almost impossible to reverse without a secret piece of information.

First, consider a one-way function: a mathematical operation that is fast to calculate, but takes too much time to undo. A common example is the multiplication of prime numbers (numbers that divide only by themselves and 1). It is easy to multiply two prime numbers together:

1. Take the prime numbers 61 and 53.

2. Multiply them to get 3,233.

Reversing this process is called prime factorisation. If someone gives you the number 3,233 and asks which two prime numbers make it, you must test different numbers until you find the answer. If the two starting primes each have 300 digits, a computer can multiply them in less than a second. However, finding those two primes from their 600-digit product would take the world's fastest computers thousands of years.

A trapdoor function is a one-way function with a secret shortcut—the "trapdoor". It is impossible to reverse the function unless you know this secret information. With the secret, reversing the function becomes easy again.

The RSA cryptosystem, one of the oldest and most common public-key systems, uses prime multiplication to build its trapdoor:

1. A computer picks two huge, random prime numbers. These primes are kept secret and used to calculate the private key (the trapdoor).

2. The computer multiplies the two primes together. The resulting product becomes part of the public key.

3. When a sender encrypts a message with the public key, the mathematical operation mixes the message with this large product.

To reverse the encryption and read the message, a computer must know the two original prime numbers. Because only the owner of the private key has these primes, only the owner can go through the trapdoor to unlock the data. Modern systems also use other hard mathematical problems to build trapdoors, such as elliptic-curve cryptography, which gets the same security with much smaller numbers.

Fact-checked against Public-key cryptography on Wikipedia

Part of the Computer science syllabus: Cryptography and Computer Security

See it on the timeline of Computer science