Data processing method, data processing system and processing terminal

By performing iterative operations on the modulus values ​​and parameters in the asymmetric encryption and decryption algorithm, and stopping the calculation when the iteration values ​​are equal, the problem of low efficiency caused by redundant calculations is solved and the speed of the encryption and decryption process is improved.

CN118573374APending Publication Date: 2024-08-30DAPUSTOR CORP
View PDF 0 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing asymmetric encryption and decryption algorithms have redundant calculations when the amount of data is large, resulting in low encryption and decryption efficiency, especially a waste of processing time in the inverse operation process.

Method used

By performing an iterative operation on the first module value and the first parameter, the iterative operation is stopped when the iteration values ​​of two adjacent rounds of iterative operations are equal, the pre-computation result is determined based on the iteration value of the current iterative operation, and the calculation is terminated early to reduce data processing time. .

Benefits of technology

It effectively reduces data processing time and improves the speed and efficiency of encryption and decryption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118573374A
    Figure CN118573374A
Patent Text Reader

Abstract

The embodiment of the invention relates to the technical field of data processing, and discloses a data processing method, a data processing system and a processing terminal.The data processing method is applied to the field of data encryption and decryption and comprises the steps that a first module value and a first parameter are obtained, and the first parameter is the power of a cardinal number; performing iterative operation on the first module value and the first parameter, obtaining a first iterative value after each round of iterative operation, and stopping the iterative operation if the first iterative value is equal to the iterative value obtained by the last round of iteration; and determining a pre-calculation result according to the current first iteration value. According to the method, the first module value and the first parameter are subjected to iterative operation, when the iterative values of two adjacent rounds of iterative operation are equal, the iterative operation is stopped, the pre-calculation result is determined according to the iterative value of the current iterative operation, the pre-calculation result is used for data encryption or decryption, calculation can be terminated in advance, the data processing time is shortened, and the data processing efficiency is improved. The speed of data encryption and decryption is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a data processing method, a data processing system and a processing terminal. Background Art

[0002] The encryption and decryption algorithm is to encrypt and decrypt data by using keys to protect the security of data. The encryption and decryption algorithms are divided into symmetric encryption algorithms and asymmetric encryption algorithms. Among them, the asymmetric encryption algorithm requires two keys, namely the public key and the private key. If one of the keys is used for encryption, the other key is required for decryption. It is mainly used in network security, e-commerce, finance and other fields, and is crucial in data transmission, storage and identity authentication.

[0003] At present, data encryption and decryption are usually achieved through asymmetric encryption and decryption algorithms. However, in the implementation process of existing asymmetric encryption and decryption algorithms, there are redundant calculations in the encryption and decryption process. When the amount of data is larger, the amount of encryption and decryption calculations is larger, resulting in low efficiency of data encryption and decryption. Summary of the invention

[0004] The embodiments of the present application provide a data processing method, a data processing system and a processing terminal, which solve the problem of redundant calculations and waste of processing time in the encryption and decryption process, can terminate the calculation in advance, reduce the data processing time, and thus improve the speed of encryption and decryption.

[0005] To solve the above technical problems, the present application provides the following technical solutions:

[0006] In a first aspect, an embodiment of the present application provides a data processing method, which is applied to the field of data encryption and decryption, and the method includes:

[0007] Obtain a first modulus value and a first parameter, wherein the first parameter is a power of a cardinality;

[0008] Performing an iterative operation on the first modulus value and the first parameter, wherein after each round of iterative operation, a first iterative value is obtained, wherein the first iterative value is an iterative value obtained by the current iterative operation;

[0009] If the first iteration value is equal to the iteration value obtained in the previous iteration, the iteration operation is stopped, wherein the first iteration value includes the inverse element of the first parameter with respect to the first modulus value;

[0010] A pre-calculation result is determined according to the current first iteration value, wherein the pre-calculation result is used for data encryption or decryption.

[0011] In some embodiments, performing an iterative operation on the first modulus value and the first parameter includes:

[0012] Perform an iterative operation on the first modulus value bit by bit to obtain a first iterative value, wherein the first iterative value includes:

[0013] W=N -1 modb r

[0014] Where W is the first iteration value, N is the first modulus value, r is the bit width, b is the base, and N -1 modb r The inverse element is obtained by taking the lower r bits of the first modulus value.

[0015] In some embodiments, the method further comprises:

[0016] Detect the parity state of the binary bit corresponding to the first modulus value in the current iteration operation. If the current binary bit is an even number, use the square value of the iteration value obtained in the previous iteration as the first iteration value;

[0017] If the current binary bit is in an odd state, the product of the iteration value obtained in the previous iteration and the first modulus value is used as the first iteration value.

[0018] In some embodiments, if the current binary bit is an even state, the first iteration value includes:

[0019] W=W1*W1modρ

[0020] Wherein, W is the first iteration value, W1 is the iteration value of the previous round of iteration operation, ρ is the first parameter, and W1*W1 is the square value of the iteration value obtained in the previous round of iteration;

[0021] If the current binary bit is an odd state, the first iteration value includes:

[0022] W=W1*Nmodρ

[0023] Wherein, W is the first iteration value, W1 is the iteration value of the previous round of iterative operation, N is the first module value, and W1*N is the product of the iteration value of the previous round of iteration and the first module value.

[0024] In some embodiments, the method further comprises:

[0025] If the first iteration value is not equal to the iteration value obtained in the previous round of iteration, the first iteration value will overwrite the iteration value obtained in the previous round of iteration, and continue with the next round of iteration operation.

[0026] In some embodiments, determining the pre-calculation result according to the current first iteration value includes:

[0027] Subtract the first iteration value from the first parameter to obtain the pre-calculated result.

[0028] In some embodiments, the first iteration value includes:

[0029]

[0030] Where W is the first iteration value, N is the first modulus value, ρ is the first parameter, is the number of positive integers less than or equal to ρ that are relatively prime to ρ;

[0031] Precomputed results include:

[0032]

[0033] Among them, ω is the pre-calculated result, ρ is the first parameter, N is the first modulus value, is the number of positive integers less than or equal to ρ that are relatively prime to ρ.

[0034] In a second aspect, an embodiment of the present application provides a data processing system, which is applied to the field of data encryption and decryption, and the system includes: a control module, a multiplier, and a comparator;

[0035] A control module, connected to the multiplier, for obtaining a first modulus value and a first parameter;

[0036] a multiplier connected to the control module, and configured to perform an iterative operation on the first modulus value and the first parameter, wherein after each round of iterative operation, a first iterative value is obtained, wherein the first iterative value is an iterative value obtained by the current iterative operation;

[0037] A comparator is connected to the multiplier and the control module, and is used to send an end signal to the control module if the first iteration value is equal to the iteration value obtained in the previous round of iteration, wherein the first iteration value includes the inverse element of the first parameter with respect to the first module value.

[0038] In some embodiments, the control module includes: a counter for recording the parity state of a binary bit corresponding to the first parameter;

[0039] The system also includes: a selector, a register;

[0040] A selector, connected to the counter and the multiplier, is used to select the corresponding input parameter according to the state recorded by the counter;

[0041] The register is connected to the multiplier and the comparator and is used to store the iteration value of the previous round of iterative operation of the multiplier.

[0042] In a third aspect, an embodiment of the present application provides a processing terminal, including:

[0043] The data processing system as in the second aspect;

[0044] and / or,

[0045] at least one processor, and

[0046] a memory communicatively connected to at least one processor; wherein,

[0047] The memory stores instructions that can be executed by at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the data processing method according to the first aspect.

[0048] The beneficial effect of the embodiments of the present application is: different from the prior art, the embodiments of the present application provide a data processing method, which is applied to the field of data encryption and decryption, and the method includes: obtaining a first modulus value and a first parameter, wherein the first parameter is a power of a base; performing iterative operations on the first modulus value and the first parameter, wherein after each round of iterative operations, a first iteration value is obtained, wherein the first iteration value is an iteration value obtained by the current iteration operation; if the first iteration value is equal to the iteration value obtained by the previous round of iteration, the iterative operation is stopped, wherein the first iteration value includes the inverse element of the first parameter with respect to the first modulus value; according to the current first iteration value, a pre-calculation result is determined, wherein the pre-calculation result is used for data encryption or decryption.

