A bit frequency screening method, device, electronic equipment and medium

Through the bit frequency screening method, CPU instructions are used to perform bit 1 number statistics and deviation calculations, which solves the problem of wasting computing resources and storage space in frequency detection within a block, improves computing efficiency and pass rate, and is suitable for cloud computing and mass Data scenario.

CN117827147BActive Publication Date: 2024-09-17BEIJING HAITAI FANGYUAN HIGH TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311669939.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-07
Publication Date
2024-09-17
Estimated Expiration
2043-12-07

AI Technical Summary

Technical Problem

Existing intra-block frequency detection methods are wasteful in terms of computational resource consumption and storage space. In particular, table lookup-based methods require additional storage space, while bit processing-based methods have low computational efficiency.

Method used

Through a bit frequency screening method, CPU instructions are used to carry out bit 1 number statistics and deviation calculations, and the calculation amount is allocated to two steps for execution to avoid large-scale data processing at one time, using the block cache module and the detection and evaluation module Perform data screening and evaluation to output data that meets requirements.

Benefits of technology

It improves computing efficiency and pass rate, avoids additional storage space requirements, is suitable for cloud computing and massive data scenarios, and improves execution efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117827147B
    Figure CN117827147B
Patent Text Reader

Abstract

The present application provides a method, device, electronic device and medium for screening bit frequency, the method comprising: receiving an original random number from a random number generator, and storing the original random number from the random number generator as first data; counting the number of bit 1s in the stored first data, and storing multiple first data that meet the requirements and the number of bit 1s in each first data as second data according to the statistical result; performing statistical evaluation on the second data, and storing the second data that meet the requirements as third data according to the statistical evaluation result; and outputting the stored third data according to an external request. The present application accelerates statistical analysis of data blocks and greatly improves execution efficiency, and is particularly suitable for scenarios of frequency detection within cloud computing and massive data calculation blocks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of information security, and in particular to a bit frequency screening method, device, electronic equipment and medium. Background Art

[0002] With the development of information technology and computer technology, while people are enjoying the many benefits brought by information technology, network security issues have become a common challenge faced by mankind in the information age.

[0003] The output of a random number generator is called a random number, which is widely used in various fields, such as key generation for symmetric and asymmetric cryptographic algorithms, challenge values ​​in challenge-response mechanisms, secret information in digital signature schemes, and resistance to side-channel analysis attacks.

[0004] The quality of random numbers can be tested using more common statistical testing methods to check whether there are obvious defects in the output quality. Common statistical test suites include the US NIST SP 800-22 "A Statistical Test Suite for Random and Pseudorandom Number Generators for Cryptographic Applications" and my country's national standard GM / T 0005-2021 "Randomness Testing Specifications". Both standard documents recommend 15 statistical testing methods, both of which recommend the use of the intra-block frequency test method.

[0005] The intra-block frequency test divides the n-bit sequence to be tested into N non-overlapping subsequences according to the block length m, and discards the redundant bits; then the proportion of bit 1 in each subsequence is calculated; then the proportion of bit 1 in all subsequences is accumulated, and then the P value is calculated and compared with the significance level to determine whether the test sequence passes the test.

[0006] There are two methods for performing randomness tests using the existing intra-block frequency detection:

[0007] The first is a bit-based processing method: first convert the data to be detected into bits, then count the number of bit 1s bit by bit in each block, calculate the proportion of bit 1s in the block, and then perform statistical and P value calculations. This method can be found in the randomness detection suite provided by the National Institute of Standards and Technology (NIST). However, this method does not fully consider the computing resources of the CPU, resulting in a large waste of computing resources. In order to calculate the statistics in the intra-block frequency detection algorithm, N subtractions, N squares, N divisions, mN+N additions, and 2 multiplications are required, where N is the number of complete subsequences.

