Out-of-order processing method and device of data sequence, chip, storage medium and product

CN121309151BActive Publication Date: 2026-09-22OPEN SECURITY RES INC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511613010.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-04
Publication Date
2026-09-22
Estimated Expiration
2045-11-04

AI Technical Summary

Technical Problem

然而取模运算的效率较低,从而会影响计算设备(如加密芯片)的处理速度

Benefits of technology

[0011]本申请实施例中,能够确保乱序处理的遍历过程按照设计逻辑顺利执行完毕,并限制遍历结束条件为对多个元素中除首个元素之外的所有元素遍历完成,从而能够避免冗余的计算操作。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121309151B_ABST
    Figure CN121309151B_ABST
Patent Text Reader

Abstract

Embodiments of the application disclose a data sequence disorder processing method and device, a chip, a storage medium and a product. The method comprises the following steps: obtaining a normal data sequence which can disorder the password operation sequence; starting from the last element of the data sequence, traversing the plurality of elements from back to front one by one, and when the i-th element corresponding to the current traversal position i is traversed, determining a current random number based on a current bit length; the current bit length is related to the number of elements that have been traversed and the length of the data sequence; the bit length of the current random number is the same as the current bit length; determining a to-be-swapped position j based on the current random number and / or the current traversal position i, and the size relationship between the current random number and the current traversal position i; and based on the current traversal position i and the to-be-swapped position j, swapping the i-th element and the j-th element to obtain a current disorder data sequence. The application can improve the efficiency of disorder processing of the data sequence.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to data processing technology, and more particularly to a method, apparatus, chip, storage medium, and product for processing out-of-order data sequences. Background Technology

[0002] In the process of operating on finite data sequences using cryptographic algorithms, randomizing the data sequence can improve its security and defend against side-channel attacks and fault injection attacks. The Fisher-Yates Shuffle algorithm is commonly used for this purpose. However, executing the Fisher-Yates Shuffle algorithm requires generating a random number for each element in the data sequence and performing a modulo operation on the generated random number. This modulo operation is inefficient, which can impact the processing speed of computing devices (such as encryption chips). Summary of the Invention

[0003] This application provides a method, apparatus, chip, storage medium, and product for out-of-order processing of data sequences, which can improve the efficiency of out-of-order processing of data sequences.

[0004] The technical solution of this application embodiment is implemented as follows: In a first aspect, embodiments of this application provide a method for scrambling a data sequence. The method includes: obtaining a normal data sequence whose cryptographic operation order can be shuffled; wherein the data sequence includes multiple elements; traversing the multiple elements one by one from the last element of the data sequence, and when traversing to the i-th element corresponding to the current traversal position i, determining a current random number based on the current bit length; wherein the current bit length is related to the number of traversed elements and the length of the data sequence, the bit length of the current random number is the same as the current bit length, i is less than or equal to the number of multiple elements, and i is a positive integer; determining a position j to be swapped based on the current random number and / or the current traversal position i, and the size relationship between the current random number and the current traversal position i; wherein j is less than or equal to the number of multiple elements, and j is a positive integer; swapping the i-th element and the j-th element based on the current traversal position i and the position j to be swapped, to obtain the current scrambled data sequence.

[0005] In this embodiment, the current bit length is dynamically adjusted with the number of traversals, thereby controlling the numerical range of the random number based on the current bit length. This achieves randomness in the generation of the random number, and allows the numerical range of the position to be swapped to be constrained to the range of [0, i] based on the current traversal position i and the random number without subsequent modulo operations, thus reducing computational complexity.

[0006] In some implementations, determining the position j to be swapped based on the current random number and / or the current traversal position i, and the relationship between the current random number and the current traversal position i, includes: determining the relationship between the current random number and the current traversal position i; if the current random number is greater than the current traversal position i, determining the position j to be swapped based on the difference between the current random number and the current traversal position i; if the current random number is less than or equal to the current traversal position i, determining the current random number as the position j to be swapped.

[0007] In this embodiment, the position j to be swapped can be determined by performing a simple size comparison between the current random number r and the current traversal position i, and at most by performing a subtraction operation between the current random number r and the current traversal position i, without needing to perform a modulo operation on the current random number r. Since the comparison and subtraction operations can usually be completed within one clock cycle in the hardware logic, while the modulo operation requires multiple cycles, the operation speed of the encryption chip can be improved, and the risk of uneven random number distribution caused by the modulo operation can be avoided, ensuring that the position j to be swapped is uniformly distributed within the range [0, i].

[0008] In some implementations, after swapping the i-th element and the j-th element based on the current traversal position i and the position to be swapped j to obtain the current disordered data sequence, the method further includes: reducing the current first count value by a preset step to obtain a target count value; wherein the current first count value is related to the number of elements traversed and the length of the data sequence; if the target count value is equal to the preset threshold, determining an updated second count value based on the current second count value and a preset multiple; wherein the current second count value is used to determine the number of elements to be traversed before the current bit length is reduced, and the updated second count value is less than the current second count value; determining the updated second count value as the updated first count value; and reducing the current bit length by the preset step to obtain the updated bit length.

[0009] In this embodiment of the application, by setting a first counter value counter and a second counter value counter_const, the bit length bitlen of the random number can be dynamically adjusted at intervals to ensure that the bit length of most of the random numbers r generated in multiple traversals can match the numerical range of the current traversal position i without performing modulo operations; and the update of the first counter value counter and the second counter value counter_const only involves simple subtraction and shifting, thereby saving the computing resources of the encryption chip.

[0010] In some implementations, the method further includes: determining whether all elements except the first element in the plurality of elements have been traversed; if all elements except the first element in the plurality of elements have been traversed, performing scrambling on the data sequence and outputting the current scrambled data sequence; if all elements except the first element in the plurality of elements have not been traversed, continuing to traverse the (i-1)th element in the plurality of elements.