[0049] By iteratively operating the first modulus and the first parameter, when the iteration values ​​of two adjacent iterative operations are equal, the iterative operation is stopped, and the pre-calculated result is determined according to the iteration value of the current iterative operation. This application can terminate the calculation in advance, reduce data processing time, and thus increase the speed of data encryption and decryption. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0051] Figure 1 It is a schematic diagram of a process of encrypting and decrypting plaintext data during transmission provided by an embodiment of the present application;

[0052] Figure 2 This is a schematic diagram of the RSA encryption algorithm provided in the embodiment of the present application.

[0053] Figure 3 It is a flowchart of a data processing method provided in an embodiment of the present application;

[0054] Figure 4 yes Figure 3 A detailed flow chart of step S302;

[0055] Figure 5 is a schematic diagram of a process for calculating a first iteration value provided by an embodiment of the present application;

[0056] Figure 6 yes Figure 3 A detailed flow chart of step S307;

[0057] Figure 7 It is an overall flow chart of an iterative operation provided by an embodiment of the present application;

[0058] Figure 8 is an overall structural diagram of a data processing system provided in an embodiment of the present application;

[0059] Fig. 9 is a connection diagram of a control module and a selector provided in an embodiment of the present application;

[0060] Fig.10 This is a schematic diagram of a processing terminal provided in an embodiment of the present application.

[0061] Fig.11 It is a structural diagram of another processing terminal provided in an embodiment of the present application.

[0062] Description of Figure Numbers:

[0063] Label name Label name 1000 Processing Terminal 400 register 800 Data processing system 500 Comparator 100 Control Module 900 Processing Terminal 10 counter 1001 processor 200 Selector 1002 Memory 300 Multiplier DETAILED DESCRIPTION

[0064] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0065] It should be noted that, if there is no conflict, the various features in the embodiments of the present application can be combined with each other, all within the scope of protection of the present application. In addition, although the functional module division is performed in the device schematic diagram and the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in a sequence different from the module division in the device or the flow chart. Furthermore, the words "first", "second", "third", etc. used in this application do not limit the data and execution order, but only distinguish the same items or similar items with basically the same functions and effects.

[0066] In addition, the technical features involved in each embodiment of the present application described below can be combined with each other as long as they do not conflict with each other.

[0067] Before introducing the embodiments of the present application, a data encryption and decryption method known to the inventor of the present application is briefly introduced to facilitate subsequent understanding of the embodiments of the present application.

[0068] Existing data encryption and decryption algorithms include symmetric encryption algorithms and asymmetric encryption algorithms. Among them, the asymmetric encryption algorithm requires the use of two keys, namely a public key and a private key. The public key and the private key are usually in pairs. When one key is used for encryption, the other key is used for decryption.

[0069] See also Figure 1 , Figure 1 It is a schematic diagram of a process of encrypting and decrypting plaintext data during transmission provided by an embodiment of the present application;

[0070] like Figure 1 As shown, when a sender sends data to another sender (also called a receiver), an asymmetric encryption algorithm is used to process the plaintext data to obtain ciphertext data, and then the ciphertext data is sent to the receiver. The specific processing process is as follows: a pair of keys (public key and private key) are generated according to the current plaintext data. The public key is kept by the sender, and the private key is kept by the receiver. The sender uses the public key and the corresponding encryption function to encrypt the plaintext data to obtain the ciphertext data, and sends the ciphertext data to the receiver. The receiver uses the private key and the corresponding decryption function to decrypt the ciphertext data to obtain the plaintext data.

[0071] In an asymmetric encryption algorithm, the public key, plaintext data, and ciphertext data are usually converted into digital form for processing. For example, in the RSA algorithm, the following formula can be used to convert plaintext data into ciphertext data:

[0072] M=m e (mod n)

[0073] Among them, M is the ciphertext data, m is the plaintext data, e is the first power exponent, n is the modulus value, and (e, n) is the public key.

[0074] The following formula can be used to convert ciphertext data into plaintext data:

[0075] m=M d (mod n)

[0076] Among them, M is the ciphertext data, m is the plaintext data, d is the second power exponent, n is the modulus value, and (d, n) is the private key.

[0077] It can be seen that the essence of the RSA algorithm is modular exponentiation, and modular exponentiation requires pre-calculation of some parameters to speed up data encryption and decryption.

[0078] In the process of generating parameters by existing asymmetric encryption and decryption methods, iterative operations are usually performed within a set period, and the iterative operations are not stopped until the entire preset period is completed. When the amount of data calculated is larger, the operation time will be longer, especially in the inverse operation process, when the pre-calculated value appears in the operation cycle, the iterative operation is still not completed, which leads to a waste of processing time and reduces the efficiency of the calculation.

[0079] In response to the above problems, an embodiment of the present application provides a data processing method, which performs iterative operations on a first modulus value and a first parameter. When the iteration values ​​of two adjacent rounds of iterative operations are equal, the iterative operation is stopped, and a pre-calculated result value is determined according to the iteration value of the current iterative operation, so as to encrypt or decrypt the data through the pre-calculated result. The present application can terminate the calculation in advance, reduce the data processing time, and thus increase the speed of data encryption and decryption.

[0080] Before explaining the present application in detail, the terms and formulas known to the inventors of the present application are explained first. The terms and terms involved in the embodiments of the present application are subject to the following explanations.

[0081] (1) Euler's theorem: also known as the Fermat-Euler theorem or the Euler function theorem. In number theory, Euler's theorem is a property about congruence. If n and a are positive integers and n and a are relatively prime, then the formula is:

[0082]

[0083] in, is the number of positive integers less than or equal to n that are relatively prime to n. When n is a prime number, the formula can be strengthened to Fermat's Little Theorem, that is:

[0084]

[0085] (2) In the field of asymmetric encryption and decryption, Euler's theorem can usually be used to perform modular inverse operations. The formula is:

[0086]

[0087] (3) Inverse element: If a linear congruential equation ax≡1(modn), then x is called the inverse element of amodn, denoted by a -1 , where n is the modulus, and usually n is a prime number.

[0088] According to the properties of inverse elements, if n is a prime number, for any non-zero integer a, its inverse element can be calculated by calculating a n- 1 modn=1, because under modulo n, we have:

[0089] a*a n-2= a n-1 ≡ 1 (mod n)

[0090] Therefore, a n=2 is the multiplicative inverse of a.

[0091] (4) Montgomery modular multiplication algorithm, an efficient modular multiplication algorithm, is widely used in modular exponentiation of large numbers. The key of the Montgomery modular multiplication algorithm lies in introducing a positive integer that is relatively prime to the modulus value. This positive integer is usually a power of the base, such as a power of 2, so that bit shift operations in binary can be used to replace traditional division, thereby accelerating the calculation speed. The following takes the RSA encryption algorithm using the Montgomery modular multiplication algorithm as an example for illustration:

[0092] Please refer to Figure 2 , Figure 2 which is a schematic flowchart of an RSA encryption algorithm provided by an embodiment of this application;

[0093] As Figure 2 shown, the process of the RSA encryption algorithm includes:

[0094] Step S201: Obtain input data;

[0095] Among them, the input data includes plaintext data m, the first exponent e, and the modulus value n.

[0096] Step S202: Let i = 0;

[0097] Specifically, i is a variable. When i increments from 0 and takes different values each time by adding one, each bit of i in binary corresponds one-to-one with each bit of the first exponent e. Initialize the ciphertext variable M and the intermediate variable P, let M = 1 and assign the plaintext data m to P, then let i increment from 0. When i < L(n), verify whether the i-th bit of the first exponent e in binary is 1 in sequence from right to left, where L(n) is the number of bits of the modulus value n.

[0098] If the i-th bit of the first exponent e is 1, perform a modular exponentiation operation on the intermediate variable P and the ciphertext variable M, that is, execute steps S203 - S207, and assign the obtained modular exponentiation result to the ciphertext variable M, then update the value of the intermediate variable P to the square value of the intermediate variable P. If the i-th bit of the first exponent e is 0, only update the value of the intermediate variable P to the square value of the intermediate variable P. When i = L(n), end the process, and take the value of the ciphertext variable M at this time as the ciphertext data.

