REST API and a simple quantum application generating random numbers
Randomness plays a vital role in numerous computer applications, especially in various types of computer simulations. The generation of random numbers is essential for these simulations, and they extensively rely on these random numbers throughout the process.
Generating random numbers can be easily achieved using software libraries in various programming languages. However, it’s important to note that these libraries generate pseudo-random numbers, meaning that the generated numbers can be considered random only to a certain extent. The initialization of the pseudo-random generator can be done by setting a specific method to establish the “seed,” or it can be left unset, with the system automatically initializing the seed using the system clock. However, both methods of seed initialization can introduce biases in the simulation, which is why an independent seed source could be valuable.
To address this issue, the website quantum-random.com provides a solution by offering quantum random numbers. These numbers are not correlated with any activity of the client computer and are considered truly random, as they are generated using the properties of quantum mechanics.
This has been implemented using a micro-service web-app structure and an external quantum computer. In this picture you can see a schematics view of the system.
The generation of quantum random numbers is accomplished by employing an external quantum computer. The quantum algorithm utilized for this purpose is relatively straightforward. It involves applying a Hadamard gate to a specific number of qubits, which may vary depending on the available quantum machine. Following the application of the Hadamard gate, the state is measured. Once a set of quantum numbers is generated through this process, they are injected into the database to be served by the web application.
The web application is accessible over the internet through an Nginx web server, which handles the request redirection to a Node.js application. The application itself is straightforward, featuring a landing page that provides a link to the REST API. This API allows users to retrieve random numbers in a JSON format. To interface with a PostgreSQL database, the web application utilizes Sequelize, a popular ORM (Object-Relational Mapping) tool.