[0008] The second is a table-based processing method: directly look up the table for the byte data to be checked, count the number of bit 1s in each block by pre-setting up the table, calculate the proportion of bit 1s in the block, and then perform statistical and P value calculations. This method can be found in the literature: Luo Ying, Zhang Wenke, Yin Yihua, et al. Research on the rapid implementation of single-bit frequency detection and intra-block frequency detection [J]. Communication Technology, 2015, 48(9): 1073-1077. In addition, the second solution has higher execution efficiency than the first solution. However, this method requires the establishment of a lookup table in advance. The size of the table can be 8-bit or 16-bit depending on the actual processing situation, which requires additional storage space. The former requires an additional 256 bytes of storage space, and the latter requires an additional 64KB of storage space. Summary of the invention

[0009] In order to solve one of the above-mentioned technical defects, a bit frequency screening method, device, electronic device and medium are provided in the embodiments of the present application.

[0010] A first aspect of an embodiment of the present application provides a bit frequency screening method, the method comprising:

[0011] Receiving an original random number from a random number generator, and storing the original random number from the random number generator as first data;

[0012] Counting the number of bits 1 in the stored first data, and storing a plurality of first data meeting the requirements and the number of bits 1 in each first data as second data according to the statistical result;

[0013] Performing statistical evaluation on the second data, and storing the second data meeting the requirements as third data according to the statistical evaluation result;

[0014] The stored third data is outputted according to an external request.

[0015] Preferably, the process of counting the number of bits 1 in the stored first data and storing the plurality of first data meeting the requirements and the number of bits 1 in each first data as the second data according to the statistical result includes:

[0016] Counting the number of bits 1 in each of the first data;

[0017] Calculate the deviation between the number of bits 0 and the number of bits 1 in each of the first data;

[0018] When the deviation is less than or equal to a preset deviation upper limit, storing the first data and the number of bits 1 in the first data as second data;

[0019] When the deviation is greater than a preset deviation upper limit, the first data is discarded.

[0020] Preferably, the process of counting the number of bits 1 in each of the first data includes:

[0021] Set an initial value, reset the number m1 of bits 1 in the first data to 0, and set the remaining unprocessed bit length r in the first data to m, where m is the original bit length of the first data;

[0022] When the remaining unprocessed bit length r is greater than 0, the first s bits of the unprocessed portion of the first data are taken as data D, and the unprocessed bit length r=rs is updated;

[0023] Calculate the number z of bits 1 of the data D;

[0024] Update the number of bits 1 in the first data to m1=m1+z, and repeat the above calculation process until the remaining unprocessed bit length r is equal to 0;

[0025] Output the updated number m1 of bits 1 in the first data.

[0026] Preferably, when the remaining unprocessed bit length r is less than s, the process of counting the number of bits 1 in the first data further includes:

[0027] The first data is loaded into data D, the last sr bit of the data D is set to 0, and the unprocessed bit length r is updated to 0.

[0028] Preferably, the process of performing statistical evaluation on the second data and storing the second data meeting the requirements as the third data according to the statistical evaluation result includes:

[0029] Calculate a statistic according to the number of bits 1 in each first data in the second data;

[0030] Calculate the P value and Q value according to the statistic;

[0031] When the P value is greater than or equal to a preset value, storing the second data as third data;

[0032] When the P value is less than a preset value, the second data is discarded.

[0033] Preferably, the method further comprises:

[0034] When the data volume of the first data reaches a first preset value, the number of bits 1 in the first data is counted.

[0035] Preferably, the method further comprises:

[0036] When the data volume of the second data reaches a second preset value, a statistical evaluation is performed on the second data, and the second preset value is greater than the first preset value.

[0037] A second aspect of an embodiment of the present application provides a bit frequency screening device, the device comprising:

[0038] A block cache module, configured to receive an original random number from a random number generator and store the original random number from the random number generator as first data;

[0039] a block statistics module, configured to count the number of bits 1 in the first data stored in the block cache module, and send a plurality of first data meeting the requirements and the number of bits 1 in each first data as second data to the main cache module according to the statistical result;

[0040] A main cache module, used for storing the second data sent by the block statistics module;

[0041] a detection and evaluation module, configured to perform statistical evaluation on the second data, and send the second data meeting the requirements as third data to the data storage module according to the statistical evaluation result;

[0042] The data storage module is used to store the third data sent by the detection and evaluation module and output the third data according to an external request.

