*Originating authors are Graeme L. Cohen (University of Technology, Sydney), Steven Galbraith (University of Auckland) and Edoardo Persichetti (University of Auckland).*

How can we safely send our credit card details over the internet, or using a mobile phone, when others can intercept our messages? How can we trust software updates, when we know that computer viruses are common? Cryptography (the study of techniques for secure communication in the presence of adversaries) provides answers to these questions, and mathematics provides its foundations.

**A little history**

Secure communication has been important for thousands of years: there is evidence of Julius Caesar using a simple cryptographic method to communicate with his generals. The scheme is known as the “Caesar cipher” and it consists of shifting the letters in a message by a certain number of positions to obtain a new document called the *ciphertext*. The message can be recovered at the other end by inverting this operation, i.e. shifting back the letters of the received ciphertext by the *same* number of positions.

The crucial idea is that the sender and receiver both know a secret value (in this case, the number of positions) that is assumed to be unknown to the people trying to learn the message. The secret value is called the *key*. In the case of the Caesar cipher the key is a number between and . The *encryption* algorithm takes as input a message and a key , for example (HELLO)=KHOOR. The algorithm takes as input a ciphertext and the same key , for example (KHOOR)=HELLO.

Cryptosystems where the same key is used for encrypting and decrypting are called *symmetric-key* schemes.

The Caesar cipher itself is much too simple to be secure in the modern world, but there are modern symmetric-key ciphers that are currently used in many situations; an example is the very famous AES, one of the US government standards for transmitting data. These systems are efficient and secure, but there is one problem: both sender and receiver must already share a secret. How can we communicate securely over the internet with people we have never met?

An amazing concept called *public-key cryptography*, initiated in 1976 in the paper “New directions in cryptography” by Whitfield Diffie and Martin Hellman, solves this problem.

In this setting, instead of using the same key for encrypting and decrypting, there is a *public key*, available to all potential users, and a *private key* that remains secret to a specific user. In other words, everybody can send a message but only one person can receive it: Anyone can drop a letter in the posting slot, but only the person who has the key of the mailbox can get the letter. To communicate securely with Alice one looks up their public key and uses it to generate a ciphertext. Only Alice can decrypt the ciphertext, as only she knows the private key.

Public key cryptosystems must be based on computational problems that are hard to solve. Mathematics provides such problems. For example, the RSA cryptosystem is based on the difficulty of finding the prime factors of a very large integer.

**Some Number Theory**

Before describing the very popular RSA public-key encryption scheme we need to develop some results in number theory. This requires a modest familiarity with the binomial theorem and modular arithmetic.

In modular arithmetic, we collect integers into classes according to their remainder after division by a certain number , called *modulus*. So for example if we have that 9 is in the class of 2, and 5, 12 and 19 are all in the same class. We write and . It is easy to see that there are only 7 possible classes, represented by when working modulo . It is possible to perform addition and multiplication modulo 7 by simply reducing the result after performing the operation normally, so and . Note that if then is a multiple of .

Let and be primes, and let be an integer that is not a multiple of or . We will now show that the formula holds. This formula is a special case of the Fermat-Euler theorem.

The proof begins with the formula for binomial coefficients:

where is an integer with . From

it follows that must be a divisor of , since divides the right-hand side but does not divide .

Then, for any integers and , by the binomial theorem,

Taking a further integer ,

In this way, for any integers, , , …, ,

Now put and we obtain

This equation means that is a multiple of . Since does not divide and is prime it follows that

Now raise both sides of this congruence to the power :

Repeating the argument but using instead of , we find

These say, respectively, that there are integers and such that

so . Then divides (since and are distinct primes), and so , say, for some integer . Now we have , or

This completes the proof.

**The RSA cryptosystem**

The acronym RSA stands for Rivest, Shamir and Adleman, who first proposed this scheme in 1977. It works as follows.

First choose two distinct primes, and . Calculate and . Choose an integer at random between 3 and , but such that and have no prime factors in common. The public key is the pair . The private key , which the sender will keep secret, is calculated so that , that is, the number such that (this is easily done using Euclid’s algorithm). For example, take , , and .

Messages in the RSA system are integers such that . It might not initially be clear how to encrypt text messages with a scheme that uses integer numbers. However, cryptographic schemes are implemented on computers and all documents are just binary data, which can be encoded using integers.

The encryption process is the following. Suppose Bob wants to send a message to Alice. He looks up Alice’s public key , calculates , and sends to Alice. To decrypt the ciphertext , Alice makes use of the private key , by calculating .

It is important to point out that, even though and are huge, it is possible to efficiently compute, for example, , using a technique called *modular exponentiation*.

Decryption works since , for some integer , and as we showed above

(in practice the case when is a multiple of or can be ignored), and so

A malicious user that does not know the private key would need to factor to recover and . This is beyond the limits of current computing if these primes are sufficiently large, say 200 digits each (the current world records for factoring are where and are around 100 digits each).

This is actually defining the *level of security* of the scheme. The main notion about public-key cryptography, in fact, is that a cryptosystem is *secure* as long as the computational effort required to break it is beyond the attacker’s resources. This is fixed a priori (usually or bit operations) and depends on the context and aim of the communication. Clearly, a CIA secret message and an email between two internet users are expected to meet very different standards of security!!!

**Signatures**

We can now turn to the problem of software updates. In other words the problem of *authentication*. As before, we have a public key and a private key. Alice, using her private key, constructs a *digital signature* to be sent along with a document, in order to prove its authenticity (the signature depends on the document and cannot be cut-and-pasted to a different document). The receiver then verifies the digital signature using the public key.

Suppose, for example, that your computer tells you it found an update for Adobe. How does the computer know the software comes from Adobe and is not a virus disguised as an update? The solution is that the update has a digital signature with respect to the Adobe public key. This public key is already installed on your computer in the Adobe software, so your computer can verify the signature before installing the update; a successful verification proves the update is really from Adobe and no one else.

We now show how to construct digital signatures using RSA.

The private and public keys are the same as for encryption. When Alice wants to authenticate a document (e.g., a software update) she encodes it as an integer , computes , and attaches the signature to the document. To verify the signature Bob looks up Alice’s public key, and verifies the signature by calculating and checking that . It is clear that, just as for the RSA cryptosystem, a malicious user aiming to produce a valid signature (for example a hacker designing a virus) would need the exponent , hence requiring to factor .

**Current Research**

We have sketched the RSA cryptosystem and digital signature schemes, but there are many other systems based on mathematical objects like finite fields, elliptic curves, systems of non-linear multivariate equations, error-correcting codes and more.

Public key cryptography is a very active research area, and there are still open questions being studied.

**A post-quantum scenario**

Are all our problems solved with RSA? Unfortunately, the answer is no. The security of RSA, as well as many other schemes based on number theory, is seriously threatened by the potential development of quantum computers. Shor’s algorithm, published in a 1994 paper with the portentous title “Polynomial time algorithms for discrete logarithms and factoring on a quantum computer”, is capable of breaking the RSA cryptosystem as long as a large enough quantum computer can be built. Quantum computers of a very small size are already a reality and it is plausible to expect improvements in the near future.

It is therefore important to provide alternative systems whose security won’t be affected in case this scenario becomes real. The cryptographic community is very active in this direction, and current research is focusing on developing new cryptosystems from various areas of mathematics, based on computational problems that will hopefully not suffer the same vulnerabilities to quantum algorithms.

**References**

[1] Simon Singh, *The Code Book: The Science of Secrecy from Ancient Egypt to Quantum Cryptography* (2000), Anchor.