[0099] Step S203: Data preprocessing;

[0100] Specifically, each time the RSA encryption algorithm performs a modular exponentiation operation, it is necessary to perform data preprocessing first to calculate the first pre-calculated parameter w and the Montgomery domain data dat1, and the formula is as follows:

[0101] w=-n -1

[0102] dat1=dat*ρ(mod n)

[0103] Among them, w is the first pre-calculated parameter, n is the module value, dat1 is the Montgomery domain data of dat, ρ is the first parameter, dat is the multiplier required to perform Montgomery modular multiplication operation, and dat includes the intermediate variable P or the ciphertext variable M.

[0104] Step S204: Montgomery modular multiplication operation;

[0105] Specifically, in the RSA encryption algorithm, a Montgomery modular multiplication operation is performed on the intermediate variable P and the ciphertext variable M to obtain a Montgomery modular multiplication result.

[0106] The Montgomery modular multiplication operation includes integer multiplication and Montgomery reduction operation, that is, after multiplying two Montgomery field data to obtain a multiplication result, the multiplication result is Montgomery reduced to obtain a Montgomery modular multiplication result.

[0107] For example: for two Montgomery domain data x and y, x and y are both greater than zero, and x and y are both less than the modulus value n, the Montgomery modulus multiplication result r = x*y*ρ -1 , where ρ is the first parameter, satisfying: specify the minimum k, ρ = b k >n, the second parameter b=2 h , the second parameter b is relatively prime to the modulus n.

[0108] When b is 2, the Montgomery modular multiplication operation steps include steps S1 to S3:

[0109] Step S1: let r=0;

[0110] Step S2: Let a = 0, when a increases from 0 to L n-1 When , for each a, repeat:

[0111] u=(r0+y a *x0)*w(mod b)

[0112] r=(r+y a *x+u*n) / b

[0113] Where a is a variable. When a increases from 0 to different values, a corresponds to each bit of the Montgomery domain data y in binary. n-1is one less than the bit width of the modulus value n, u is the first calculation result, r is the second calculation result, r0 is the low bit of r, and y a is the a-th bit of the Montgomery domain data y, x0 is the low bit of the Montgomery domain data x, w is the first pre-calculation parameter, b is the second parameter, x is the Montgomery domain data, and n is the modulus value.

[0114] It can be understood that when the first parameter b = 2, the number of loop iterations in step S2 is L(n) times, where L(n) is the bit width of the modulus value n, r0 is the low 1 bit of r, and x0 is the low 1 bit of the Montgomery domain data x; when the second parameter b = 2 h the number of loop iterations in step S2 is L(n) / h times, r0 is the low h bits of r, and x0 is the low h bits of the Montgomery domain data x.

[0115] Step S3: If r ≥ n, the Montgomery modular multiplication result is r - n.

[0116] Step S205: Montgomery reduction operation;

[0117] Specifically, for a given data t, the formula for the Montgomery reduction operation is as follows:

[0118]

[0119] where is the Montgomery reduction result, t is the data that needs to perform the Montgomery reduction operation, ρ is the first parameter, and n is the modulus value.

[0120] Further, after obtaining the Montgomery reduction result, assign the Montgomery reduction result to the ciphertext variable M to update the ciphertext variable M.

[0121] Step S206: Let i = i + 1;

[0122] Step S207: Determine whether i is less than L(n);

[0123] Specifically, if i < L(n), then return to step S203 to perform the next modular exponentiation operation on the updated intermediate variable P and the updated ciphertext variable M; if i ≥ L(n), then enter step S208.

[0124] Step S208: Output the ciphertext data.

[0125] Specifically, if i ≥ L(n), then the value of the ciphertext variable M in step S205 at this time is the ciphertext data M corresponding to the plaintext data m.

[0126] It can be seen that for the RSA encryption algorithm that uses the Montgomery modular multiplication algorithm for modular exponentiation, each time a modular exponentiation operation is performed, data preprocessing is required, and then Montgomery modular multiplication and reduction processing is performed, which consumes a lot of time and reduces the encryption speed of the RSA encryption algorithm. In addition, asymmetric encryption algorithms such as the SM2 algorithm and the elliptic curve cryptography (ECC) algorithm all involve modular multiplication operations. In order to increase the speed of data encryption and decryption, the pre-calculation process needs to be further improved.

[0127] Based on this, an embodiment of the present application provides a data processing method, including: obtaining a first modulus value and a first parameter, wherein the first parameter is a power of a base; performing iterative operations on the first modulus value and the first parameter, obtaining a first iterative value after each round of iterative operations, and stopping the iterative operation if the first iterative value is equal to the iterative value obtained in the previous round of iterations, wherein the first iterative value includes the inverse element of the first parameter with respect to the first modulus value; determining a pre-calculated result according to the current first iterative value, and the pre-calculated result is used for data encryption or decryption. By performing iterative operations on the first modulus value and the first parameter, when the iterative values ​​of two adjacent rounds of iterative operations are equal, stopping the iterative operation, and determining the pre-calculated result according to the iterative value of the current iterative operation, the present application can terminate the calculation in advance, reduce the data processing time, so as to improve the data processing efficiency, and further improve the encryption and decryption speed of the data.

[0128] The technical solution of this application is described in detail below with reference to the accompanying drawings:

[0129] See also Figure 3 , Figure 3 It is a flowchart of a data processing method provided in an embodiment of the present application;

[0130] The method can be applied to various electronic devices, such as terminals, servers and other electronic devices. Specifically, the execution subject of the method is one or at least two processors in the electronic device.

[0131] like Figure 3 As shown, the data processing method comprises:

[0132] Step S301: obtaining a first modulus value and a first parameter, wherein the first parameter is a power of a cardinality;

[0133] In the embodiments of the present application, the first modulus value and the first parameter are some parameters that need to be used in the pre-calculation process. Taking the RSA encryption algorithm as an example, in the pre-calculation process, the first modulus value is determined by two prime numbers, that is, the first modulus value = the first prime number * the second prime number. For example: the first prime number is 17, the second prime number is 19, then the first modulus value = 17*19 = 323. It should be noted that the prime number that generates the first modulus value is usually a prime number that is large enough. How to obtain the prime number to generate the first modulus value is usually obtained by randomly selecting and testing the properties of the prime number within a certain range, which will not be described in detail here. Specifically, the first modulus value and the first parameter are obtained, wherein the first parameter is a power of the base number. For example: when the base number is 2, the first parameter = 2 k , k is the minimum value of the power of the cardinality that satisfies the condition of being greater than the first modulus value, that is, the condition is: 2 k >first modulus value, then k is the minimum value that satisfies this condition.

[0134] Step S302: performing an iterative operation on the first modulus value and the first parameter, wherein after each round of iterative operation, a first iterative value is obtained, wherein the first iterative value is an iterative value obtained by the current iterative operation;

[0135] Specifically, an iterative operation is performed on the first modulus and the first parameter, wherein after each round of iterative operation, a first iterative value is obtained, wherein the first iterative value is an iterative value obtained by the current iterative operation. The specific iterative operation process is as follows: Figure 4 shown.

[0136] Please refer to Figure 4 , Figure 4 yes Figure 3 A detailed flow chart of step S302;

[0137] like Figure 4 As shown, step S302 includes:

[0138] Step S3021: performing an iterative operation on the first modulus value bit by bit to obtain a first iterative value;

[0139] In the embodiment of the present application, performing iterative operation on the first modulus value and the first parameter to obtain the first iterative value is essentially a process of obtaining the inverse element of the first modulus value, and the first iterative value includes:

[0140] W=N -1 modρ

[0141] Where W is the first iteration value, N is the first modulus value, ρ is the first parameter, and N -1 is the inverse element of the first modulus under the first parameter.

