Quantum Random Number Generation in SAP UI5

by | Feb 18, 2023 | UI5, UI5 Integrations

Home » SAP » UI5 » UI5 Integrations » Quantum Random Number Generation in SAP UI5

Preface – This post is part of the UI5 Integration Programs series.

Introduction

A quantum random number is a number generated using a quantum-mechanical process, which is inherently unpredictable. In classical computing, random numbers are generated using algorithms that are deterministic, meaning they use a predetermined set of rules to produce the numbers. However, these deterministic algorithms can be prone to biases or patterns, which makes them not truly random.

In contrast, quantum random number generators (QRNGs) use the principles of quantum mechanics to produce truly random numbers. One such process is the measurement of a quantum system, such as a photon, that has properties that are inherently uncertain. The outcome of this measurement is truly random and can be used to generate a random number.

QRNGs are important for many applications in cryptography, simulations, and other fields that require high-quality random numbers. They are also used in quantum key distribution protocols, where two parties use a shared set of random numbers to generate a secret key for secure communication.

It’s worth noting that not all random number generators based on quantum mechanics are truly random. Some so-called “pseudo-random number generators” use a deterministic process but rely on the inherent randomness of the physical processes involved, such as the thermal noise in a resistor, to produce random numbers. While these generators are not truly random, they are still useful for many applications where high-quality randomness is not required.

What is Quantum Random Number Generation?

Quantum random number generation is the process of generating truly random numbers using quantum-mechanical processes. Unlike classical methods of generating random numbers that are based on algorithms and pseudorandom number generators, quantum random number generation produces numbers that are truly unpredictable and cannot be replicated.

The basic principle behind quantum random number generation is that quantum-mechanical phenomena, such as the polarization of photons or the decay of radioactive atoms, have inherent randomness that cannot be predicted. By measuring these phenomena, one can generate a sequence of numbers that are truly random.

There are several different methods for generating random numbers using quantum-mechanical processes, including:

  1. Photon-based quantum random number generators, which use the polarization of photons to generate random numbers.
  2. Vacuum fluctuation-based quantum random number generators, which use the random fluctuations in the vacuum of space to generate random numbers.
  3. Radioactive decay-based quantum random number generators, which use the unpredictable decay of radioactive atoms to generate random numbers.

These methods are based on different quantum-mechanical phenomena, but they all share the same basic principle of using the inherent randomness of quantum mechanics to generate truly random numbers.

Quantum random number generators have many important applications in cryptography, simulation, and other fields that require high-quality randomness. They are also a key component in quantum key distribution, where two parties use a shared set of random numbers to generate a secret key for secure communication.

Difference between Quantum Random Number Generation and Random Number Generation

The main difference between quantum random number generation and random number generation is in the source of the randomness. Random number generation refers to any method of generating numbers that appear random, regardless of the source of that randomness. In contrast, quantum random number generation specifically refers to the use of quantum-mechanical processes to generate truly random numbers.

Classical methods of random number generation, such as pseudorandom number generators (PRNGs), use algorithms to generate a sequence of numbers that appear random but are actually deterministic. PRNGs start with a seed value, and then use a mathematical formula to generate a sequence of numbers that, while not truly random, appear random and are suitable for many applications.

In contrast, quantum random number generation uses the inherent randomness of quantum-mechanical processes, such as the polarization of photons or the decay of radioactive atoms, to generate truly random numbers that cannot be predicted or replicated. Quantum random number generation provides a higher level of randomness than classical methods and is important for applications that require the highest level of security and unpredictability, such as in cryptography.

Another difference between the two methods is the speed at which they can generate random numbers. Quantum random number generation is typically slower than classical methods, due to the time it takes to measure the quantum-mechanical processes involved. This makes it less suitable for applications that require large amounts of random data to be generated quickly, such as in simulations or games. In contrast, classical random number generators can generate large amounts of random data quickly, making them better suited for such applications.

In summary, the main difference between quantum random number generation and classical random number generation is the source of the randomness. Quantum random number generation uses the inherent unpredictability of quantum-mechanical processes to generate truly random numbers, while classical methods use deterministic algorithms to generate numbers that appear random.

