Pseudo-random number generation method and device, computer equipment and storage medium

By using different mapping functions and processing logic in the pseudo-random number generation method to generate and scramble numerical matrices, the problem of uneven probability density distribution of pseudo-random number sequences is solved, the generation efficiency is improved and the randomness requirements are met.

CN118567606APending Publication Date: 2024-08-30INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410702778.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-31
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

In the existing pseudo-random number generation methods, the commonly used chaotic mapping causes the probability density distribution of the pseudo-random number sequence to be uneven and requires uniformity processing, resulting in low efficiency in generating pseudo-random numbers.

Method used

By setting the local mapping function in the mapping expression to a different function, the second numerical value and the third numerical value are generated, and the preset processing logic is used to shorten their length, and the position coordinates of the initial matrix are used as the scrambling operation to generate a numerical matrix to obtain Pseudo-random number sequence, the process is repeated until the target length is reached.

Benefits of technology

It improves the efficiency of pseudo-random number generation, meets the randomness requirements, takes up less computing resources, and solves the problem of low generation efficiency caused by uneven probability density distribution of pseudo-random number sequences.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118567606A
    Figure CN118567606A
Patent Text Reader

Abstract

The invention relates to the technical field of computers, and discloses a pseudo-random number generation method and device, computer equipment and a storage medium, the method comprises the following steps: setting a local mapping function of a mapping expression as a first mapping function, and performing mapping processing on a first numerical value to obtain a second numerical value; inputting the second numerical value into the mapping expression to obtain the second numerical value; setting the local mapping function as a second mapping function, and performing mapping processing on the second numerical value to obtain a third numerical value; obtaining a fourth value and a fifth value according to the second value and the third value; and taking the fifth numerical value as a position coordinate of a fourth numerical value, filling the fourth numerical value into the initial matrix to obtain a numerical value matrix, and obtaining a target pseudo-random number according to the numerical value matrix. The problem that the efficiency of generating the pseudo-random number is low due to the fact that the generated pseudo-random number sequence is not uniform in probability density distribution and needs to be homogenized is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a pseudo-random number generation method, device, computer equipment and storage medium. Background Art

[0002] Pseudo-random numbers are widely used in the computer field. For example, in order to ensure the reliability of data storage in a solid state disk (SSD), it is required to use pseudo-random numbers to randomize the data written to the SSD. Therefore, the randomness of the data after randomization depends on the randomness of the pseudo-random numbers generated by the pseudo-random number generator. Using pseudo-random numbers with better randomness can improve the storage reliability of data written to the SSD.

[0003] At present, the pseudo-random number algorithm selects a specific chaotic map as the local map, but the probability density of the commonly used chaotic map is often uneven, which leads to the uneven probability density distribution of the pseudo-random sequence finally iterated, and it needs to be homogenized. However, the homogenization process results in only one bit being output at a time, and the efficiency of generating pseudo-random numbers is low.

[0004] Therefore, the related art has the problem that the probability density distribution of the generated pseudo-random number sequence is uneven and needs to be uniformly processed, resulting in low efficiency in generating pseudo-random numbers. Summary of the invention

[0005] In view of this, the present invention provides a pseudo-random number generation method, apparatus, computer equipment and storage medium to solve the problem that the probability density distribution of the generated pseudo-random number sequence is uneven and needs to be uniformly processed, resulting in low efficiency in generating pseudo-random numbers.

[0006] In a first aspect, the present invention provides a pseudo-random number generation method, comprising:

[0007] The local mapping function in the mapping expression is set to the first mapping function, and the first preset number of first values ​​obtained are respectively mapped using the mapping expression to obtain the first preset number of second values, wherein the mapping expression is used to generate a pseudo-random number;

[0008] The local mapping function in the mapping expression is set to the second mapping function to obtain a modified mapping expression, and the modified mapping expression is used to perform mapping processing on the first preset number of second values ​​to obtain the first preset number of third values;

[0009] Processing the second value using a preset processing logic to obtain a first preset number of fourth values, and processing the third value using a preset processing logic to obtain a first preset number of fifth values, wherein the preset processing logic is used to shorten the lengths of the second value and the third value;

[0010] The fifth value is used as the position coordinate of the fourth value in the initial matrix, and the fourth value is filled into the initial matrix according to the position coordinate to obtain a numerical matrix, and a numerical sequence is obtained according to the numerical matrix.

[0011] The pseudo-random number generation method provided in this embodiment successively sets the local mapping function in the mapping expression to the first mapping function and the second mapping function, generates the second value and the third value through the mapping expression; obtains the fourth value and the fifth value with pseudo-randomness according to the second value and the third value, and the fifth value is used to perform a scrambling operation on the second value; uses the fifth value as the position coordinate of the fourth value, fills the fourth value into the initial matrix, completes the scrambling operation on the fourth value, obtains the numerical matrix, and obtains the numerical sequence through the numerical matrix. Repeat the above process until enough numerical sequences are obtained to obtain the target pseudo-random number. The above method has high scrambling efficiency, occupies less computing resources, and can generate the target pseudo-random number that meets the randomness requirements. It solves the problem that the probability density distribution of the generated pseudo-random number sequence is uneven, and it needs to be homogenized, resulting in low efficiency in generating pseudo-random numbers.

[0012] In some optional implementations, the local mapping function in the mapping expression is set to a first mapping function, and the mapping expression is used to map the first preset number of first values ​​obtained to obtain the first preset number of second values, including:

[0013] The local mapping function in the mapping expression is set to the first mapping function, and the mapping expression is used to respectively perform mapping processing on the first preset number of first values ​​obtained to obtain a first preset number of intermediate values;

[0014] Inputting the intermediate value into a mapping expression to obtain a first preset number of second values;

[0015] The target pseudo-random number is obtained according to the numerical matrix, including:

[0016] Obtain a numerical sequence based on a numerical matrix;

[0017] Compare the data length of the numerical sequence with the length of the target pseudo-random number;

[0018] When the data length is equal to the length of the target pseudo-random number, the numerical sequence is used as the target pseudo-random number;

[0019] When the data length is less than the length of the target pseudo-random number, the second numerical value is used as an intermediate numerical value, and subsequent steps are performed starting from inputting the intermediate numerical value into the mapping expression to obtain a first preset number of second numerical values, and the process stops until a second preset number of numerical sequences are obtained, and the second preset number of numerical sequences are concatenated to obtain the target pseudo-random number, wherein the second preset number is obtained by dividing the length of the target pseudo-random number by the data length of the numerical sequence.

[0020] In this embodiment, the data length of the numerical sequence is compared with the length of the target pseudo-random number, and the number of numerical sequences used to obtain the target pseudo-random number is determined according to the comparison result to ensure that the generated target pseudo-random number has a length that meets the requirements.

[0021] In some optional implementations, obtaining a numerical sequence according to a numerical matrix includes:

[0022] According to a preset size, the total number of rows and the total number of columns of the numerical matrix are adjusted to obtain an intermediate matrix, wherein the total number of rows is equal to the total number of columns;

[0023] The intermediate matrix is ​​mapped using the third mapping function to obtain a target matrix;

[0024] The third mapping function satisfies:

[0025] Where N represents the total number of rows or columns of the intermediate matrix, x n Indicates the row number of the intermediate matrix, x n+1 Indicates the row number of the target matrix, y n Indicates the column number of the intermediate matrix, y n+1 Indicates the column number of the target matrix, n is the sequence number, a and b are the parameters of the third mapping function, and mod represents the modulo operation;

[0026] Sum the values ​​contained in the target matrix into a sequence of values.

[0027] In this embodiment, in the process of obtaining a numerical sequence according to a numerical matrix, a third mapping function is introduced to scramble and map the numerical matrix again, which can further hide the coupling relationship between the numerical values ​​obtained in a single iteration, so that the pseudo-random number finally output meets the randomness requirements.

[0028] In some optional implementations, the local mapping function in the mapping expression is set to a first mapping function, and the mapping expression is used to map the first preset number of first values ​​obtained to obtain a first preset number of intermediate values, including:

[0029] Setting the local mapping function in the mapping expression to the first mapping function;

[0030] The mapping expression satisfies:

[0031] x t+1 i,j =((c)f(x t i,j )+(d)(f(x t i,(j+1)%e )+f(x t (i+1)%e,j ))+(j+i*e) / (w))mod1, where f() represents the local mapping function, x t i,j represents the value of the i-th row and j-th column in the matrix to be processed at time t, x t+1 i,j represents the value of the i-th row and j-th column in the processed matrix at time t+1, c, d, e, and w are parameters of the mapping expression, the matrix to be processed includes a first preset number of first values, and % and mod both represent a modulo operation;