[0142] It can be understood that the inverse element exists only when N and ρ are mutually prime. In the RSA encryption algorithm, the inverse element is used to generate the public key and the private key, and plays an important role in the encryption or decryption process. For example, to encrypt the plaintext M, use the public key (e, n) to calculate the ciphertext C = M e modn, for example: decrypt the ciphertext C, use the private key (d, n), and calculate the plaintext M = C d modn, where e is an integer, n is the modulus value, n = p*q, p and q are two different large prime numbers, d is the modulus of e The inverse element, is the number of positive integers less than or equal to n that are relatively prime to n.

[0143] Furthermore, according to Fermat's little theorem, the first iteration value can be equivalent to:

[0144]

[0145] Further, it is transformed into:

[0146]

[0147] Where W is the first iteration value, ρ is the first parameter, is the number of positive integers less than or equal to ρ that are relatively prime to ρ.

[0148] Specifically, the first modulus value is iterated bit by bit, that is, Converted to binary form, Starting from the lowest bit, traverse to the left bit by bit, and iterate the first modulus value.

[0149] In the present embodiment, Convert to binary to perform iterative operations based on binary. When the number of bits of the integer processed by the processor at a time is less than When the corresponding binary digits are used, it is necessary to limit the bit width of the binary processed in each iterative operation. The bit widths processed by general processors include: 32bit, 64bit, and 128bit. When the bit width is 64bit, in order to ensure that the processed data is within 64bit, ρ=2 k =2 64 .

[0150] In the embodiment of the present application, the index is decomposed into Expressed in binary form, for example: Assume for The binary representation of e nis the highest bit, e0 is the lowest bit, and according to each binary bit, the corresponding calculation method is selected to calculate the first iteration value. Each time the first iteration value corresponding to each binary bit is calculated, the current iteration value is updated until the target iteration value appears, and then the iterative operation is stopped.

[0151] It should be noted that when performing fast exponentiation, exponential decomposition can take advantage of the properties of exponentiation and the binary representation of the exponent. Represented in binary form, it allows Decompose into multiple The product of, it is understandable that, It can easily become very large. Decomposing and using modular operations to limit the size of the calculated result value can reduce the amount of calculation.

[0152] In the embodiment of the present application, the first modulus value is iteratively calculated based on binary, then is the integer power of 2 minus 1, that is

[0153]

[0154] The first iteration value Converts to:

[0155]

[0156] Furthermore, by extracting 2 from the exponents of the above formula, we get:

[0157]

[0158] In the embodiment of the present application, when the states corresponding to the binary bits are different, the input parameters used in the iterative operation are different. The specific process is as follows: Figure 5 shown.

[0159] Please refer to Figure 5 , Figure 5 is a schematic diagram of a process for calculating a first iteration value provided by an embodiment of the present application;

[0160] like Figure 5 As shown, the calculation of the first iteration value includes:

[0161] Step S501: Get the current binary bit;

[0162] Specifically, the binary bit corresponding to the first modulus value in the current iterative operation is obtained, where the value of the binary bit is 0 or 1.

[0163] Step S502: Determine whether the current binary bit is an even number;

[0164] Specifically, if the binary bit corresponding to the first modulus value in the current iterative operation is 0, it indicates an even state, and jumps to step S503. If the current binary bit is 1, it indicates an odd state, and jumps to step S504.

[0165] Step S503: taking the square value of the iteration value of the previous round of calculation as the first iteration value;

[0166] Specifically, when the binary bit is an even number, the iteration value of the previous round of iteration operation is squared to obtain a square value, and the square value is subjected to a modulo operation to obtain a first iteration value. The specific formula is:

[0167] W=W1*W1modρ

[0168] Wherein, W is the first iteration value, ρ is the first parameter, and W1 is the iteration value obtained by the previous round of iterative operation.

[0169] Step S504: taking the product of the iteration value of the previous round of calculation and the first modulus value as the first iteration value;

[0170] Specifically, when the binary bit is an odd number, the iteration value of the previous round of iterative operation is multiplied by the first modulus value to obtain a product, and the product is subjected to a modulus operation to obtain a first iteration value. The specific formula is:

[0171] W=W1*Nmodρ

[0172] Wherein, W is the first iteration value, N is the first modulus value, ρ is the first parameter, and W1 is the iteration value obtained by the previous round of iterative operation.

[0173] In an embodiment of the present application, the data processing method further includes: setting a maximum cycle, which is used to limit the number of iterative operations so that the iterative operation time does not exceed the maximum cycle. By setting the maximum cycle, it is prevented from falling into an infinite loop when the expected results are not obtained during the iterative operation within the maximum cycle. The maximum cycle can be:

[0174] In an embodiment of the present application, a counter is added to record the parity state corresponding to the binary bit, and a multiplier is used to select the corresponding multiplication operation according to the state recorded by the counter. When the binary bit is in an even state, W1*W1modρ is executed, and when the binary bit is in an odd state, W1*Nmodρ is executed. The present application uses a counter to track the parity of the current cycle of the loop to determine the multiplication operation that needs to be performed currently. Two different multiplication operations can be implemented to achieve multiplexing of the multiplier, that is, using the same multiplier to implement two different multiplication operations, thereby improving resource utilization and efficiency.

[0175] In an embodiment of the present application, during the iterative operation of the first modulus value, it is necessary to initialize the variable to 1, because the 0th power of any number is 1, wherein the variable is used to store the iteration value of the current iterative operation, that is, to store the first iteration value W, and the first iteration value is stored in a register.

[0176] Step S303: Determine whether the current first iteration value is equal to the iteration value obtained in the previous iteration;

[0177] Specifically, the iteration value of the previous round of iterative operation is obtained from the register, and the iteration value of the previous round of iterative operation is compared with the current first iteration value to see whether they are equal. If they are equal, jump to step S304; if they are not equal, jump to step S305.

[0178] Step S304: stop iterative operation;

[0179] Specifically, when the iteration value of the previous iteration operation is equal to the current first iteration value, the current iteration operation is stopped.

[0180] In an embodiment of the present application, when the binary bit is 0, W=W1*W1modρ is executed, and when the binary bit is 1, W=W1*Nmodρ is executed. Each time the first iteration value corresponding to a binary bit is calculated, a round of iterative operation is performed, and then it is determined whether the current first iteration value is equal to the previous round of iteration value. If they are equal, the current iteration operation is terminated. If they are not equal, the iterative operation is continued until the target iteration value is obtained.

[0181] In the embodiment of the present application, by determining whether the iteration values ​​of two adjacent rounds of iterative operations are equal, if they are equal, stopping the current iterative operation, the calculation time can be greatly reduced.

[0182] For example: ρ = 2 4 , N = 11, (N mod ρ) 511 (modρ)=11 511 (mod16) = 3, but in fact, (Nmodρ) 15 (modρ)=11 15 (mod16)=3.

[0183] For another example: Let N = 667, then ρ = 1024, According to the above calculation formula for iterative value operation W = N 511 (mod1024)=667 511 (mod1024)=915, but actually W=N 255 (mod1024)=667 255 (mod1024)=915.

[0184] Therefore, terminating the iterative operation early can save a lot of time and improve the efficiency of the calculation.

[0185] Step S305: Overwrite the iteration value obtained in the previous iteration with the current first iteration value;

[0186] Specifically, when the iteration value of the previous round of iterative calculation is not equal to the current first iteration value, the current first iteration value overwrites the iteration value obtained by the previous round of iteration stored in the register, and jumps to step S306.

[0187] Step S306: perform the next round of iterative calculation;

[0188] Specifically, when the iteration value of the previous round of iterative calculation is not equal to the current first iteration value, the current first iteration value overwrites the iteration value obtained by the previous round of iteration stored in the register, continues the next round of iterative calculation, and jumps to step S303.

[0189] Step S307: Determine the pre-calculation result according to the current first iteration value.

[0190] Specifically, after the iterative operation is stopped, the pre-calculation result is calculated according to the current first iteration value, wherein the pre-calculation result is the pre-calculation parameter, and the pre-calculation result is used for data encryption or decryption.

[0191] Please refer to Figure 6 , Figure 6 yes Figure 3 A detailed flow chart of step S307;

[0192] like Figure 6 As shown, step S307 includes:

[0193] Step S3071: subtract the first iteration value from the first parameter to obtain a pre-calculation result;