How can we Generate Quantum Random Numbers?

Quantum random numbers can be generated using various methods based on the inherent randomness of quantum-mechanical processes. Here are three common methods of generating quantum random numbers:

  1. Photon-Based Quantum Random Number Generation: In this method, random numbers are generated by measuring the polarization of photons. A polarizing beam splitter is used to split a single photon into two orthogonal polarizations. The measurement of one of the polarizations is used to generate a random number. Since the polarization of the photon is a quantum-mechanical process that is inherently random, the resulting numbers are also random.
  2. Vacuum Fluctuation-Based Quantum Random Number Generation: This method utilizes the random fluctuations in the vacuum of space to generate random numbers. The energy of these fluctuations is measured using a device called a quantum noise generator, and the resulting measurements are used to generate random numbers.
  3. Radioactive Decay-Based Quantum Random Number Generation: In this method, the unpredictable decay of radioactive isotopes is used to generate random numbers. A radioactive source is used to emit particles, and the time between emissions is used to generate random numbers. Since the decay of the radioactive isotopes is a quantum-mechanical process that is inherently random, the resulting numbers are also random.

It is important to note that generating high-quality random numbers requires careful design and implementation of the experimental setup. Any imperfections or biases in the measurement apparatus can potentially introduce biases into the generated numbers. Therefore, careful calibration and verification are necessary to ensure the randomness and quality of the generated numbers.

Quantum random number generators have important applications in cryptography, simulation, and other fields that require high-quality randomness. They are also a key component in quantum key distribution, where two parties use a shared set of random numbers to generate a secret key for secure communication.

What is Qrypt?

Qrypt is a company that provides a quantum-based security solution using quantum key distribution (QKD) to secure communications between two parties. The Qrypt system includes a QKD device, a trusted node, and secure communication channels. Here’s an overview of the Qrypt setup:

  1. QKD Device: The QKD device is a specialized hardware device that generates and distributes the quantum keys used for secure communication. The device generates the keys by measuring the polarization of individual photons or other quantum-mechanical properties. The keys are then transmitted to the trusted node over a quantum channel, which ensures the keys are transmitted securely and cannot be intercepted or measured without detection.
  2. Trusted Node: The trusted node receives the quantum keys from the QKD device and performs error correction and privacy amplification to ensure the keys are secure and error-free. The trusted node then sends the final keys to the communication endpoints over a classical channel, which can be any secure communication channel, such as an internet connection, optical fiber, or a satellite link. The trusted node is a critical component of the system, as it ensures the integrity and security of the generated keys.
  3. Secure Communication Channels: The final keys are used to secure the communication channels between the two parties. The keys are used to encrypt the data, ensuring that only the intended recipient can decrypt and read the message. The communication channels can be any secure communication channel, such as a virtual private network (VPN), encrypted email, or a secure messaging app.

The Qrypt system is designed to provide secure communication channels that cannot be intercepted or decrypted by any third party, even if they have the most advanced computing resources available. The system is based on the fundamental principles of quantum mechanics and provides a high level of security and privacy for sensitive communications.

Setup of Qrypt

To setup Qrypt, follow the given steps:

1. Visit https://portal.qrypt.com
Qrypt portal

2. Enter your details are create your account, you will land on your dashboard:
Qrypt Dashboard

3. Go to Token, and provide values as below to generate one for yourself:
Generate Entropy Token

4. Save the generated token somewhere locally, and it will be used in the integration later:
Save your token

5. You can check all your tokens as shown below:
Token Created

SAP UI5 Integration with Quantum Random Number Generator Qrypt

Before you start with the development in UI5, test the same in Postman with given data:
Type: Get
URL: https://api-eus.qrypt.com/api/v1/quantum-entropy?size=1
Authorization Type: Bearer Token
Token Value: <Your Generated token>
The postman output will look like this:

Postman Output

Now, implement the following:

View.xml