[0032] The first mapping function satisfies:

[0033] x m+1 =gx m (1-x m ), where x m+1 Represents the value of the output of the first mapping function, x m represents the value input into the first mapping function, and g represents the parameter of the first mapping function;

[0034] Taking the first value as input data;

[0035] Input a first preset number of input data into the mapping expression respectively to obtain a first preset number of output data, use the output data as input data, and repeat this step until the number of repetitions reaches a third preset number, then end, and obtain a first preset number of intermediate values;

[0036] The second mapping function satisfies:

[0037] x q+1 =hsin(πx q ), where x q Represents the value of the input second mapping function, x q+1 represents the value output by the second mapping function, and h represents the parameter of the first mapping function.

[0038] In some optional implementations, using a preset processing logic to process the second value to obtain a first preset number of fourth values, and using a preset processing logic to process the third value to obtain a first preset number of fifth values, includes:

[0039] Performing base conversion on the second value and the third value respectively to obtain a converted second value and a converted third value;

[0040] According to a fourth preset number of preset data bits, obtaining a fourth preset number of first data to be processed from the converted second value, and obtaining a fourth preset number of second data to be processed from the converted third value;

[0041] Performing a bitwise XOR operation on data of a part of preset data bits in the first data to be processed and data of another part of preset data bits to obtain a first preset number of fourth values;

[0042] A bitwise XOR operation is performed on a portion of the preset data bits in the second data to be processed and another portion of the preset data bits to obtain a first preset number of fifth values.

[0043] In this embodiment, the second and third values ​​are processed using a preset processing logic to shorten the lengths of the second and third values, and the generated fourth and fifth values ​​still have pseudo-randomness, thereby facilitating the generation of target pseudo-random numbers.

[0044] In some optional implementations, the fifth value is used as the position coordinate of the fourth value in the initial matrix, and the fourth value is filled into the initial matrix according to the position coordinate to obtain a numerical matrix, including:

[0045] determining a first sequential number for the fourth value and a second sequential number for the fifth value;

[0046] Determine the first fourth value according to the first sequence number, and use the first fourth value as the value to be filled in;

[0047] The fifth value whose second sequence number is equal to the value to be filled in is used as the position coordinate;

[0048] Determine whether the data at the position coordinates in the initial matrix is ​​equal to the preset data. If so, fill the value to be filled in at the position coordinates in the initial matrix. If not, start searching from the position coordinates until the target position where the data of the initial matrix is ​​equal to the preset data is found, and fill the value to be filled in at the target position.

[0049] According to the first sequence number, determine the next fourth value of the value to be filled in, take the next fourth value as the value to be filled in, and start executing subsequent steps from the fifth value whose second sequence number is equal to the value to be filled in as the position coordinate, until multiple fourth values ​​are filled in the initial matrix, then end and obtain a numerical matrix.

[0050] In this embodiment, the fifth value is used as the position coordinate of the fourth value, the fourth value is filled into the initial matrix, and the fifth value is used to complete the scrambling operation on the fourth value, so as to disrupt the coupling between the values ​​and improve the randomness of the data.

[0051] In some optional implementations, before setting the local mapping function in the mapping expression to the first mapping function, the method further includes:

[0052] Generate an initial data matrix using an initial data generation function, wherein the initial data matrix includes a first preset number of first numerical values;

[0053] The initial data generating function satisfies:

[0054] cml_map[o][p]=(o*16+p256), wherein cml_map represents the initial data matrix, o represents the rows of the initial data matrix, and p represents the columns of the initial data matrix.

[0055] In some optional implementations, after obtaining the target pseudo-random number according to the numerical matrix, the method further includes:

[0056] Get the data to be processed;

[0057] Perform an XOR operation on the target pseudo-random number and the data to be processed to obtain the target data.

[0058] In this embodiment, the target pseudo-random number is used to perform random processing on the data to be processed to obtain the target data, thereby improving the storage reliability of the data.

[0059] In a second aspect, the present invention provides a pseudo-random number generating device, comprising:

[0060] A first mapping processing module, used to set the local mapping function in the mapping expression to a first mapping function, and use the mapping expression to respectively perform mapping processing on the first preset number of first values ​​obtained to obtain a first preset number of second values, wherein the mapping expression is used to generate a pseudo-random number;

[0061] An input module, used for inputting the second value into a mapping expression to obtain a first preset number of second values;

[0062] A second mapping processing module, used to set the local mapping function in the mapping expression to a second mapping function to obtain a modified mapping expression, and use the modified mapping expression to perform mapping processing on a first preset number of second values ​​respectively to obtain a first preset number of third values;

[0063] a processing module, configured to process the second value using a preset processing logic to obtain a first preset number of fourth values, and to process the third value using a preset processing logic to obtain a first preset number of fifth values, wherein the preset processing logic is configured to shorten the lengths of the second value and the third value;

[0064] A filling module, used for taking the fifth value as the position coordinate of the fourth value in the initial matrix, filling the fourth value into the initial matrix according to the position coordinate to obtain a numerical matrix, and obtaining a numerical sequence according to the numerical matrix;

[0065] A loop module is used to take the second numerical value as the second numerical value, start executing subsequent steps from inputting the second numerical value into a mapping expression to obtain a first preset number of second numerical values, and stop until a second preset number of numerical sequences are obtained, and splice the second preset number of numerical sequences to obtain a target pseudo-random number, wherein the second preset number is obtained by dividing the length of the target pseudo-random number by the data length of the numerical sequence.

[0066] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the pseudo-random number generation method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.

[0067] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the pseudo-random number generation method of the first aspect or any corresponding embodiment thereof.

[0068] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions, wherein the computer instructions are used to enable a computer to execute the pseudo-random number generation method of the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS

[0069] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0070] Figure 1 is a schematic diagram of data randomization processing according to an embodiment of the present invention;

[0071] Figure 2 is a schematic flow chart of a pseudo-random number generation method according to an embodiment of the present invention;

[0072] Figure 3 is a structural block diagram of a pseudo-random number generating device according to an embodiment of the present invention;

[0073] Figure 4 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0074] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0075] The process of randomizing data stored in a solid-state drive (SSD) is as follows: Figure 1 As shown, a 16-bit scrambler digital seed (16-bit Scrambler Seed) is used to generate a pseudo-random number, and the pseudo-random number is stored in a 32-bit linear feedback shift register (32-bit Linear Feedback Shift Register, 32-bit LFSR). The input data (InputData) is XORed with the pseudo-random number in the 32-bit LFSR to obtain the output data (Output Data), and the output data is written to the SSD to complete the randomization of the data. The randomness of the output data depends on the randomness of the pseudo-random number generated by the pseudo-random number generator. Using a pseudo-random number with better randomness can improve the data written to the NAND.

[0076] Since chaotic mapping has pseudo-randomness, ergodicity, initial value sensitivity and is a mapping between real numbers, it is similar to scrambling and diffusion, so it can be used to generate pseudo-random numbers. In the process of designing pseudo-random number algorithms, the two-dimensional (2D) coupled map lattice model (CML) generally needs to select a specific chaotic map as a local mapping. The overall probability density distribution of 2D CML is related to the local mapping, and the probability density of commonly used chaotic mappings is often uneven. Therefore, the probability density distribution of the pseudo-random number sequence finally iterated is also uneven. It is necessary to process the iterated sequence. For example, when the value range of the sequence is (0,1), it is necessary to determine whether the value of the sequence is greater than the midpoint (mid) of the probability density distribution. If it is greater than mid, 1 is output, otherwise 0 is output. However, this output method can only output one random bit per lattice iteration, resulting in a waste of efficiency. In addition, CML can be improved by adding an offset value to each two-dimensional coupled map lattice so that its probability density distribution is approximately uniform. The improved CML mapping form is x i,j =((1-ε)f(x i,j )+(ε / 2)(f(x i,(j+1)%Rmax )+f(x (i+1)%Lmax,j ))+(j+i*Rmax) / (Rmax*Lmax))mod1, where f(x i,j ) is the value of the i-th row and j-th column after local mapping, Rmax and Lmax are the number of rows and columns of CML, ε is the coupling strength, the value range of ε is (0, 1), and the optimal value of ε is 0.1.