[0011] In this embodiment, it can be ensured that the out-of-order traversal process is executed smoothly according to the design logic, and the traversal termination condition is limited to the completion of traversal of all elements except the first element, thereby avoiding redundant calculation operations.

[0012] In some implementations, determining whether all elements except the first element among the plurality of elements have been traversed includes: determining whether all elements except the first element among the plurality of elements have been traversed if the target count value is not equal to the preset threshold.

[0013] In this embodiment of the application, if the first count value is not equal to the preset threshold, it is sufficient to continue to determine whether the data sequence traversal is complete, without needing to update the parameters, thereby reducing the computational overhead caused by frequent updates.

[0014] In some embodiments, before traversing the plurality of elements one by one from the last element of the data sequence, the method further includes: determining the length of the data sequence; and determining an initial bit length, an initial first count value, and an initial second count value of the data sequence based on the length of the data sequence; wherein the initial first count value and the initial second count value are equal in magnitude.

[0015] In this embodiment, the parameters (bit length, first count value and second count value) are initialized based on the length of the data sequence, which can ensure that the bit length, first count value and second count value can be adapted to the length of the data sequence during the traversal process.

[0016] Secondly, embodiments of this application provide a data sequence scrambling processing apparatus, the apparatus comprising: an acquisition module, configured to acquire a normal data sequence whose cryptographic operation order can be scrambled; wherein the data sequence includes multiple elements; and a first determination module, configured to traverse the multiple elements from back to front, starting from the last element of the data sequence, and when traversing to the i-th element corresponding to the current traversal position i, determine a current random number based on the current bit length; wherein the current bit length is related to the number of traversed elements and the length of the data sequence, and the current bit length is... The bit length of the random number is the same as the current bit length, i is less than or equal to the number of the multiple elements, and i is a positive integer; the second determining module is used to determine the position j to be swapped based on the current random number and / or the current traversal position i, and the size relationship between the current random number and the current traversal position i; where j is less than or equal to the number of the multiple elements, and j is a positive integer; the swapping module is used to swap the i-th element and the j-th element based on the current traversal position i and the position j to be swapped, to obtain the current disordered data sequence.

[0017] In some implementations, the second determining module is specifically used to: determine the size relationship between the current random number and the current traversal position i; if the current random number is greater than the current traversal position i, determine the position j to be swapped based on the difference between the current random number and the current traversal position i; if the current random number is less than or equal to the current traversal position i, determine the current random number as the position j to be swapped.

[0018] In some embodiments, the device further includes: a parameter update module; the parameter update module is configured to: reduce the current first count value by a preset step to obtain a target count value; wherein the current first count value is related to the number of elements traversed and the length of the data sequence; if the target count value is equal to the preset threshold, determine an updated second count value based on the current second count value and a preset multiple; wherein the current second count value is used to determine the number of elements to be traversed before the current bit length is reduced, and the updated second count value is less than the current second count value; determine the updated second count value as the updated first count value; reduce the current bit length by the preset step to obtain the updated bit length.

[0019] In some embodiments, the device further includes a third determining module; the third determining module is configured to: determine whether all elements except the first element in the plurality of elements have been traversed; if all elements except the first element in the plurality of elements have been traversed, perform disorder processing on the data sequence and output the current disordered data sequence; if all elements except the first element in the plurality of elements have not been traversed, continue to traverse the (i-1)th element in the plurality of elements.

[0020] In some implementations, the third determining module is specifically used to: determine whether all elements except the first element among the plurality of elements have been traversed when the target count value is not equal to the preset threshold.

[0021] In some embodiments, the apparatus further includes a fourth determining module; the fourth determining module is configured to: determine the length of the data sequence; and based on the length of the data sequence, determine an initial bit length, an initial first count value, and an initial second count value of the data sequence; wherein the initial first count value is equal to the initial second count value.

[0022] Thirdly, embodiments of this application provide an encryption chip, including a cryptographic function module and a data sequence scrambling module. The data sequence scrambling module is used to implement some or all of the steps in the above method to obtain a scrambled data sequence. The cryptographic function module is used to perform at least one of the following operations based on the scrambled data sequence: encryption, decryption, signing, signature verification, and key negotiation.

[0023] Fourthly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements some or all of the steps in the above-described method.

[0024] Fifthly, embodiments of this application provide a program product, which includes a computer program or instructions that, when executed by a processor, implement some or all of the steps in the above-described method.

[0025] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and are not intended to limit the technical solutions of this application. Attached Figure Description

[0026] Figure 1 This is a schematic diagram of the structure of an encryption chip provided in an embodiment of this application; Figure 2 A schematic diagram of a number theory transformation of a post-quantum cryptography algorithm provided in an embodiment of this application; Figure 3A schematic diagram illustrating the implementation flow of a data sequence disordering method provided in an embodiment of this application; Figure 4 A schematic diagram illustrating the implementation flow of another data sequence disordering method provided in this application embodiment; Figure 5 A schematic diagram illustrating the implementation flow of another data sequence disordering method provided in this application embodiment; Figure 6 This application provides a data sequence disorder processing apparatus according to an embodiment of the present application.

[0027] It should be noted that the terms "first" and "second" mentioned above are only used to distinguish between different options and do not represent the degree of superiority or inferiority of the options or their priority in the implementation process. Detailed Implementation

[0028] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application are further described in detail below with reference to the accompanying drawings and embodiments. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0029] In the following description, references to "some embodiments" refer to a subset of all possible embodiments. It is understood that "some embodiments" may be the same or different subsets of all possible embodiments and may be combined with each other without conflict. The terms "first / second / third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first / second / third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0030] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. The terminology used herein is for descriptive purposes only and is not intended to limit the scope of this application.