[0194] Specifically, the pre-calculation result is calculated according to the current first iteration value, and the pre-calculation result includes:

[0195]

[0196] The precomputed result can also be equivalent to:

[0197]

[0198] Among them, ω is the pre-calculated result, ρ is the first parameter, N is the modulus value, is the number of positive integers less than or equal to ρ that are relatively prime to ρ.

[0199] In an embodiment of the present application, the pre-calculated result is used to encrypt or decrypt data.

[0200] Please refer again Figure 2 , Figure 2 It is a flow chart of an RSA encryption algorithm provided in an embodiment of the present application;

[0201] When the RSA encryption algorithm performs modular exponentiation operation each time, data preprocessing is required to calculate the first pre-calculated parameter w, which is used to perform Montgomery modular multiplication operation. The Montgomery modular multiplication operation step includes steps S1 to S3:

[0202] Step S1: let r=0;

[0203] Step S2: Let a = 0, when a increases from 0 to L n-1 When , for each a, repeat:

[0204] u=(r0+y a *x0)*w(mod b)

[0205] r=(r+y a *x+u*n) / b

[0206] Where a is a variable. When a increases from 0 to different values, a corresponds to each bit of the Montgomery domain data y in binary. n-1 is the bit width of the modulus value n minus one, u is the first calculation result, r is the second calculation result, r0 is the low bit of r, y a is the a-th bit of the Montgomery domain data y, x0 is the low bit of the Montgomery domain data x, w is the first pre-calculated parameter, b is the second parameter, x is the Montgomery domain data, and n is the modulus value.

[0207] Step S3: If r≥n, the result of the Montgomery modular multiplication is rn.

[0208] It can be seen that the first pre-calculation parameter is used to calculate the first calculation result, the first calculation result is further used to calculate the second calculation result, and the Montgomery modular multiplication result is calculated by the second calculation result. The Montgomery modular multiplication result is the result obtained by performing Montgomery modular multiplication operation on the intermediate variable P and the ciphertext variable M.

[0209] In an embodiment of the present application, the pre-calculation result includes a pre-calculation parameter, and the pre-calculation parameter includes a first pre-calculation parameter. The present application stops the iterative operation by judging that the iteration values ​​of two adjacent iterative operations are equal, determines the pre-calculation result according to the iteration value of the current iterative operation, and calculates the Montgomery modular multiplication result by the pre-calculation result to further encrypt the data, so as to terminate the current iterative operation in advance, reduce the amount of calculation, and improve the data processing speed. In an embodiment of the present application, by iteratively operating the first modular value and the first parameter, when the iteration values ​​of two adjacent iterative operations are equal, the iterative operation is stopped, and the pre-calculation result is determined according to the iteration value of the current iterative operation, so as to achieve early termination of the iterative operation, reduce data processing time, improve data processing efficiency, and improve the speed of data encryption and decryption.

[0210] Please refer to Figure 7 , Figure 7 It is an overall flow chart of an iterative operation provided by an embodiment of the present application;

[0211] like Figure 7 As shown, the iterative operation includes:

[0212] Step S701: Initialize variables;

[0213] Specifically, a first module value N and a first parameter ρ are input, and a first iteration value W=1 is initialized.

[0214] Step S702: performing iterative operation;

[0215] Specifically, the exponent of the first modulus value is converted into binary, and the first modulus value N is iterated according to the binary bits corresponding to the exponent, where the exponent is

[0216] Step S703: Determine the parity state corresponding to the current binary bit;

[0217] Specifically, when the binary bit corresponding to the exponent is 0, it is an even state, and the process jumps to step S704; when the binary bit corresponding to the exponent is 1, it is an odd state, and the process jumps to step S705.

[0218] Step S704: square the iteration value obtained in the previous round, and perform a modulo operation to obtain a first iteration value;

[0219] Specifically, when the binary bit corresponding to the exponent is 0, the iteration value (W1) obtained in the previous round is squared and a modulo operation is performed to obtain the first iteration value (W), that is, W=W1*W1modρ.

[0220] Step S705: multiplying the iteration value obtained in the previous round by the first modulus value, and performing a modulus operation to obtain a first iteration value;

[0221] Specifically, when the binary bit corresponding to the exponent is 1, the iteration value (W1) obtained in the previous round is multiplied by the first modulus value, and a modulus operation is performed to obtain the first iteration value (W), that is, W=W1*Nmodρ.

[0222] Step S706: determining whether the iteration value obtained in the previous round of iterative calculation is equal to the current first iteration value;

[0223] Specifically, determine whether the iteration value obtained in the previous round of iterative calculation is equal to the current first iteration value. If they are not equal, the current first iteration value (W) will overwrite the iteration value (W1) obtained in the previous round of iteration, even if W1=W, and jump to step S602. If the iteration value obtained in the previous round of iterative calculation is equal to the current first iteration value, the current iterative calculation is terminated.

[0224] It should be noted that the data processing method in the present application can be used in any processing based on Euler's formula or Fermat's little theorem to complete early termination in its calculation, for example: for asymmetric encryption algorithms, which include RSA encryption algorithms, SM2 algorithms, elliptic curve cryptography (ECC) and other algorithms.

[0225] In the embodiment of the present application, by comparing the iteration values ​​of two adjacent iterative operations and finding that they are equal, the iterative operation is ended to terminate the calculation in advance and obtain the pre-calculated result, which can reduce the calculation time and improve the efficiency of data processing.

[0226] See also Figure 8 , Figure 8 is an overall structural diagram of a data processing system provided in an embodiment of the present application;

[0227] like Figure 8 As shown, the data processing system 800 includes: a control module 100 (Control), a selector 200 (Multiplexer, MUX), a multiplier 300 (bit*bit multiplier), a register 400 (Register), and a comparator 500 (comparing unit). The data processing system 800 includes but is not limited to: a computer terminal, a notebook, a server, and other devices capable of processing data.

[0228] The control module 100 is connected to the selector 200 and the comparator 500. The control module 100 is used to control the start and end of the iterative operation and convert the acquired first module value into a binary form to perform iterative operation on the first module value in the binary form.

[0229] It is understandable that the control module 100 is used to receive input signals, perform signal processing based on these input signals, and generate corresponding output signals. The control module 100 in the embodiment of the present application is used to convert the input first module value, specifically, convert the first module value into a binary form, and perform iterative operations in the binary form to obtain the iterative value of each round of operation, and output the pre-calculated result according to the iterative value of each round of operation.

[0230] In an embodiment of the present application, the control module 100 includes a processor of a processing terminal. The control module 100 is a core component for executing program instructions or for performing data processing. Specifically, the control module 100 includes a central processing unit (CPU), a microprocessor, a microcontroller (MCU), a microprocessor system, a coprocessor, a neural processing unit (NPU), a digital signal processor (DSP) or a programmable gate array (FPGA), etc.

[0231] See also Fig. 9 , Fig. 9 is a connection diagram of a control module and a selector provided in an embodiment of the present application;

[0232] like Fig. 9 As shown, the control module 100 includes a counter 10, which is connected to the selector 200. The counter 10 is used to record the parity state of the lowest binary bit corresponding to the first modulus value, wherein the parity state includes an odd state and an even state, the odd state corresponds to a value of 1 for the lowest binary bit, and the even state corresponds to a value of 0 for the lowest binary bit.

[0233] It is understandable that the counter 10 is used to record the number of occurrences of an event, such as measuring time and frequency. In an embodiment of the present application, the counter 10 is also used to record the parity state of the lowest binary bit corresponding to the first modulus value, wherein the parity state is 0 or 1. In an embodiment of the present application, the counter 10 includes a binary counter, a synchronous counter, an asynchronous counter, a programmable counter, and the like. Preferably, the counter in the embodiment of the present application is a binary counter.

[0234] The selector 200 is connected to the control module 100 and the multiplier 300 . The selector 200 is used to select the corresponding input parameter according to the parity state of the lowest bit recorded by the counter in the control module 1000 .

[0235] It is understood that the selector is a basic component of digital and analog circuit design, which is used to select one of multiple input signals and directly transmit the selected input to a single output, thereby controlling the flow of signals and realizing signal selection and routing. In the embodiment of the present application, the selector 200 includes a digital selector, or an analog selector.