[0043] Preferably, the block statistics module is specifically used for:

[0044] Counting the number of bits 1 in each of the first data;

[0045] Calculate the deviation between the number of bits 0 and the number of bits 1 in each of the first data;

[0046] When the deviation is less than or equal to a preset deviation upper limit, sending the first data and the number of bits 1 in the first data as second data to the primary cache module;

[0047] When the deviation is greater than a preset deviation upper limit, the first data is discarded.

[0048] Preferably, the block statistics module is further used for:

[0049] Set an initial value, reset the number m1 of bits 1 in the first data to 0, and set the remaining unprocessed bit length r in the first data to m, where m is the original bit length of the first data;

[0050] When the remaining unprocessed bit length r is greater than 0, the first s bits of the unprocessed portion of the first data are taken as data D, and the unprocessed bit length r=rs is updated;

[0051] Calculate the number z of bits 1 of the data D;

[0052] Update the number of bits 1 in the first data to m1=m1+z, and repeat the above calculation process until the remaining unprocessed bit length r is equal to 0;

[0053] Output the updated number m1 of bits 1 in the first data.

[0054] Preferably, the block statistics module is further used for:

[0055] When the remaining unprocessed bit length r is less than s, the first data is loaded into the data D, the last sr bits of the data D are set to 0, and the unprocessed bit length r is updated to 0.

[0056] Preferably, the detection and evaluation module is specifically used for:

[0057] Calculate a statistic according to the number of bits 1 in each first data in the second data;

[0058] Calculate the P value and Q value according to the statistic;

[0059] When the P value is greater than or equal to a preset value, sending the second data as third data to the data storage module;

[0060] When the P value is less than a preset value, the second data is discarded.

[0061] Preferably, the block cache module is further configured to: send the first data to the block statistics module when the data volume of the first data reaches a first preset value.

[0062] Preferably, the main cache module is further specifically used for: sending the second data to the detection and evaluation module when the data volume of the second data reaches a second preset value, and the second preset value is greater than the first preset value.

[0063] A third aspect of the embodiments of the present application provides an electronic device, including: a processor and a memory;

[0064] Among them, one or more computer programs are stored in the memory, and the one or more computer programs include instructions; when the instructions are executed by the processor, the electronic device executes the method described in the first aspect of the embodiment of the present application.

[0065] A fourth aspect of an embodiment of the present application provides a computer storage medium, including computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the method described in the first aspect of the embodiment of the present application.

[0066] By adopting the bit frequency screening method provided in the embodiment of the present application, there is no need to add precious storage space in the overall method flow. The embodiment of the present application first stores and processes the first data, and then stores and processes the second data. Through a two-step implementation method, the amount of calculation is distributed to the two steps for execution, avoiding the surge caused by a large amount of data being processed in a short time at one time. At the same time, the data is screened during the first data processing, which greatly improves the pass rate and calculation efficiency in the second data processing process. The embodiment of the present application makes full use of the characteristics of the CPU, and uses the instructions provided by the CPU to calculate the number of bits 1 in a data block, which accelerates the statistical analysis of the data block and greatly improves the execution efficiency. It is particularly suitable for cloud computing and the scene of frequency detection within the calculation block of massive data. BRIEF DESCRIPTION OF THE DRAWINGS

[0067] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0068] Figure 1 A flowchart of the bit frequency screening method provided in Example 1 of the present application;

[0069] Figure 2 A schematic diagram of the principle of the bit frequency screening device provided in Example 2 of the present application;

[0070] Figure 3 This is a schematic diagram of the principle of the electronic device provided in Example 3 of the present application. DETAILED DESCRIPTION

[0071] In order to make the technical solutions and advantages in the embodiments of the present application more clearly understood, the exemplary embodiments of the present application are further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than an exhaustive list of all the embodiments. It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.

[0072] Example 1

[0073] like Figure 1 As shown, this embodiment proposes a bit frequency screening method, which includes:

[0074] S101. Receive an original random number from a random number generator, and store the original random number from the random number generator as first data.