[0031] In related technologies, the Fisher-Yates shuffle algorithm is commonly used when scrambling data sequences. For example, for a data sequence containing n elements, starting from the last element (i.e., the element with position index i = n-1), the algorithm iterates backward to the second element (i.e., the element with position index i = 1). When iterating to position i, the random number r generated by the random number generator in the computing device hardware is used to determine the position index j to be swapped, and the element at position i is swapped with the element at position j. However, since the output bit width (i.e., bit length) of the random number generator is usually fixed, that is, the random number generator can only generate random numbers of fixed bit length (e.g., it can only generate random numbers of 8 bits in length, ranging from [0, 255]), it is necessary to perform a modulo operation on the random number r (i.e., calculate r%(i+1)), and use the result of the modulo operation as the position index j to be swapped, so as to adjust the range of position index j to [0, i].

[0032] However, since modulo operations involve complex division or remainder calculations, cryptographic devices and embedded systems require more circuit modules and more clock cycles to complete them, significantly increasing the computational burden on the hardware. Furthermore, if the range of random numbers generated by the random number generator is not an integer multiple of the target range (e.g., [0, i]), the probability of the position index j obtained after modulo operation appearing within the target range will deviate significantly, resulting in an uneven distribution of random numbers. This uneven distribution undermines the requirement for fairness in randomness in cryptographic scenarios and may even allow attackers to exploit distributional biases to predict or crack data sequences. Therefore, a method is needed to avoid modulo operations when scrambling data sequences to improve the computational efficiency of computing devices.

[0033] This application provides a method for reordering data sequences, which can be executed by a data sequence reordering module of an encryption chip. The encryption chip can be configured in computing devices with data processing capabilities, such as servers, laptops, tablets, desktop computers, smart TVs, set-top boxes, and mobile devices (e.g., mobile phones, portable video players, personal digital assistants, dedicated messaging devices, portable gaming devices).

[0034] Figure 1 This is a schematic diagram of the structure of an encryption chip provided in an embodiment of this application, as shown below. Figure 1As shown, the encryption chip 100 may include a cryptographic function module 110 and a data sequence scrambling module 120. The cryptographic function module 110 can perform functions such as encryption, decryption, signing, signature verification, and key negotiation. The data sequence scrambling module 120 is used to scramble the original data sequence (e.g., 0, 1…255…) sent by the cryptographic function module 110, randomly changing the positions of each element in the original data sequence to obtain a scrambled data sequence (e.g., 155, 3…213…). The scrambled data sequence can be used for encryption, decryption, signing, signature verification, and key negotiation functions of the cryptographic function module, thereby introducing randomness into cryptographic operations without affecting the correctness of the algorithm, thus improving the security protection capability of the encryption chip 100.

[0035] In cryptographic algorithm design, disordered data sequences can alter the original execution order of the algorithm. The method provided in this application can be applied to cryptographic functions where disordered data sequences do not affect the correctness of the algorithm. (Reference) Figure 2 The example shown illustrates the multiplication of two polynomial variables a and b in the Number Theoretic Transform (NTT) field of a post-quantum cryptographic algorithm. Since polynomial multiplication in the NTT field involves multiplying the coefficients of the polynomials one by one, the coefficients are extracted sequentially and the multiplications are performed in order to obtain the polynomial result. However, if the data sequence composed of the original coefficients is scrambled before performing polynomial multiplication, the order of operations becomes unpredictable because a new scrambled sequence is used before each multiplication operation. Therefore, since attackers need to accurately locate the operation positions when launching attacks (such as side-channel attacks or fault injection attacks), the scrambled data sequence can prevent attackers from launching attacks. This algorithm can be applied to various cryptographic algorithm operations that do not affect the correctness of the algorithm, such as S-box lookup in symmetric algorithms and NTT transformations.

[0036] Figure 3 This application provides a schematic diagram of the implementation process of a method for reordering data sequences, as illustrated in the embodiments below. Figure 3 As shown, the method includes S301 to S304: S301, Obtain a normal data sequence that can shuffle the order of cryptographic operations.

[0037] In some implementations, the encryption chip can obtain a normal data sequence whose cryptographic operation order can be scrambled through a data sequence scrambling module. This data sequence includes those whose scrambling would affect the correctness of the cryptographic algorithm; therefore, this type of data sequence usually cannot be scrambled, and thus cannot change the cryptographic operation order. It also includes data sequences whose scrambling would change the cryptographic operation order but would not affect the correctness of the cryptographic algorithm. In this embodiment, the normal data sequence whose cryptographic operation order can be scrambled is one whose scrambling would change the cryptographic operation order but would not affect the correctness of the cryptographic algorithm. That is, after scrambling the obtained data sequence, the resulting scrambled data sequence will change the cryptographic operation order without affecting the correctness of the cryptographic algorithm. For example, this data sequence can be generated by the cryptographic function module, such as when the cryptographic function module generates a data sequence that needs to be scrambled based on the currently processed intermediate data or key during operation; or, the data sequence can be predefined and stored in the encryption chip. This embodiment does not limit the method of obtaining the data sequence.

[0038] For example, after receiving a data sequence, the length of the data sequence can be determined first, that is, the number of elements contained in the data sequence. For example, if the obtained data sequence x is "0, 1, 3, 255", then the data sequence x contains 4 elements, that is, the length of the data sequence x is n=4. It should be noted that the number of elements contained in the data sequence can be arbitrary, and the specific length of the data sequence is not limited in this embodiment.