[0236] Among them, the digital selector includes a digital multiplexer, which is used to direct one or more of the multiple input signals to the output according to the state of the select lines. For example, a 2-to-1 multiplexer (2:1MUX) has two inputs, a select line, and an output. The select line determines which input signal is connected to the output. If the select line is 0, the first input is connected; if the select line is 1, the second input is connected. Alternatively, a selector with a higher number of inputs, such as a 4-to-1 (4:1MUX), has two select lines, and one of the four input signals can be selected according to the binary value of the select line.

[0237] The analog selector includes an analog multiplexer, which can select one of multiple analog inputs according to a control signal and transmit it to a single output.

[0238] The multiplier 300 is connected to the selector 200 , the register 400 , and the comparator 500 . The multiplier 300 is used to perform iterative operations on the input parameters selected by the selector, and save the iterative values ​​of the iterative operations into the register 400 .

[0239] It is understood that a multiplier is a circuit for performing a multiplication operation. A multiplier is used to calculate the product of two numbers. In an embodiment of the present application, the multiplier is a hardware multiplier, which includes a serial multiplier, a parallel multiplier, an array multiplier, or a bit-serial multiplier. Preferably, the multiplier in the embodiment of the present application is a bit-by-bit multiplier.

[0240] The register 400 is connected to the multiplier 300 and the comparator 500 , and is used to store the result calculated by the multiplier 300 .

[0241] It is understood that registers are used to store instructions, data and calculation results. In the embodiment of the present application, registers include data registers, address registers, instruction registers, status registers or flag registers. Preferably, registers include data registers to store the results calculated by multiplier 300.

[0242] The comparator 500 is connected to the multiplier 300, the register 400, and the control module 100. The comparator 500 is used to compare the iteration value of the current iteration operation of the multiplier 300 with the iteration value obtained by the previous round of iteration operation stored in the register 400. If they are equal, an end signal is sent to the control module 100. The end signal includes a level signal (high level or low level), for example: the comparator outputs a high level signal to indicate the end of the iteration operation, or the comparator outputs a low level signal to indicate the end of the iteration operation. It can be understood that the end signal can also include an interrupt signal, for example: the comparator sends an interrupt request to the control module to instruct the control module to execute a corresponding processing program.

[0243] As you can understand, a comparator is a circuit or device that compares two values ​​and outputs the comparison result. The basic function of a comparator is to determine the magnitude relationship between input signals A and B and output different signals accordingly. Depending on the complexity of the comparison, a comparator can simply compare two binary numbers or perform more complex multi-digit comparisons.

[0244] In the embodiment of the present application, the comparator includes a digital comparator (Digital Comparator) or an analog comparator (Analog Comparator), wherein the digital comparator is used to compare the size of two binary numbers (such as two 4-digit numbers), and the binary comparator has multiple outputs, which can represent equal, greater than or less than relationships. The analog comparator is used to compare the voltage or current size of two analog signals. Usually there is only one output, indicating whether one input is higher than the other input.

[0245] Specifically, the data processing system 800 performs an iterative operation on the first modulus value bit by bit to obtain a first iterative value, which includes:

[0246] W=N -1 modρ

[0247] Where W is the first iteration value, N is the first modulus value, ρ is the first parameter, and N -1 is the inverse element of the first modulus under the first parameter.

[0248] The first iteration value may be equivalent to:

[0249]

[0250] Where W is the first iteration value, ρ is the first parameter, is the number of positive integers less than or equal to ρ that are relatively prime to ρ.

[0251] Specifically, a variable in the register 400 is pre-initialized to 1, and the variable is used to store the iteration value of the current iteration operation, that is, the first iteration value.

[0252] The control module 100 obtains a first modulus value and a first parameter, wherein the first parameter is a power of a base. For example, when the base is 2, the first parameter = 2 k , k is the minimum value of the power of the cardinality that satisfies the condition of being greater than the first modulus value, that is, the condition is: 2 k >first modulus value, then k is the minimum value that satisfies this condition.

[0253] The control module 100 will Convert it into binary form, and control counter 10 to record the parity state corresponding to the current binary. Starting from the lowest bit, traverse leftward bit by bit, and control the selector 200 to select the corresponding input parameter according to the parity state corresponding to each binary bit, wherein if the current binary bit is 0, it indicates an even state, and if the current binary bit is 1, it indicates an odd state.

[0254] In the embodiment of the present application, the first modulus value is iteratively calculated based on binary, then is the integer power of 2 minus 1, that is

[0255]

[0256] The first iteration value Converts to:

[0257]

[0258] Furthermore, by extracting 2 from the exponents of the above formula, we get:

[0259]

[0260] Further, the selector 200 selects the corresponding input parameter according to the parity state recorded by the counter 10. When the binary bit is an even number, the iteration value of the previous round of iterative operation is input and sent to the multiplier 300. The multiplier 300 squares the iteration value of the previous round of iterative operation and takes the modulus to obtain the first iteration value. The specific formula is:

[0261] W=W1*W1modρ

[0262] Wherein, W is the first iteration value, ρ is the first parameter, and W1 is the iteration value obtained by the previous round of iterative operation.

[0263] When the binary bit is an odd number, the selector 200 selects to input the first modulus value and the iteration value of the previous round of iterative operation to the multiplier 300, and the multiplier 300 multiplies the iteration value of the previous round of iterative operation with the first modulus value and takes the modulus to obtain the first iteration value. The specific formula is:

[0264] W=W1*Nmodρ

[0265] Wherein, W is the first iteration value, N is the first modulus value, ρ is the first parameter, and W1 is the iteration value obtained by the previous round of iterative operation.

[0266] In the embodiment of the present application, the multiplier 300 includes a first multiplication unit and a second multiplication unit, wherein the first multiplication unit is used to execute the calculation step of W=W1*W1modρ, and the second multiplication unit is used to execute the calculation step of W=W1*Nmodρ.

[0267] In an embodiment of the present application, the multiplier 300 includes a bit-serial multiplier, wherein the bit-serial multiplier includes a first multiplication register and a second multiplication register. Specifically, a multiplication operation is performed through the bit-serial multiplier, including: when the binary bit is in an even state, the selector selects to input two iteration values ​​obtained in the previous round of iterative operation, and saves them to the first multiplication register and the second multiplication register respectively, and the first multiplication unit obtains the values ​​in the first multiplication register and the second multiplication register to execute the calculation step of W=W1*W1modρ; when the binary bit is in an odd state, the selector selects to input the iteration value and the first modulus value obtained in the previous round of iterative operation, and saves them to the first multiplication register and the second multiplication register respectively, and the first multiplication unit obtains the values ​​in the first multiplication register and the second multiplication register to execute the calculation step of W=W1*Nmodρ.

[0268] In an embodiment of the present application, when the selector 200 recognizes that the state corresponding to the binary bit recorded by the counter 10 is an even state, two iteration values ​​of the previous round of iterative operations are input, and the input iteration values ​​are multiplied and modulo by the multiplier 300. When the state corresponding to the binary bit is an odd state, the selector 200 selects to input the iteration value of the previous round of iterative operations and the first modulus value, and multiplies and modulo by the multiplier 300. The present application adds a counter to record the parity state corresponding to the binary bit, and the selector selects the input parameter according to the parity state recorded by the counter, so that the counter controls the loop to perform iterative operations, so as to realize two different multiplication operations through the same multiplier, thereby improving resource utilization and efficiency.

[0269] Further, the multiplier 300 sends the current iteration value to the selector 200 so as to use the current iteration value as an operation parameter for the next round of iterative operation. At the same time, the multiplier 300 sends the current iteration value to the comparator 500 .

[0270] Furthermore, the comparator 500 determines whether the current first iteration value is equal to the iteration value obtained in the previous iteration.