[0075] Specifically, as a method for performing randomness testing on a random number generator, this embodiment needs to receive the original random number of the random number generator and temporarily store the original random number of the random number generator. This process can be implemented using a cache module. Since this embodiment involves the transmission of multiple data, this embodiment records the original random number of the random number generator as the first data to distinguish subsequent data.

[0076] More specifically, this embodiment implements setting the bit length of the block cache module storing the first data to a first preset value. The first preset value can usually be set to be no less than the parameter m of the frequency detection within the block, for example, m is 10000 according to GM / T 0005. Of course, the specific value of the parameter m can be adaptively adjusted according to actual conditions. When the amount of the first data stored in the block cache module reaches m bits, the m-bit data is moved as a whole to the next unit or module for subsequent processing.

[0077] S102: Count the number of bits 1 in the stored first data, and store multiple first data that meet the requirements and the number of bits 1 in each first data as second data according to the statistical result.

[0078] Specifically, this embodiment counts the number of bit 1s in the stored first data, and determines whether to subsequently process the first data and the number of bit 1s or directly discard them based on whether the counted number of bit 1s is within an allowed range.

[0079] More specifically, this embodiment first counts the number of bit 1s m1 in each first data in turn, then calculates the deviation δ=|2m1-m| between the number of bits 0 and bit 1 in each first data, and finally makes a transfer or discard processing based on whether the deviation is within the allowed range.

[0080] The process of counting the number of bits 1 in the first data specifically includes:

[0081] Setting initial values: resetting the number m1 of bits 1 in the first data to 0, and setting the remaining unprocessed bit length r in the first data to m, where m is the original bit length of the first data;

[0082] Loop judgment and data loading: When the remaining unprocessed bit length r is greater than 0, the first s bits of the unprocessed part of the first data are taken as data D, and the unprocessed bit length r=rs is updated;

[0083] Calculate the number of bits 1 of the loaded data: Calculate the number z of bits 1 of the data D. In this embodiment, the Hamming weight counting instruction (hereinafter referred to as CNT) can be used to obtain the number z of bits 1 of the s-bit data D = CNT (D);

[0084] Update the accumulated value: update the number of bits 1 in the first data m1=m1+z, and repeat the above calculation process until the remaining unprocessed bit length r is equal to 0;

[0085] Output: Output the number m1 of bits 1 in the updated first data.

[0086] In this embodiment, s represents the number of bits 1 of s-bit data that can be obtained at one time by the CPU executing this embodiment. According to the characteristics of the CPU itself, s can be 16, 32, 64, 128, 256, 512, etc. For example, if 64-bit words are used, s is 64, if SSE instructions are used, s is 128, if AVX2 instructions are used, s is 256, and if AVX512 instructions are used, s is 512.

[0087] When calculating the number of first data bits 1, if the remaining unprocessed bit length r is less than s, the first data is loaded into data D, the last sr bits of data D are set to 0, and the unprocessed bit length r=0 is updated.

[0088] After obtaining the number m1 of bit 1 in the first data, the deviation δ=|2m1-m| of the number of bit 0 and bit 1 in each first data can be calculated. Then, it is determined whether the calculated deviation of the number of bit 0 and bit 1 in the first data is within the allowed range. If δ≤A, the first data and its number m1 of bit 1 are transferred to the subsequent processing module, otherwise, the first data is discarded.

[0089] The threshold A is an integer, which represents the upper limit of the deviation of the number of 0 bits and 1 bits allowed, and is calculated as follows:

[0090]

[0091] Here, Z represents a set of integers, erfc is the residual error function, and α is the significance level. For example, in GM / T 0005, α is 0.01.

[0092] Taking the value of α as 0.01 and the value of m as 10000 as specified in GM / T 0005 as an example, after calculation by the above formula, A=257. That is, when the calculated deviation of the number of 0 bits and 1 bits δ=|2m1-m| is not greater than 257, the first data and its bit 1 number m1 are transferred to the subsequent processing module, otherwise, the first data is discarded.