[0039] Furthermore, the initial bit length bitlen0, initial first count value counter0, and initial second count value counter_const0 of the data sequence can be determined based on the length of the data sequence. Here, the length of the data sequence n = 2^bitlen0; the initial first count value and the initial second count value are equal, i.e., counter0 = counter_const0; and counter0 = counter_const0 = 2^(bitlen0 - 1). For example, for the data sequence x above, since its length is 4, the initial bit length bitlen0 of data sequence x can be determined to be 2, the initial first count value counter0 = 2^(2 - 1) = 2, and the initial second count value counter_const0 = 2.

[0040] S302, starting from the last element of the data sequence, traverse multiple elements one by one from back to front, and when traversing to the i-th element corresponding to the current traversal position i, determine the current random number based on the current bit length.

[0041] In some implementations, the data sequence can then be iterated over multiple elements. Each element in the data sequence corresponds to a different position index; for example, the position indices i of the n elements in the data sequence can be "0, 1, 2, ..., n-1". During the traversal, the sequence can be started from the last element (i.e., the element with position index n-1) and traversed backwards until the element with position index i (hereinafter referred to as the current traversal position i) is 1 (i.e., the i-th element). That is, 1 ≤ i ≤ n-1, where i is a positive integer. For example, when traversing the data sequence x above, the elements "255", "3", and "1" are traversed in sequence.

[0042] During the traversal of the data sequence, the initial bit length bitlen0 can be updated according to a preset step (e.g., 1) to obtain the current bit length bitlen corresponding to the current traversal position i, and a current random number r is generated based on the current bit length bitlen. The current bit length bitlen is related to the number of elements traversed and the length of the data sequence; the current random number r is a positive integer in the range [0, 2^bitlen-1], and the bit length of the generated current random number r is the same as the current bit length bitlen.

[0043] For example, for the data sequence x above, when the current traversal position i=3, the current random number r1 can be generated based on the initial bit length bitlen0=2. Since 2^bitlen0-1=3, the current random number r1 can take any positive integer in the range [0, 3].

[0044] S303, based on the current random number and / or the current traversal position i, and the size relationship between the current random number and the current traversal position i, determine the position j to be swapped.

[0045] In some implementations, after determining the current random number r, the size relationship between the current random number r and the current traversal position i can be determined. Based on the current random number r and / or the current traversal position i, and the aforementioned size relationship, the position j to be swapped in the data sequence can be determined. Here, 0 ≤ j ≤ n-1, and j is a positive integer. Since the bit length of the generated current random number r is the same as the current bit length bitlen, no modulo operation is needed to constrain the value range of the position j to be swapped to [0, i] based on the current traversal position i and the current random number r. For example, if the current traversal position i = 3 and the current random number r1 = 2, then the current random number r1 can be directly determined as the position j to be swapped, i.e., j = r = 2.

[0046] S304. Based on the current traversal position i and the position to be swapped j, swap the i-th element and the j-th element to obtain the current disordered data sequence.

[0047] In some implementations, after determining the position j to be swapped, the i-th element and the j-th element in the current data sequence can be swapped to obtain the current disordered data sequence. For example, taking the data sequence x "0, 1, 3, 255" as an example, where the current traversal position i=3 and the position j to be swapped is 2, the 3rd element and the 2nd element in the data sequence x can be swapped, that is, the element "255" and the element "1" can be swapped, and the resulting disordered data sequence is "0, 255, 3, 1".

[0048] In this embodiment, the current bit length is dynamically adjusted with the number of traversals, thereby enabling control of the numerical range of the random number based on the current bit length. No modulo operation is required, which ensures the randomness of the generated random number. Furthermore, without subsequent modulo operations, the numerical range of the position to be swapped, i, can be constrained to the range of [0, i] based on the current traversal position i and the random number, thereby reducing the computational complexity.

[0049] Figure 4 This is a schematic diagram illustrating the implementation flow of another data sequence reordering method provided in this application embodiment. This method can be executed by the data sequence reordering module of the encryption chip. Based on Figure 3 , Figure 3 S303 in the middle can be updated to S401 to S403, which will combine Figure 4 The steps shown are explained.

[0050] S401, determine the size relationship between the current random number and the current traversal position i.

[0051] In some implementations, after determining the current random number r, the size relationship between the current random number r and the current traversal position i can be determined, such as determining whether the current random number r is greater than the current traversal position i.

[0052] S402, if the current random number is greater than the current traversal position i, determine the position j to be swapped based on the difference between the current random number and the current traversal position i.

[0053] In some implementations, if the current random number r is greater than the current traversal position i, then since the bit length of the generated current random number r is the same as the current bit length bitlen, the value range of the position j to be swapped can be constrained to the range [0, i] by determining the difference between the current random number r and the current traversal position i, and this difference is determined as the position j to be swapped. For example, if the current traversal position i = 2 and the current random number r1 = 3, then the position j to be swapped can be determined as ri = 3 - 2 = 1.

[0054] S403, if the current random number is less than or equal to the current traversal position i, determine the current random number as the position j to be swapped.

[0055] In some implementations, if the current random number r is less than or equal to the current traversal position i, then the random number r1 is within the range of [0, i]. In this case, the current random number r can be directly determined as the position j to be swapped, and thus the position j to be swapped is also within the range of [0, i]. For example, if the current traversal position i = 3 and the current random number r1 = 2, then the position j to be swapped can be determined as the random number r1 = 2.

[0056] In this embodiment, the position j to be swapped can be determined by performing a simple size comparison between the current random number r and the current traversal position i, and at most by performing a subtraction operation between the current random number r and the current traversal position i, without needing to perform a modulo operation on the current random number r. Since the comparison and subtraction operations can usually be completed within one clock cycle in the hardware logic, while the modulo operation requires multiple cycles, the operation speed of the encryption chip can be improved, and the risk of uneven random number distribution caused by the modulo operation can be avoided, ensuring that the position j to be swapped is uniformly distributed within the range [0, i].