[0271] Specifically, the comparator 500 obtains the iteration value of the previous round of iterative operations from the register 400, and compares the iteration value of the previous round of iterative operations with the current iteration value. When the iteration value of the previous round of iterative operations is not equal to the current iteration value, the current iteration value is saved in the register 400, that is, the current iteration value overwrites the iteration value of the previous round of iterative operations saved in the register 400, and continues with the next round of iterative operations. When the iteration value of the previous round of iterative operations is equal to the current iteration value, the comparator 500 sends an end signal to the control module 100, and the control module 100 terminates the current iterative operation after receiving the end signal.

[0272] In the embodiment of the present application, by determining whether the iteration values ​​of two adjacent rounds of iterative operations are equal, if they are equal, the current iterative operation is stopped, thereby terminating the iterative operation in advance, thereby significantly reducing the calculation time.

[0273] For example: ρ = 2 4 , N = 11, (N mod ρ) 511 (modρ)=11 511 (mod16) = 3, but in fact, (Nmodρ) 15 (modρ)=11 15 (mod16)=3.

[0274] For another example: Let N = 667, then ρ = 1024, According to the above calculation formula for iterative value operation W = N 511 (mod1024)=667 511 (mod1024)=915, but actually W=N 255 (mod1024)=667 255 (mod1024)=915.

[0275] It can be seen that the desired result may appear before the maximum cycle of the iterative operation is completed, thereby terminating the iterative operation in advance. Specifically, the present application performs iterative operations on data through the above-mentioned data processing system, and then stops the iterative operation when it is determined that the iteration values ​​of two adjacent rounds of iterative operations are equal. This can terminate the current iterative operation before running to the maximum cycle, thereby saving operation time and improving calculation efficiency.

[0276] Further, the pre-calculation result is calculated according to the current first iteration value, and the pre-calculation result includes:

[0277]

[0278] The precomputed result can also be equivalent to:

[0279]

[0280] Among them, ω is the pre-calculated result, ρ is the first parameter, N is the modulus value, is the number of positive integers less than or equal to ρ that are relatively prime to ρ. The functions of the various modules in the above-mentioned data processing system 800 can be implemented by an integrated circuit, which includes: transistors, logic gates and other electronic components, wherein the logic gates include an arithmetic logic unit (Arithmetic and Logic Unit, ALU), and the arithmetic logic unit can perform related calculations of Euler's formula or Fermat's little theorem. The functions of the various modules in the data processing system 800 can also be integrated into a single chip, such as: a microprocessor, a microprocessor system or a programmable array logic (Field Programmable Gate Array, FPGA).

[0281] In an embodiment of the present application, the input parameters are selected by the parity state corresponding to the binary system recorded by the counter. When the parity state corresponding to the binary system is different, different input parameters are selected to realize alternating operation of different operation processes in the parity state, thereby realizing the iterative operation process. The present application can realize the multiplexing of hardware multipliers under the premise of one multiplier, thereby improving the utilization efficiency of the multiplier.

[0282] It should be noted that the data processing system in the present application can be used in any data encryption and decryption processing based on modular exponentiation to complete the early termination of its calculation to improve the speed of data encryption and decryption. Among them, the data processing system can be a hardware circuit, which can be applied in various environments, including but not limited to: scientific research, financial fields, communications and network security, medical image processing, artificial intelligence and machine learning. For example: in scientific research, especially in research projects involving sensitive information or confidential data, data encryption and decryption technology can ensure the confidentiality of data. For example: in the financial field, it is crucial to protect transaction data and customer information. In the field of communications and network security, in order to protect the security of data during transmission, data encryption and decryption technology is required. The data processing system provided in the embodiment of the present application can speed up the calculation and improve the efficiency of data processing.

[0283] In an embodiment of the present application, a first module value and a first parameter are obtained through a control module. During the iterative operation, a selector selects an input parameter by judging the parity state recorded by a counter in the control module. A multiplier operates on the first module value and the first parameter. A comparator compares the iteration value of the current operation of the multiplier with the iteration value of the previous round of operation stored in a register. If the iteration values ​​of two adjacent rounds of operation are equal, an end signal is sent to the control module to end the current iterative operation, thereby determining a pre-calculated result according to the iteration value of the current iterative operation. The present application can terminate the calculation in advance, reduce the pre-calculated data processing time, and thereby improve the processing efficiency of the Montgomery modular multiplication algorithm, so as to further improve the speed of data encryption and decryption.

[0284] See also Fig.10 , Fig.10 is a structural diagram of a processing terminal provided in an embodiment of the present application;

[0285] like Fig.10 As shown, the processing terminal 1000 includes a data processing system 800, wherein the data processing system 800 is Figure 8 The data processing system 800 shown in FIG. 1 includes a tablet computer, a notebook computer, a desktop computer, etc., but is not limited thereto.

[0286] The data processing system 800 includes Figure 8 The control module 100 , the selector 200 , the multiplier 300 , the register 400 , and the comparator 500 are shown.

[0287] Specifically, the control module 100 obtains a first modulus value and a first parameter, wherein the first parameter is a power of a base. For example, when the base is 2, the first parameter = 2 k , k is the minimum value of the power of the cardinality that satisfies the condition of being greater than the first modulus value, that is, the condition is: 2 k >first modulus value, then k is the minimum value that satisfies this condition.

[0288] The control module 100 will Convert it into binary form, and control counter 10 to record the parity state corresponding to the current binary. Starting from the lowest bit, traverse leftward bit by bit, and control the selector 200 to select the corresponding input parameter according to the parity state corresponding to each binary bit, wherein if the current binary bit is 0, it indicates an even state, and if the current binary bit is 1, it indicates an odd state.

[0289] The selector 200 selects the corresponding input parameter according to the parity state recorded by the counter 10. When the binary bit is an even number, the iteration value of the previous round of iterative operation is input and sent to the multiplier 300. The multiplier 300 squares the iteration value of the previous round of iterative operation and takes the modulus, that is, executes the calculation step of W=W1*W1modρ to obtain the first iteration value. When the binary bit is an odd number, the selector 200 selects to input the first modulus value and the iteration value of the previous round of iterative operation to the multiplier 300. The multiplier 300 multiplies the iteration value of the previous round of iterative operation with the first modulus value and takes the modulus, that is, executes the calculation step of W=W1*Nmodρ to obtain the first iteration value.

[0290] In an embodiment of the present application, when the selector 200 recognizes that the state corresponding to the binary bit recorded by the counter 10 is an even state, two iteration values ​​of the previous round of iterative operations are input, and the input iteration values ​​are multiplied and modulo by the multiplier 300. When the state corresponding to the binary bit is an odd state, the selector 200 selects to input the iteration value of the previous round of iterative operations and the first modulus value, and multiplies and modulo by the multiplier 300. The present application adds a counter to record the parity state corresponding to the binary bit, and the selector selects the input parameter according to the parity state recorded by the counter, so that the counter controls the loop to perform iterative operations, so as to realize two different multiplication operations through the same multiplier, thereby improving resource utilization and efficiency.

[0291] The comparator 500 obtains the iteration value of the previous round of iterative operation from the register 400, and compares the iteration value of the previous round of iterative operation with the current iteration value. When the iteration value of the previous round of iterative operation is not equal to the current iteration value, the current iteration value is saved in the register 400, that is, the current iteration value overwrites the iteration value of the previous round of iterative operation saved in the register 400, and continues to the next round of iterative operation. When the iteration value of the previous round of iterative operation is equal to the current iteration value, the comparator 500 sends an end signal to the control module 100, and the control module 100 terminates the current iterative operation after receiving the end signal.

[0292] It should be noted that the processing terminal 1000 mentioned above includes: Figure 8 The data processing system 800 shown in FIG. 8 may refer to the related contents mentioned in the above embodiments and Figure 8 The data processing system 800 shown is not described in detail here.

[0293] In an embodiment of the present application, the various modules in the data processing system 800 cooperate with each other to perform iterative operations, and when it is determined that the iteration values ​​of two adjacent rounds of iterative operations are equal, the iterative operations are stopped. This can terminate the current iterative operation before running to the maximum cycle, thereby saving operation time and improving calculation efficiency.

[0294] In an embodiment of the present application, the processing terminal 1000 includes a data processing system 800. The processing terminal 1000 in the present application can terminate the calculation in advance, reduce the data processing time, so as to improve the data processing efficiency, and further improve the speed of data encryption and decryption.

