Thursday 16 March 2023

WHY RANDOM ISN’T RANDOM

 



Introduction

Sorry for the pun in the title but, yes, random is not random. You aren’t random and computers aren’t random. Now, let me explain…

 

Why aren’t computers random?

Computers, or better their CPUs, work with inputs and outputs, without really “thinking”. Every operation they make is “predictable” just by knowing their internal structure because they only apply mathematical algorithms.

 

For example, we can take one of the simplest operations CPUs make, called OR: its name self-explains “something” OR “something else” and its behaviour is “if at least one of the two inputs is 1, the output is 1, if they’re both 0, the output is 0”. This can be represented just with a math function (see the image below).

  


 

Why am I taking this example? Well, math can define random sequences, but not produce them. In fact, numbers produced by an algorithm cannot be random and computers, using algorithms to “act”, cannot produce random numbers.

 But…

 How do computers generate “random” numbers?

To “fake” the generation of a random number, computers take data from different sources (information) available to them and, through algorithms, generate a number apparently random. For example, computers have access to the current date and time, workload (how much they have been working), CPU temperature and other data. The values taken from there are called “seeds” (in cryptography) since they are responsible for the creation of a random number.

 Where’s the problem?

The problem is that in our daily life, we use cryptography to create an account on a site, login to our smartphone, computer and so on, which is all related to the generation of a random value (the seed) for encryption, but encrypting with an algorithm with predictable outputs can discover the input used and how to predict it (ex. predict the next output).

 So how do we solve this problem?

As said before, real random values don’t exist and the only thing we can do is use an algorithm like AES (used as a standard by the U.S. government), which makes it difficult to predict the output algorithm without knowing the secret key (the seed) used for encryption.

 Can humans generate random numbers?

Not really, they can generate random numbers, but they may not be truly random. Humans tend to be influenced by their environment and create patterns to help choose a number.

A proof? Try this version of “rock, paper, scissors” with an AI (artificial intelligence) trying to identify your pattern and you’ll find out that it will probably stay one step ahead of you just after 10 matches and you’ll lose if don’t think about your movements and take some pattern changes.

 Why do both random and cryptographically random exist?

While random values are good for things like “extractions” or “random value between x and y”, password generation, communication through encryption (WhatsApp end-to-end encryption) etc. requires more than an “apparently” random value, one (theoretically) unpredictable.

 Conclusion

This article came to my mind while thinking about some scheduled oral tests we planned with my class. In order to draw the calendar with the names of the students for each session, we used a random numbers generator online, but I know you can actually predict all the numbers that are going to be picked up, which is the same as saying each one of us was “destined” to have his or her oral test on that specific day.

 The next time you’ll be picked up to be the first in an oral test, you’ll know that you have the seed to blame for it.

GIORGIO B., 4sc

No comments:

Post a Comment