[0057] In some embodiments, the method further includes: reducing the current first count value by a preset step to obtain a target count value; wherein the current first count value is related to the number of elements traversed and the length of the data sequence; if the target count value is equal to a preset threshold, determining an updated second count value based on the current second count value and a preset multiple; wherein the current second count value is used to determine the number of elements to be traversed before the current bit length is reduced, and the updated second count value is less than the current second count value; determining the updated second count value as the updated first count value; and reducing the current bit length by a preset step to obtain the updated bit length.

[0058] In some implementations, after obtaining the current out-of-order data sequence during the traversal process, the current first count value `counter` can be further updated according to a preset step to obtain the current target count value. If the current target count value `counter` equals a preset threshold, the current bit length `bitlen` and the current second count value `counter_const` are updated to obtain the updated bit length and the updated second count value.

[0059] For example, the current first count value `counter` can be decreased by a preset step (e.g., 1), resulting in the current target count value `counter-1`. If the current target count value `counter` equals a preset threshold (e.g., 0), the updated second count value can be determined by multiplying the current second count value `counter_const` by a preset multiple (e.g., 0.5), resulting in an updated second count value of 0.5 * `counter_const` (i.e., `counter_const / 2`). This updated second count value `counter_const` is then used to update the current target count value `counter`, meaning the updated first count value `counter` equals the updated second count value `target count value` `counter`.

[0060] Furthermore, since the next traversal needs to be performed, the current traversal position i will decrease. As the current traversal position i decreases, the bit length of the required random number r will also decrease. Therefore, the bit length bitlen can be decreased according to a preset step (e.g., 1) to obtain an updated bit length bitlen. This ensures that the bit length of the random number r obtained based on the updated bit length bitlen in the next traversal will also decrease accordingly, so that the random number r can conform to the numerical range [0, i] of this traversal, thereby avoiding unnecessary computational costs.

[0061] The first counter value, `counter`, is a decrementing counter that decreases by a preset step (e.g., 1) after each element swap, until it equals a preset threshold (e.g., 0), triggering an update. This ensures that the bit length `bitlen` only decreases after processing a certain number of elements, avoiding updating `bitlen` on each traversal and thus saving computational resources.

[0062] The second counter value, `counter_const`, can be seen as a threshold controlling the update frequency of each parameter. Its initial value is 2^(bitlen-1), meaning the bit length is reduced only once every 2^(bitlen-1) elements processed. For example, when the data sequence length is 8, `bitlen=3` and `counter_const=4`, so a 3-bit random number is used in the first four elements' disordering processes. Even if the current traversal position `i` has decreased, the bit length `bitlen` is not immediately adjusted, thus reducing the computational overhead caused by frequent updates. In other words, the second counter value `counter_const` represents the number of traversals (i.e., the number of elements to be traversed) required before the bit length `bitlen` decreases.

[0063] In this embodiment, by setting a first counter value counter and a second counter value counter_const, the bit length bitlen of the random number can be dynamically adjusted at intervals to ensure that the bit length of most of the random numbers r generated in multiple traversals can match the numerical range of the current traversal position i. Furthermore, the update of the first counter value counter and the second counter value counter_const only involves simple subtraction and shifting, thereby saving the computing resources of the encryption chip and improving the execution speed of the algorithm.

[0064] In some implementations, the method further includes: determining whether all elements except the first element in the plurality of elements have been traversed; if all elements except the first element in the plurality of elements have been traversed, performing scrambling of the data sequence and outputting the current scrambled data sequence; if all elements except the first element in the plurality of elements have not been traversed, continuing to traverse the (i-1)th element in the plurality of elements.

[0065] For example, after updating the above parameters, it can be determined whether all elements except the first element in the data sequence have been traversed. If not, the traversal continues to the (i-1)th element; if the traversal is complete, the current disordered data sequence is output, and the disordering of the data sequence is completed. In some implementations, if the current target count value counter is not equal to a preset threshold, the above parameters do not need to be updated, and it is sufficient to determine whether all elements except the first element have been traversed.

[0066] In this embodiment of the application, by limiting the traversal termination condition to the completion of traversal of all elements except the first element, redundant calculation operations can be avoided. For example, when the current traversal value i=0, the determined position j to be swapped can only be 0, that is, the position of the element will not be changed at this time, so there is no need to traverse the first element in the data sequence.

[0067] Figure 5 This is a schematic diagram illustrating the implementation flow of another data sequence disordering method provided in an embodiment of this application, as shown below. Figure 5 As shown, the method includes steps S501 to S515. The following summarizes the data sequence disorder processing method provided in the embodiments of this application.

[0068] S501, based on the length of the data sequence, determine the initial values ​​of the bit length bitlen, the first count value counter, and the second count value counter_const.

[0069] For example, the implementation of S501 can be referred to the description of S301, and will not be repeated here.

[0070] S502, iterate through the i-th element in the data sequence.

[0071] For example, the implementation of S502 can be referred to the description of S302, and will not be repeated here.

[0072] S503 generates a random number r based on the bit length bitlen.

[0073] For example, the implementation of S503 can be referred to the description of S302, and will not be repeated here.

[0074] S504, determine whether the random number r is greater than the current traversal position i.

[0075] Next, it can be determined whether the random number r1 is greater than the current traversal position i. If the random number r1 is greater than the current traversal position i, then execute S505; if the random number r1 is less than or equal to the current traversal position i, then execute S506. For example, when the random number r1=3 and the current traversal position i=2, the random number r1 is greater than the current traversal position i, so execute S505; when the random number r1=2 and the current traversal position i=3, the random number r1 is less than the current traversal position i, so execute S506.