[0077] Although the overall probability density distribution can be made approximately uniform by adding different offset values ​​to each grid, the probability density of the sequence output by each grid is still uneven, which leads to a certain regularity in the output sequence at each interval Rmax*Lmax. In the process of designing a pseudo-random number generator, it is necessary to perform scrambling operations on the sequence. For example, the S-box + PCA (partitioned cellular automaton) of AES (Advanced Encryption Standard) uses the nonlinear operation of the hash algorithm to perform scrambling operations on the initial chaotic sequence and further process the obtained pseudo-random generator. The S-box (Substitution-box) is a symmetric key algorithm. However, the algorithm of the S-box + PCA part of AES is too complicated, the scrambling efficiency is low, the calculation is cumbersome and occupies too many computing resources.

[0078] Based on the above content, an embodiment of the present invention provides a pseudo-random number generation method, which successively sets the local mapping function in the mapping expression to the first mapping function and the second mapping function, generates the second value and the third value through the mapping expression; obtains the fourth value and the fifth value with pseudo-randomness according to the second value and the third value, and the fifth value is used to perform a scrambling operation on the second value; takes the fifth value as the position coordinate of the fourth value, fills the fourth value into the initial matrix, completes the scrambling operation on the fourth value, obtains the numerical matrix, and obtains the numerical sequence through the numerical matrix. In addition, in the process of obtaining the numerical sequence, the cat mapping can also be introduced to perform the scrambling operation on the numerical matrix again, further hiding the coupling relationship between the numerical values. Repeat the above process until enough numerical sequences are obtained to obtain the target pseudo-random number. Moreover, the above method can generate a pseudo-random number of 2048 bits through one iteration. So as to achieve the effect of high process scrambling efficiency, less computing resources occupied, and being able to generate the target pseudo-random number that meets the randomness requirements.

[0079] According to an embodiment of the present invention, a pseudo-random number generation embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer device with data processing capabilities, such as a computer, a server, etc., and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0080] In this embodiment, a pseudo-random number generation method is provided, which can be used in the above-mentioned computer device. Figure 2 is a flow chart of a pseudo-random number generation method according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:

[0081] Step S201, setting the local mapping function in the mapping expression to the first mapping function, using the mapping expression to respectively map the acquired first preset number of first numerical values ​​to obtain a first preset number of second numerical values, wherein the mapping expression is used to generate a pseudo-random number.

[0082] Specifically, a pseudo-random number generator can be generated based on the pseudo-random number generation method of the present invention to generate a target pseudo-random number.

[0083] The mapping expression is, for example, the improved 2D coupled map lattice model (2D CML) mapping form mentioned above. As a common high-dimensional chaotic mapping, 2DCML can very conveniently construct a chaotic mapping of any dimension through a one-dimensional chaotic mapping. Through 2D CML, a high-dimensional mapping of Rmax*Lmax dimension can be very conveniently constructed from a one-dimensional mapping. And because 2D CML has chaotic phenomena in both time and space, it is often used to design pseudo-random number generators. The local mapping function in the mapping expression is set to the first mapping function. The first mapping function is, for example, logistic mapping, Sine mapping, etc. The pseudo-random number generator first obtains a first preset number of first values. The first preset number is the number of lattices in the CML model, for example, 256. The first value is, for example, a pseudo-random number generated by an encryption algorithm. The local mapping function in the mapping expression is set as the first mapping function, and the first preset number of first values ​​obtained are respectively input into the mapping expression of each grid, and the first value is mapped and iterated using the mapping expression, that is, the first value is substituted into the mapping expression for calculation to obtain the first preset number of second values, and the second value can be temporarily stored in the form of a matrix, for example: if the number of grids is 256, the size of the matrix can be 16×16. In addition, in order to separate adjacent values ​​of different grids as much as possible, the output of the mapping expression can be input into the mapping expression again for iteration, and the process is repeated multiple times, and the final output result is used as the first preset number of second values.

[0084] Step S202: Set the local mapping function in the mapping expression to the second mapping function to obtain a modified mapping expression, and use the modified mapping expression to map a first preset number of second values ​​to obtain a first preset number of third values.

[0085] Specifically, the second mapping function is, for example, logistic mapping, Sine mapping, etc. The first mapping function is different from the second mapping function. The local mapping function in the mapping expression is set to the second mapping function to obtain a modified mapping expression.

[0086] The second value is input into the modified mapping expression, and the first preset number of second values ​​are mapped using the modified mapping expression to calculate the first preset number of third values. The third value is used for subsequent scrambling operations. The third value can be temporarily stored in the form of a matrix, for example: the second value is temporarily stored in the matrix cml_map_scrambles, and the size of the matrix cml_map_scrambles can be 16×16.

[0087] Step S203, using a preset processing logic to process the second value to obtain a first preset number of fourth values, and using a preset processing logic to process the third value to obtain a first preset number of fifth values, wherein the preset processing logic is used to shorten the length of the second value and the third value.

[0088] Specifically, the preset processing logic is used to shorten the length of the second value and the third value, for example: select 2 digits from the second value as the fourth value, and the process of obtaining the fifth value is similar; select two 2-digit numbers from the second value, perform an XOR operation on the two numbers to obtain the fourth value, and the process of obtaining the fifth value is similar.

[0089] The second value is processed by the preset processing logic to obtain a first preset number of fourth values, and the third value is processed by the preset processing logic to obtain a first preset number of fifth values.

[0090] Step S204, taking the fifth value as the position coordinate of the fourth value in the initial matrix, filling the fourth value into the initial matrix according to the position coordinate to obtain a numerical matrix, and obtaining a numerical sequence according to the numerical matrix.

[0091] Specifically, according to the specific value of the fourth value, a fifth value corresponding to each fourth value is determined in a first preset number of fifth values ​​as its position coordinate.

[0092] Before filling the fourth value into the initial matrix, the pseudo-random number generator initializes the initial matrix so that the element values ​​in the initial matrix are numbers that cannot be included in the fourth value and the fifth value, for example, -1. In addition, the number of elements in the initial matrix is ​​the first preset number, for example, if the first preset number is equal to 256, the size of the initial matrix can be 16×16.

[0093] According to the position coordinates, the fourth value is filled into the initial matrix to obtain a numerical matrix, and the size of the numerical matrix can be 16 × 16. The elements in the numerical matrix are aggregated to obtain a target pseudo-random number, for example: the elements of the first row of the numerical matrix are used as the starting position of the target pseudo-random number, and the elements of the second row are placed in the subsequent position, and so on, to obtain the target pseudo-random number.

[0094] The pseudo-random number generation method provided in this embodiment successively sets the local mapping function in the mapping expression to the first mapping function and the second mapping function, generates the second value and the third value through the mapping expression; obtains the fourth value and the fifth value with pseudo-randomness according to the second value and the third value, and the fifth value is used to perform a scrambling operation on the second value; uses the fifth value as the position coordinate of the fourth value, fills the fourth value into the initial matrix, completes the scrambling operation on the fourth value, obtains the numerical matrix, and obtains the target pseudo-random number through the numerical matrix. The above method has high scrambling efficiency, occupies less computing resources, and can generate target pseudo-random numbers that meet the randomness requirements. It solves the problem that the probability density distribution of the generated pseudo-random number sequence is uneven, and it needs to be homogenized, resulting in low efficiency in generating pseudo-random numbers.

[0095] In some optional implementations, step S201 "setting the local mapping function in the mapping expression to the first mapping function, and using the mapping expression to respectively map the acquired first preset number of first values ​​to obtain a first preset number of second values" includes steps A1 to A2:

[0096] Step A1, setting the local mapping function in the mapping expression as the first mapping function, and using the mapping expression to respectively perform mapping processing on the first preset number of first values ​​obtained to obtain a first preset number of intermediate values;

[0097] Step A2, inputting the intermediate value into a mapping expression to obtain a first preset number of second values;

[0098] The step of “obtaining a target pseudo-random number according to a numerical matrix” in step S204 includes steps B1 to B4:

[0099] Step B1, obtaining a numerical sequence according to a numerical matrix;

[0100] Step B2, comparing the data length of the numerical sequence with the length of the target pseudo-random number;

[0101] Step B3, when the data length is equal to the length of the target pseudo-random number, using the numerical sequence as the target pseudo-random number;