[0093] For the first data whose offset is within the allowable range, this embodiment stores the first data and the number of bit 1s thereof as the second data. It should be noted that, in this embodiment, the second data includes multiple first data and the number of bit 1s in each first data. The process of storing the second data can be implemented using a main cache module. The bit length of the main cache module is set to a second preset value. When the amount of second data in the main cache module reaches the second preset value, the second data is transferred to a subsequent processing module. In this embodiment, the second preset value can generally be set to be not less than the parameter n of the frequency detection within the block. For example, according to GM / T 0005, n is 1000000. Of course, the specific value of the parameter n can be adaptively adjusted according to actual conditions. The number of bits 1 in a data block (each data block is m bits) is recorded as m1 (i) , i=0,1,2,…,N-1, where Indicates that x is rounded down. Taking the value of m as 10000 and the value of n as 1000000 as specified in GM / T0005 as an example,

[0094] S103: Perform statistical evaluation on the second data, and store the second data that meets the requirements as third data according to the statistical evaluation result.

[0095] Specifically, in this embodiment, after the amount of the second data reaches n bits, the statistics of the second data are calculated. (i) , i=0,1,2,…,N-1 calculate the statistic V, the calculation process is:

[0096]

[0097] Then calculate the P value and Q value and evaluate them. The process of calculating the P value and Q value is:

[0098] Q=P=igamc(N / 2,V / 2)

[0099] If P≥α, the second data is stored as the third data, otherwise, the second data is discarded. α is the significance level, for example, in GM / T 0005, α is 0.01.

[0100] S104: Output the stored third data according to an external request.

[0101] Specifically, when the external party needs random data, the third data is sent to the external party according to the request length in the external request.

[0102] The bit frequency screening method provided in this embodiment does not require additional valuable storage space in the overall method flow. This embodiment first stores and processes the first data, and then stores and processes the second data. Through a two-step implementation method, the amount of computation is distributed to the two steps for execution, avoiding surges caused by a large amount of data being processed in a short period of time at one time. At the same time, data screening is performed during the first data processing, which greatly improves the pass rate and calculation efficiency during the second data processing. This embodiment makes full use of the characteristics of the CPU and uses the instructions provided by the CPU to calculate the number of bits 1 in a data block, which accelerates the statistical analysis of the data block and greatly improves the execution efficiency. It is particularly suitable for cloud computing and the frequency detection of massive data calculation blocks.

[0103] The method of this embodiment is implementable, compatible and has a wide range of scenarios. It is compatible with low-end servers such as small VPNs to high-end servers, and shows a high performance improvement. It has rich configurations, algorithm parameters can be freely selected, parameter sizes can be freely set, and data loading width parameters s can be freely selected. It is compatible with a variety of different parameters m. This makes this embodiment have better compatibility and a wider range of uses, such as supporting m=10000, m=100000 specified in GM / T 0005 and m=100 in GB / T 32915-2016 "Information Security Technology Binary Sequence Randomness Detection Method". For example:

[0104] (1) Set as a workstation. For example, when using an Intel 11th I9 processor, select:

[0105] The internal parameter s representing the data loading width is set to 512.

[0106] m is set to 10000 for testing.

[0107] The value of α is 0.01.

[0108] (2) Set to low power consumption scenario, such as VPN security products, such as Atom processors, and select:

[0109] The internal parameter s representing the data loading width is set to 32.

[0110] m is set to 10000 for testing.

[0111] The value of α is 0.01.

[0112] This embodiment is also fully compatible with the test item "Frequency Test within a Block" in the U.S. NIST SP800-22 test standard. For example, the parameter m is set to 128 recommended by NIST SP800-22, and the result obtained is the test result of the test item "Frequency Test within a Block" in the NIST SP800-22 test standard.

[0113] In addition, in this embodiment, in application scenarios with high execution efficiency requirements such as high-configuration workstations / servers, each block only needs 10000 / 512=20 data loads, 20 VPOPCNTs, 20 vector additions, and 15 ordinary additions to complete statistics; while the traditional solution requires 1250 data loads, 1250 table lookups, and 1250 additions. The performance gap between the two is dozens of times. Therefore, in low-configuration and low-power scenarios, such as VPN security products, each block only needs 10000 / 32≈313 data loads, 313 POPCNTs, and 313 additions to complete statistics; while the traditional solution requires 10000 / 8=1250 data loads, 1250 table lookups, and 1250 additions. The performance gap between the two is about 4 times.