[0076] S505, if the random number r1 is greater than the current traversal position i, then determine the position to be swapped j = random number r - current traversal position i.

[0077] For example, the implementation of S505 can be referred to the description of S402, and will not be repeated here.

[0078] S506, if the random number r1 is less than or equal to the current traversal position i, then determine the position to be swapped j = random number r.

[0079] For example, the implementation of S506 can be referred to the description of S403, and will not be repeated here.

[0080] S507, swap the i-th element with the j-th element to obtain a disordered data sequence.

[0081] For example, the implementation of S507 can be referred to the description of S305, and will not be repeated here.

[0082] S508, determine the first count value counter = counter - 1.

[0083] For example, the implementation of S508 can be referred to the description of the above embodiments, and will not be repeated here.

[0084] S509, determine whether the first count value counter is 0.

[0085] Next, it can be determined whether the current target count value counter is equal to the preset threshold (e.g., 0). If the current target count value counter is equal to 0, then execute S510-S512; if the current target count value counter is not equal to 0, then execute S513.

[0086] S510, if the current target count value counter is equal to 0, then determine the second count value counter_const = counter_const / 2.

[0087] For example, the implementation of S510 can be referred to the description of the above embodiments, and will not be repeated here.

[0088] S511, determine that the first count value counter = the second count value counter_const.

[0089] For example, the implementation of S511 can be referred to the description of the above embodiments, and will not be repeated here.

[0090] S512, determine the bit length bitlen = bitlen-1.

[0091] For example, the implementation of S512 can be referred to the description of the above embodiments, and will not be repeated here.

[0092] S513, determine whether the traversal is complete.

[0093] In some implementations, after the execution result of S509 is that the current target count value counter is not equal to 0, or after the execution of S510-S512 is completed, it can be determined whether the traversal of the data sequence is completed, that is, whether the current traversal position i is equal to 1. If the traversal of the data sequence is not completed (i.e., the current traversal position i is not equal to 1), then S514 is executed; if the traversal of the data sequence is completed (i.e., the current traversal position i is equal to 1), then S514 is executed.

[0094] S514, if the traversal of the data sequence has not been completed, then determine the current traversal position i = i-1.

[0095] For example, the implementation of S514 can be referred to the description of the above embodiments, and will not be repeated here.

[0096] S515: If the traversal of the data sequence is completed, output the disordered data sequence.

[0097] If the current traversal of the data sequence is completed, the scrambled data sequence obtained by the current traversal (i.e. the scrambled data sequence obtained by S507) is output, and the scrambling of the data sequence is ended.

[0098] The following example illustrates the method for reordering data sequences: 1) Taking the traversal of the 4 elements in the data sequence x = "0, 1, 3, 255" as an example, we can determine the initial bit length bitlen0 = 2, the initial first count value counter0 = 2, and the initial second count value counter_const0 = 2 based on the length n = 4 of the data sequence x.

[0099] 2) Next, starting from the 3rd element (i=3) "255", the traversal continues. The current bit length bitlen0=2, so the range of the current random number r1 generated based on the current bit length bitlen0 is [0, 3]. Here, we take the generation of the current random number r1=2 as an example.

[0100] Determine if the current random number r1 is greater than the current traversal position i. Since the current random number r1 is less than the current traversal position i, the position to be swapped is determined to be j = the current random number r1 = 2. Therefore, swap the third element "255" with the second element "3" to obtain the current disordered data sequence x1 = "0, 1, 255, 3".

[0101] The initial first count value counter0 is updated according to the preset step of 1, and the current target count value counter0' is determined to be counter0-1=2-1=1. At this time, the current target count value counter0' is not equal to the preset threshold 0, so the traversal continues to the next element. At this time, the current traversal position i=3-1=2.

[0102] 3) Iterate through the second element "255" in the disordered data sequence x1. The current bit length bitlen0 = 2. Then, the range of the current random number r2 generated based on the current bit length bitlen0 is [0, 3]. Here, we take the generation of the current random number r2 = 3 as an example.

[0103] Determine if the current random number r2 is greater than the current traversal position i. Since the current random number r2 is greater than the current traversal position i, the position to be swapped is determined as j = current random number r1 - current traversal position i = 3 - 2 = 1. Therefore, swap the first element "1" with the second element "255" to obtain the current disordered data sequence x2 = "0, 255, 1, 3".

[0104] The current first count value, counter0', is updated according to a preset step of 1, and the current target count value, counter0'', is determined to be counter0'-1=1-1=0. At this point, the current target count value, counter0'', equals the preset threshold of 0. Therefore, the initial second count value, counter_const0, is updated according to a preset multiplier of 0.5, resulting in the updated second count value, counter_const1=2*0.5=1. The updated first count value, counter1, is determined to be counter_const1=1. Furthermore, the current bit length, bitlen0, is updated according to a preset step of 1, and the updated bit length, bitlen1, is determined to be bitlen0-1=2-1=1. Since the traversal of the data sequence is not yet complete, the traversal continues to the next element. The current traversal position is i=2-1=1.

[0105] 4) Iterate through the first element "255" in the disordered data sequence x2. The current bit length bitlen1 = 1. Then, the range of the current random number r3 generated based on the current bit length bitlen1 is [0, 1]. Here, we take the generation of the current random number r3 = 1 as an example.

[0106] Determine if the current random number r3 is greater than the current traversal position i. Since the current random number r3 is equal to the current traversal position i, the position to be swapped is determined to be j = the current random number r3 = 1. Because the position to be swapped j is equal to the current traversal position i, no element swapping is performed, resulting in the current disordered data sequence x3 = x2 = "0, 255, 1, 3".