[0102] Step B4, when the data length is less than the length of the target pseudo-random number, use the second numerical value as an intermediate numerical value, and start executing subsequent steps from inputting the intermediate numerical value into the mapping expression to obtain a first preset number of second numerical values, until a second preset number of numerical sequences are obtained, then stop, and concatenate the second preset number of numerical sequences to obtain the target pseudo-random number, wherein the second preset number is obtained by dividing the length of the target pseudo-random number by the data length of the numerical sequence.

[0103] Specifically, the first mapping function is, for example, logistic mapping, Sine mapping, etc.

[0104] The local mapping function in the mapping expression is set as the first mapping function, and the first preset number of first values ​​obtained are respectively input into the mapping expression of each grid, and the first value is mapped and iterated using the mapping expression, that is, the first value is substituted into the mapping expression for calculation to obtain the first preset number of intermediate values, which can be temporarily stored in the form of a matrix, for example: if the number of grids is 256, the size of the matrix can be 16×16. In addition, in order to separate adjacent values ​​of different grids as much as possible, the output of the mapping expression can be input into the mapping expression again for iteration, and the process is repeated multiple times, and the final output result is used as the first preset number of intermediate values.

[0105] The intermediate value is input into the mapping expression, and the mapping expression is used to iterate the mapping of the intermediate value to calculate a first preset number of second values, where the second value is a pseudo-random number to be output. The second value can be temporarily stored in the form of a matrix, for example: the second value is temporarily stored in the matrix cml_map_origins, and the size of the matrix cml_map_origins can be 16×16.

[0106] Sum up the elements in the numerical matrix to get a numerical sequence. The purpose of the target pseudo-random number is different, and the required length of the pseudo-random number is different. Compare the data length of the numerical sequence with the length of the target pseudo-random number. If the data length is equal to the length of the target pseudo-random number, only one numerical sequence is needed to get the target pseudo-random number with the required length, and the numerical sequence is directly used as the target pseudo-random number.

[0107] If the data length is less than the length of the target pseudo-random number, then only one numerical sequence cannot obtain a target pseudo-random number of length that meets the requirements. The pseudo-random number generator first divides the required length of the target pseudo-random number by the data length of a single numerical sequence to obtain a second preset number, i.e., the number of numerical sequences required. For example, if the data length of the numerical sequence is 256*8 bits (bit), i.e., 2048 bits, and if the required length of the target pseudo-random number is 4096Kb, then 2000 numerical sequences are required.

[0108] The second value is used as the intermediate value, and the above steps A2 to B4 are repeatedly performed until a second preset number of value sequences are obtained, and then the process stops. The first obtained value sequence is used as the starting point, and the subsequent obtained value sequences are sequentially spliced ​​backward to obtain a target pseudo-random number with a length that meets the requirements.

[0109] In this embodiment, the data length of the numerical sequence is compared with the length of the target pseudo-random number, and the number of numerical sequences used to obtain the target pseudo-random number is determined according to the comparison result to ensure that the generated target pseudo-random number has a length that meets the requirements.

[0110] In some optional implementations, obtaining a numerical sequence according to a numerical matrix includes:

[0111] According to a preset size, the total number of rows and the total number of columns of the numerical matrix are adjusted to obtain an intermediate matrix, wherein the total number of rows is equal to the total number of columns;

[0112] The intermediate matrix is ​​mapped using the third mapping function to obtain a target matrix;

[0113] The third mapping function satisfies:

[0114] Where N represents the total number of rows or columns of the intermediate matrix, x n Indicates the row number of the intermediate matrix, x n+1 Indicates the row number of the target matrix, y n Indicates the column number of the intermediate matrix, y n+1 Indicates the column number of the target matrix, n is the sequence number, a and b are the parameters of the third mapping function, and mod represents the modulo operation;

[0115] Sum the values ​​contained in the target matrix into a sequence of values.

[0116] Specifically, the number of rows and columns of the matrix in the preset size is equal, and the preset size is determined based on the first preset number. For example, if the first preset number is 256, indicating that there are 256 grids, the preset size is 16×16. If the first preset number is 64, indicating that there are 64 grids, the preset size is 8×8, etc.

[0117] According to the preset size, the total number of rows and the total number of columns of the numerical matrix are adjusted to obtain an intermediate matrix. For example, the original size of the numerical matrix is ​​1×256. According to the preset size, the total number of rows and the total number of columns are adjusted to 16 to obtain an intermediate matrix. The size of the intermediate matrix is ​​16×16.

[0118] The third mapping function is cat mapping, parameter a can be -2, parameter b can be -3, and a and b can be set to other values ​​according to requirements. The third mapping function is used to map the intermediate matrix, for example: Indicates the xth n Row y n The elements of the column are mapped using cat mapping to obtain Indicates the xth n+1 Row y n+1After mapping all elements in the intermediate matrix, the target matrix out_puts_final is obtained, and the size of out_puts_final can be 16×16.

[0119] Sum the values ​​contained in the target matrix out_puts_final to obtain a sequence of values.

[0120] In this embodiment, in the process of obtaining a numerical sequence according to a numerical matrix, a third mapping function is introduced to scramble and map the numerical matrix again, which can further hide the coupling relationship between the numerical values ​​obtained in a single iteration, so that the pseudo-random number finally output meets the randomness requirements.

[0121] In some optional implementations, the local mapping function in the mapping expression is set to a first mapping function, and the mapping expression is used to map the first preset number of first values ​​obtained to obtain a first preset number of intermediate values, including:

[0122] Setting the local mapping function in the mapping expression to the first mapping function;

[0123] The mapping expression satisfies:

[0124] x t+1 i,j =((c)f(x t i,j )+(d)(f(x t i,(j+1)%e )+f(x t (i+1)%e,j ))+(j+i*e) / (w))mod1, where f() represents the local mapping function, x t i,j represents the value of the i-th row and j-th column in the matrix to be processed at time t, x t+1 i,j represents the value of the i-th row and j-th column in the processed matrix at time t+1, c, d, e, and w are parameters of the mapping expression, the matrix to be processed includes a first preset number of first values, and % and mod both represent a modulo operation;

[0125] The first mapping function satisfies:

[0126] x m+1 =gx m (1-x m ), where x m+1 Represents the value of the output of the first mapping function, x m represents the value input into the first mapping function, and g represents the parameter of the first mapping function;

[0127] Taking the first value as input data;

[0128] Input a first preset number of input data into the mapping expression respectively to obtain a first preset number of output data, use the output data as input data, and repeat this step until the number of repetitions reaches a third preset number, then end, and obtain a first preset number of intermediate values;

[0129] The second mapping function satisfies:

[0130] x q+1 =hsin(πx q ), where x q Represents the value of the input second mapping function, x q+1 represents the value output by the second mapping function, and h represents the parameter of the first mapping function.

[0131] Specifically, the first mapping function is logistic mapping as an example for explanation, and g in logistic mapping can be 4 or other values. The matrix is ​​used to temporarily store a first preset number of first values ​​to obtain a matrix to be processed. If the first preset number is 256, the size of the matrix to be processed can be 16×16.

[0132] The local mapping function f() in the mapping expression is set to the first mapping function. The c in the mapping expression can be 0.9 or other values, d can be 0.05 or other values, e can be 16 or other values, and w can be 256 or other values. Take the first preset number of 256 as an example. There are 16×16=256 grids. The first value in the matrix to be processed is used as input data and input into the mapping expression in the grid at the corresponding position to calculate the first preset number of output data. For example: at time t, the first value x in the i-th row and j-th column of the matrix to be processed is t i,j Enter the mapping expression of the grid in row i and column j to calculate the output data x t+1 i,j , the output data can be temporarily stored in the processed matrix. The output data is used as the input data, and this step is repeated until the number of repetitions reaches the third preset number, then the step ends, and the first preset number of intermediate values ​​is obtained. The third preset number is, for example, 2000. By repeated iterations, adjacent values ​​of different grids are separated as much as possible, and the initial value sensitivity of the pseudo-random number generator is realized.

[0133] The second mapping function needs to be different from the first mapping function. The second mapping function may adopt sine mapping, and h in the sine mapping may be 0.99 or other values.

[0134] It should be noted that

[0135] The mapping expression used in this embodiment is:

[0136] x t+1 i,j =((c)f(x t i,j )+(d)(f(x t i,(j+1)%e )+f(x t (i+1)%e,j ))+(j+i*e) / (w))mod1

[0137] The first mapping function is:

[0138] x m+1 =gx m (1-x m ),

