Let’s talk about random number generation
Tags: privacy, internet, cryptography, security
Published: 2023-08-30 18:07:54

---
title: Let’s talk about random number generation
published: true
date: 2022-04-11 20:39:26 UTC
tags: privacy,internet,cryptography,security
canonical_url: 
---

![](https://cdn-images-1.medium.com/max/1024/0*g7E3X-_hGZkMypVQ)
_Image retrieved from https://www.prancentral.com.au/getattachment/a16cf471-26ab-4627-9bbc-1c32a34b21fc/4-Benefits-of-Playing-the-Lottery_

**Random numbers generation (RNG)** is the process to create a sequence of numbers or symbols that can’t be easily predictable more than using the random chance is generated and it has an important job in our lives, they are used in the lottery, statistical sampling, simulations, cryptography, our current privacy on the internet relies on the RNG, even the hacker attacks rely on the RNG.

The real randomness depends on the measurement of uncertainty or disorder in a system that guarantees us that there will not be a pattern in the outcome given; in simple words, the real randomness can be found in the measurement of those environmental noises that can be unpredictable like thermal noise, photoelectric effect, etc.

![](https://cdn-images-1.medium.com/max/640/0*yaDG7gGXhPNZpoBN.png)
_Image retrieved from https://www.incibe-cert.es/sites/default/files/blog/comprobando-aleatoriedad/dilbert.png_

### So, how our computer can generate random numbers?

The architecture of the traditional computers makes them deterministic, this means that if you ask them the same question, always will give you the same answer, and it makes the computers bad to generate random results, but they can be imitated.

In the computer science field, we talk about two methods to generate random numbers: **True Random Number Generator (TRNG)**, and **Pseudorandom number generator** (**PRNG).**

The **True Random Number Generators** are specific hardware that measures physical environment changes that can be impossible to model, normally those hardware has in-built translators to parse the physical events into electrical signals.

The **Pseudorandom number generator** is an algorithm that mimics the selection of a number to approximate true randomness using a mathematical formula meaning there will be always patterns and outcome values are determined by an initial value called the  **seed.**

Knowing this we can ensure that an online poker game can be hacked if you know the algorithm and the initial seed used, with that simple information you will be able to determine what will be the next card to be dealt.

### **Where are the Random Number Generators used in computer science?**

The most used case for the RNG is Cryptography, these random numbers are used in passwords salt, TLS nonce, TCP/IP sequence, ASLR offset, and the generation of keys to encryption systems. Without randomness, all crypto operations would be predictable and hence insecure.

Let’s review one of the use cases, the key generation, maybe when you were generating an SSH key pair for authentication using Putty software get asked to move your mouse in a blank area.

![](https://cdn-images-1.medium.com/max/474/0*RJjpc9WfahGV2Xvw.png)

This is made to gather random values based on the user input, the computer reads information like the exact time when the mouse was moved and the moves that you're doing to get some entropy and provides an RNG value using that info, making your key more unpredictable.

### Conclusions

Random numbers get a great role in the computer science field, the privacy of the users depends on the way those numbers or sequences are generated, even if the computers are deterministic they can generate real random numbers using special hardware to measure the real world and translate it in electrical signals.

### Recommendations

If you want to dive more into this topic, I would like to recommend you some articles:

1. [Random Number Generators](https://en.wikipedia.org/wiki/Random_number_generation)
2. [Hardware Number Generators](https://en.wikipedia.org/wiki/Hardware_random_number_generator)
3. [Understanding Random Number Generations and their limitations, in Linux](https://www.redhat.com/en/blog/understanding-random-number-generators-and-their-limitations-linux)
4. [Can a computer generate a truly random number?](https://engineering.mit.edu/engage/ask-an-engineer/can-a-computer-generate-a-truly-random-number/)
5. [UEFI entropy gathering protocol](https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/uefi-entropy-gathering-protocol)

And keep an eye on this Medium page to get in touch with the latest papers.