[0107] Update the current first count value counter1 according to the preset step of 1, and determine the current target count value counter1' = counter1 - 1 = 1 - 1 = 0. At this time, the current target count value counter1' is equal to the preset threshold 0, so the above parameters are updated. At this time, the traversal of the data sequence has been completed, so the current disordered data sequence x3 = "0, 255, 1, 3" is output, and the disordering of the data sequence is completed.

[0108] The data sequence disorder processing method provided in this application avoids the modulo operation in traditional disordering algorithms by dynamically adjusting the bit length of random numbers, thereby reducing the computational burden on the encryption chip while ensuring the uniform distribution of random numbers.

[0109] Based on the foregoing embodiments, this application provides a small-sample incremental learning device based on multimodal cue learning. The device includes the included units and the modules included in each unit, which can be implemented by the data sequence disordering module in the encryption chip; of course, it can also be implemented by specific logic circuits.

[0110] Figure 6 This is a schematic diagram of the composition structure of a data sequence out-of-order processing device provided in an embodiment of this application, as shown below. Figure 6 As shown, the data sequence out-of-order processing device 600 includes: an acquisition module 610, a first determination module 620, a second determination module 630, and an exchange module 640, wherein: The acquisition module 610 is used to acquire a normal data sequence that can shuffle the order of password operations.

[0111] The data sequence includes multiple elements.

[0112] The first determining module 620 is used to traverse multiple elements from the last element of the data sequence one by one from the end to the beginning, and when traversing to the i-th element corresponding to the current traversal position i, determine the current random number based on the current bit length.

[0113] The current bit length is related to the number of elements traversed and the length of the data sequence. The bit length of the current random number is the same as the current bit length. i is less than or equal to the number of multiple elements and i is a positive integer.

[0114] The second determining module 630 is used to determine the position j to be swapped based on the current random number and / or the current traversal position i, and the size relationship between the current random number and the current traversal position i.

[0115] Where j is less than or equal to the number of multiple elements, and j is a positive integer.

[0116] The swapping module 640 is used to swap the i-th element and the j-th element based on the current traversal position i and the position to be swapped j, so as to obtain the current disordered data sequence.

[0117] In some implementations, the second determining module 630 is specifically used to: determine the size relationship between the current random number and the current traversal position i; if the current random number is greater than the current traversal position i, determine the position j to be swapped based on the difference between the current random number and the current traversal position i; if the current random number is less than or equal to the current traversal position i, determine the current random number as the position j to be swapped.

[0118] like Figure 6 As shown, the data sequence disorder processing device 600 also includes a parameter update module 650.

[0119] In some implementations, the parameter update module 650 is used to: reduce the current first count value by a preset step to obtain a target count value; wherein the current first count value is related to the number of elements traversed and the length of the data sequence; if the target count value is equal to a preset threshold, determine an updated second count value based on the current second count value and a preset multiple; wherein the current second count value is used to determine the number of elements to be traversed before the current bit length is reduced, and the updated second count value is less than the current second count value; determine the updated second count value as the updated first count value; and reduce the current bit length by a preset step to obtain the updated bit length.

[0120] like Figure 6 As shown, the data sequence disorder processing device 600 further includes a third determination module 660.

[0121] In some implementations, the third determining module 660 is used to: determine whether all elements except the first element in the plurality of elements have been traversed; if all elements except the first element in the plurality of elements have been traversed, complete the disordering of the data sequence and output the current disordered data sequence; if all elements except the first element in the plurality of elements have not been traversed, continue to traverse the (i-1)th element in the plurality of elements.

[0122] In some implementations, the third determining module 660 is specifically used to: determine whether all elements except the first element have been traversed when the target count value is not equal to a preset threshold.

[0123] like Figure 6 As shown, the data sequence disorder processing device 600 further includes a fourth determination module 670.

[0124] In some implementations, the fourth determining module 670 is used to: determine the length of the data sequence; and based on the length of the data sequence, determine the initial bit length, the initial first count value, and the initial second count value of the data sequence; wherein the initial first count value and the initial second count value are equal in magnitude.

[0125] The descriptions of the apparatus embodiments above are similar to those of the method embodiments above, and have similar beneficial effects. In some embodiments, the functions or modules included in the apparatus provided in this application can be used to perform the methods described in the method embodiments above. For technical details not disclosed in the apparatus embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.

[0126] It should be noted that, in the embodiments of this application, if the above-mentioned data sequence disorder processing method or the training method of the small-sample incremental learning model based on multimodal cue learning is implemented in the form of software functional modules and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, or the part that contributes to the related technology, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause the encryption chip to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, mobile hard drives, read-only memory (ROM), magnetic disks, or optical disks. Thus, the embodiments of this application are not limited to any specific hardware, software, or firmware, or any combination of hardware, software, and firmware.

[0127] This application provides an encryption chip, including a cryptographic function module and a data sequence scrambling module. The data sequence scrambling module is used to implement some or all of the steps in the above method to obtain a scrambled data sequence. The cryptographic function module is used to perform at least one of the following operations based on the scrambled data sequence: encryption, decryption, signing, signature verification, and key negotiation.

[0128] This application provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements some or all of the steps in the above-described method. The computer-readable storage medium can be transient or non-transient.

[0129] This application provides a computer program including computer-readable code. When the computer-readable code is run in an encryption chip, the processor in the encryption chip performs some or all of the steps in the above method.

[0130] This application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program. When the computer program is read and executed by a computer, it implements some or all of the steps in the above-described method. This computer program product can be implemented specifically through hardware, software, or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium; in other embodiments, the computer program product is specifically embodied as a software product, such as a software development kit (SDK), etc.