[0139] The second mapping function is:

[0140] x q+1 =hsin(πx q )

[0141] Both functions can ensure that the maximum Lyapunov exponent of the improved model is positive. The Lyapunov exponent measures the average separation speed of two similar points after iteration. The Lyapunov exponent can be used as a sign of chaotic properties in engineering.

[0142] Since the offset added to each grid of the improved CML model after adding the offset is constant, the improved model first obtains the tangent vector δz=[δx(1),δx(2),…,δx(256)] of the two-dimensional model vector z=[x(1),x(2),…,x(256)] in rows and then in columns. n The value of (i) is consistent with that of the CML model before improvement, which is δx n+1 (i) = (1-ε)f′(x n (i))δx n (i)+ε / 2(f′(x n (k))δx n (k)+f′(x n (m))δx n (m)) Therefore, the Jacobian matrix J n =f′(x n )g, where A3=A4=...=A R =0, also consistent.

[0143] It can be obtained that the Lyapunov exponent spectrum of the improved 16*16 model is consistent with that before the improvement. It should be noted that LE (Lyapunov index) is a measure of the average separation speed of two similar points after iteration. The LE expression of one-dimensional mapping is where f′(x i ) is the value of the derivative of the one-dimensional mapping at the iteration number i. LE is positive. No matter how close the two points are, they will eventually separate after multiple iterations. This mapping is considered a chaotic mapping. The maximum value of is 0, so it is necessary to select a mapping with a positive Lyapunov exponent as the local mapping to ensure that the maximum Lyapunov exponent of the improved model is positive. Since the logistic mapping and the sine mapping are often used as common one-dimensional chaotic mappings due to their simple calculations, the Lyapunov exponents of Equations 2 and 3 are both around 0.5 through the wolf method approximation. Since the selected ε value is 0.1, the Lyapunov exponent map of the improved CML model using the logistic mapping and the sine mapping is approximately The maximum Lyapunov exponent of the model is about 0.5, and the minimum Lyapunov exponent is about 0.27. The Lyapunov exponent can be used as a sign of chaotic properties in engineering. Therefore, the model used by the pseudo-random generator has pseudo-randomness, ergodicity, and initial value sensitivity in 256 directions.

[0144] In some optional implementations, using a preset processing logic to process the second value to obtain a first preset number of fourth values, and using a preset processing logic to process the third value to obtain a first preset number of fifth values, includes:

[0145] Performing base conversion on the second value and the third value respectively to obtain a converted second value and a converted third value;

[0146] According to a fourth preset number of preset data bits, obtaining a fourth preset number of first data to be processed from the converted second value, and obtaining a fourth preset number of second data to be processed from the converted third value;

[0147] Performing a bitwise XOR operation on data of a part of preset data bits in the first data to be processed and data of another part of preset data bits to obtain a first preset number of fourth values;

[0148] A bitwise XOR operation is performed on a portion of the preset data bits in the second data to be processed and another portion of the preset data bits to obtain a first preset number of fifth values.

[0149] Specifically, this embodiment temporarily stores a first preset number of second values ​​in the matrix cml_map_origins, and temporarily stores a first preset number of third values ​​in the matrix cml_map_scrambles.

[0150] The second value in cml_map_origins and the third value in cml_map_scrambles are respectively converted into bases, for example, from binary to hexadecimal, to obtain the converted second value and the converted third value.

[0151] The fourth preset number represents a plurality of, for example, 4, and the specific value is set according to actual needs, and the preset data bits are, for example, the 15th, 16th, 23rd, and 24th decimal places. According to the fourth preset number of preset data bits, a fourth preset number of first data to be processed is obtained from the converted second value, and a fourth preset number of second data to be processed is obtained from the converted third value. If the preset data bit in the second value or the third value is empty, 0 can be added.

[0152] A bitwise XOR operation is performed on the data of a part of the preset data bits in the first data to be processed and the data of another part of the preset data bits to obtain a first preset number of fourth values, for example: the 15th bit is 5, the 16th bit is B, the 23rd bit is 8, and the 24th bit is A, then the first data to be processed includes 5, B, 8, A, the data of a part of the preset data bits is 5B, and the data of another part of the preset data bits is 8A, then the data of a part of the preset data bits and the data of another part of the preset data bits are bitwise XORed to 5B^8A=24, ^ represents a bitwise XOR operation, then the fourth value corresponding to the current first data to be processed is 24. In addition, the fourth value can be saved in a matrix form, for example: matrix out_put_origins.

[0153] A bitwise XOR operation is performed on a part of the preset data bits in the second data to be processed and another part of the preset data bits to obtain a first preset number of fifth values. The calculation process of this step is similar to the previous step and will not be repeated. In addition, the fifth value can be saved in a matrix form, for example: matrix out_put_scrambles.

[0154] In this embodiment, the second and third values ​​are processed using a preset processing logic to shorten the lengths of the second and third values, and the generated fourth and fifth values ​​still have pseudo-randomness, thereby facilitating the generation of target pseudo-random numbers.

[0155] In some optional implementations, the fifth value is used as the position coordinate of the fourth value in the initial matrix, and the fourth value is filled into the initial matrix according to the position coordinate to obtain a numerical matrix, including:

[0156] determining a first sequential number for the fourth value and a second sequential number for the fifth value;

[0157] Determine the first fourth value according to the first sequence number, and use the first fourth value as the value to be filled in;

[0158] The fifth value whose second sequence number is equal to the value to be filled in is used as the position coordinate;

[0159] Determine whether the data at the position coordinates in the initial matrix is ​​equal to the preset data. If so, fill the value to be filled in at the position coordinates in the initial matrix. If not, start searching from the position coordinates until the target position where the data of the initial matrix is ​​equal to the preset data is found, and fill the value to be filled in at the target position.

[0160] According to the first sequence number, determine the next fourth value of the value to be filled in, take the next fourth value as the value to be filled in, and start executing subsequent steps from the fifth value whose second sequence number is equal to the value to be filled in as the position coordinate, until multiple fourth values ​​are filled in the initial matrix, then end and obtain a numerical matrix.

[0161] Specifically, this embodiment is described by taking the first preset number as 256 as an example. The fourth value is temporarily stored in the matrix out_put_origins, and the fifth value is temporarily stored in the matrix out_put_scrambles.

[0162] Determine the first sequence number of the fourth value and the second sequence number of the fifth value, for example: the first sequence number of the fourth value is determined according to the coordinate of the fourth value in out_put_origins, the first sequence number of the fourth value in the first row and first column is 1, the first sequence number of the fourth value in the first row and second column is 2, and so on. The second sequence number of the fifth value is determined according to the coordinate of the fifth value in out_put_scrambles, the second sequence number of the fifth value in the first row and first column is 1, the second sequence number of the fifth value in the first row and second column is 2, and so on.

[0163] Determine the first fourth value according to the first sequence number, and use the first fourth value as the value to be filled in, and use the fifth value whose second sequence number is equal to the value to be filled in as the position coordinate. For example: the first fourth value is out_put_origins[1]=25, which represents the first fourth value in the matrix out_put_origins, the second sequence number of the fifth value corresponding to out_put_origins[1] is 25, and the fifth value is out_put_scrambles

[25] =64, then the position coordinate of the fourth value is 64.

[0164] Before filling the fourth value into the initial matrix, the pseudo-random number generator will initialize the initial matrix so that the element values ​​in the initial matrix are numbers that cannot be included in the fourth value and the fifth value, that is, preset data, such as: -1. Determine whether the data at the position coordinates in the initial matrix is ​​equal to the preset data. If it is equal, fill the value to be filled in at the position coordinates in the initial matrix. If it is not equal, start searching from the position coordinates until the target position where the data of the initial matrix is ​​equal to the preset data is found, and fill the value to be filled in the target position. According to the first sequence number, determine the next fourth value of the value to be filled in, use the next fourth value as the value to be filled in, and start executing subsequent steps from the fifth value whose second sequence number is equal to the value to be filled in as the position coordinate until all fourth values ​​are filled in the initial matrix, then end and obtain a numerical matrix.

[0165] In this embodiment, the fifth value is used as the position coordinate of the fourth value, the fourth value is filled into the initial matrix, and the fifth value is used to complete the scrambling operation on the fourth value, so as to disrupt the coupling between the values ​​and improve the randomness of the data.

[0166] In some optional implementations, before setting the local mapping function in the mapping expression to the first mapping function, the method further includes:

[0167] Generate an initial data matrix using an initial data generation function, wherein the initial data matrix includes a first preset number of first numerical values;

[0168] The initial data generating function satisfies:

[0169] cml_map[o][p]=(o*16+p256), wherein cml_map represents the initial data matrix, o represents the rows of the initial data matrix, and p represents the columns of the initial data matrix.

[0170] Specifically, the size of the initial data matrix is ​​determined according to the first preset number and the distribution of the grids. For example, if the first preset number is 256 and the distribution of the grids is 16×16, then the size of the initial data matrix is ​​16×16.

[0171] The initial data generation function is the key IV (initialization vector) algorithm, which uses the encryption algorithm to generate pseudo-random numbers, following the encryption algorithm.

[0172] An initial data matrix is ​​generated using an initial data generation function. For example, the first value of the first row and first column in the initial data matrix is ​​(16+1 / 256), and the first value of the fifth row and thirteenth column is (5*16+13 / 256). The initial data matrix includes a first preset number of first values, wherein the first values ​​are real numbers between (0, 1).

[0173] It should be noted that since the selected key IV algorithm can generate 256 real numbers between (0, 1), the 64-bit decimal precision defined in the IEEE (Institute of Electrical Engineers) 754 standard is 10^-15, so the key space is 10^(15*256)=10^3084 combinations. The usual key space size and brute force attack capability are shown in the table below.

[0174]

[0175] Therefore, when the key space is 10^3084, a brute force attack requires approximately 10^3084 / 2^168*(5.9*10^30)year, which is approximately 1.57*10^3064year. Therefore, it can meet the requirements of resisting brute force attacks.

[0176] Add perturbations to the initial condition cml_map in the key IV algorithm, generate 256 random numbers after the first iteration, and calculate the correlation coefficients under different perturbations. The added perturbations are as follows:

[0177] Case 1: cml_map[0][0] increases 2^-44 and then modulo 1; Case 2: cml_map[0]

[15] increases 2^-44 and then modulo 1; Case 3: cml_map

[15] [0] increases 2^-44 and then modulo 1; Case 4: cml_map

[15]

[15] increases 2^-44 and then modulo 1; Case 5: cml_map[7][7] increases 2^-44 and then modulo 1.

[0178] The correlation coefficients under different cases are as follows:

[0179]

[0180]

[0181] A correlation coefficient less than 0.1 indicates that the algorithm has a high pseudo-randomness. From the above table, we can see that no matter what the case, the correlation coefficient of the two sequences is less than 0.1, which proves that the pseudo-random number generator has good key sensitivity.

[0182] In some optional implementations, after obtaining the target pseudo-random number according to the numerical matrix, the method further includes:

[0183] Get the data to be processed;

[0184] Perform an XOR operation on the target pseudo-random number and the data to be processed to obtain the target data.

[0185] Specifically, the data to be processed is obtained, where the data to be processed is data that needs to be written into the SSD.

[0186] The target pseudo-random number is used to perform random processing on the data to be processed, including: performing an XOR operation on the target pseudo-random number and the data to be processed to obtain target data, and writing the target data into the SSD to improve the storage reliability of the data.

[0187] In this embodiment, the target pseudo-random number is used to perform random processing on the data to be processed to obtain the target data, thereby improving the storage reliability of the data.

[0188] In some optional implementations, the target pseudo-random number may also be used for information encryption, and the specific encryption process includes steps C1 to C2:

[0189] Step C1, after generating the target pseudo-random number, obtaining the information to be encrypted and the encryption base.

[0190] Specifically, the information to be encrypted may be character information, or may be a file such as a picture or a document. The corresponding character information may be obtained by parsing the file such as the picture or the document. The encryption base may be 1 bit, 2 bits, 4 bits, 8 bits, etc., 1 bit is one character bit, and the encryption base of 4 bits corresponds to four character bits. The number of numerical bits contained in the target pseudo-random number is equal to the number of bits of the encryption base. Specifically, in the process of generating an encryption seed, one may randomly select one from a plurality of numbers as the corresponding encryption base, and generate a target pseudo-random number of corresponding numerical bits according to the randomly selected encryption base. Each numerical value in the target pseudo-random number is randomly generated, and the numerical value of the target pseudo-random number may be an integer within [0,9] (an integer corresponding to a decimal number); or, may be an integer within [0,F] (an integer corresponding to a hexadecimal number). For example, if the randomly selected encryption base is 4 bits, a target pseudo-random number containing 4 values ​​is generated, and the 4 values ​​in the target pseudo-random number are all randomly generated; if the randomly selected encryption base is 8 bits, a target pseudo-random number containing 8 values ​​is generated, and the 8 values ​​in the target pseudo-random number are all randomly generated.

[0191] Step C2, reading the basic data corresponding to the encryption base from the information to be encrypted in turn, and performing transposition encryption on the basic data according to the target pseudo-random number to obtain the corresponding ciphertext data.

[0192] The basic data corresponding to the encryption base is read from the information to be encrypted in sequence, and the basic data is transposed and encrypted according to the target pseudo-random number to obtain the corresponding ciphertext data. The basic data corresponding to the encryption base is read from the information to be encrypted in sequence, and each basic data is equal to the number of bits of the encryption base. The basic data is transposed and encrypted by the target pseudo-random number to obtain the ciphertext data corresponding to each basic data. Compared with the traditional encryption method, the transposition encryption of the basic data by the target pseudo-random number can greatly reduce the complexity of the encryption operation and shorten the time of the encryption process.

[0193] Optionally, step C2 includes steps C21 to C24.

[0194] Step C21, determining whether the information to be encrypted contains unencrypted data.

[0195] Step C22: If the information to be encrypted contains unencrypted data, basic data corresponding to the encryption base is sequentially read from the information to be encrypted.

[0196] Specifically, it can be determined whether the information to be encrypted contains unencrypted data. If the information to be encrypted contains unencrypted data, the basic data corresponding to the encryption base is sequentially read from the information to be encrypted, and the number of bits of the basic data read each time is equal to the number of bits of the encryption base.

[0197] Step C23, generating a corresponding transposition bit number according to the target pseudo-random number.

[0198] Generate the corresponding transposition number according to the target pseudo-random number. In the specific application process, the target pseudo-random number can be directly used as the transposition number; or the corresponding transposition number can be generated according to the target pseudo-random number and the number of encryption bases obtained, such as multiplying the number of encryption bases obtained by each value in the target pseudo-random number, and the last value of each product is used as the transposition number. For example, the encryption base is obtained from the information to be encrypted for the third time, the number of encryption bases obtained is 3, the target pseudo-random number is 4768, the first value "4" of the target pseudo-random number is multiplied by "3", and the product is 12, then the last value "2" of 12 is used as the first value in the transposition number.

[0199] Step C24, encrypt the basic data and the transposition bit to obtain the corresponding ciphertext data.

[0200] The basic data and the transposition digit can be encrypted to obtain the corresponding ciphertext data. Each value in the transposition digit is also the carry digit of the value in the basic data. The encryption operation is performed on each value in the basic data by the transposition digit, so as to obtain the ciphertext data corresponding to the basic data. The number of digits of the values ​​in the basic data and the ciphertext data is equal. In the process of encrypting each value in the basic data, the corresponding value can be carried according to the encoding rule of the basic data. For example, if the first value in the basic data is "g" and the first value in the transposition digit is "2", then "g" is carried by 2 digits to obtain "i", and the ciphertext value corresponding to the first value in the basic data is "i"; by obtaining the ciphertext values ​​corresponding to each value in the basic data by the above method, the ciphertext data corresponding to the basic data can be obtained.

[0201] It should be noted that the present invention tests the randomness of the pseudo-random number generator, and the test process and results are as follows:

[0202] Using the above pseudo-random number generator, a pseudo-random bit with a length of more than 1,000,000,000 bits can pass 15 random tests. Since there are too many NonOverlappingTemplates, the average value is taken here. The test results are as follows, and the * indicates the case of taking the average value:

[0203]

[0204]

[0205]

[0206] In this NIST test, the minimum number of passed items with a sample size of 1000 is 980 / 1000, and the minimum number of passed items with a sample size of 610 is 590 / 610. The P_VAL in the test result is calculated based on the p_val of each subsequence. If the sequence to be tested is random, then the p_val of the subsequence test should also be evenly distributed in (0,1). The calculation of P_VAL is obtained through the chi-square test, as follows: where F i is the number of p_val in subinterval i, s is the size of the sequence, P_VAL = igamc (9 / 2, x 2 / 2), P_VAL is greater than or equal to 0.0001, which means that the p_val of this test is approximately uniformly distributed in (0,1). From the above table, we can see that the pseudo-random generator mentioned in this article can meet the 15 random checks of NIST and has good randomness.

