# A Quantum-Secure Cryptographic Algorithm Integrating Fractals and Prime Numbers
## 4 Overview of the Infrastructure  
The system for obtaining the cryptographic key is composed of four components:  
* A fractal numerical algorithm for generating the fractal sub-key, which randomly chooses one of the fractals listed above;
* The RSA algorithm for creating the numerical code and the private key, which serves in some of the processes in the F&NIF part, as we will see below;
* A multiscale algorithm for generating another number, which is then concatenated to the fractal number;
* The quantum F&NIF algorithm, which includes the mathematical operations on the matrices, transformation at a random time, and quantum security. A diagram of the quantum F&NIF algorithm is shown in Figure 8.  
F&NIF algorithm takes three numerical vectors as its input: the first one is generated by the fractal algorithm; the other is the module, that is, the product of two primes \(p\) and \(q\) generated by the multiscale algorithm; and the third one is the private RSA key generated through execution of the RSA algorithm. The size of the first two vectors is selected automatically according to the following relation:  
\[dimModule=\frac{dim}{2}\]  
\[dimFract=dim-dimModule\]  
with  
_dim_: The dimension of the new cryptographic key;  
_dimModule_: The dimension of the RSA module's sub-key;  
_dimFract_: The dimension of the fractal sub-key. The multiscale algorithm, as discussed above, consists of generating two prime numbers, the product of which is then concatenated to the fractal number to obtain one single number. So, the algorithm consists of a procedure that is repeated twice, once for each prime number. In the introduction, we explained that this procedure is based on the findings described in the previous section, and the primes generated belong to a particular set, which is determined by the multiscale level, the alpha number, and k. Below is an image of how a multiscale hierarchy is created using the rules in [3], and this was presented in the previous section (see Figure 9). At this point, we have all the necessary ingredients to implement the new quantum F&NIF algorithm:  
* The product of the primes;
* The RSA private key;
* The number generated from the fractals. Figure 8: Scheme of the novel algorithm quantum F&NIF. The first step is to concatenate the product of the primes and the fractal number. For simplicity, we call this new obtained number \"hybrid\". Now, we need to arrange the hybrid number into a squared matrix. The dimension of the matrix is determined by finding the next square number from the number of digits of the hybrid. So, if, for example, the hybrid has a dimension 14, the matrix has a dimension 16. Now, we need to add the remaining padding elements at the end of the matrix, and their values are selected in this way: We travel through the RSA private key, and the digits that we find, one at a time, represent the index of the element of the hybrid that we add. So, in a programmatic way, if the first digit of the RSA private key is 2, then, the element hybrid [2], so the second digit of the hybrid, is added in a padding position. This is conducted until the padding elements are exhausted. By considering \(a\in Z^{\text{m}}\) and \(b\in Z^{\text{n}}\) as the two vectors representing the multiscale sub-key and the fractal sub-key, and \(l\in Z\) as  
\[l=m+n\]  
the number of padding elements \(p\) in the matrix is calculated as  
\[p=dim-l\]  
where \(dim\) is the dimension of the matrix, obtained from the next square number mentioned above, and so two cases can be distinguished:  
\[\left\{ \begin{array}{ll}p=0&\text{no added padding}\\ p>0&\text{addition of $p$ numbers of padding}\end{array} \right.\]  
Consequently, the number of rows of the matrix is  
\[rows=\sqrt{dim}\]  
Then, we construct another matrix, a permutation matrix. A permutation matrix is a matrix that is obtained by swapping some rows or columns in the identity matrix. The matrix thus must be composed of all zeros and a one in every row in different positions. Figure 9: Multiscale hierarchy for generating primes.