Sampling method and device obeying central binomial distribution
Patent Information
- Application Number
- CN202611203992.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-10
- Publication Date
- 2026-10-16
AI Technical Summary
对于在同一颗芯片上集成多种格基密码算法的应用场景,缺少可扩展和可重构特性,难以支撑多种算法的不同参数集,且不能很好地适应新的采样参数
[0021] In a sixth aspect, this application provides a computer program product, including a computer program that, when executed by a processor, implements the sampling method following a central binomial distribution as described in the first aspect above.
Smart Images

Figure CN122932980A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of information security technology, and in particular relates to a sampling method and apparatus that follows a central binomial distribution. Background Technology
[0002] In related technologies, lattice-based cryptography, as a quantum-resistant cryptosystem that combines quantum-hardening security with high performance, has become a popular standardization approach. Error sampling in lattice-based cryptography has a crucial impact on the security and performance of the algorithm. Early lattice-based cryptographic schemes used discrete Gaussian distributions for error sampling, which later evolved to achieve the more efficient central binomial distribution (CBD). The range of sampled values satisfying this distribution is... The closer the integer is to 0, the higher the probability. Specifically, if the random variable... Obtain the parameter as The central binomial distribution (CBD) (usually a positive integer) Then the sampling probability .in, The mean of this distribution is 0, and the variance is... Currently, most mainstream structured lattice-based encryption algorithms / key encapsulation algorithms involve sampling according to a central binomial distribution, and lattice-based signature algorithms such as HAWK also involve sampling according to a central binomial distribution.
[0003] Existing sampling methods following a central binomial distribution are mostly designed and implemented for specific parameter sets of a particular algorithm, supporting a limited number of sampling parameters. For applications integrating multiple lattice-based cryptographic algorithms on a single chip, these methods lack scalability and reconfigurability, making it difficult to support different parameter sets for various algorithms and adapt well to new sampling parameters. Therefore, how to achieve sampling from a central binomial distribution applicable to multiple lattice-based cryptographic algorithms has become a pressing technical challenge in this field. Summary of the Invention
[0004] The present invention aims to at least solve one of the technical problems existing in the prior art. To this end, the present invention proposes a sampling method and apparatus that follows a central binomial distribution, which can realize sampling from a central binomial distribution applicable to various lattice-based cryptographic algorithms.
[0005] Firstly, this application provides a sampling method that follows a central binomial distribution, the method comprising: Obtain the target number of samples, the target sampling parameters, and the set of sampling parameters for the basic sampling unit; Based on the target sampling parameters and the set of sampling parameters of existing basic sampling units, the number of target basic sampling units and the quantity of each target basic sampling unit are determined; each basic sampling unit is used to sample the first uniform random bit sequence input, and the sampling result is the sum of the first half of the first uniform random bit sequence input minus the sum of the second half of the first uniform random bit sequence input; the length of the first uniform random bit sequence input is twice the sampling parameters of the basic sampling unit; the target basic sampling unit includes at least one of the basic sampling units; The following operation is repeated a number of times equal to the target number of samples: For the second uniform random bit sequence input, a continuous bit subsequence input is obtained in a preset order. The target sampling unit, composed of each of the target basic sampling units, is sampled to obtain a first sampling result that follows a central binomial distribution; the second uniform random bit sequence input contains a number of non-overlapping continuous bit subsequences of the same length equal to the target number of samples.
[0006] According to the sampling method following the central binomial distribution in this application, compared with the implementation methods in related technologies that follow the central binomial distribution, such as calculating the two Hamming weights first and then performing subtraction, this method uses a reconfigurable design concept to build a sampling module with large sampling parameters by arranging the data of the input bit sequence (referring to the second uniform random bit sequence input) and calling the basic sampling unit with small sampling parameters. This method can achieve stronger scalability while ensuring the consistency of sampling results, support multiple sampling parameters, and be applicable to a variety of typical lattice-based cryptographic algorithms.
[0007] According to one embodiment of this application, the step of obtaining a continuous bit subsequence input in a preset order by a target sampling unit composed of each of the target basic sampling units to obtain a first sampling result that follows a central binomial distribution includes: For each of the target basic sampling units, the following operation is repeated a number of times equal to the number of target basic sampling units: selecting a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the first half of the continuous bit subsequence and selecting a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the second half of the continuous bit subsequence, concatenating them, and inputting them into the target basic sampling unit to obtain the second sampling result; Based on each of the second sampling results, the first sampling result is obtained.
[0008] According to one embodiment of this application, when the target sampling parameter is a positive integer, the target sampling parameter is a linear combination of the sampling parameters of each of the target basic sampling units with the number of target basic sampling units as the coefficient, and the length of the second uniform random bit sequence input is twice the product of the number of target samples and the target sampling parameter.
[0009] According to one embodiment of this application, obtaining the first sampling result based on each of the second sampling results includes: The sum of each of the second sampling results is obtained and used as the first sampling result.
[0010] According to one embodiment of this application, determining the target basic sampling unit and the number of each target basic sampling unit based on the target sampling parameters and the set of sampling parameters of existing basic sampling units includes: Based on the target sampling parameters and the sampling parameters of each of the basic sampling units, a first linear combination of the sampling parameters of each of the target basic sampling units with the minimum number of sampling parameters is determined, using the number of target basic sampling units as a coefficient. Based on the first linear combination, the target basic sampling unit and the number of each target basic sampling unit are determined.
[0011] According to one embodiment of this application, determining the target basic sampling unit and the number of each target basic sampling unit based on the target sampling parameters and the set of sampling parameters of existing basic sampling units includes: Based on the target sampling parameters and the sampling parameters of each of the basic sampling units, a second linear combination of the sampling parameters of each of the target basic sampling units with the smallest sum of the number of target basic sampling units and the number of target basic sampling units as the coefficient is determined; Based on the second linear combination, the target basic sampling unit and the number of each target basic sampling unit are determined.
[0012] According to one embodiment of this application, when the target sampling parameter is a negative integer power of 2, the sampling parameter of the target basic sampling unit is 1, the number of the target basic sampling units is the logarithm of the reciprocal of the target sampling parameter to the base 2 plus 1, and the length of the second uniform random bit sequence input is twice the product of the number of target samples and the number of target basic sampling units.
[0013] According to one embodiment of this application, obtaining the first sampling result based on each of the second sampling results includes: The product of each of the second sampling results is obtained as the first sampling result.
[0014] According to one embodiment of this application, bits selected from the unselected bits in the first half of the continuous bit subsequence, representing a number equal to the sampling parameters of the target basic sampling unit, and bits selected from the unselected bits in the second half of the continuous bit subsequence, representing a number equal to the sampling parameters of the target basic sampling unit, are concatenated and input into the target basic sampling unit to obtain a second sampling result, including: According to the target method, a number of bits equal to the sampling parameters of the target basic sampling unit are selected from the unselected bits in the first half of the consecutive bit subsequence, and a number of bits equal to the sampling parameters of the target basic sampling unit are selected from the unselected bits in the second half of the consecutive bit subsequence.
[0015] According to one embodiment of this application, the step of selecting a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the first half of the continuous bit subsequence and selecting a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the second half of the continuous bit subsequence, includes any one of the following: Randomly select a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the first half of the continuous bit subsequence, and randomly select a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the second half of the continuous bit subsequence; In order of position, a number of bits equal to the sampling parameters of the target basic sampling unit are selected from the unselected bits in the first half of the consecutive bit subsequence, and in order of position, a number of bits equal to the sampling parameters of the target basic sampling unit are selected from the unselected bits in the second half of the consecutive bit subsequence.
[0016] Secondly, this application provides a sampling device that follows a central binomial distribution, the device comprising: The acquisition module is used to obtain the target sample count and target sampling parameters; A determining module is used to determine the target basic sampling unit and the number of each target basic sampling unit based on the target sampling parameters and the set of sampling parameters of existing basic sampling units; each basic sampling unit is used to sample the first uniform random bit sequence input, and the sampling result is the sum of the first half of the first uniform random bit sequence input minus the sum of the second half of the first uniform random bit sequence input; the length of the first uniform random bit sequence input is twice the sampling parameters of the basic sampling unit; the target basic sampling unit includes at least one of the basic sampling units; The sampling module is used to repeatedly perform the following operations a number of times equal to the target number of samples: for the second uniform random bit sequence input, a continuous bit subsequence input is obtained in a preset order by sampling the target sampling unit composed of each of the target basic sampling units to obtain a first sampling result that follows a central binomial distribution; the second uniform random bit sequence input contains a number of non-overlapping continuous bit subsequences of the same length equal to the target number of samples.
[0017] According to the sampling device following the central binomial distribution of this application, compared with the implementation methods in related technologies that follow the central binomial distribution, such as calculating the two Hamming weights first and then performing subtraction, this device uses a reconfigurable design concept to build a sampling module with large sampling parameters by arranging the data of the input bit sequence (referring to the second uniform random bit sequence input) and calling the basic sampling unit with small sampling parameters. This enables stronger scalability while ensuring the consistency of sampling results, supports multiple sampling parameters, and is applicable to a variety of typical lattice-based cryptographic algorithms.
[0018] Thirdly, this application provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements a sampling method following a central binomial distribution as described in the first aspect above.
[0019] Fourthly, this application provides a non-volatile computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the sampling method following a central binomial distribution as described in the first aspect above.
[0020] Fifthly, this application provides a chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being used to run programs or instructions to implement the sampling method following a central binomial distribution as described in the first aspect.
[0021] In a sixth aspect, this application provides a computer program product, including a computer program that, when executed by a processor, implements the sampling method following a central binomial distribution as described in the first aspect above.
[0022] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0023] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which: Figure 1This is one of the flowcharts illustrating a sampling method following a central binomial distribution provided in an embodiment of this application; Figure 2 This is the second flowchart illustrating a sampling method following a central binomial distribution provided in an embodiment of this application. Figure 3 This is the third flowchart illustrating the sampling method following a central binomial distribution provided in the embodiments of this application; Figure 4 This is a schematic diagram of the structure of a sampling device that follows a central binomial distribution, as provided in an embodiment of this application. Figure 5 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0024] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.
[0025] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0026] The following table shows representative lattice-based cryptographic algorithms and their sampling parameters and methods for central binomial distribution sampling.
[0027] Table 1. Summary of typical lattice-based cryptographic algorithms involving CBD sampling
[0028] Although the sampling involved in the above-mentioned lattice-based cryptography algorithms all satisfy the central binomial distribution, the specific sampling methods that follow the central binomial distribution used by each algorithm are slightly different.
[0029] Method (1) in Table 1 is the Hamming weight difference method for consecutive bit subsequences. The basic steps of the Hamming weight difference method for consecutive bit subsequences include: for a given bit sequence, take bits of length 1... For a continuous bit subsequence, calculate the Hamming weights of the first and second halves of the continuous bit subsequence, and subtract the results to obtain the CBD sample value.
[0030] Method (2) in Table 1 is the overall bit sequence segmentation method. In the LAC algorithm, CBD_1 divides the entire bit sequence into two segments. Starting from the least significant bit of each segment, it subtracts the corresponding bits to obtain the CBD sample value. (The Scloud+ algorithm uses a similar method, the difference being that it subtracts the bits at the corresponding positions from the least significant bit of each segment.) After subtracting the bits, sum the results to obtain the CBD sample value); CBD_1 / 2 divides the entire bit sequence into four segments. Starting from the least significant bit of each segment, subtract the corresponding bits of the first and second segments, subtract the corresponding bits of the third and fourth segments, and then multiply the two results to obtain the CBD sample value.
[0031] Method (3) in Table 1 is the Hamming weight shift method for consecutive bit subsequences. The basic steps of the Hamming weight shift method for consecutive bit subsequences include: for a given bit sequence, take bits of length 10 ... Given a continuous bit subsequence, calculate the Hamming weight of the continuous bit subsequence and subtract the offset. The CBD sample value is obtained.
[0032] Sampling method (2) requires waiting for the random bit sequence to be completely generated before CBD sampling can begin. In contrast, methods (1) and (3) are more hardware-friendly and can be used with a random number generator to complete CBD sampling in a shorter number of clock cycles.
[0033] In addition, for CBD_ Given a uniform random bit sequence, all three methods can generate sampled values that satisfy the central binomial distribution, but the sampled results obtained by different methods may be different. For the standard algorithm ML-KEM, sampling methods (2) and (3) in Table 1 cannot guarantee the "sampling result consistency" with method (1) ("sampling result consistency" means that the same CBD sampled values are obtained under the same input random bit sequence), which will cause problems in algorithm correctness verification and algorithm consistency.
[0034] The sampling method, sampling device, electronic device, and readable storage medium following the central binomial distribution provided in this application will be described in detail below with reference to the accompanying drawings and through specific embodiments and application scenarios.
[0035] Among them, the sampling method that follows the central binomial distribution can be applied to the terminal, specifically by the hardware or software in the terminal.
[0036] The sampling method following a central binomial distribution provided in this application embodiment can be executed by an electronic device or a functional module or entity within an electronic device that can implement the sampling method following a central binomial distribution. The electronic devices mentioned in this application embodiment include, but are not limited to, mobile phones, tablets, computers, cameras, and wearable devices. The sampling method following a central binomial distribution provided in this application embodiment will be described below using an electronic device as the execution subject as an example.
[0037] like Figure 1 As shown, the sampling method that follows a central binomial distribution includes steps 110, 120, and 130.
[0038] Step 110: Obtain the target number of samples and the target sampling parameters.
[0039] In actual execution, the target number of samples can be obtained by receiving input. and target sampling parameters Among them, the number of target samples The target sampling parameter is a positive integer. It can be a positive integer or a negative power of 2.
[0040] Step 120: Based on the target sampling parameters and the set of sampling parameters of existing basic sampling units, determine the target basic sampling units and the number of each target basic sampling unit; each basic sampling unit is used to sample the first uniform random bit sequence input, and the sampling result is the sum of the first half of the first uniform random bit sequence input minus the sum of the second half of the first uniform random bit sequence input; the length of the first uniform random bit sequence input is twice the sampling parameters of the basic sampling unit; the target basic sampling unit includes at least one basic sampling unit.
[0041] In actual implementation, there is already a set of sampling parameters for the basic sampling unit. It can include sampling parameters from existing basic sampling units. The number of existing basic sampling units can be at least one. Each basic sampling unit can be used for sampling following a central binomial distribution, with sampling parameters as follows: The basic sampling unit can be denoted as the basic sampling unit CBD_ .
[0042] In some embodiments, the basic sampling unit CBD_ In the input bit sequence is In this case, the output result is .
[0043] It should be noted that the above bit sequence This is the first uniformly random bit sequence input. A uniformly random bit sequence input refers to an input sequence consisting of independent, unbiased 0 and 1 bits, where each bit has a strictly 50% probability of being 0 or 1, and the values of all bits are independent of each other. It is the core auxiliary input source for random algorithms in computer science.
[0044] In some embodiments, it can be based on target sampling parameters Determine the set of sampling parameters for the basic sampling unit. Which one or more of the basic sampling units can be used to form the sampling parameters as the target sampling parameters? Target sampling unit CBD_ And the number of basic sampling units for each target.
[0045] In some embodiments, in the target sampling parameters When the value is a positive integer, the target sampling parameter Can be derived from a set The sampling parameters of the basic sampling unit are obtained by linear combination, for example .
[0046] Step 130: Repeat the following operation for the target number of samples: For the second uniform random bit sequence input, obtain a continuous bit subsequence input in a preset order. The target sampling unit composed of each target basic sampling unit is sampled to obtain a first sampling result that follows a central binomial distribution. The second uniform random bit sequence input contains a continuous bit subsequence of the same length that is non-overlapping and has the same number of samples as the target number of samples.
[0047] In actual implementation, a second uniform random bit sequence can be input, and consecutive bit subsequences can be selected in a preset order as reconfigurable target sampling units (CBD_). The input, target sampling unit CBD_ Internally, each target basic sampling unit can sample a continuous bit subsequence to generate a corresponding CBD sampling result, which is the first sampling result. The above steps are repeated until the output is reached. The first sampling result. (The above) The first sampling result is the required CBD sample value, i.e., the target number of samples. and target sampling parameters The corresponding sampling results follow a central binomial distribution.
[0048] In some embodiments, the second uniform random bit sequence can be divided into n consecutive bit subsequences, each of which has a length that is one-nth of the length of the input second uniform random bit sequence, and no two consecutive bit subsequences overlap. Here, n is the target sampling number.
[0049] In some embodiments, the preset order can be the ascending order, the descending order, or other order (e.g., odd numbers first, even numbers second, or random, etc.) according to the position of the consecutive bit subsequences in the second uniform random bit sequence.
[0050] The sampling method following the central binomial distribution provided in the embodiments of this application, compared with the implementation methods in related technologies that follow the central binomial distribution, such as calculating the two Hamming weights first and then subtracting, uses a reconfigurable design concept to build a sampling module with large sampling parameters by arranging the data of the input bit sequence (referring to the second uniform random bit sequence input) and calling the basic sampling unit with small sampling parameters. This can achieve stronger scalability while ensuring the consistency of sampling results, support multiple sampling parameters, and be applicable to a variety of typical lattice-based cryptographic algorithms.
[0051] In some embodiments of this application, a continuous bit subsequence is obtained in a preset order and input into a target sampling unit composed of each target basic sampling unit for sampling, to obtain a first sampling result that follows a central binomial distribution. This includes: sequentially performing the following operations for each target basic sampling unit: selecting bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the first half of the continuous bit subsequence and selecting bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the second half of the continuous bit subsequence, concatenating them, and inputting them into the target basic sampling unit to obtain a second sampling result.
[0052] In actual execution, the second uniform random bit sequence is used as the input. For example, the length can be obtained sequentially according to a preset order. A continuous subsequence of bits. Each of the subsequences has a length of... The continuous bit subsequence input is sampled by the target sampling unit composed of each target basic sampling unit, and a first sampling result following a central binomial distribution can be obtained for each. Therefore, each length of... The continuous bit subsequence is input to the target sampling unit CBD_ By sampling, we can obtain The first sampling result. Where n is the target number of samples; m is a positive integer.
[0053] In some embodiments, in the target sampling parameters When the integer is positive, give a length of The continuous bit subsequence input is sampled by target sampling units composed of target basic sampling units, which may include: sequentially performing a sampling operation for each target basic sampling unit, repeating the sampling operation a number of times equal to the number of target basic sampling units. For example, target sampling parameters , If the target basic sampling unit consists of one basic sampling unit with a sampling parameter of 1 and three basic sampling units with a sampling parameter of 3, then inputting a continuous bit subsequence into the target sampling unit composed of these target basic sampling units for sampling can include: the basic sampling unit with a sampling parameter of 1 performing one sampling operation and the basic sampling unit with a sampling parameter of 3 performing three sampling operations. For example, the target sampling parameter... , If the target basic sampling unit consists of two basic sampling units with a sampling parameter of 2, then inputting a continuous bit subsequence into the target sampling unit composed of each target basic sampling unit for sampling can include: the basic sampling unit with a sampling parameter of 2 performing two sampling operations.
[0054] It should be noted that the order in which the sampling operations are performed by each target basic sampling unit is not specifically limited in the embodiments of this application. For example, in the case where the basic sampling unit with sampling parameter 1 performs one sampling operation and the basic sampling unit with sampling parameter 3 performs three sampling operations, the basic sampling unit with sampling parameter 1 can first perform one sampling operation, and then the basic sampling unit with sampling parameter 3 can perform three sampling operations; or the basic sampling unit with sampling parameter 3 can first perform three sampling operations, and then the basic sampling unit with sampling parameter 1 can perform one sampling operation; or the basic sampling unit with sampling parameter 3 can first perform one or two sampling operations, then the basic sampling unit with sampling parameter 1 can perform one sampling operation, and then the basic sampling unit with sampling parameter 3 can perform the remaining two or one sampling operations.
[0055] In some embodiments, a sampling parameter is The basic sampling unit performing the above sampling operation may include: taking the first bit from a continuous bit subsequence Bit and after Take each bit Bits at different positions ( (Bits at different positions can be consecutive or non-consecutive) are concatenated together to form the sampling parameter. Basic sampling unit CBD_ The input is used to obtain the basic sampling unit CBD_. The second sampling result output this time.
[0056] It should be noted that any two target basic sampling units are derived from the first two bits of a continuous bit subsequence. Bit and after Take each bit Each bit at a different position is different, and in each repeated sampling operation of the target basic sampling unit, the first bit in the continuous bit subsequence is selected. Bit and after Take each bit Each bit at a different position is different, therefore for a length of The continuous bit subsequences are input into each target basic sampling unit, which makes full use of all the bits in all the continuous bit subsequences.
[0057] Based on each second sampling result, the first sampling result is obtained.
[0058] In actual execution, based on the target sampling parameters If the value is a positive integer or a negative power of 2, it can be used to perform accumulation or multiplication operations on each second sampling result to obtain a first sampling result.
[0059] In some embodiments, a continuous bit subsequence is obtained in a preset order and sampled by a target sampling unit composed of each target basic sampling unit to obtain a first sampling result that follows a central binomial distribution. This may include the following steps.
[0060] The first step is to obtain the target number of samples. The vector formed by the sampling parameters of each target basic sampling unit ; All are positive integers and Any two of them can be equal or unequal.
[0061] The second step is to consider the length as... A uniform random bit input (referring to a continuous subsequence of bits) can be processed according to a vector. Perform data arrangement: For i ranging from 0 to k-1, start from the first... Bit and after Take each bit Bits at different positions are concatenated together to form the subsequent basic sampling unit CBD_ The input is selected with no repetition of bit positions throughout the entire data arrangement process, and all bits are used exactly. Bit data. In some embodiments, refer to Figure 2 A simple data arrangement method is the one that was previously... Bit and after Select consecutive bits in sequence Bit concatenation.
[0062] The third step is to call... Each basic sampling unit performs a sampling operation to generate the corresponding... The second sampling result.
[0063] The fourth step is to analyze the target sampling parameters. If the integer is a positive integer or a negative power of 2, you can perform accumulation or multiplication operations on each second sample result, and output the result as a CBD_. The sampling result, i.e., the first sampling result.
[0064] The sampling method following the central binomial distribution provided in the embodiments of this application, compared with the implementation methods in related technologies that follow the central binomial distribution, such as calculating the two Hamming weights first and then subtracting, uses a reconfigurable design concept to build a sampling module with large sampling parameters by arranging the data of the input bit sequence (referring to the second uniform random bit sequence input) and calling the basic sampling unit with small sampling parameters. This can achieve stronger scalability while ensuring the consistency of sampling results, support multiple sampling parameters, and be applicable to a variety of typical lattice-based cryptographic algorithms.
[0065] In some embodiments of this application, when the target sampling parameter is a positive integer, the target sampling parameter is a linear combination of the sampling parameters of each target basic sampling unit with the number of target basic sampling units as the coefficient, and the length of the second uniform random bit sequence input is twice the product of the number of target samples and the target sampling parameter.
[0066] In actual implementation, target sampling parameters It can be a positive integer. In the target sampling parameters When the values are positive integers, the number of target basic sampling units and the sampling parameters satisfy the following conditions: target sampling parameters It is a linear combination of the sampling parameters of each target basic sampling unit, with the number of target basic sampling units as the coefficient.
[0067] For example, target sampling parameters Given 7, 7 = 1 × 1 + 3 × 2, the target basic sampling unit can be one basic sampling unit with a sampling parameter of 1 and three basic sampling units with a sampling parameter of 2, or the target basic sampling unit can be one basic sampling unit with a sampling parameter of 1 and two basic sampling units with a sampling parameter of 3. For example, the target sampling parameter... If the value is 9, then 9 = 3 × 3 = 1 × 1 + 2 × 4. Therefore, the target basic sampling unit can be 3 basic sampling units with a sampling parameter of 3, or the target basic sampling unit can be 1 basic sampling unit with a sampling parameter of 1 and 4 basic sampling units with a sampling parameter of 2.
[0068] Accordingly, the length of the second uniform random bit sequence input is The length of the consecutive bit subsequence is .
[0069] The sampling method following the central binomial distribution provided in the embodiments of this application, compared with the implementation methods in related technologies that follow the central binomial distribution, such as calculating the two Hamming weights first and then subtracting, uses a reconfigurable design concept to build a sampling module with large sampling parameters by arranging the data of the input bit sequence (referring to the second uniform random bit sequence input) and calling the basic sampling unit with small sampling parameters. This can achieve stronger scalability while ensuring the consistency of sampling results, support multiple sampling parameters, and be applicable to a variety of typical lattice-based cryptographic algorithms.
[0070] In some embodiments of this application, obtaining a first sampling result based on each second sampling result includes: obtaining the sum of each second sampling result as the first sampling result.
[0071] In actual execution, the target sampling parameters When the result is a positive integer, an accumulation operation can be performed on each second sampling result to obtain the sum of each second sampling result as a first sampling result.
[0072] In some embodiments, the target sampling parameters For positive integers, step 130 can be implemented using the following pseudocode. Where B[x:y] indicates that the bit sequence B is a continuous bit subsequence with the starting position at x and the ending position at y-1.
[0073] n-CBD_ : Input: Length is A uniform random bit sequence B Output: n numbers that obey the parameters as follows Data from the central binomial distribution for i from 0 to n-1 do f[i] = CBD_ (B[2i : 2i +2 ]) end for.
[0074] In some embodiments, the reconfigurable sampling unit CBD_ satisfies the requirements of the second step described above. The sampling operation can be performed using the following pseudocode.
[0075] CBD_ : Input: Length is a uniform random bit sequence b Output: A function that obeys the parameter . Data from the central binomial distribution f for j from 0 to k-1 do X[j] = CBD_ (b[ : ] || b[ + : + ]) end for f= .
[0076] in, This is used to determine the segmentation position of consecutive bit subsequences in this data arrangement method.
[0077] In some embodiments, the reconfigurable sampling unit CBD_ A diagram illustrating the working process can be found here. Figure 2 After data arrangement, small-parameter CBD sampling, and result summation, the parameters that satisfy the condition can be obtained. CBD sampled values (target sampling parameters) (The case where it is a positive integer).
[0078] The sampling method following the central binomial distribution provided in the embodiments of this application, compared with the implementation methods in related technologies that follow the central binomial distribution, such as calculating the two Hamming weights first and then subtracting, uses a reconfigurable design concept to build a sampling module with large sampling parameters by arranging the data of the input bit sequence (referring to the second uniform random bit sequence input) and calling the basic sampling unit with small sampling parameters. This can achieve stronger scalability while ensuring the consistency of sampling results, support multiple sampling parameters, and be applicable to a variety of typical lattice-based cryptographic algorithms.
[0079] In some embodiments of this application, determining the target basic sampling unit and the number of each target basic sampling unit based on the target sampling parameters and the set of sampling parameters of existing basic sampling units includes: determining a first linear combination of the sampling parameters of each target basic sampling unit that has the fewest sampling parameters and is denoted by the number of target basic sampling units as a coefficient, based on the target sampling parameters and the sampling parameters of each basic sampling unit.
[0080] In actual execution, the target sampling parameters When the value is a positive integer, the target sampling parameter Sampling parameters of the basic sampling unit The linear combination can take many forms, meaning there are multiple linear combinations of the sampling parameters of each target basic sampling unit, with the number of target basic sampling units as the coefficient. From these multiple linear combinations, the one with the fewest sampling parameters of the target basic sampling units can be selected as the first linear combination.
[0081] In some embodiments, if the number of linear combinations with the fewest number of sampling parameters of the target basic sampling unit is greater than or equal to 2, any one of them can be selected as the first linear combination, or one can be determined as the first linear combination by combining other criteria (such as minimizing the total number of all target basic sampling units).
[0082] For example, target sampling parameters Given 4, 4 = 1 + 3 = 2 + 2 = 1 + 1 + 1 + 1 = 1 + 1 + 2, various linear combinations can be denoted as vectors (1, 3), (2, 2), (1, 1, 1, 1), and (1, 1, 2), respectively. The number of sampling parameters of the basic sampling unit is 2, 1, 1, and 2, respectively. The minimum number of sampling parameters of the target basic sampling unit is 1. The linear combination represented by vector (1, 3) or (2, 2) can be selected as the first linear combination, or the linear combination represented by vector (2, 2) can be selected as the first linear combination based on the criterion of minimizing the total number of target basic sampling units.
[0083] Based on the first linear combination, the target basic sampling unit and the number of each target basic sampling unit are determined.
[0084] In actual implementation, the target basic sampling units and the number of each target basic sampling unit can be determined based on the first linear combination. For example, for the first linear combination corresponding to the aforementioned vector (2,2), the target basic sampling units are two basic sampling units with a sampling parameter of 2; for the first linear combination corresponding to the aforementioned vector (1,3), the target basic sampling units are one basic sampling unit with a sampling parameter of 1 and one basic sampling unit with a sampling parameter of 3.
[0085] The sampling method following the central binomial distribution provided in the embodiments of this application, compared with the implementation methods in related technologies that follow the central binomial distribution, such as calculating the two Hamming weights first and then subtracting, uses a reconfigurable design concept to build a sampling module with large sampling parameters by arranging the data of the input bit sequence (referring to the second uniform random bit sequence input) and calling the basic sampling unit with small sampling parameters. This can achieve stronger scalability while ensuring the consistency of sampling results, support multiple sampling parameters, and be applicable to a variety of typical lattice-based cryptographic algorithms.
[0086] In some embodiments of this application, determining the target basic sampling unit and the number of each target basic sampling unit based on the target sampling parameters and the set of sampling parameters of existing basic sampling units includes: determining a second linear combination of the sampling parameters of each target basic sampling unit that minimizes the total number of each target basic sampling unit and uses the number of target basic sampling units as a coefficient, based on the target sampling parameters and the sampling parameters of each basic sampling unit.
[0087] In actual execution, the target sampling parameters When the value is a positive integer, the target sampling parameter Sampling parameters of the basic sampling unit The linear combination can take many forms, meaning there are multiple linear combinations of the sampling parameters of each target basic sampling unit, with the number of target basic sampling units as the coefficient. From these multiple linear combinations, the one with the smallest sum of the number of target basic sampling units can be selected as the second linear combination.
[0088] In some embodiments, if the number of linear combinations with the smallest sum of the number of target basic sampling units is greater than or equal to 2, any one of them can be selected as the second linear combination, or one can be determined as the second linear combination by combining other criteria (such as the minimum number of sampling parameters of the target basic sampling units).
[0089] For example, target sampling parameters Given 4, 4 = 1 + 3 = 2 + 2 = 1 + 1 + 1 + 1 = 1 + 1 + 2, various linear combinations can be denoted as vectors (1, 3), (2, 2), (1, 1, 1, 1), and (1, 1, 2), respectively. The total number of each target basic sampling unit is 2, 1, 4, and 3, respectively. The minimum total number of each target basic sampling unit is 2. The linear combination represented by vector (1, 3) or (2, 2) can be selected as the second linear combination. Alternatively, the linear combination represented by vector (2, 2) can be selected as the second linear combination, based on the criterion of having the fewest sampling parameters of the target basic sampling unit.
[0090] Based on the second linear combination, the target basic sampling unit and the number of each target basic sampling unit are determined.
[0091] In actual implementation, the target basic sampling units and the number of each target basic sampling unit can be determined based on the second linear combination. For example, for the second linear combination corresponding to the aforementioned vector (2,2), the target basic sampling units are two basic sampling units with a sampling parameter of 2; for the second linear combination corresponding to the aforementioned vector (1,3), the target basic sampling units are one basic sampling unit with a sampling parameter of 1 and one basic sampling unit with a sampling parameter of 3.
[0092] The sampling method following the central binomial distribution provided in the embodiments of this application, compared with the implementation methods in related technologies that follow the central binomial distribution, such as calculating the two Hamming weights first and then subtracting, uses a reconfigurable design concept to build a sampling module with large sampling parameters by arranging the data of the input bit sequence (referring to the second uniform random bit sequence input) and calling the basic sampling unit with small sampling parameters. This can achieve stronger scalability while ensuring the consistency of sampling results, support multiple sampling parameters, and be applicable to a variety of typical lattice-based cryptographic algorithms.
[0093] In some embodiments of this application, bits selected from the unselected bits in the first half of a continuous bit subsequence, equal to the number of sampling parameters of the target basic sampling unit, and bits selected from the unselected bits in the second half of the continuous bit subsequence, equal to the number of sampling parameters of the target basic sampling unit, are concatenated and input into the target basic sampling unit to obtain a second sampling result. This includes selecting bits from the unselected bits in the first half of a continuous bit subsequence, equal to the number of sampling parameters of the target basic sampling unit, and selecting bits from the unselected bits in the second half of a continuous bit subsequence, equal to the number of sampling parameters of the target basic sampling unit, according to the target method.
[0094] In actual implementation, in some embodiments (target sampling parameters) In the range of positive integers, for the basic sampling unit CBD_ Data can be arranged according to the target method, that is, from the previous Bits selected according to the target method 1 bit and from after Bits selected according to the target method 1 bit, then concatenate them to satisfy the condition that all basic sampling units are used up 2 bits. The requirement is simply the number of bits.
[0095] The embodiments of this application do not limit the target method. For example, the target method can be random selection, sequential selection, or selection at fixed intervals.
[0096] The sampling method following the central binomial distribution provided in the embodiments of this application, compared with the implementation methods in related technologies that follow the central binomial distribution, such as calculating the two Hamming weights first and then subtracting, uses a reconfigurable design concept to build a sampling module with large sampling parameters by arranging the data of the input bit sequence (referring to the second uniform random bit sequence input) and calling the basic sampling unit with small sampling parameters. This can achieve stronger scalability while ensuring the consistency of sampling results, support multiple sampling parameters, and be applicable to a variety of typical lattice-based cryptographic algorithms.
[0097] In some embodiments of this application, selecting a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the first half of a consecutive bit subsequence and selecting a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the second half of a consecutive bit subsequence, according to the target method, includes any one of the following: Randomly select a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the first half of the continuous bit subsequence, and randomly select a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the second half of the continuous bit subsequence; In order of position, select a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the first half of the consecutive bit subsequence, and in order of position, select a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the second half of the consecutive bit subsequence.
[0098] In actual execution, the target sampling parameters When CBD_ is a positive integer, for the basic sampling unit CBD_ ,refer to Figure 2 A simple data arrangement method is the one that was previously... Bit and after consecutive bits are selected sequentially according to their positions. Bit concatenation. For example, when the basic sampling unit consists of one basic sampling unit with a sampling parameter of 1 and multiple basic sampling units with a sampling parameter of 3, for the basic sampling unit with a sampling parameter of 1, it can be concatenated from the first... Select the first bit from the bits and start from the last bit. Select the first bit from the bits (B[0] and B[... Then concatenate; for the first basic sampling unit with a sampling parameter of 3, it can be started from the previous... Select the 2nd to 4th bits from the last bit and start from the last bit. Select bits 2 to 4 from the bits (B[1:4] and B[... ]), and then splice; for the second basic sampling unit with a sampling parameter of 3, it can be started from the previous Select bits 5 through 7 from the last bit and then... Select the 5th to 7th bits from the set of bits (B[4:7] and B[). Then assemble them; and so on, until all 2 are used up. Bit.
[0099] In some embodiments, for the basic sampling unit CBD_ Alternatively, data can be arranged in a random manner, that is, from the previous... Random selection from bits 1 bit and from after Random selection from bits Each bit is then concatenated to ensure that all basic sampling units are used without repetition. The requirement is simply the number of bits.
[0100] The sampling method following the central binomial distribution provided in the embodiments of this application, compared with the implementation methods in related technologies that follow the central binomial distribution, such as calculating the two Hamming weights first and then subtracting, uses a reconfigurable design concept to build a sampling module with large sampling parameters by arranging the data of the input bit sequence (referring to the second uniform random bit sequence input) and calling the basic sampling unit with small sampling parameters. This can achieve stronger scalability while ensuring the consistency of sampling results, support multiple sampling parameters, and be applicable to a variety of typical lattice-based cryptographic algorithms.
[0101] In some embodiments of this application, when the target sampling parameter is a negative integer power of 2, the sampling parameter of the target basic sampling unit is 1, the number of target basic sampling units is the logarithm of the reciprocal of the target sampling parameter to the base 2 plus 1, and the length of the second uniform random bit sequence input is twice the product of the number of target samples and the number of target basic sampling units.
[0102] In actual execution, the target sampling parameters It can be a negative integer power of 2. This applies to the target sampling parameters involved in the LAC algorithm. In cases where the value is less than 1, the aforementioned embodiments of this application can be extended to generate samples that meet the conditions.
[0103] In target sampling parameters When the value is a negative power of 2, the sampling parameter of the target basic sampling unit is 1, and the number of target basic sampling units is the logarithm of the reciprocal of the target sampling parameter to the base 2 plus 1. That is, in ( In the case of ), the sampling parameter of the target basic sampling unit is 1, and the target basic sampling unit CBD_ The quantity is .
[0104] For example, target sampling parameters If the value is 1 / 2, then the target basic sampling unit can be two basic sampling units with a sampling parameter of 1; target sampling parameter If the value is 1 / 4, then the target basic sampling unit can be three basic sampling units with a sampling parameter of 1; target sampling parameter If the value is 1 / 8, then the target basic sampling unit can be 4 basic sampling units with a sampling parameter of 1.
[0105] Accordingly, the length of the second uniform random bit sequence input is The length of the consecutive bit subsequence is .
[0106] In target sampling parameters When it is a negative power of 2, ( The basic sampling unit is Each basic sampling unit has a sampling parameter of 1, and the data arrangement method can be from the previous... Select the first bit from the bits and start from the last bit. Select the first bit from the bits (B[0] and B[... Then concatenate; for the second basic sampling unit with a sampling parameter of 1, it can be started from the previous... Select the second bit from the bits and start from the last bit. Select the second bit from the bits (B[1] and B[ ]). Then concatenate; for the third basic sampling unit with a sampling parameter of 1, it can be started from the previous... Select the 3rd bit from the bits and start from the end. Select the 3rd bit from the bits (B[2] and B[ ) Then assemble them; and so on, until all 2 are used up. Bit.
[0107] The sampling method following the central binomial distribution provided in the embodiments of this application, compared with the overall bit sequence segmentation processing method in the sampling scheme following the central binomial distribution in related technologies, uses a reconfigurable design concept to build a sampling module with a sampling parameter of a negative integer power of 2 by arranging the data of the input bit sequence (referring to the second uniform random bit sequence input) and calling the basic sampling unit with a sampling parameter of 1. This can achieve stronger scalability while ensuring the consistency of the sampling results, support multiple sampling parameters, and be applicable to a variety of typical lattice-based cryptographic algorithms.
[0108] In some embodiments of this application, obtaining a first sampling result based on each second sampling result includes: obtaining the product of each second sampling result as the first sampling result.
[0109] In actual execution, the target sampling parameters When the result is a negative power of 2, a multiplication operation can be performed on each second sampling result to obtain the product of the second sampling results as a first sampling result.
[0110] In some embodiments, the reconfigurable sampling unit CBD_ based on CBD_1 can be used as the basic sampling unit. By changing the final summation operation in the sampling operation to a product operation, the parameters that are satisfied can be generated. CBD sampling ( ).
[0111] In some embodiments, n CBD_ are generated Sampling can be implemented using the following pseudocode.
[0112] n-CBD_ : Input: A uniform random bit sequence B of length 2n(a+1) Output: n parameters Data from the central binomial distribution for i from 0 to n-1 do f[i] = CBD_ (B[2i(a+1): 2i(a+1)+2(a+1)]) end for.
[0113] Among them, the call generates CBD_ Sampling can be implemented using the following pseudocode.
[0114] CBD_ : Input: A uniform random bit sequence B of length 2(a+1) Output: A function that obeys the parameter . Data from the central binomial distribution f for j from 0 to a do X[j] = CBD_1(B[j],B[k+1+j]) end for f = .
[0115] The sampling method following the central binomial distribution provided in the embodiments of this application, compared with the overall bit sequence segmentation processing method in the sampling scheme following the central binomial distribution in related technologies, uses a reconfigurable design concept to build a sampling module with a sampling parameter of a negative integer power of 2 by arranging the data of the input bit sequence (referring to the second uniform random bit sequence input) and calling the basic sampling unit with a sampling parameter of 1. This can achieve stronger scalability while ensuring the consistency of the sampling results, support multiple sampling parameters, and be applicable to a variety of typical lattice-based cryptographic algorithms.
[0116] To facilitate understanding of the above embodiments of this application, the implementation process of the sampling method that follows a central binomial distribution will be described below with reference to several implementation examples.
[0117] Implementation Example 1: The basic sampling unit is CBD_1, and the sampling parameter set of the basic sampling unit is already available. .
[0118] It is easy to see that the basic sampling unit satisfies all constraints: any positive integer parameter can be The result is obtained by adding the 1s together; CBD_1 is obtained when the input bit sequence is When, the output result is .
[0119] Accordingly, The process of sampling each basic sampling unit CBD_1 according to a central binomial distribution can be found in [reference]. Figure 3 Reconfigurable CBD sampling can be implemented using the following pseudocode.
[0120] CBD_ : Input: Length is a uniform random bit sequence b Output: A function that obeys the parameter . Data from the central binomial distribution f for j from 0 to -1 do X[j] = CBD_1(b[j],b[ +j]) end for f= .
[0121] It should be noted that the above scheme can generate samples with arbitrary sampling parameters following a central binomial distribution from the basic sampling unit CBD_1. Common target sampling parameters are listed below. Within the range of values ( The vector consisting of the sampling parameters of each target basic sampling unit (covering all positive integer sampling parameters in Table 1). .
[0122] Table 2 Common Vector within the range of values ( )
[0123] Implementation Example 2: The basic sampling units include basic sampling unit CBD_1, basic sampling unit CBD_2, and basic sampling unit CBD_3, and the sampling parameter set of the existing basic sampling units is provided. .
[0124] It should be noted that the basic sampling unit CBD_2 and the basic sampling unit CBD_3 satisfy the following constraints: Basic sampling unit CBD_ In the input bit sequence is In this case, the output result is The constraints of the basic sampling units CBD_2 and CBD_3 can be satisfied by the method (1) in Table 1 (i.e., the Hamming weight difference method before and after the continuous bit subsequence), or by the method in the aforementioned implementation example 1, i.e., each contains 2 and 3 basic sampling units CBD_1 respectively.
[0125] It should be noted that the above scheme can achieve sampling with arbitrary sampling parameters following a central binomial distribution, which can also be generated by the basic sampling units CBD_1, CBD_2, and CBD_3. Common target sampling parameters are listed below. Within the range of values ( The vector consisting of the sampling parameters of each target basic sampling unit (covering all positive integer sampling parameters in Table 1). .
[0126] It should be noted that the target sampling parameters are obtained by combining sampling parameters 1, 2, and 3. There are multiple possible combinations. Table 3 only lists the combinations involving the fewest different sampling parameters of the basic sampling unit. Under the same conditions, the combination with the shortest vector length is selected. In this case, depending on the specific implementation, other parameter vectors that meet the conditions can also be selected.
[0127] Table 3 Common Vector within the range of values ( )
[0128] As can be seen from Implementation Example 2, with the existing ML-KEM implementation (i.e., CBD_2 and CBD_3 have been implemented), only CBD_1 needs to be added to cover the central binomial distribution sampling of all positive integer sampling parameters in Table 1 by the reconfigurable sampling implementation of the central binomial distribution in this application.
[0129] It should be noted that for cases where the target sampling parameter is a positive integer, the necessary parameters can be obtained first for subsequent calculations. These necessary parameters may include the number of target samples. Target sampling parameters and the set of sampling parameters of existing basic sampling units Constraints "It can be guaranteed that the required parameters can be constructed from existing CBD sampling parameters with small sampling parameters." CBD sampling; constraint condition "basic sampling unit CBD_ In the input bit sequence is In this case, the output result is "And data arrangement can ensure the consistency of sampling results."
[0130] It should be noted that, for the case where the target sampling parameter is a positive integer, the key point of this application's embodiments includes the target sampling parameter... Requirements, i.e., constraints "; Step 130's three-stage CBD reconstruction method of "data arrangement + CBD sampling with small sampling parameters + summation"; constraint condition "basic sampling unit CBD_ In the input bit sequence is In this case, the output result is "and data arrangement requirements."
[0131] This application also provides a sampling device that follows a central binomial distribution. For example... Figure 4 As shown, the sampling device that follows a central binomial distribution includes: an acquisition module 410, a determination module 420, and a sampling module 430; The acquisition module 410 is used to acquire the target sample count and target sampling parameters; The determining module 420 is used to determine the target basic sampling unit and the number of each target basic sampling unit based on the target sampling parameters and the sampling parameter set of the existing basic sampling units; each basic sampling unit is used to sample the first uniform random bit sequence input, and the sampling result is the sum of the first half of the first uniform random bit sequence input minus the sum of the second half of the first uniform random bit sequence input; the length of the first uniform random bit sequence input is twice the sampling parameters of the basic sampling unit; the target basic sampling unit includes at least one basic sampling unit; The sampling module 430 is used to repeatedly perform the following operations for the target number of samples: for the second uniform random bit sequence input, a continuous bit subsequence input is obtained in a preset order by sampling the target sampling unit composed of each target basic sampling unit to obtain a first sampling result that follows a central binomial distribution; the second uniform random bit sequence input contains a continuous bit subsequence of the same length that is non-overlapping and has the same number of samples as the target number of samples.
[0132] The sampling device following the central binomial distribution provided in the embodiments of this application, compared with the implementation methods in related technologies that follow the central binomial distribution, such as calculating the two Hamming weights first and then subtracting, uses a reconfigurable design concept to build a sampling module with large sampling parameters by arranging the data of the input bit sequence (referring to the second uniform random bit sequence input) and calling the basic sampling unit with small sampling parameters. This can achieve stronger scalability while ensuring the consistency of sampling results, support multiple sampling parameters, and be applicable to a variety of typical lattice-based cryptographic algorithms.
[0133] In some embodiments of this application, the sampling module 430 may include: The arrangement and sampling unit is used to perform the following operations sequentially for each target basic sampling unit: selecting a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the first half of the continuous bit subsequence and selecting a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the second half of the continuous bit subsequence, concatenating them and inputting them into the target basic sampling unit to obtain the second sampling result; The acquisition unit is used to acquire the first sampling result based on each second sampling result.
[0134] In some embodiments of this application, when the target sampling parameter is a positive integer, the target sampling parameter is a linear combination of the sampling parameters of each target basic sampling unit with the number of target basic sampling units as the coefficient, and the length of the second uniform random bit sequence input is twice the product of the number of target samples and the target sampling parameter.
[0135] In some embodiments of this application, the acquisition unit may be specifically used to acquire the sum of each second sampling result as the first sampling result.
[0136] In some embodiments of this application, the determining module 420 may be specifically used for: Based on the target sampling parameters and the sampling parameters of each basic sampling unit, determine the first linear combination of the sampling parameters of each target basic sampling unit that has the fewest number of sampling parameters and uses the number of target basic sampling units as a coefficient. Based on the first linear combination, the target basic sampling unit and the number of each target basic sampling unit are determined.
[0137] In some embodiments of this application, the determining module 420 may be specifically used for: Based on the target sampling parameters and the sampling parameters of each basic sampling unit, a second linear combination of the sampling parameters of each target basic sampling unit with the minimum total number of target basic sampling units and the number of target basic sampling units as the coefficient is determined. Based on the second linear combination, the target basic sampling unit and the number of each target basic sampling unit are determined.
[0138] In some embodiments of this application, when the target sampling parameter is a negative integer power of 2, the sampling parameter of the target basic sampling unit is 1, the number of target basic sampling units is the logarithm of the reciprocal of the target sampling parameter to the base 2 plus 1, and the length of the second uniform random bit sequence input is twice the product of the number of target samples and the number of target basic sampling units.
[0139] In some embodiments of this application, the acquisition unit may be specifically used to acquire the product of each second sampling result as the first sampling result.
[0140] In some embodiments of this application, the orchestration and sampling unit may include: The arrangement subunit is used to select, according to the target method, a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the first half of the consecutive bit subsequence and a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the second half of the consecutive bit subsequence.
[0141] In some embodiments of this application, the arrangement subunit may be specifically used for any of the following: Randomly select a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the first half of the continuous bit subsequence, and randomly select a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the second half of the continuous bit subsequence; In order of position, select a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the first half of the consecutive bit subsequence, and in order of position, select a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the second half of the consecutive bit subsequence.
[0142] The sampling device following a central binomial distribution in this application embodiment can be an electronic device or a component within an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television (TV), ATM, or self-service machine, etc. This application embodiment does not specifically limit the scope of the device.
[0143] The sampling device following a central binomial distribution in this application embodiment can be a device with an operating system. This operating system can be a Microsoft (Windows) operating system, an Android operating system, an iOS operating system, or other possible operating systems; this application embodiment does not specifically limit the specific operating system used.
[0144] The sampling device following a central binomial distribution provided in this application embodiment can achieve... Figures 1 to 3 The various processes implemented in the method implementation examples will not be described again here to avoid repetition.
[0145] In some embodiments, such as Figure 5 As shown, this application embodiment also provides an electronic device 500, including a processor 501, a memory 502, and a computer program stored in the memory 502 and executable on the processor 501. When the computer program is executed by the processor 501, it implements the various processes of the above-described sampling method embodiment that follows a central binomial distribution and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0146] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.
[0147] This application also provides a non-volatile computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the above-described sampling method embodiments that follow a central binomial distribution and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0148] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0149] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described sampling method that follows a central binomial distribution.
[0150] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0151] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above-described sampling method embodiment that follows a central binomial distribution, and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0152] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.
[0153] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0154] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the related technology, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0155] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
[0156] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0157] Although embodiments of this application have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of this application, the scope of which is defined by the claims and their equivalents.
Claims
1. A sampling method following a central binomial distribution, characterized in that, include: Obtain the target number of samples, the target sampling parameters, and the set of sampling parameters for the basic sampling unit; Based on the target sampling parameters and the set of sampling parameters of existing basic sampling units, the number of target basic sampling units and the quantity of each target basic sampling unit are determined; each basic sampling unit is used to sample the first uniform random bit sequence input, and the sampling result is the sum of the first half of the first uniform random bit sequence input minus the sum of the second half of the first uniform random bit sequence input; the length of the first uniform random bit sequence input is twice the sampling parameters of the basic sampling unit; the target basic sampling unit includes at least one of the basic sampling units; The following operation is repeated a number of times equal to the target number of samples: For the second uniform random bit sequence input, a continuous bit subsequence input is obtained in a preset order. The target sampling unit, composed of each of the target basic sampling units, is sampled to obtain a first sampling result that follows a central binomial distribution; the second uniform random bit sequence input contains a number of non-overlapping continuous bit subsequences of the same length equal to the target number of samples.
2. The sampling method according to claim 1, which follows a central binomial distribution, is characterized in that, The step of obtaining a continuous bit subsequence input in a preset order and sampling it into a target sampling unit composed of each of the target basic sampling units to obtain a first sampling result that follows a central binomial distribution includes: For each of the target basic sampling units, the following operations are performed sequentially: select a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the first half of the continuous bit subsequence and a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the second half of the continuous bit subsequence, concatenate them, and input them into the target basic sampling unit to obtain the second sampling result; Based on each of the second sampling results, the first sampling result is obtained.
3. The sampling method according to claim 2, which follows a central binomial distribution, is characterized in that, When the target sampling parameter is a positive integer, the target sampling parameter is a linear combination of the sampling parameters of each of the target basic sampling units with the number of target basic sampling units as the coefficient, and the length of the second uniform random bit sequence input is twice the product of the number of target samples and the target sampling parameter.
4. The sampling method according to claim 3, which follows a central binomial distribution, is characterized in that, The step of obtaining the first sampling result based on each of the second sampling results includes: The sum of each of the second sampling results is obtained and used as the first sampling result.
5. The sampling method according to claim 3, which follows a central binomial distribution, is characterized in that, The determination of the target basic sampling unit and the number of each target basic sampling unit based on the target sampling parameters and the set of sampling parameters of existing basic sampling units includes: Based on the target sampling parameters and the sampling parameters of each of the basic sampling units, a first linear combination of the sampling parameters of each of the target basic sampling units with the minimum number of sampling parameters is determined, using the number of target basic sampling units as a coefficient. Based on the first linear combination, the target basic sampling unit and the number of each target basic sampling unit are determined.
6. The sampling method according to claim 3, which follows a central binomial distribution, is characterized in that, The determination of the target basic sampling unit and the number of each target basic sampling unit based on the target sampling parameters and the set of sampling parameters of existing basic sampling units includes: Based on the target sampling parameters and the sampling parameters of each of the basic sampling units, a second linear combination of the sampling parameters of each of the target basic sampling units with the smallest sum of the number of target basic sampling units and the number of target basic sampling units as the coefficient is determined; Based on the second linear combination, the target basic sampling unit and the number of each target basic sampling unit are determined.
7. The sampling method according to claim 2, which follows a central binomial distribution, is characterized in that, When the target sampling parameter is a negative integer power of 2, the sampling parameter of the target basic sampling unit is 1, the number of the target basic sampling units is the logarithm of the reciprocal of the target sampling parameter to the base 2 plus 1, and the length of the second uniform random bit sequence input is twice the product of the number of target samples and the number of target basic sampling units.
8. The sampling method according to claim 7, which follows a central binomial distribution, is characterized in that, The step of obtaining the first sampling result based on each of the second sampling results includes: The product of each of the second sampling results is obtained as the first sampling result.
9. The sampling method according to any one of claims 2 to 8, which follows a central binomial distribution, is characterized in that, A second sampling result is obtained by concatenating bits selected from the unselected bits in the first half of the consecutive bit subsequence (equal to the sampling parameters of the target basic sampling unit) and bits selected from the unselected bits in the second half of the consecutive bit subsequence (equal to the sampling parameters of the target basic sampling unit), and inputting the concatenated bits into the target basic sampling unit. This result includes: According to the target method, a number of bits equal to the sampling parameters of the target basic sampling unit are selected from the unselected bits in the first half of the consecutive bit subsequence, and a number of bits equal to the sampling parameters of the target basic sampling unit are selected from the unselected bits in the second half of the consecutive bit subsequence.
10. The sampling method according to claim 9, which follows a central binomial distribution, is characterized in that, The step of selecting a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the first half of the consecutive bit subsequence and selecting a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the second half of the consecutive bit subsequence, according to the target method, includes any one of the following: Randomly select a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the first half of the continuous bit subsequence, and randomly select a number of bits equal to the sampling parameters of the target basic sampling unit from the unselected bits in the second half of the continuous bit subsequence; In order of position, a number of bits equal to the sampling parameters of the target basic sampling unit are selected from the unselected bits in the first half of the consecutive bit subsequence, and in order of position, a number of bits equal to the sampling parameters of the target basic sampling unit are selected from the unselected bits in the second half of the consecutive bit subsequence.
11. A sampling device that follows a central binomial distribution, characterized in that, include: The acquisition module is used to obtain the target sample count and target sampling parameters; A determining module is used to determine the target basic sampling unit and the number of each target basic sampling unit based on the target sampling parameters and the set of sampling parameters of existing basic sampling units; each basic sampling unit is used to sample the first uniform random bit sequence input, and the sampling result is the sum of the first half of the first uniform random bit sequence input minus the sum of the second half of the first uniform random bit sequence input; the length of the first uniform random bit sequence input is twice the sampling parameters of the basic sampling unit; the target basic sampling unit includes at least one of the basic sampling units; The sampling module is used to repeatedly perform the following operations a number of times equal to the target number of samples: for the second uniform random bit sequence input, sampling is performed by the target sampling unit composed of each of the target basic sampling units in a preset order to obtain a first sampling result that follows a central binomial distribution; the second uniform random bit sequence input contains a number of non-overlapping consecutive bit subsequences of the same length equal to the target number of samples.
12. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the sampling method that follows a central binomial distribution as described in any one of claims 1 to 10.
13. A non-volatile computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the sampling method that follows a central binomial distribution as described in any one of claims 1 to 10.
14. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the sampling method that follows a central binomial distribution as described in any one of claims 1 to 10.