[0207] In summary, by introducing cat mapping and Sine-based 2D CML model, the sequence output by the improved 2DCML model no longer needs to go through the AES Sbox, but directly scrambles the output sequence through two scrambling mapping operations. The pseudo-random sequence obtained by the test meets the 15 random tests of NIST, and because the key is 256 real numbers between (0,1), there are 10^3084 combinations under the double precision defined by IEEE754. It can meet the requirements of anti-brute force attacks.

[0208] In the present embodiment, a pseudo-random number generating device is also provided, and the device is used to implement the above-mentioned embodiment and preferred implementation mode, and the description has been made no further. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware is also possible and conceived.

[0209] This embodiment provides a pseudo-random number generating device, such as Figure 3 As shown, including:

[0210] A first mapping processing module 301 is used to set the local mapping function in the mapping expression to a first mapping function, and use the mapping expression to respectively perform mapping processing on the first preset number of first values ​​obtained to obtain a first preset number of second values, wherein the mapping expression is used to generate a pseudo-random number;

[0211] A second mapping processing module 302 is used to set the local mapping function in the mapping expression to a second mapping function to obtain a modified mapping expression, and use the modified mapping expression to perform mapping processing on a first preset number of second values ​​to obtain a first preset number of third values;

[0212] The processing module 303 is used to process the second value by using a preset processing logic to obtain a first preset number of fourth values, and to process the third value by using a preset processing logic to obtain a first preset number of fifth values, wherein the preset processing logic is used to shorten the lengths of the second value and the third value;

[0213] The filling module 304 is used to use the fifth value as the position coordinate of the fourth value in the initial matrix, fill the fourth value into the initial matrix according to the position coordinate to obtain a value matrix, and obtain a value sequence according to the value matrix.

[0214] In some optional implementations, the first mapping processing module 301 sets the local mapping function in the mapping expression as the first mapping function, and uses the mapping expression to respectively perform mapping processing on the first preset number of first values ​​obtained to obtain the first preset number of second values, including:

[0215] The local mapping function in the mapping expression is set to the first mapping function, and the mapping expression is used to respectively perform mapping processing on the first preset number of first values ​​obtained to obtain a first preset number of intermediate values;

[0216] Inputting the intermediate value into a mapping expression to obtain a first preset number of second values;

[0217] Filling module 304 obtains target pseudo-random numbers according to the numerical matrix, including:

[0218] Obtain a numerical sequence based on a numerical matrix;

[0219] Compare the data length of the numerical sequence with the length of the target pseudo-random number;

[0220] When the data length is equal to the length of the target pseudo-random number, the numerical sequence is used as the target pseudo-random number;

[0221] When the data length is less than the length of the target pseudo-random number, the second numerical value is used as an intermediate numerical value, and subsequent steps are performed starting from inputting the intermediate numerical value into the mapping expression to obtain a first preset number of second numerical values, and the process stops until a second preset number of numerical sequences are obtained, and the second preset number of numerical sequences are concatenated to obtain the target pseudo-random number, wherein the second preset number is obtained by dividing the length of the target pseudo-random number by the data length of the numerical sequence.

[0222] In some optional implementations, the filling module 305 obtains the numerical sequence according to the numerical matrix, including:

[0223] According to a preset size, the total number of rows and the total number of columns of the numerical matrix are adjusted to obtain an intermediate matrix, wherein the total number of rows is equal to the total number of columns;

[0224] The intermediate matrix is ​​mapped using the third mapping function to obtain a target matrix;

[0225] The third mapping function satisfies:

[0226] Where N represents the total number of rows or columns of the intermediate matrix, x n Indicates the row number of the intermediate matrix, x n+1 Indicates the row number of the target matrix, y n Indicates the column number of the intermediate matrix, y n+1 Indicates the column number of the target matrix, n is the sequence number, a and b are the parameters of the third mapping function, and mod represents the modulo operation;

[0227] Sum the values ​​contained in the target matrix into a sequence of values.

[0228] In some optional implementations, the first mapping processing module 301 sets the local mapping function in the mapping expression as the first mapping function, and uses the mapping expression to respectively perform mapping processing on the first preset number of first values ​​obtained to obtain the first preset number of intermediate values, including:

[0229] Setting the local mapping function in the mapping expression to the first mapping function;

[0230] The mapping expression satisfies:

[0231] x t+1 i,j =((c)f(x t i,j )+(d)(f(x t i,(j+1)%e )+f(x t (i+1)%e,j ))+(j+i*e) / (w))mod1, where f() represents the local mapping function, x t i,j represents the value of the i-th row and j-th column in the matrix to be processed at time t, x t+1 i,j represents the value of the i-th row and j-th column in the processed matrix at time t+1, c, d, e, and w are parameters of the mapping expression, the matrix to be processed includes a first preset number of first values, and % and mod both represent a modulo operation;

[0232] The first mapping function satisfies:

[0233] x m+1 =gx m (1-x m ), where x m+1 Represents the value of the output of the first mapping function, x m represents the value input into the first mapping function, and g represents the parameter of the first mapping function;

[0234] Taking the first value as input data;

[0235] Input a first preset number of input data into the mapping expression respectively to obtain a first preset number of output data, use the output data as input data, and repeat this step until the number of repetitions reaches a third preset number, then end, and obtain a first preset number of intermediate values;

[0236] The second mapping function satisfies:

[0237] x q+1 =hsin(πx q ), where x q Represents the value of the input second mapping function, x q+1represents the value output by the second mapping function, and h represents the parameter of the first mapping function.

[0238] In some optional implementations, the processing module 304 processes the second value using a preset processing logic to obtain a first preset number of fourth values, and processes the third value using a preset processing logic to obtain a first preset number of fifth values, including:

[0239] Performing base conversion on the second value and the third value respectively to obtain a converted second value and a converted third value;

[0240] According to a fourth preset number of preset data bits, obtaining a fourth preset number of first data to be processed from the converted second value, and obtaining a fourth preset number of second data to be processed from the converted third value;

[0241] Performing a bitwise XOR operation on data of a part of preset data bits in the first data to be processed and data of another part of preset data bits to obtain a first preset number of fourth values;

[0242] A bitwise XOR operation is performed on a portion of the preset data bits in the second data to be processed and another portion of the preset data bits to obtain a first preset number of fifth values.

[0243] In some optional implementations, the filling module 305 uses the fifth value as the position coordinate of the fourth value in the initial matrix, and fills the fourth value into the initial matrix according to the position coordinate to obtain a value matrix, including:

[0244] determining a first sequential number for the fourth value and a second sequential number for the fifth value;

[0245] Determine the first fourth value according to the first sequence number, and use the first fourth value as the value to be filled in;

[0246] The fifth value whose second sequence number is equal to the value to be filled in is used as the position coordinate;

[0247] Determine whether the data at the position coordinates in the initial matrix is ​​equal to the preset data. If so, fill the value to be filled in at the position coordinates in the initial matrix. If not, start searching from the position coordinates until the target position where the data of the initial matrix is ​​equal to the preset data is found, and fill the value to be filled in at the target position.

[0248] According to the first sequence number, determine the next fourth value of the value to be filled in, take the next fourth value as the value to be filled in, and start executing subsequent steps from the fifth value whose second sequence number is equal to the value to be filled in as the position coordinate, until multiple fourth values ​​are filled in the initial matrix, then end and obtain a numerical matrix.

[0249] In some optional embodiments, the device further comprises:

[0250] A generating module, configured to generate an initial data matrix using an initial data generating function, wherein the initial data matrix includes a first preset number of first numerical values;

[0251] The initial data generating function satisfies:

[0252] cml_map[o][p]=(o*16+p256), wherein cml_map represents the initial data matrix, o represents the rows of the initial data matrix, and p represents the columns of the initial data matrix.

[0253] In some optional embodiments, the device further comprises:

[0254] An acquisition module is used to acquire data to be processed;

[0255] The XOR operation module is used to perform an XOR operation on the target pseudo-random number and the data to be processed to obtain the target data.

[0256] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.

[0257] The pseudo-random number generating device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0258] The embodiment of the present invention also provides a computer device having the above Figure 3 The pseudo-random number generating device shown.