<mvc:View controllerName="Test.Test.controller.Main" xmlns:mvc="sap.ui.core.mvc" displayBlock="true" xmlns="sap.m" xmlns:core="sap.ui.core"
xmlns:html="http://www.w3.org/1999/xhtml">
<Shell id="shell">
<App id="app">
<pages>
<Page id="page" title="Quantum Random Number Generation in SAP UI5">
<content>
<VBox>
<Button text="Generate Qunatum Random Number" press="onPressGenerate"/>
<Title text="Response"/>
<TextArea id="idText" height="500px" width="100%"/>
</VBox>
</content>
</Page>
</pages>
</App>
</Shell>
</mvc:View>

Controller.js

sap.ui.define([
    "sap/ui/core/mvc/Controller",
    "sap/m/MessageBox",
    "sap/m/MessageToast"
], function (Controller, MessageBox, MessageToast) {
    "use strict";
    return Controller.extend("Test.Test.controller.Main", {
        onPressGenerate: function () {
            var that = this;
            // Specfify entropy token, requested size of entropy, and subdomain
            var accesstoken =
                'eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjM3Y2FiNjNkNzFiMzRmMWNhMDQ5N2VhMWViNjhiYjE3In0.eyJleHAiOjE2NzY4Mzg4MzcsIm5iZiI6MTY3Njc1MjQzNywiaXNzIjoiQVVUSCIsImlhdCI6MTY3Njc1MjQzNywiZ3JwcyI6WyJQVUIiXSwiYXVkIjpbIlJQUyJdLCJybHMiOlsiUk5EVVNSIl0sImNpZCI6Im9pd3MyV01xT0ZyQmNMX1VyNUl5XyIsImR2YyI6IjE0NTU1NzBhZjE3OTRmN2FhZDRkM2ZjYWI3MmE2ZmVhIiwianRpIjoiNGEyYTU4OTNlYmQxNGM3OWE1NjdmMmJjNTU1ODE4YmMiLCJ0eXAiOjN9.l1NajDLH-qLrQPa6_WrxuqCBwbjXPafamRXvJvbriZPe4KOb-tI3um8a7-Ce6xfSYVAbTb0aOgHGNst_qda3bg'
            var kibData = 1;
            var sub = 'api-weu'; //api-eus is for Eastern United States and api-weu is for Western Europe
            var settings = {
                "url": "https://cors-anywhere.herokuapp.com/https://api-eus.qrypt.com/api/v1/quantum-entropy?size=1",
                "method": "GET",
                "timeout": 0,
                "headers": {
                    "Authorization": "Bearer eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjM3Y2FiNjNkNzFiMzRmMWNhMDQ5N2VhMWViNjhiYjE3In0.eyJleHAiOjE2NzY4Mzg4MzcsIm5iZiI6MTY3Njc1MjQzNywiaXNzIjoiQVVUSCIsImlhdCI6MTY3Njc1MjQzNywiZ3JwcyI6WyJQVUIiXSwiYXVkIjpbIlJQUyJdLCJybHMiOlsiUk5EVVNSIl0sImNpZCI6Im9pd3MyV01xT0ZyQmNMX1VyNUl5XyIsImR2YyI6IjE0NTU1NzBhZjE3OTRmN2FhZDRkM2ZjYWI3MmE2ZmVhIiwianRpIjoiNGEyYTU4OTNlYmQxNGM3OWE1NjdmMmJjNTU1ODE4YmMiLCJ0eXAiOjN9.l1NajDLH-qLrQPa6_WrxuqCBwbjXPafamRXvJvbriZPe4KOb-tI3um8a7-Ce6xfSYVAbTb0aOgHGNst_qda3bg"
                },
            };
            $.ajax(settings).done(function (response) {
                console.log(response);
                that.byId("idText").setValue(response);
            });
        }
    });
});

Note: Since browser doesn’t allow CORS, hence we have added https://cors-anywhere.herokuapp.com/ before our URL, to fix this. This is a temporary fix and the right way is to use Destination in SAP BTP.

Output

Quantum Random Number Generation in SAP UI5

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Author