[0131] It should be noted that the descriptions of the various embodiments above tend to emphasize the differences between them, while their similarities or commonalities can be referred to interchangeably. The descriptions of the above embodiments of the device, storage medium, computer program, and computer program product are similar to the descriptions of the above method embodiments and have similar beneficial effects. For technical details not disclosed in the embodiments of the device, storage medium, computer program, and computer program product of this application, please refer to the descriptions of the method embodiments of this application for understanding.

[0132] This application provides a computer storage medium storing one or more programs that can be executed by one or more processors to implement the steps of the data sequence disorder processing method or the training method of the few-shot incremental learning model based on multimodal cue learning as described in any of the above embodiments.

[0133] It should be noted that the descriptions of the storage medium and device embodiments above are similar to the descriptions of the method embodiments above, and have similar beneficial effects. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.

[0134] The aforementioned processor can be at least one of the following: Application Specific Integrated Circuit (ASIC), Digital Signal Processor (DSP), Digital Signal Processing Device (DSPD), Programmable Logic Device (PLD), Field Programmable Gate Array (FPGA), Central Processing Unit (CPU), Controller, Microcontroller, and Microprocessor. It is understood that other electronic devices can also implement the functions of the aforementioned processor, and this application does not specifically limit the specific implementation.

[0135] The aforementioned computer storage media / memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), magnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM), etc.; or it can be various terminals that include one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc.

[0136] The above description is merely an embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.

Claims

1. A method for reordering a data sequence, characterized in that, The method includes: Obtain a normal data sequence whose cipher operation order can be shuffled; wherein the data sequence includes multiple elements; Starting from the last element of the data sequence, the plurality of elements are traversed one by one from back to front. When the traversal reaches the i-th element corresponding to the current traversal position i, the current random number is determined based on the current bit length. The current bit length is related to the number of elements traversed and the length of the data sequence. The bit length of the current random number is the same as the current bit length. i is less than or equal to the number of the plurality of elements and i is a positive integer. Determine the size relationship between the current random number and the current traversal position i; If the current random number is greater than the current traversal position i, the position j to be swapped is determined based on the difference between the current random number and the current traversal position i; If the current random number is less than or equal to the current traversal position i, the current random number is determined as the position j to be swapped; where j is less than or equal to the number of the plurality of elements, and j is a positive integer; Based on the current traversal position i and the position j to be swapped, the i-th element and the j-th element are swapped to obtain the current disordered data sequence; The current first count value is reduced according to a preset step to obtain the target count value; wherein, the current first count value is related to the number of elements traversed and the length of the data sequence; When the target count value is equal to a preset threshold, an updated second count value is determined based on the current second count value and a preset multiple; wherein, the current second count value is used to determine the number of elements that need to be traversed before the current bit length is reduced, and the updated second count value is less than the current second count value; The updated second count value is determined as the updated first count value; The current bit length is reduced according to the preset step size to obtain the updated bit length.

2. The method according to claim 1, characterized in that, The method further includes: Determine whether all elements except the first element have been traversed; After traversing all elements except the first element, the data sequence is shuffled and the current shuffled data sequence is output. If all elements except the first element have not been traversed, the (i-1)th element of the plurality of elements continues to be traversed.

3. The method according to claim 2, characterized in that, Determining whether all elements except the first element have been traversed includes: If the target count value is not equal to the preset threshold, determine whether all elements except the first element have been traversed.

4. The method according to claim 1, characterized in that, Before traversing the plurality of elements one by one from the last element of the data sequence, the method further includes: Determine the length of the data sequence; Based on the length of the data sequence, the initial bit length, initial first count value, and initial second count value of the data sequence are determined; wherein the initial first count value and the initial second count value are equal in magnitude.

5. A data sequence disorder processing device, characterized in that, The device includes: The acquisition module is used to acquire a normal data sequence that can shuffle the order of password operations; wherein the data sequence includes multiple elements; The first determining module is used to traverse the plurality of elements from the last element of the data sequence to the front, and when traversing to the i-th element corresponding to the current traversal position i, determine the current random number based on the current bit length; wherein the current bit length is related to the number of elements traversed and the length of the data sequence, the bit length of the current random number is the same as the current bit length, i is less than or equal to the number of the plurality of elements, and i is a positive integer; The second determining module is used to determine the size relationship between the current random number and the current traversal position i; when the current random number is greater than the current traversal position i, the module determines the position j to be swapped based on the difference between the current random number and the current traversal position i; when the current random number is less than or equal to the current traversal position i, the module determines the current random number as the position j to be swapped; wherein, j is less than or equal to the number of the plurality of elements, and j is a positive integer; The swapping module is used to swap the i-th element and the j-th element based on the current traversal position i and the position to be swapped j, to obtain the current disordered data sequence; and to reduce the current first count value according to a preset step to obtain the target count value; wherein the current first count value is related to the number of elements traversed and the length of the data sequence; When the target count value is equal to a preset threshold, an updated second count value is determined based on the current second count value and a preset multiple; wherein, the current second count value is used to determine the number of elements that need to be traversed before the current bit length is reduced, and the updated second count value is less than the current second count value; the updated second count value is determined as the updated first count value; the current bit length is reduced according to the preset step to obtain the updated bit length.

6. An encryption chip, comprising a cryptographic function module and a data sequence scrambling module, characterized in that, The data sequence scrambling module is used to perform the steps in the method of any one of claims 1 to 4 to obtain a scrambled data sequence; the cryptographic function module is used to perform at least one of encryption, decryption, signing, signature verification and key negotiation based on the scrambled data sequence.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.

8. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Sequence generation method and device, electronic equipment and computer readable storage medium

    CN114968178A

  • Password protection system

    CN118862189A