[0259] See also Figure 4 , Figure 4 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 4As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 4 A processor 10 is taken as an example.

[0260] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.

[0261] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.

[0262] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0263] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.

[0264] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.

[0265] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.

[0266] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.

[0267] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A pseudo-random number generation method, characterized in that: The method comprises: Setting the local mapping function in the mapping expression as a first mapping function, and using the mapping expression to respectively perform mapping processing on the first preset number of first values ​​obtained to obtain a first preset number of second values, wherein the mapping expression is used to generate a pseudo-random number; The local mapping function in the mapping expression is set to a second mapping function to obtain a modified mapping expression, and a first preset number of the second values ​​are respectively mapped using the modified mapping expression to obtain a first preset number of the third values; Processing the second value by using a preset processing logic to obtain a first preset number of fourth values, and processing the third value by using a preset processing logic to obtain a first preset number of fifth values, wherein the preset processing logic is used to shorten the lengths of the second value and the third value; The fifth value is used as the position coordinate of the fourth value in the initial matrix, and according to the position coordinate, the fourth value is filled into the initial matrix to obtain a numerical matrix, and a target pseudo-random number is obtained according to the numerical matrix.

2. The method according to claim 1, characterized in that The step of setting the local mapping function in the mapping expression to a first mapping function, and using the mapping expression to respectively perform mapping processing on the first preset number of first values ​​obtained to obtain the first preset number of second values, comprises: The local mapping function in the mapping expression is set to a first mapping function, and the mapping expression is used to perform mapping processing on the first preset number of first values ​​obtained, respectively, to obtain a first preset number of intermediate values; Inputting the intermediate value into the mapping expression to obtain a first preset number of the second values; The step of obtaining a target pseudo-random number according to the numerical matrix comprises: Obtaining a numerical sequence according to the numerical matrix; Comparing the data length of the numerical sequence with the length of the target pseudo-random number; In a case where the data length is equal to the length of the target pseudo-random number, using the numerical sequence as the target pseudo-random number; In the case where the data length is less than the length of the target pseudo-random number, the second numerical value is used as the intermediate numerical value, and subsequent steps are performed starting from inputting the intermediate numerical value into the mapping expression to obtain a first preset number of second numerical values, until a second preset number of the numerical sequence is obtained, then the method stops, and the second preset number of the numerical sequences are concatenated to obtain the target pseudo-random number, wherein the second preset number is obtained by dividing the length of the target pseudo-random number by the data length of the numerical sequence.

3. The method according to claim 1, characterized in that The using a preset processing logic to process the second value to obtain a first preset number of fourth values, and the using a preset processing logic to process the third value to obtain a first preset number of fifth values, includes: Performing base conversion on the second value and the third value respectively to obtain a converted second value and a converted third value; According to a fourth preset number of preset data bits, obtaining a fourth preset number of first data to be processed from the converted second value, and obtaining a fourth preset number of second data to be processed from the converted third value; Performing a bitwise XOR operation on a portion of the preset data bits in the first data to be processed and another portion of the preset data bits to obtain a first preset number of the fourth values; A bitwise XOR operation is performed on a portion of the preset data bits in the second data to be processed and another portion of the preset data bits to obtain a first preset number of the fifth values.

4. The method according to claim 1, characterized in that: The step of using the fifth value as the position coordinate of the fourth value in the initial matrix and filling the fourth value into the initial matrix according to the position coordinate to obtain a value matrix includes: Determining a first sequential number of the fourth value and a second sequential number of the fifth value; Determine a first fourth value according to the first sequence number, and use the first fourth value as the value to be filled in; Taking a fifth value having a second sequence number equal to the value to be filled in as the position coordinate; Determine whether the data at the position coordinate in the initial matrix is ​​equal to the preset data, if so, fill the value to be filled in the position coordinate in the initial matrix, if not, start searching from the position coordinate until a target position where the data of the initial matrix is ​​equal to the preset data is found, and fill the value to be filled in the target position; According to the first sequence number, determine the next fourth value of the value to be filled in, use the next fourth value as the value to be filled in, and execute subsequent steps starting from the fifth value whose second sequence number is equal to the value to be filled in as the position coordinate, until multiple fourth values ​​are filled in the initial matrix, then end and obtain the numerical matrix.

5. The method according to claim 2, characterized in that: The step of obtaining a numerical sequence according to the numerical matrix comprises: According to a preset size, adjusting the total number of rows and the total number of columns of the numerical matrix to obtain an intermediate matrix, wherein the total number of rows is equal to the total number of columns; Using a third mapping function to map the intermediate matrix to obtain a target matrix; The third mapping function satisfies: Wherein, N represents the total number of rows or columns of the intermediate matrix, x n represents the row number of the intermediate matrix, x n+1 Indicates the row number of the target matrix, y n represents the column number of the intermediate matrix, y n+1 represents the column number of the target matrix, n is the sequence number, a and b are the parameters of the third mapping function, and mod represents the modulo operation; The values ​​contained in the target matrix are summarized to obtain the value sequence.

6. The method according to claim 2, characterized in that The step of setting the local mapping function in the mapping expression to a first mapping function, and using the mapping expression to respectively perform mapping processing on the first preset number of first values ​​obtained to obtain a first preset number of intermediate values, comprises: Setting the local mapping function in the mapping expression to the first mapping function; The mapping expression satisfies: x t+1 i,j = ((c)f(x t i,j )) + (d)(f(x t i,(j+1)%e )) + f(x t (i+1)%e,j )) + (j + i * e) / (w)) mod 1, where In the above example, f() represents the local mapping function, x t i,j represents the value of the i-th row and j-th column in the matrix to be processed at time t, x t+1 i,j represents the value of the i-th row and j-th column in the processed matrix at time t+1, c, d, e, and w are parameters of the mapping expression, the matrix to be processed includes a first preset number of the first values, and % and mod both represent a modulo operation; The first mapping function satisfies: x m+1 =gx m (1-x m ), where x m+1 represents the value output by the first mapping function, x m represents a value input into the first mapping function, and g represents a parameter of the first mapping function; Using the first value as input data; Inputting the first preset number of input data into the mapping expression respectively, obtaining the first preset number of output data, using the output data as the input data, and repeating this step until the number of repetitions reaches a third preset number, then ending, and obtaining the first preset number of intermediate values; The second mapping function satisfies: x q+1 =hsin(πx q ), where x q represents the value of the second mapping function, x q+1 represents the numerical value output by the second mapping function, and h represents the parameter of the first mapping function.

7. The method according to claim 1, characterized in that Before setting the local mapping function in the mapping expression to the first mapping function, the method further includes: Generate an initial data matrix using an initial data generation function, wherein the initial data matrix includes a first preset number of the first values; The initial data generation function satisfies: cml_map[o][p]=(o*16+p256), wherein cml_map represents the initial data matrix, o represents the rows of the initial data matrix, and p represents the columns of the initial data matrix.

8. The method according to claim 1, characterized in that After obtaining the target pseudo-random number according to the numerical matrix, the method further includes: Get the data to be processed; An XOR operation is performed on the target pseudo-random number and the data to be processed to obtain target data.

9. A pseudo-random number generating device, characterized in that: The device comprises: A first mapping processing module, used to set a local mapping function in a mapping expression as a first mapping function, and use the mapping expression to respectively perform mapping processing on a first preset number of first values ​​obtained to obtain a first preset number of second values, wherein the mapping expression is used to generate a pseudo-random number; A second mapping processing module, used to set the local mapping function in the mapping expression to a second mapping function to obtain a modified mapping expression, and use the modified mapping expression to perform mapping processing on a first preset number of the second values ​​respectively to obtain a first preset number of third values; a processing module, configured to process the second value using a preset processing logic to obtain a first preset number of fourth values, and to process the third value using a preset processing logic to obtain a first preset number of fifth values, wherein the preset processing logic is configured to shorten the lengths of the second value and the third value; The filling module is used to use the fifth value as the position coordinate of the fourth value in the initial matrix, fill the fourth value into the initial matrix according to the position coordinate to obtain a numerical matrix, and obtain a numerical sequence according to the numerical matrix.

10. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the pseudo-random number generation method according to any one of claims 1 to 8 by executing the computer instructions.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the pseudo-random number generation method according to any one of claims 1 to 8.

Citation Information

Cited By

  • Random number generator and method thereof

    TWI941238B