[0114] Example 2

[0115] Corresponding to Example 1, Figure 2 As shown, this embodiment provides a bit frequency screening device, which includes:

[0116] A block cache module, configured to receive an original random number from a random number generator and store the original random number from the random number generator as first data;

[0117] a block statistics module, configured to count the number of bits 1 in the first data stored in the block cache module, and send a plurality of first data meeting the requirements and the number of bits 1 in each first data as second data to the main cache module according to the statistical result;

[0118] A main cache module, used for storing the second data sent by the block statistics module;

[0119] a detection and evaluation module, configured to perform statistical evaluation on the second data, and send the second data meeting the requirements as third data to the data storage module according to the statistical evaluation result;

[0120] The data storage module is used to store the third data sent by the detection and evaluation module and output the third data according to an external request.

[0121] Specifically, the block statistics module is used to:

[0122] Counting the number of bits 1 in each first data;

[0123] Calculate the deviation between the number of bits 0 and the number of bits 1 in each first data;

[0124] When the deviation is less than or equal to the preset deviation upper limit, the first data and the number of bits 1 in the first data are sent as second data to the primary cache module;

[0125] When the deviation is greater than a preset deviation upper limit, the first data is discarded.

[0126] The block statistics module is also specifically used for:

[0127] Set an initial value, reset the number m1 of bits 1 in the first data to 0, and set the remaining unprocessed bit length r in the first data to m, where m is the original bit length of the first data;

[0128] When the remaining unprocessed bit length r is greater than 0, the first s bits of the unprocessed portion of the first data are taken as data D, and the unprocessed bit length r=rs is updated;

[0129] Calculate the number z of bits 1 in data D;

[0130] Update the number of bits 1 in the first data to m1=m1+z, and repeat the above calculation process until the remaining unprocessed bit length r is equal to 0;

[0131] Output the number m1 of bits 1 in the updated first data.

[0132] The block statistics module is also specifically used for:

[0133] When the remaining unprocessed bit length r is less than s, the first data is loaded into the data D, the last sr bits of the data D are set to 0, and the unprocessed bit length r=0 is updated.

[0134] The detection and evaluation module is specifically used for:

[0135] Calculate a statistic based on the number of bits 1 in each of the first data in the second data;

[0136] Calculate P and Q values ​​based on the statistics;

[0137] When the P value is greater than or equal to a preset value, the second data is sent to the data storage module as the third data;

[0138] When the P value is less than a preset value, the second data is discarded.

[0139] The block cache module is further specifically configured to: send the first data to the block statistics module when the data volume of the first data reaches a first preset value.

[0140] The main cache module is also specifically used to: send the second data to the detection and evaluation module when the data volume of the second data reaches a second preset value, and the second preset value is greater than the first preset value.

[0141] The specific working principle of the bit frequency screening device proposed in this embodiment can refer to the content recorded in Example 1, and this embodiment will not be repeated here.

[0142] This embodiment first stores and processes the first data, and then stores and processes the second data. Through the two-step implementation method, the amount of computation is distributed to the two steps for execution, avoiding the surge caused by the one-time processing of a large amount of data in a short time. At the same time, the data is screened during the first data processing, which greatly improves the pass rate and computing efficiency in the second data processing process. This embodiment makes full use of the characteristics of the CPU and uses the instructions provided by the CPU to calculate the number of bit 1s in a data block, which accelerates the statistical analysis of the data block and greatly improves the execution efficiency. It is particularly suitable for cloud computing and the frequency detection of massive data calculation blocks.

[0143] Example 3

[0144] This embodiment provides an electronic device, including: a processor and a memory;

[0145] Among them, one or more computer programs are stored in the memory, and the one or more computer programs include instructions; when the instructions are executed by the processor, the electronic device executes the method described in the first aspect of the embodiment of the present application.