[0295] See also Fig.11 , Fig.11 is a schematic diagram of the structure of another processing terminal provided in an embodiment of the present application;

[0296] like Fig.11 As shown, the processing terminal 1000 includes one or more processors 1001 and a memory 1002. Fig.11 A processor 1001 is taken as an example.

[0297] The processor 1001 and the memory 1002 may be connected via a bus or other means. Fig.11 The example of connecting through bus is taken in the following.

[0298] Processor 1001 is used to provide computing and control capabilities to control processing terminal 1000 to perform corresponding tasks, for example, to control processing terminal 1000 to perform a data processing method in any of the above method embodiments, the data processing method is applied to the field of data encryption and decryption, and the method includes: obtaining a first modulus value and a first parameter, wherein the first parameter is a power of a base; performing iterative operations on the first modulus value and the first parameter, wherein after each round of iterative operations, a first iteration value is obtained, wherein the first iteration value is an iteration value obtained by the current iteration operation; if the first iteration value is equal to the iteration value obtained by the previous round of iterations, the iteration operation is stopped, wherein the first iteration value includes the inverse element of the first parameter with respect to the first modulus value; and determining a pre-calculation result according to the current first iteration value, wherein the pre-calculation result is used for data encryption or decryption.

[0299] By iteratively operating the first modulus and the first parameter, when the iteration values ​​of two adjacent iterative operations are equal, the iterative operation is stopped, and the pre-calculated result is determined according to the iteration value of the current iterative operation, so as to encrypt or decrypt the data through the pre-calculated result. The present application can terminate the calculation in advance, reduce the data processing time, so as to improve the data processing efficiency and increase the speed of data encryption and decryption.

[0300] The processor 1001 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), a hardware chip or any combination thereof; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof. The above-mentioned PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.

[0301] The memory 1002, as a non-transient computer-readable storage medium, can be used to store non-transient software programs, non-transient computer executable programs and modules, such as program instructions / modules corresponding to the data processing method in the embodiment of the present application. The processor 1001 can implement the data processing method in any of the above method embodiments by running the non-transient software programs, instructions and modules stored in the memory 1002. Specifically, the memory 1002 may include a volatile memory (volatile memory, VM), such as a random access memory (random access memory, RAM); the memory 1002 may also include a non-volatile memory (non-volatile memory, NVM), such as a read-only memory (read-only memory, ROM), a flash memory (flash memory), a hard disk drive (hard disk drive, HDD) or a solid-state drive (solid-state drive, SSD) or other non-transient solid-state storage devices; the memory 1002 may also include a combination of the above types of memories.

[0302] The memory 1002 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some embodiments, the memory 1002 may optionally include a memory remotely arranged relative to the processor 1001, and these remote memories may be connected to the processor 1001 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0303] One or more modules are stored in the memory 1002, and when executed by one or more processors 1001, the data processing method in any of the above method embodiments is executed, for example, the data processing method described above is executed. Figure 3 The steps shown.

[0304] In the embodiment of the present application, the processing terminal 1000 may include a data processing system 800 , a processor 1001 , and a memory 1002 .

[0305] The present application also provides a non-volatile computer-readable storage medium, such as a memory including a program code, and the program code can be executed by a processor to complete the data processing method in the above embodiment. For example, the non-volatile computer-readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CDROM), a magnetic tape, a floppy disk, and an optical data storage device.

[0306] The present application also provides a computer program product, which includes one or more program codes, which are stored in a non-volatile computer-readable storage medium. The processor of the flash memory device reads the program code from the non-volatile computer-readable storage medium, and the processor executes the program code to complete the steps of the data processing method provided in the above embodiment.

[0307] A person skilled in the art will appreciate that all or part of the steps for implementing the above embodiments may be accomplished by hardware or by hardware associated with a program code, and the program may be stored in a non-volatile computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0308] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution can be essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute various embodiments or certain parts of the embodiments.

[0309] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Under the concept of the present application, the technical features in the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other changes in different aspects of the present application as above, which are not provided in detail for the sake of simplicity. Although the present application has been described in detail with reference to the aforementioned embodiments, a person of ordinary skill in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features can be replaced by equivalents. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A data processing method, It is characterized in that Applied to the field of data encryption and decryption, the method includes: Obtain a first modulus value and a first parameter, wherein the first parameter is a power of a cardinality; Performing an iterative operation on the first modulus value and the first parameter, wherein after each round of iterative operation, a first iterative value is obtained, wherein the first iterative value is an iterative value obtained by the current iterative operation; If the first iteration value is equal to the iteration value obtained in the previous iteration, the iteration operation is stopped, wherein the first iteration value includes the inverse element of the first parameter with respect to the first modulus value; A pre-calculation result is determined according to the current first iteration value, wherein the pre-calculation result is used for data encryption or decryption.

2. The method according to claim 1, It is characterized in that The iterative operation on the first modulus value and the first parameter includes: Performing an iterative operation on the first modulus value bit by bit to obtain the first iterative value, wherein the first iterative value includes: W=N -1 modρ Where W is the first iteration value, N is the first modulus value, ρ is the first parameter, and N -1 is the inverse element of the first modulus under ρ.

3. The method according to claim 2, It is characterized in that The method further comprises: Detecting the parity state of the binary bit corresponding to the first modulus value in the current iterative operation, if the current binary bit is in an even state, taking the square value of the iterative value obtained in the previous iteration as the first iterative value; If the current binary bit is in an odd state, the product of the iteration value obtained in the previous iteration and the first modulus value is used as the first iteration value.

4. The method according to claim 3, It is characterized in that If the current binary bit is an even state, the first iteration value includes: W=W 1 *IN 1 modρ Where W is the first iteration value, W 1 is the iteration value of the previous round of iterative operation, ρ is the first parameter, W 1 *W 1 is the square value of the iteration value obtained in the previous iteration; If the current binary bit is in an odd state, the first iteration value includes: W=W 1 *Nmodρ Where W is the first iteration value, W 1 is the iteration value of the previous iteration operation, N is the first modulus value, W 1 *N is the product of the iteration value of the previous iteration and the first modulus value.

5. The method according to claim 3, It is characterized in that The method further comprises: If the first iteration value is not equal to the iteration value obtained in the previous round of iteration, the iteration value obtained in the previous round of iteration is overwritten by the first iteration value, and the next round of iteration operation is continued.

6. The method according to claim 5, It is characterized in that The step of determining the pre-calculation result according to the current first iteration value includes: The first iteration value is subtracted from the first parameter to obtain the pre-calculation result.

7. The method according to claim 6, It is characterized in that The first iteration value includes: Where W is the first iteration value, N is the first modulus value, ρ is the first parameter, is the number of positive integers less than or equal to ρ that are coprime with ρ; The pre-calculation results include: Among them, ω is the pre-calculated result, ρ is the first parameter, N is the first modulus value, is the number of positive integers less than or equal to ρ that are relatively prime to ρ.

8. A data processing system, It is characterized in that Applied to the field of data encryption and decryption, the system comprises: a control module, a multiplier, and a comparator; The control module is connected to the multiplier and is used to obtain a first modulus value and a first parameter; The multiplier is connected to the control module and is used to perform an iterative operation on the first module value and the first parameter, wherein after each round of iterative operation, a first iterative value is obtained, wherein the first iterative value is an iterative value obtained by the current iterative operation; The comparator is connected to the multiplier and the control module, and is used to send an end signal to the control module if the first iteration value is equal to the iteration value obtained in the previous round of iteration, wherein the first iteration value includes the inverse element of the first parameter with respect to the first modulus value.

9. The system according to claim 8, It is characterized in that The control module includes: a counter, used to record the parity state of the binary bit corresponding to the first parameter; The system further comprises: a selector and a register; The selector is connected to the counter and the multiplier, and is used to select a corresponding input parameter according to the state recorded by the counter; The register is connected to the multiplier and the comparator, and is used to store the iteration value of the previous round of iterative operation of the multiplier.

10. A processing terminal, It is characterized in that include: The data processing system according to claim 8 or 9; and / or, at least one processor, and a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the data processing method according to any one of claims 1 to 7.