[0146] like Figure 3 As shown, the electronic device provided in this embodiment includes a processor 31, a communication interface 33, a memory 32 and a communication bus 34, wherein the processor 31, the communication interface 33 and the memory 32 communicate with each other through the communication bus 34. The processor 31 can call the logic instructions in the memory 32 to execute the bit frequency screening method, which includes:

[0147] Receiving an original random number from a random number generator, and storing the original random number from the random number generator as first data;

[0148] Counting the number of bits 1 in the stored first data, and storing a plurality of first data meeting the requirements and the number of bits 1 in each first data as second data according to the statistical result;

[0149] Performing statistical evaluation on the second data, and storing the second data meeting the requirements as third data according to the statistical evaluation result;

[0150] The stored third data is outputted according to an external request.

[0151] This embodiment first stores and processes the first data, and then stores and processes the second data. Through the two-step implementation method, the amount of computation is distributed to the two steps for execution, avoiding the surge caused by the one-time processing of a large amount of data in a short time. At the same time, the data is screened during the first data processing, which greatly improves the pass rate and computing efficiency in the second data processing process. This embodiment makes full use of the characteristics of the CPU and uses the instructions provided by the CPU to calculate the number of bit 1s in a data block, which accelerates the statistical analysis of the data block and greatly improves the execution efficiency. It is particularly suitable for cloud computing and the frequency detection of massive data calculation blocks.

[0152] In addition, the logic instructions in the above-mentioned memory 32 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0153] Example 4

[0154] This embodiment provides a computer storage medium including computer instructions. When the computer instructions are executed on an electronic device, the electronic device performs a bit frequency screening method, the method including:

[0155] Receiving an original random number from a random number generator, and storing the original random number from the random number generator as first data;

[0156] Counting the number of bits 1 in the stored first data, and storing a plurality of first data meeting the requirements and the number of bits 1 in each first data as second data according to the statistical result;

[0157] Performing statistical evaluation on the second data, and storing the second data meeting the requirements as third data according to the statistical evaluation result;

[0158] The stored third data is outputted according to an external request.

[0159] This embodiment first stores and processes the first data, and then stores and processes the second data. Through the two-step implementation method, the amount of computation is distributed to the two steps for execution, avoiding the surge caused by the one-time processing of a large amount of data in a short time. At the same time, the data is screened during the first data processing, which greatly improves the pass rate and computing efficiency in the second data processing process. This embodiment makes full use of the characteristics of the CPU and uses the instructions provided by the CPU to calculate the number of bit 1s in a data block, which accelerates the statistical analysis of the data block and greatly improves the execution efficiency. It is particularly suitable for cloud computing and the frequency detection of massive data calculation blocks.

[0160] In the description of the present application, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present application.

[0161] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0162] In this application, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection, an electrical connection, or can communicate with each other; it can be a direct connection, or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.

[0163] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0164] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A bit frequency screening method, It is characterized in that The method comprises: Receiving an original random number from a random number generator, and storing the original random number from the random number generator as first data; Counting the number of bits 1 in the stored first data, and storing a plurality of first data meeting the requirements and the number of bits 1 in each first data as second data according to the statistical result; Performing statistical evaluation on the second data, and storing the second data meeting the requirements as third data according to the statistical evaluation result; outputting the stored third data according to an external request; The process of counting the number of bits 1 in the stored first data and storing the plurality of first data meeting the requirements and the number of bits 1 in each first data as the second data according to the statistical result includes: Counting the number of bits 1 in each of the first data; Calculate the deviation between the number of bits 0 and the number of bits 1 in each of the first data; When the deviation is less than or equal to a preset deviation upper limit, storing the first data and the number of bits 1 in the first data as second data; When the deviation is greater than a preset deviation upper limit, discarding the first data; The process of counting the number of bits 1 in each of the first data includes: Set the initial value and set the number of bits 1 in the first data to m 1 Reset to 0, and set the remaining unprocessed bit length r in the first data to m, where m is the original bit length of the first data; When the remaining unprocessed bit length r is greater than 0, the first s bits of the unprocessed portion of the first data are taken as data D, and the unprocessed bit length r=rs is updated; Calculate the number z of bits 1 of the data D; Update the number m of bits 1 in the first data 1 =m 1 +z, and repeat the calculation process until the remaining unprocessed bit length r is equal to 0; Output the updated number m of bits 1 in the first data 1 ; The process of performing statistical evaluation on the second data and storing the second data that meets the requirements as third data according to the statistical evaluation result includes: Calculate a statistic according to the number of bits 1 in each first data in the second data; Calculate the P value and Q value according to the statistic; When the P value is greater than or equal to a preset value, storing the second data as third data; When the P value is less than a preset value, the second data is discarded.

2. The method according to claim 1, It is characterized in that When the remaining unprocessed bit length r is less than s, the process of counting the number of bits 1 in the first data further includes: The first data is loaded into data D, the last sr bit of the data D is set to 0, and the unprocessed bit length r is updated to 0.

3. The method according to claim 1, It is characterized in that The method further comprises: When the data volume of the first data reaches a first preset value, the number of bits 1 in the first data is counted.

4. The method according to claim 3, It is characterized in that The method further comprises: When the data volume of the second data reaches a second preset value, a statistical evaluation is performed on the second data, and the second preset value is greater than the first preset value.

5. A bit frequency screening device, It is characterized in that The device comprises: A block cache module, configured to receive an original random number from a random number generator and store the original random number from the random number generator as first data; a block statistics module, configured to count the number of bits 1 in the first data stored in the block cache module, and send a plurality of first data meeting the requirements and the number of bits 1 in each first data as second data to the main cache module according to the statistical result; A main cache module, used for storing the second data sent by the block statistics module; a detection and evaluation module, configured to perform statistical evaluation on the second data, and send the second data meeting the requirements as third data to the data storage module according to the statistical evaluation result; A data storage module, used for storing the third data sent by the detection and evaluation module, and outputting the third data according to an external request; The block statistics module is specifically used for: Counting the number of bits 1 in each of the first data; Calculate the deviation between the number of bits 0 and the number of bits 1 in each of the first data; When the deviation is less than or equal to a preset deviation upper limit, sending the first data and the number of bits 1 in the first data as second data to the primary cache module; When the deviation is greater than a preset deviation upper limit, discarding the first data; The block statistics module is also specifically used for: Set the initial value and set the number of bits 1 in the first data to m 1 Reset to 0, and set the remaining unprocessed bit length r in the first data to m, where m is the original bit length of the first data; When the remaining unprocessed bit length r is greater than 0, the first s bits of the unprocessed portion of the first data are taken as data D, and the unprocessed bit length r=rs is updated; Calculate the number z of bits 1 of the data D; Update the number m of bits 1 in the first data 1 =m 1 +z, and repeat the calculation process until the remaining unprocessed bit length r is equal to 0; Output the updated number m of bits 1 in the first data 1 ; The detection and evaluation module is specifically used for: Calculate a statistic according to the number of bits 1 in each first data in the second data; Calculate the P value and Q value according to the statistic; When the P value is greater than or equal to a preset value, sending the second data as third data to the data storage module; When the P value is less than a preset value, the second data is discarded.

6. The device according to claim 5, It is characterized in that The block statistics module is also specifically used for: When the remaining unprocessed bit length r is less than s, the first data is loaded into the data D, the last sr bits of the data D are set to 0, and the unprocessed bit length r is updated to 0.

7. The device according to claim 5, It is characterized in that The block cache module is further specifically configured to: when the data volume of the first data reaches a first preset value, send the first data to the block statistics module.

8. The device according to claim 5, It is characterized in that The main cache module is further specifically used for: sending the second data to the detection and evaluation module when the data volume of the second data reaches a second preset value, and the second preset value is greater than the first preset value.

9. An electronic device, It is characterized in that include: Processor and memory; One or more computer programs are stored in the memory, and the one or more computer programs include instructions; when the instructions are executed by the processor, the electronic device executes the method according to any one of claims 1 to 4.

10. A computer storage medium, It is characterized in that The method comprises computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 4.