Modular multiplication array, data processing method and processing terminal

By using parallel computing and precomputing parameters in the modular multiplication array, the number of multiplication operations in each cycle of the RSA encryption algorithm is reduced, the encryption efficiency is improved, and the problem of low efficiency of the RSA encryption algorithm is solved.

CN118689451APending Publication Date: 2024-09-24DAPUSTOR CORP
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410724002.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-05
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

The RSA encryption algorithm requires multiple multiplication operations during the loop calculation process, resulting in low encryption efficiency.

Method used

Design a modular multiplication array. By modifying the algorithm structure and hardware pipeline design, one multiplication operation is reduced for each cycle, and parallel computing is used to improve the efficiency of modular multiplication operations.

Benefits of technology

The encryption efficiency is improved, the number of multiplication operations in each cycle is reduced by precomputing parameters, and the processing speed of data encryption and decryption is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118689451A
    Figure CN118689451A
Patent Text Reader

Abstract

The invention relates to the technical field of data encryption and decryption, and discloses a modular multiplication array, a data processing method and a processing terminal.The modular multiplication array is used for carrying out N rounds of cyclic calculation on a preset modular multiplication algorithm, the modular multiplication array comprises a multiplication unit and an addition unit, the multiplication unit comprises a plurality of first multipliers and a plurality of second multipliers, and the first multipliers and the second multipliers are arranged in parallel. The addition unit comprises a plurality of first adders, a plurality of first multipliers and a plurality of first adders perform parallel operation in the process of each round of circulation calculation, through the hardware design of the pipeline of the modular multiplication array, one multiplication operation is reduced in each round of circulation, the efficiency of modular multiplication operation can be better improved, and then the encryption efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the technical field of data encryption and decryption, and in particular to a modular multiplication array, a data processing method and a processing terminal. Background Art

[0002] In order to ensure the confidentiality of data transmission, cryptographic technology is usually used to encrypt data that needs to be kept confidential before transmission. For example, bank passwords, company confidential files, etc. need to be encrypted before being uploaded to the Internet, otherwise there will be a risk of data theft.

[0003] At present, encryption systems usually use the RSA (Rivest-Shamir-Adleman) encryption algorithm to encrypt data. The RSA encryption algorithm is an asymmetric encryption algorithm that encrypts plaintext data using a public key to obtain ciphertext data.

[0004] At present, during the cyclic calculation process of the RSA encryption algorithm, each round of calculation requires multiple multiplication operations, resulting in low encryption efficiency. Summary of the invention

[0005] The embodiment of the present application provides a modular multiplication array, a data processing method and a processing terminal. By modifying the algorithm structure and the hardware design of the pipeline, one multiplication operation is reduced in each cycle. The present application can better improve the efficiency of modular multiplication operations, thereby improving encryption efficiency.

[0006] The embodiments of the present application provide the following technical solutions:

[0007] In a first aspect, an embodiment of the present application provides a modular multiplication array, which is applied to the field of data encryption and decryption. The modular multiplication array is used to perform N rounds of cyclic calculations on a preset modular multiplication algorithm. The modular multiplication array includes: a multiplication unit and an addition unit, wherein the multiplication unit includes a plurality of first multipliers and a plurality of second multipliers, and the addition unit includes a plurality of first adders, and the plurality of first multipliers and the plurality of first adders operate in parallel during each round of cyclic calculation; wherein,

[0008] In the 0th clock cycle, the first multiplier in the multiplication unit is used to calculate a first multiplication result according to the Montgomery domain data;

[0009] In the 1st to N-1th clock cycles, the first adder in the adding unit is used to obtain a first addition result according to the first multiplication result, and perform a low-order operation on the first addition result to obtain first low-order data; the second multiplier in the multiplying unit is used to multiply the first low-order data with the second pre-calculated parameter to obtain a first calculation result; the first adder is also used to add the first addition result to the first calculation result to obtain a second addition result, and perform a shift operation on the second addition result to obtain a first shift result, and then add the first shift result to the first multiplication result to obtain a third addition result, and the first multiplier in the multiplying unit is used to calculate the second multiplication result according to the Montgomery domain data; thereafter, the third addition result of this round is used as the first addition result of the next round, and the second multiplication result is used as the first multiplication result of the next round, and the above steps are repeated for loop calculation until the number of loop calculations is greater than or equal to N;

[0010] In the Nth clock cycle, the first adder in the adding unit is used to obtain a fourth addition result according to the third addition result obtained in the N-1th clock cycle and the first calculation result, and the second multiplier in the multiplying unit is used to perform a shift operation on the fourth addition result to obtain a second shift result, and obtain a fifth addition result according to the second shift result and the second multiplication result, and then perform a low-order operation on the fifth addition result to obtain second low-order data, and obtain a third multiplication result according to the second low-order data and the first pre-calculated parameter;

[0011] In the N+1th clock cycle, the first multiplier in the multiplication unit is used to perform a low-order operation on the third multiplication result to obtain third low-order data, and obtain a fourth multiplication result according to the third low-order data and the modulus value:

[0012] In the N+2th clock cycle, the first adder in the adding unit is used to obtain a sixth addition result according to the fourth addition result and the fourth multiplication result, and perform a shift operation on the sixth addition result to obtain a third shift result:

[0013] In the N+3th clock cycle, the first adder in the adding unit is used to perform a modulo operation on the third shift result to obtain a modular multiplication result, wherein the modular multiplication result is used to perform data encryption or decryption.

[0014] In some embodiments, the preset modular multiplication algorithm includes a Montgomery modular multiplication operation, the input data of the modular multiplication algorithm includes the first Montgomery domain data and the second Montgomery domain data, and the modular multiplication array is further used to call the preset modular multiplication algorithm, wherein the preset modular multiplication algorithm is:

[0015] The value of i ranges from 0 to N-1, where r0=0, and the following steps are executed cyclically:

[0016] u=ri (mod b)*(w(mod b)*n),

[0017] r i+1 =(r i +u) / b+y i *x,

[0018] Among them, r0 is the initial value of r, u is the first calculation result, r i is the first addition result of this round, r i (mod b) is r i The low-order data of w(mod b)*n is the second pre-calculated parameter, b is the base value, n is the modulus value, r i+1 is the first addition result of the next round, x is the first Montgomery domain data, y is the second Montgomery domain data, y i is the i-th data of y.

[0019] In some embodiments, the modular multiplication array is further used to call the Montgomery modular multiplication operation after obtaining the modular multiplication operation result, so as to perform a reduction operation on the modular multiplication operation result to obtain a reduced operation result, including:

[0020] Calling a Montgomery modular multiplication operation, setting the first Montgomery field data of the Montgomery modular multiplication operation to 1, and setting the second Montgomery field data to the modular multiplication operation result;

[0021] A reduction calculation is performed on the modular multiplication result according to the first Montgomery field data and the second Montgomery field data to obtain a reduction calculation result.

[0022] In some embodiments, the pre-calculation parameters include a first pre-calculation parameter and a second pre-calculation parameter, and the modular multiplication array is further used to obtain the first pre-calculation parameter and the second pre-calculation parameter, including:

[0023] Obtaining input parameters, wherein the input parameters include a first parameter, a second parameter, a modulus value, and a base value;

[0024] Determine a third parameter according to the modulus value and the base value;

[0025] Calculate the fourth parameter according to the third parameter and the base value, specifically including:

[0026] ρ=b^k,

[0027] Among them, ρ is the fourth parameter, b is the base value, and k is the third parameter;

[0028] Calculating the first pre-calculation parameter and the second pre-calculation parameter according to the fourth parameter specifically includes:

[0029] w=ρ-n^(ρ-1)(modρ),

[0030] wn=(wmodb)*n,

[0031] Wherein, w is the first pre-calculated parameter, ρ is the fourth parameter, n is the modulus value, wn is the second pre-calculated parameter, and b is the base value;

[0032] In some embodiments, the modular multiplication array is further used to calculate the first Montgomery field data and the second Montgomery field data, including:

[0033] Calculating the first Montgomery domain data and the second Montgomery domain data according to the first parameter, the second parameter and the fourth parameter specifically includes:

[0034] x=x1*ρ(modn),

[0035] y=y1*ρ(modn),

[0036] Wherein, x is the first Montgomery domain data, x1 is the first parameter, ρ is the fourth parameter, n is the module value, y is the second Montgomery domain data, and y1 is the second parameter.

[0037] In a second aspect, an embodiment of the present application provides a data processing method, which is applied to the modular multiplication array in the first aspect, and the data processing method includes:

[0038] Acquire pre-calculated parameters and Montgomery domain data, wherein the Montgomery domain data includes first Montgomery domain data and second Montgomery domain data;

[0039] Based on the pre-calculated parameters and the Montgomery domain data, a Montgomery modular multiplication operation is performed on a preset modular multiplication algorithm to obtain a modular multiplication operation result;

[0040] Call the Montgomery modular multiplication operation and perform a reduction calculation on the modular multiplication operation result to obtain a reduced operation result.

[0041] In some embodiments, based on the pre-calculated parameters and the Montgomery domain data, a Montgomery modular multiplication operation is performed on a preset modular multiplication algorithm to obtain a modular multiplication operation result, including:

[0042] According to the pre-calculation parameters and the Montgomery domain data, the first calculation result and the first addition result are cyclically calculated, specifically including:

[0043] u=r i (mod b)*(w(mod b)*n),

[0044] r i+1 =(r i +u) / b+y i *x,

[0045] Among them, the value of i ranges from 0 to N-1, r0 is the initial value of r, r0=0, u is the first calculation result, r i is the first addition result of this round, r i (mod b) is r i The low-order data of w(mod b)*n is the second pre-calculated parameter, b is the base value, n is the modulus value, r i+1 is the first addition result of the next round, x is the first Montgomery domain data, y is the second Montgomery domain data, y i is the i-th data of y;

[0046] The bit width value of the modulus value is obtained. If the number of loop calculations is greater than or equal to the bit width value of the modulus value, a modulus operation is performed according to the first calculation result and the first addition result to obtain a modular multiplication operation result.

[0047] In some embodiments, the input data of the Montgomery modular multiplication operation includes the first Montgomery domain data and the second Montgomery domain data, and the Montgomery modular multiplication operation is called to perform a reduction calculation on the modular multiplication operation result to obtain a reduced operation result, including:

[0048] Calling a Montgomery modular multiplication operation, setting the first Montgomery field data of the Montgomery modular multiplication operation to 1, and setting the second Montgomery field data to the modular multiplication operation result;

[0049] A reduction calculation is performed on the modular multiplication result according to the first Montgomery field data and the second Montgomery field data to obtain a reduction calculation result.

[0050] In some embodiments, the pre-calculation parameters include a first pre-calculation parameter and a second pre-calculation parameter, and obtaining the pre-calculation parameters and the Montgomery domain data includes:

[0051] Obtaining input parameters, wherein the input parameters include a first parameter, a second parameter, a modulus value, and a base value;

[0052] Determine a third parameter according to the modulus value and the base value;

[0053] Calculate the fourth parameter according to the third parameter and the base value, specifically including:

[0054] ρ=b^k,

[0055] Among them, ρ is the fourth parameter, b is the base value, and k is the third parameter;

[0056] Calculating the first pre-calculation parameter and the second pre-calculation parameter according to the fourth parameter specifically includes:

[0057] w=ρ-n^(ρ-1)(modρ),

[0058] wn=(wmodb)*n,

[0059] Wherein, w is the first pre-calculated parameter, ρ is the fourth parameter, n is the modulus value, wn is the second pre-calculated parameter, and b is the base value;

[0060] Calculating the first Montgomery domain data and the second Montgomery domain data according to the first parameter, the second parameter and the fourth parameter specifically includes:

[0061] x=x1*ρ(modn),

[0062] y=y1*ρ(modn),

[0063] Wherein, x is the first Montgomery domain data, x1 is the first parameter, ρ is the fourth parameter, n is the module value, y is the second Montgomery domain data, and y1 is the second parameter.

[0064] In a third aspect, an embodiment of the present application provides a processing terminal, including the modular multiplication array according to the first aspect;

[0065] and / or,

[0066] at least one processor; and

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

[0068] The memory stores instructions that can be executed by at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the data processing method as described in the second aspect.

[0069] In a fourth aspect, an embodiment of the present application provides a non-volatile computer-readable storage medium, which stores computer-executable instructions, and the computer-executable instructions are used to enable a processing terminal to execute the data processing method of the first aspect.

[0070] The beneficial effects of the embodiments of the present application are as follows: Different from the prior art, the embodiments of the present application provide a modular multiplication array, which is applied to the field of data encryption and decryption. The modular multiplication array is used to perform N rounds of cyclic calculations on a preset modular multiplication algorithm. The modular multiplication array includes: a multiplication unit and an addition unit, wherein the multiplication unit includes a plurality of first multipliers and a plurality of second multipliers, and the addition unit includes a plurality of first adders, and the plurality of first multipliers and the plurality of first adders operate in parallel during each round of cyclic calculation; wherein, in the 0th clock cycle, the first multiplier in the multiplication unit is used to calculate a first multiplication result according to Montgomery domain data;

[0071] In the 1st to N-1th clock cycles, the first adder in the adding unit is used to obtain a first addition result according to the first multiplication result, and perform a low-order operation on the first addition result to obtain first low-order data; the second multiplier in the multiplying unit is used to multiply the first low-order data with the second pre-calculated parameter to obtain a first calculation result; the first adder is also used to add the first addition result to the first calculation result to obtain a second addition result, and perform a shift operation on the second addition result to obtain a first shift result, and then add the first shift result to the first multiplication result to obtain a third addition result, and the first multiplier in the multiplying unit is used to calculate the second multiplication result according to the Montgomery domain data; thereafter, the third addition result of this round is used as the first addition result of the next round, and the second multiplication result is used as the first multiplication result of the next round, and the above steps are repeated for loop calculation until the number of loop calculations is greater than or equal to N;

[0072] In the Nth clock cycle, the first adder in the adding unit is used to obtain a fourth addition result according to the third addition result obtained in the N-1th clock cycle and the first calculation result, and the second multiplier in the multiplying unit is used to perform a shift operation on the fourth addition result to obtain a second shift result, and obtain a fifth addition result according to the second shift result and the second multiplication result, and then perform a low-order operation on the fifth addition result to obtain second low-order data, and obtain a third multiplication result according to the second low-order data and the first pre-calculated parameter;

[0073] In the N+1th clock cycle, the first multiplier in the multiplication unit is used to perform a low-order operation on the third multiplication result to obtain third low-order data, and obtain a fourth multiplication result according to the third low-order data and the modulus value;

[0074] In the N+2th clock cycle, the first adder in the adding unit is used to obtain a sixth addition result according to the fourth addition result and the fourth multiplication result, and perform a shift operation on the sixth addition result to obtain a third shift result;

[0075] In the N+3th clock cycle, the first adder in the adding unit is used to perform a modulo operation on the third shift result to obtain a modular multiplication result, wherein the modular multiplication result is used to perform data encryption or decryption.

[0076] By performing pre-calculation before executing the preset modular multiplication algorithm to obtain a first pre-calculation parameter and a second pre-calculation parameter, and then applying the first pre-calculation parameter and the second pre-calculation parameter to the preset modular multiplication algorithm, since a multiplication operation has been performed during the pre-calculation process, there is no need to perform the multiplication operation in the preset modular multiplication algorithm, thereby reducing one multiplication operation in each cycle. Based on this, the present application reduces one multiplication operation in each cycle by modifying the algorithm structure and the hardware design of the pipeline, which can better improve the efficiency of the modular multiplication operation and thus improve the encryption efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0078] Figure 1 is a flow chart of an improved Montgomery modular multiplication algorithm provided in an embodiment of the present application;

[0079] Figure 2 is a schematic diagram of the structure of a modular multiplication array provided in an embodiment of the present application;

[0080] Figure 3 It is a data flow diagram of a modular multiplication array provided in an embodiment of the present application;

[0081] Figure 4 is a data flow diagram of another modular multiplication array provided in an embodiment of the present application;

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

[0083] Figure 6 yes Figure 5 A detailed flow chart of step S501 in FIG.

[0084] Figure 7 yes Figure 5 A detailed flow chart of step S502 in FIG.

[0085] Figure 8 yes Figure 5 A detailed flow chart of step S503 in FIG.

[0086] Fig. 9 It is a schematic diagram of the overall flow of a data processing method provided in an embodiment of the present application;

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

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

[0089] Description of Figure Numbers:

[0090] Label name Label name 100 Processing Terminal 101 processor 200 Modular multiplication array 102 Memory 201 Addition unit 202 Multiplication Unit 2011 First adder 2021 First multiplier 2022 Second multiplier DETAILED DESCRIPTION

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

[0092] 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.

[0093] Unless otherwise defined, all technical and scientific terms used in this specification have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used in this specification and in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The term "and / or" used in this specification includes any and all combinations of one or more of the related listed items.

[0094] The technical solution of this application is described as follows in conjunction with the accompanying drawings:

[0095] In the embodiment of the present application, the application environment of the Montgomery modular multiplication algorithm is: in order to ensure the confidentiality of data transmission, cryptographic technology is usually used to encrypt the data that needs to be kept confidential before transmission. For example, bank passwords, company confidential files, etc. need to be encrypted before being uploaded to the network, otherwise there will be a risk of data theft.

[0096] At present, the RSA (Rivest-Shamir-Adleman) encryption algorithm is usually used to encrypt data. The RSA encryption algorithm is an asymmetric encryption algorithm that encrypts plaintext data with a public key to obtain ciphertext data. Specifically, in RSA, plaintext data, public key, and ciphertext data are all numbers. The process of the RSA encryption algorithm can be expressed by the following formula:

[0097] M=m e (mod n)

[0098] 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.

[0099] It can be seen that the essence of the RSA encryption algorithm is modular exponentiation, and modular multiplication is an operation that repeatedly calls modular multiplication. Therefore, it can be deduced that the core of the RSA encryption algorithm is modular multiplication operation. The following takes the Montgomery modular multiplication algorithm as an example for illustration:

[0100] Specifically, please refer to Figure 1 , Figure 1 which is a schematic flow diagram of a Montgomery modular multiplication algorithm before improvement provided by an embodiment of the present application;

[0101] As Figure 1 shown, the Montgomery modular multiplication algorithm before improvement includes:

[0102] Step S101: Obtain the modulus value, base value, first Montgomery domain data, and second Montgomery domain data;

[0103] Specifically, first determine the modulus value n and the base value b, where b = 2 h , for example, set b to 2, satisfying gcd(n, b) = 1, that is, n and b are relatively prime. Specify the smallest k such that ρ = b k > n, to obtain ρ. It should be noted that if it is binary, b is not necessarily equal to 2, and b can be equal to 2 h .

[0104] In an embodiment of the present application, the input parameters of the Montgomery modular multiplication algorithm are the modulus value, base value, first Montgomery domain data, and second Montgomery domain data. Obtain the modulus value n, base value b, first Montgomery domain data x, and second Montgomery domain data y, where 0 < x, y < n, b = 2^64, and the output r = x * y * ρ^-1.

[0105] Step S102: Calculate the first calculation result and the second calculation result according to the modulus value, base value, first Montgomery domain data, and second Montgomery domain data;

[0106] Specifically, first perform an initialization operation on the first calculation result and the second calculation result. For example, initialize the values of the first calculation result and the second calculation result to zero. i is used to represent the number of loop calculations, and the value range of the number of loop calculations i is [0, (L n / h) - 1], where L n refers to the bit width value of the modulus value n,

[0107] For i from 0 to (L n / h) - 1. For example, if h = 64, then for i = 0 to (Ln / 64) - 1, the following calculation formula is repeatedly executed:

[0108] u = (r0 + y i *x0)*w (mod b),

[0109] r = (r + y i *x + u*N) / b,

[0110] where u is the first calculation result, r is the second calculation result, r0 is the low - order data of r. For example, r0 is the low 64 - bit data of r, y is the second Montgomery domain data, yi is the i - th group data of y, x is the first Montgomery domain data, x0 is the low - order data of x, w is the first pre - calculated parameter, b is the base value, and N is the modulus value.

[0111] Step S103: Determine whether the second calculation result is greater than or equal to the bit - width value of the modulus;

[0112] Specifically, after executing the above calculation formula for a preset number of rounds, it is necessary to determine whether the current second calculation result is greater than or equal to the bit - width value of the modulus. The preset number of rounds is set according to the bit - width value of N and the base value. For example, when the bit - width value of N is 2048 bit, b = 2^64, and h = 64, the preset number of rounds is 2048 / 64 = 32 rounds. If the current second calculation result is less than the bit - width value of the modulus (i.e., r < N), then directly output r. If the current second calculation result is greater than or equal to the bit - width value of the modulus (i.e., r ≥ N), then proceed to step S104.

[0113] Step S104: Output the modulo result of the second calculation result;

[0114] Specifically, if the current second calculation result is greater than or equal to the bit - width value of the modulus (r ≥ N), then perform a modulo operation on the second calculation result r, that is, r = r - N, to obtain the modulo result of the second calculation result, and output this modulo result. The modulo result written as a Montgomery expression is r = x*y*ρ - 1.

[0115] Step S105: Output the second calculation result;

[0116] Specifically, if the current second calculation result is less than the bit - width value of the modulus (r < N), then directly output the second calculation result r. The second calculation result written as a Montgomery expression is r = x*y*ρ - 1.

[0117] In the embodiment of the present application, the above steps are based on the binary b=2^64 (h=64), so i represents every 64 bits, and the number of loop calculations is the bit width value of N divided by 64. (For example, assuming b=2^h, binary N is less than 2^2048 (N is less than 2048 bits), b=2^64 (b is 64 bits) is selected, then the number of loop calculations is 2048 / 64=32 times).

[0118] In the embodiment of the present application, according to the above Figure 1 It can be seen from the Montgomery modular multiplication algorithm before improvement that in the process of cyclic calculation (step S102), each round of calculation requires multiple multiplication operations, and the Montgomery modular multiplication algorithm is a serial calculation. Therefore, Figure 1 The improved Montgomery modular multiplication algorithm has the disadvantages of slow speed and low efficiency. Figure 1 In order to overcome the shortcomings of the Montgomery modular multiplication algorithm before the improvement, the inventive concept of the present application is to propose a modular multiplication operation that supports pipeline design, that is, to use a modular multiplication array for parallel calculation, wherein the structure of the modular multiplication array is composed of a first adder, a first multiplier and a second multiplier. Specifically, the two groups of multiplications yi*x and u in the modular multiplication operation are parallel operations, mod b is to take the low bit, / b is right shift, yi*x0 can be directly extracted without calculation of the low bit of yi*x. For example, for the RSA algorithm with a key bit width of 2048 bits, if the modular multiplication array in the present application is used and the bit width of the multiplier is 64 bits and the bit width of the adder is 256 bits, 65 multipliers and 32 first adders are needed, and only 36 clocks are consumed to complete the parallel calculation of Montgomery modular multiplication. Compared with the above-mentioned serial calculation of Montgomery modular multiplication, the parallel calculation of Montgomery modular multiplication can improve the calculation speed.

[0119] See also Figure 2 , Figure 2 is a schematic diagram of the structure of a modular multiplication array provided in an embodiment of the present application;

[0120] like Figure 2As shown, the modular multiplication array 200 includes an addition unit 201 and a multiplication unit 202, the addition unit 201 includes a first adder 2011, and the multiplication unit 202 includes a first multiplier 2021 and a second multiplier 2022. It should be noted that the modular multiplication array includes multiple groups of first adders, multiple groups of first multipliers and multiple groups of second multipliers. Here, a group of first adders, a group of first multipliers and a group of second multipliers are used as examples. The first adder 2011 is connected to the first multiplier 2021 and the second multiplier 2022 respectively, and is used to perform addition operation on the input data to obtain the addition result, and transmit the addition result to the first multiplier or the second multiplier; the first multiplier 2021 is connected to the first adder 2011, and is used to perform multiplication operation on the input data to obtain the multiplication result; the second multiplier 2022 is connected to the first adder 2011, and is used to perform multiplication operation on the input data to obtain the multiplication result, wherein the first adder, the first multiplier and the second multiplier operate in parallel during each round of cyclic calculation.

[0121] See also Figure 3 , Figure 3 is a schematic diagram of the structure of a modular multiplication array provided in an embodiment of the present application;

[0122] like Figure 3 As shown, the modular multiplication array is applied to the field of data encryption and decryption, and the modular multiplication array is used to perform N rounds of cyclic calculations on a preset modular multiplication algorithm. The modular multiplication array includes: a multiplication unit and an addition unit, wherein the multiplication unit includes a plurality of first multipliers and a plurality of second multipliers, and the addition unit includes a plurality of first adders, and the plurality of first multipliers and the plurality of first adders operate in parallel during each round of cyclic calculation; wherein the multipliers and adders in the modular multiplication array can be reused in each clock cycle.

[0123] In the 0th clock cycle, the first multiplier in the multiplication unit is used to calculate a first multiplication result based on the Montgomery domain data, wherein the Montgomery domain data includes first Montgomery domain data and second Montgomery domain data. In an embodiment of the present application, the first Montgomery domain data is x, and the second Montgomery domain data is y. Specifically, the input parameters of the modular multiplication array include the first Montgomery domain data, the second Montgomery domain data, the modular value, the base value, the first pre-calculated parameter, and the second pre-calculated parameter. The first multiplier in the multiplication unit is specifically used to calculate the product of the low-order data of the first Montgomery domain data and the second Montgomery domain data to obtain a first multiplication result, wherein the low-order data of the second Montgomery domain data can be represented by y0, and the first multiplication result obtained is represented as y0*x.

[0124] In the 1st to N-1st clock cycles, the first adder in the adding unit is used to obtain the first addition result according to the first multiplication result, and perform a low-order operation on the first addition result to obtain the first low-order data; specifically, when performing the calculation of the first clock cycle, the initial value of the first calculation result (r) is set to 0, and after the second number of first adders in the adding unit receive the first multiplication result transmitted by the first multiplier in the multiplication unit, since it is the first addition operation and the initial value of r is 0, the initial value of the first addition result is added to the first multiplication result to obtain the first addition result r=0+y0*x, and perform a low-order operation on the first addition result to obtain the first low-order data, wherein the low-order operation refers to: assuming that the base value is b=2 h , then the low-order operation is to take the low h bits of the first addition result to obtain the first low-order data. For example, if h=64, the first low-order data is the low 64 bits of the first addition result:

[0125] The second multiplier in the multiplication unit is used to multiply the first low-order data with the second pre-calculation parameter to obtain a first calculation result; specifically, after the third number of second multipliers in the multiplication unit receive the first low-order data sent by the first adder in the addition unit, the first low-order data is multiplied with the second pre-calculation parameter to obtain a first calculation result, wherein the second pre-calculation parameter is a result pre-calculated in the present application, and the second pre-calculation parameter is wn=(wmodb)*n, wherein w is the first pre-calculation parameter, wn is the second pre-calculation parameter, n is the modulus value, and b is the base value, that is, the first pre-calculation parameter and the modulus value are multiplied, and the multiplication result obtained is determined as the second pre-calculation parameter, and the first low-order data (r0) is multiplied with the second pre-calculation parameter (wn) to obtain a first calculation result u=r0*(w(mod b)*n), wherein u is the first calculation result, r is the second calculation result, r0 is the low-order data of r, w(mod b)*n is the second pre-calculation parameter, b is the base value, and n is the modulus value;

[0126] The second number of first adders are further used to add the first addition result and the first calculation result to obtain a second addition result, and to perform a shift operation on the second addition result to obtain a first shift result, and then to add the first shift result to the first multiplication result to obtain a third addition result; specifically, after the second number of first adders receive the first calculation result sent by the second multiplier, the first addition result (r) is added to the first calculation result (u) to obtain a second addition result (r+u), and then a shift operation is performed on the second addition result, and the shift operation refers to shifting the second addition result right by b bits according to the base value b, that is, dividing the second addition result by the base value to obtain the first shift result ((r+u)). i+u) / b), and finally add the first shift result to the first multiplication result to obtain the third addition result (r i+1 =(r i +u) / b+y i *x);

[0127] The first multiplier in the multiplication unit is used to calculate the second multiplication result according to the Montgomery domain data; then, the third addition result of this round is used as the first addition result of the next round, and the second multiplication result is used as the first multiplication result of the next round, and the above steps are repeated for loop calculation until the number of loop calculations is greater than or equal to N-1; specifically, in the 1st to N-1st clock cycles, the first number of first multipliers in the multiplication unit cyclically calculate the second multiplication result y according to the first Montgomery domain data and the second Montgomery domain data. i *x, where x represents the first Montgomery domain data, y represents the second Montgomery domain data, i represents the number of loop calculations, and y i Represents the i-th group of data of y. After that, the third addition result of this round is used as the first addition result of the next round, and the second multiplication result is used as the first multiplication result of the next round. The above steps are repeated for loop calculation until the number of loop calculations is greater than or equal to N.

[0128] In the Nth clock cycle, the first adder in the adding unit is used to obtain a fourth addition result according to the third addition result obtained in the N-1th clock cycle and the first calculation result; specifically, the second number of first adders in the adding unit add the third addition result (r i+1 ) and the first calculation result (u=low-order data of ri*wn) are added to obtain a fourth addition result;

[0129] The second multiplier in the multiplication unit is used to perform a shift operation on the fourth addition result to obtain a second shift result, obtain a fifth addition result according to the second shift result and the second multiplication result, and then perform a low-order operation on the fifth addition result to obtain second low-order data, and obtain a third multiplication result according to the second low-order data and the first pre-calculated parameter; specifically, after the fourth number of second multipliers in the multiplication unit obtain the fourth addition result, the second multiplier performs a shift operation on the fourth addition result, and the shift operation refers to According to the base value b, the fourth addition result is shifted right by b places, that is, the fourth addition result is divided by the base value to obtain a second shift result, and then the second shift result and the second multiplication result are added to obtain a fifth addition result, and then the fifth addition result is subjected to a low-order operation to obtain second low-order data (r0), and the second low-order data (r0) is multiplied by the first pre-calculated parameter (w) to obtain a third multiplication result (r0*w), wherein the first pre-calculated parameter is w=ρ-n^(ρ-1)(modρ).

[0130] In the N+1th clock cycle, the first multiplier in the multiplication unit is used to perform a low-order operation on the third multiplication result to obtain third low-order data, and obtain a fourth multiplication result according to the third low-order data and the modulus value; specifically, the first number of first multipliers in the multiplication unit perform a low-order operation on the third multiplication result to obtain third low-order data (r0), and multiply the third low-order data with the modulus value to obtain a fourth multiplication result (r0*n), wherein the low-order operation refers to: assuming that the base value is b=2 h , then the low-order operation is to take the low h bits of the third multiplication result to obtain the third low-order data. For example, if h=64, the third low-order data is the low 64 bits of the third multiplication result.

[0131] In the N+2th clock cycle, the first adder in the adding unit is used to obtain a sixth addition result according to the fourth addition result and the fourth multiplication result; specifically, the second number of first adders in the adding unit add the fourth addition result and the fourth multiplication result according to the fourth addition result and the fourth multiplication result, so as to obtain a sixth addition result (r i+1 =r i +u), and perform a shift operation on the sixth addition result, the shift operation means that according to the base value b, the sixth addition result is shifted right by b positions to obtain a third shift result (r i+1 =(r i +u) / b).

[0132] In the N+3th clock cycle, the first adder in the adding unit is used to perform a modulo operation on the third shift result to obtain a modular multiplication result; specifically, the modulo operation refers to modn, and the bit width of the third shift result at this time is one bit wider than the bit width of the modulus value n, so only one modulo operation is required, and the second number of first adders in the adding unit perform a modulo operation on the third shift result to obtain a modular multiplication result, wherein the modular multiplication result is used to encrypt or decrypt data.

[0133] In an embodiment of the present application, the parallel operation between the multipliers and adders in the above-mentioned modular multiplication array constitutes an ingenious pipeline design. Through the pipeline design and the parallel calculation of multiple multipliers and adders, each clock cycle is fully utilized to improve the speed of obtaining the modular multiplication operation results.

[0134] It should be noted that the following quantitative relationship exists among the first number, second number, third number and fourth number mentioned above: the third number is greater than the first number, the first number is greater than the fourth number, the second number is greater than the fourth number, and the total number of multipliers in the multiplication unit = the first number + the third number, and the total number of adders in the addition unit = the second number. For example, when the number of first multipliers is 32 groups and the number of second multipliers is 33 groups, the total number of multipliers in the multiplication unit is 65 groups, and when the number of first adders is 32 groups, the total number of adders in the addition unit is 32 groups.

[0135] In an embodiment of the present application, the present application also provides a method for evaluating the number of multipliers and adders required for a modular multiplication array according to the bit width of RSA, and the method is as follows:

[0136] Assuming that the bit width of RSA is a, and the bit width of the selected multiplier is b, and the bit width of the adder is c, the modular multiplication array requires (a / b*2+1) sets of multipliers and (a / c*4) sets of adders. For example, if the bit width of RSA is 2048 bits, and the bit width of the selected multiplier is 64 bits, and the bit width of the adder is 256 bits, then 2048bit / 64bit*2+1=65 sets of multipliers and 2048bit / 256bit*4=32 sets of adders are required.

[0137] It should be noted that in addition to the methods provided above, in actual application scenarios, the number and bit width of multipliers can also be adjusted according to the project area performance requirements. For example, when RSA is required to meet 2048 bits and the project area does not exceed the area requirement, the bit width of the selected multiplier and the project area size can be combined to determine whether the project area size exceeds the area requirement. If the project area size exceeds the area requirement, the bit width of the multiplier is reduced, that is, the number of multipliers is increased, so that the overall project area is reduced to meet the project area requirement.

[0138] In addition, in the embodiment itself, when multipliers with different bit widths are selected, the clock cycles for completing the Montgomery modular multiplication algorithm are different. For example, if a multiplier with a bit width of 64 bits is selected, 2048 / 64+4=36 clock cycles are required to complete the algorithm; if a multiplier with a bit width of 32 bits is selected, 2048 / 32+4=68 clock cycles are required to complete the algorithm.

[0139] The following example uses the RSA bit width of 2048 bits, the multiplier bit width of 64 bits, and the adder bit width of 256 bits.

[0140] See also Figure 4 , Figure 4is a schematic structural diagram of another modular multiplication array provided in an embodiment of the present application;

[0141] like Figure 4 As shown, the modular multiplication array is based on the RSA algorithm with a bit width of 2048 bits. The selected first adder is 256bit*256bit, the first multiplier is 64bit*64bit, and the second multiplier is 64bit*64bit. The modular multiplication array includes 32 groups of adders and 65 groups of multipliers, including 32 groups of 256bit*256bit first adders, 32 groups of 64bit*64bit first multipliers, and 33 groups of 64bit*64bit second multipliers.

[0142] In the 0th clock cycle, the 32 groups of 64bit*64bit first multipliers in the multiplication unit are used to calculate the first multiplication result according to the Montgomery domain data, wherein the Montgomery domain data includes the first Montgomery domain data and the second Montgomery domain data. In the embodiment of the present application, the first Montgomery domain data is x, and the second Montgomery domain data is y. Specifically, the input parameters of the modular multiplication array include the first Montgomery domain data, the second Montgomery domain data, the modular value, the base value, the first pre-calculated parameter and the second pre-calculated parameter. The 32 groups of 64bit*64bit first multipliers in the multiplication unit are specifically used to calculate the product of the low-order data of the first Montgomery domain data and the second Montgomery domain data to obtain the first multiplication result, wherein the low-order data of the second Montgomery domain data can be represented by y0, and the first multiplication result obtained is represented as y0*x.

[0143] In the 1st to N-1st clock cycles, the 32 groups of 256bit*256bit first adders in the adding unit are used to obtain the first addition result according to the first multiplication result, and perform a low-order operation on the first addition result to obtain the first low-order data; specifically, when performing the calculation of the first clock cycle, the initial value of the first calculation result (r) is set to 0. After the 32 groups of 256bit*256bit first adders in the adding unit receive the first multiplication result transmitted by the first multiplier in the multiplication unit, since it is the first addition operation and the initial value of r is 0, the initial value of the first addition result is added to the first multiplication result to obtain the first addition result r=0+y0*x, and perform a low-order operation on the first addition result to obtain the first low-order data, wherein the low-order operation refers to: assuming that the base value is b=2 h , then the low-order operation is to take the low h bits of the first addition result to obtain the first low-order data. For example, if h=64, the first low-order data is the low 64 bits of the first addition result:

[0144] The 33 groups of 64bit*64bit second multipliers in the multiplication unit are used to multiply the first low-order data with the second pre-calculation parameter to obtain a first calculation result; specifically, after the 33 groups of 64bit*64bit second multipliers in the multiplication unit receive the first low-order data sent by the first adder in the addition unit, the first low-order data is multiplied with the second pre-calculation parameter to obtain a first calculation result, wherein the second pre-calculation parameter is a result pre-calculated in the present application, and the second pre-calculation parameter is wn=(wmodb)*n, wherein w is the first pre-calculation parameter, wn is the second pre-calculation parameter, n is the modulus value, and b is the base value, that is, the first pre-calculation parameter and the modulus value are multiplied, and the multiplication result obtained is determined as the second pre-calculation parameter, and the first low-order data (r0) is multiplied with the second pre-calculation parameter (wn) to obtain a first calculation result u=r0*(w(mod b)*n), wherein u is the first calculation result, r is the second calculation result, r0 is the low-order data of r, w(mod b)*n is the second pre-calculated parameter, b is the base value, and n is the modulus value;

[0145] The 32 groups of 256bit*256bit first adders are also used to add the first addition result and the first calculation result to obtain a second addition result, and perform a shift operation on the second addition result to obtain a first shift result, and then add the first shift result to the first multiplication result to obtain a third addition result: Specifically, after the 32 groups of 256bit*256bit first adders receive the first calculation result sent by the second multiplier, the first addition result (r) is added to the first calculation result (u) to obtain a second addition result (r+u), and then a shift operation is performed on the second addition result. The shift operation refers to shifting the second addition result right by b bits according to the base value b, that is, dividing the second addition result by the base value to obtain the first shift result ((r+u)). i +u) / b), and finally add the first shift result to the first multiplication result to obtain the third addition result (r i+1 =(r i +u) / b+y i *x);

[0146] The 32 groups of 64bit*64bit first multipliers in the multiplication unit are used to calculate the second multiplication result according to the Montgomery domain data; thereafter, the third addition result of this round is used as the first addition result of the next round, and the second multiplication result is used as the first multiplication result of the next round, and the above steps are repeated for loop calculation until the number of loop calculations is greater than or equal to N; specifically, in the 1st to N-1st clock cycles, the 32 groups of 64bit*64bit first multipliers in the multiplication unit are used to loop calculate the second multiplication result y according to the first Montgomery domain data and the second Montgomery domain data. i*x, where x represents the first Montgomery domain data, y represents the second Montgomery domain data, i represents the number of loop calculations, and y i Represents the i-th group of data of y. After that, the third addition result of this round is used as the first addition result of the next round, and the second multiplication result is used as the first multiplication result of the next round. The above steps are repeated for loop calculation until the number of loop calculations is greater than or equal to N.

[0147] In the Nth clock cycle, the 32 groups of 256bit*256bit first adders in the adding unit are used to obtain a fourth addition result according to the third addition result obtained in the N-1th clock cycle and the first calculation result: Specifically, the 32 groups of 256bit*256bit first adders in the adding unit add the third addition result (r i+1 ) and the first calculation result (u=ri's low-order data *wn) are added to obtain a fourth addition result:

[0148] A group of 64bit*64bit second multipliers in the multiplication unit is used to perform a shift operation on the fourth addition result to obtain a second shift result, and perform a low-order operation on the second shift result to obtain second low-order data, and obtain a third multiplication result based on the second low-order data and the first pre-calculated parameter; specifically, after the group of 64bit*64bit second multipliers in the multiplication unit obtains the fourth addition result, the second multiplier performs a shift operation on the fourth addition result, and the shift operation refers to right shifting the fourth addition result by b bits according to a base value b, that is, dividing the fourth addition result by the base value to obtain a second shift result, and then adding the second shift result and the second multiplication result to obtain a fifth addition result, and then performing a low-order operation on the fifth addition result to obtain second low-order data (r0), and multiplying the second low-order data (r0) by the first pre-calculated parameter (w) to obtain a third multiplication result (r0*w), wherein the first pre-calculated parameter is w=ρ-n^(ρ-1)(modρ).

[0149] In the N+1th clock cycle, the 32 groups of 64bit*64bit first multipliers in the multiplication unit are used to perform a low-order operation on the third multiplication result to obtain third low-order data, and obtain a fourth multiplication result according to the third low-order data and the modulus value; specifically, the 32 groups of 64bit*64bit first multipliers in the multiplication unit perform a low-order operation on the third multiplication result to obtain third low-order data (r0), and multiply the third low-order data with the modulus value to obtain a fourth multiplication result (r0*n), wherein the low-order operation refers to: assuming that the base value is b=2 h , then the low-order operation is to take the low h bits of the third multiplication result to obtain the third low-order data. For example, if h=64, the third low-order data is the low 64 bits of the third multiplication result.

[0150] In the N+2th clock cycle, the 32 groups of 256bit*256bit first adders in the adding unit are used to obtain a sixth addition result according to the fourth addition result and the fourth multiplication result; specifically, the 32 groups of 256bit*256bit first adders in the adding unit add the fourth addition result and the fourth multiplication result according to the fourth addition result and the fourth multiplication result, thereby obtaining a sixth addition result (r i+1 =r i +u), and perform a shift operation on the sixth addition result, the shift operation means that according to the base value b, the sixth addition result is shifted right by b positions to obtain a third shift result (r i+1 =(r i +u) / b).

[0151] In the N+3th clock cycle, the 32 groups of 256bit*256bit first adders in the adding unit are used to perform a modulo operation on the third shift result to obtain a modular multiplication result; specifically, the modulo operation refers to modn, and the bit width of the third shift result at this time is one bit wider than the bit width of the modulus value n, so only one modulo operation is required, and the 32 groups of 256bit*256bit first adders in the adding unit perform a modulo operation on the third shift result to obtain a modular multiplication result, wherein the modular multiplication result is used to encrypt or decrypt data.

[0152] In an embodiment of the present application, the preset modular multiplication algorithm includes a Montgomery modular multiplication operation, the input data of the modular multiplication algorithm includes first Montgomery domain data and second Montgomery domain data, and the modular multiplication array is further used to call the preset modular multiplication algorithm, wherein the preset modular multiplication algorithm is:

[0153] The value of i ranges from 0 to N-1, where r0=0, and the following steps are executed cyclically:

[0154] u=r i (mod b)*(w(mod b)*n),

[0155] r i+1 =(r i +u) / b+y i *x,

[0156] Among them, r0 is the initial value of r, u is the first calculation result, r i is the first addition result of this round, r i (mod b) is r i The low-order data of w(mod b)*n is the second pre-calculated parameter, b is the base value, n is the modulus value, r i+1 is the first addition result of the next round, x is the first Montgomery domain data, y is the second Montgomery domain data, yi is the i-th data of y.

[0157] In the embodiment of the present application, when i=N, that is, when the number of loop calculations is equal to the bit width value of the modulus value, the first calculation result and the first addition result are calculated according to the following formula:

[0158] u=(r i (mod b)*w(mod b))(mod b)*n,

[0159] r i+1 =(r i +u) / b,

[0160] Where i=N, u is the first calculation result, r i is the first addition result of this round, w(mod b) is the first pre-calculated parameter, b is the base value, n is the modulus value, r i+1 This is the first addition result for the next round.

[0161] In the embodiment of the present application, the modular multiplication array is further used to call the Montgomery modular multiplication operation after obtaining the modular multiplication operation result, so as to perform a simplified calculation on the modular multiplication operation result to obtain a simplified operation result, specifically including:

[0162] Call the Montgomery modular multiplication operation, set the first Montgomery domain data of the Montgomery modular multiplication operation to 1, and set the second Montgomery domain data to the modular multiplication operation result; specifically, because the result of Montgomery simplification is the input data x multiplied by ρ-1(x*ρ-1), the result of Montgomery modular multiplication is the product of the two input data x and y multiplied by ρ-1(x*y*ρ-1), so only one of the multipliers needs to be set to 1, and the other is the simplified input, that is, the modular multiplication operation result obtained by the above modular multiplication array.

[0163] According to the first Montgomery domain data and the second Montgomery domain data, a reduction calculation is performed on the modular multiplication operation result to obtain a reduced operation result; specifically, in an embodiment of the present application, the reduction calculation is replaced by a Montgomery modular multiplication operation, and therefore, a Montgomery modular multiplication operation is performed once by the modular multiplication array according to the above-mentioned preset modular multiplication algorithm to obtain a reduced operation result x1*y1(modn).

[0164] In the embodiment of the present application, the pre-calculation parameters include a first pre-calculation parameter and a second pre-calculation parameter, and the modular multiplication array is also used to obtain the first pre-calculation parameter and the second pre-calculation parameter, specifically including:

[0165] Obtaining input parameters, wherein the input parameters include a first parameter, a second parameter, a modulus value, and a base value;

[0166] Determine the third parameter according to the modulus value and the base value; specifically, assuming the modulus value is n, the base value is b, and the arbitrary parameter is k, the modulus value, the base value and the arbitrary parameter need to satisfy a preset rule in order to determine the parameter as the third parameter, wherein the preset rule is b^k>n.

[0167] Calculate the fourth parameter according to the third parameter and the base value, including:

[0168] ρ=b^k,

[0169] Among them, ρ is the fourth parameter, b is the base value, and k is the third parameter;

[0170] Calculating the first pre-calculation parameter and the second pre-calculation parameter according to the fourth parameter includes:

[0171] w=ρ-n^(ρ-1)(modρ),

[0172] wn=(wmodb)*n,

[0173] Wherein, w is the first pre-calculated parameter, ρ is the fourth parameter, n is the modulus value, wn is the second pre-calculated parameter, and b is the base value;

[0174] Calculating the first Montgomery domain data and the second Montgomery domain data according to the first parameter, the second parameter and the fourth parameter includes:

[0175] x=x1*ρ(modn),

[0176] y=y1*ρ(modn),

[0177] Among them, x is the first Montgomery domain data, x1 is the first parameter, ρ is the fourth parameter, n is the modulus value, y is the second Montgomery domain data, and y1 is the second parameter; specifically, according to the formula for calculating the first Montgomery domain data and the second Montgomery domain data, multiplying by ρ means performing a left shift operation on x1 and y1, and each left shift requires a modulus n to obtain the first Montgomery domain data and the second Montgomery domain data.

[0178] In the embodiment of the present application, the above modular multiplication array is based on structural improvements, and in terms of method, Figure 5 The data processing method in Figure 1 The method is improved on the basis of the above method, namely, by improving the operation steps of the Montgomery modular multiplication algorithm: before executing the preset modular multiplication algorithm, pre-calculation is performed in advance to obtain the first pre-calculation parameter and the second pre-calculation parameter, and then the first pre-calculation parameter and the second pre-calculation parameter are applied to the following data processing method. Then, because a multiplication operation has been performed in the pre-calculation process, there is no need to perform the multiplication operation in this method, thereby reducing one multiplication operation in each cycle, improving the efficiency of the modular multiplication operation, and further improving the encryption efficiency.

[0179] See also Figure 5 , Figure 5 This is a flow chart of a data processing method provided in an embodiment of the present application:

[0180] The data processing method is applied to a processing terminal, and the execution subject of the data processing method is one or at least two processors of the processing terminal.

[0181] like Figure 5 As shown, the data processing method comprises:

[0182] Step S501: obtaining pre-calculated parameters and Montgomery domain data;

[0183] In the embodiment of the present application, the pre-calculation parameters include a first pre-calculation parameter and a second pre-calculation parameter, and the Montgomery domain data include a first Montgomery domain data and a second Montgomery domain data.

[0184] Please refer to Figure 6 , Figure 6 yes Figure 5 A detailed flow chart of step S501 in FIG.

[0185] like Figure 6 As shown, step S501: obtaining pre-calculated parameters and Montgomery domain data, including:

[0186] Step S5011: obtaining input parameters, wherein the input parameters include a first parameter, a second parameter, a modulus value, and a base value;

[0187] Specifically, input parameters are obtained, wherein the input parameters include a first parameter, a second parameter, a modulus value, and a base value. It should be noted that the input parameters can be set according to actual needs.

[0188] Step S5012: Determine a third parameter according to the modulus value and the base value;

[0189] Specifically, the third parameter is determined according to the modulus value and the base value; specifically, assuming that the modulus value is n, the base value is b, and the arbitrary parameter is k, the modulus value, the base value and the arbitrary parameter need to satisfy a preset rule in order to determine the parameter as the third parameter, wherein the preset rule is b^k>n.

[0190] Step S5013: Calculate the fourth parameter according to the third parameter and the base value;

[0191] Specifically, the fourth parameter is determined by calculating the kth power of the base value, and the specific calculation formula is as follows:

[0192] ρ=b^k,

[0193] Among them, ρ is the fourth parameter, b is the base value, and k is the third parameter.

[0194] Step S5014: Calculate the first pre-calculation parameter and the second pre-calculation parameter according to the fourth parameter;

[0195] Specifically, the first pre-calculated parameter is calculated according to the fourth parameter and the modulus value, and then the first pre-calculated parameter is modulo-operated (modb) according to the first pre-calculated parameter, the base value and the modulus value to obtain a modulo result, and then the modulo result is multiplied by the modulus value to calculate the second pre-calculated parameter. The specific calculation formula is as follows:

[0196] w=ρ-n^(ρ-1)(modρ),

[0197] wn=(wmodb)*n,

[0198] Among them, w is the first pre-calculated parameter, ρ is the fourth parameter, n is the modulus value, wn is the second pre-calculated parameter, and b is the base value.

[0199] In the embodiment of the present application, the first pre-calculated parameter is calculated using a 64-bit multiplier.

[0200] Step S5015: Calculate the first Montgomery domain data and the second Montgomery domain data according to the first parameter, the second parameter and the fourth parameter;

[0201] Specifically, according to the first parameter, the second parameter and the fourth parameter, the first parameter is multiplied by the fourth parameter and then a modulo operation is performed to obtain the first Montgomery domain data, and the second parameter is multiplied by the fourth parameter and then a modulo operation is performed to obtain the second Montgomery domain data. The specific calculation formula for calculating the first Montgomery domain data and the second Montgomery domain data is as follows:

[0202] x=x1*ρ(modn),

[0203] y=y1*ρ(modn),

[0204] Wherein, x is the first Montgomery domain data, x1 is the first parameter, ρ is the fourth parameter, n is the module value, y is the second Montgomery domain data, and y1 is the second parameter.

[0205] In the embodiment of the present application, according to the formula for calculating the first Montgomery field data and the second Montgomery field data, multiplication by ρ represents a left shift operation on x1 and y1, and each left shift requires modulo n to obtain the first Montgomery field data and the second Montgomery field data.

[0206] Step S502: Based on the pre-calculated parameters and the Montgomery domain data, a Montgomery modular multiplication operation is performed on a preset modular multiplication algorithm to obtain a modular multiplication operation result;

[0207] Please refer to Figure 7 , Figure 7 yes Figure 5 A detailed flow chart of step S502 in FIG.

[0208] like Figure 7 As shown, step S502: based on the pre-calculated parameters and the Montgomery domain data, a Montgomery modular multiplication operation is performed on the preset modular multiplication algorithm to obtain a modular multiplication operation result, including:

[0209] Step S5021: cyclically calculating the first calculation result and the first addition result according to the pre-calculation parameters and the Montgomery domain data;

[0210] Specifically, the formula for calculating the first calculation result and the first addition result is as follows:

[0211] u=r i (mod b)*(w(mod b)*n),

[0212] r i+1 =(r i +u) / b+y i *x,

[0213] Among them, the value of i ranges from 0 to N-1, r0 is the initial value of r, r0=0, u is the first calculation result, r i is the first addition result of this round, r i (mod b) is r i The low-order data of w(mod b)*n is the second pre-calculated parameter, b is the base value, n is the modulus value, r i+1 is the first addition result of the next round, x is the first Montgomery domain data, y is the second Montgomery domain data, y i is the i-th data of y.

[0214] In the embodiment of the present application, compared with the above Figure 1 The improvement of this data processing method is that the result of the Montgomery modular multiplication algorithm is added with y in advance. i *x, then in the next round of calculating the first calculation result u, Figure 1 The calculation of r0+yi*x0 can be replaced by taking the lower bit of r, that is, r0. This method can reduce a set of addition calculations in the process of calculating the first calculation result, so as to improve the efficiency of the algorithm.

[0215] In the embodiment of the present application, when i=N, that is, when the number of loop calculations is equal to the bit width value of the modulus value, the first calculation result and the first addition result are calculated according to the following formula:

[0216] u=(ri (mod b)*w(mod b))(mod b)*n,

[0217] r i+1 =(r i +u) / b,

[0218] Where i=N, u is the first calculation result, r i is the first addition result of this round, w(mod b) is the first pre-calculated parameter, b is the base value, n is the modulus value, r i+1 This is the first addition result for the next round.

[0219] Step S5022: Obtain the bit width value of the modulus value;

[0220] Specifically, according to the value of the modulus value, the bit width value of the modulus value is obtained, wherein the unit of the bit width value is bit.

[0221] Step S5023: Determine whether the number of loop calculations is greater than or equal to the bit width of the modulus value;

[0222] Specifically, determine whether the number of loop calculations is greater than or equal to the bit width value of the modulus value. If the number of loop calculations is less than the bit width value of the modulus value, return to step S5021 until the number of loop calculations is greater than or equal to the bit width value of the modulus value; if the number of loop calculations is greater than or equal to the bit width value of the modulus value, enter step S5024.

[0223] Step S5024: performing a modulo operation according to the first calculation result and the first addition result to obtain a modular multiplication operation result;

[0224] Specifically, if the number of loop calculations is greater than or equal to the bit width value of the modulus value, a modulus operation is performed based on the first calculation result and the first addition result. The modulus operation refers to mod n. At this time, the bit width of the first addition result is one bit wider than the bit width of the modulus value n, so only one modulus operation is required. A modulus operation is performed on the first addition result to obtain the modular multiplication result.

[0225] Step S503: calling the Montgomery modular multiplication operation to perform a reduction operation on the modular multiplication operation result to obtain a reduced operation result;

[0226] Please refer to Figure 8 , Figure 8 yes Figure 5 A detailed flow chart of step S503 in FIG.

[0227] like Figure 8 As shown, step S503: calling the Montgomery modular multiplication operation to perform a reduction calculation on the modular multiplication operation result to obtain a reduced operation result, including:

[0228] Step S5031: calling the Montgomery modular multiplication operation, setting the first Montgomery field data of the Montgomery modular multiplication operation to 1, and setting the second Montgomery field data to the modular multiplication operation result;

[0229] Specifically, because the result of Montgomery reduction is the input data x multiplied by ρ -1 (x*ρ -1 ), the result of Montgomery modular multiplication is the product of the two input data x and y multiplied by ρ -1 (x*y*ρ -1 ), so we only need to set one of the multipliers to 1, and the other is the simplified input, that is, the modular multiplication result obtained by the above modular multiplication array.

[0230] Step S5032: performing a reduction calculation on the modular multiplication result according to the first Montgomery field data and the second Montgomery field data to obtain a reduction calculation result;

[0231] Specifically, the reduction calculation is replaced by the Montgomery modular multiplication operation. Therefore, the modular multiplication array performs a Montgomery modular multiplication operation according to the above preset modular multiplication algorithm to obtain the reduction operation result, and the expression of the reduction operation result is x1*y1(modn).

[0232] Please refer to Fig. 9 , Fig. 9 It is a schematic diagram of the overall flow of a data processing method provided in an embodiment of the present application;

[0233] like Fig. 9 As shown, the overall process of the data processing method includes:

[0234] Step S901: obtaining input parameters, which include a modulus value and a base value;

[0235] Specifically, input parameters are obtained, wherein the input parameters include a first parameter x1, a second parameter y1, a modulus value n, and a base value b. It should be noted that the input parameters can be set according to actual needs.

[0236] Step S902: obtaining a third parameter;

[0237] Specifically, the third parameter k serves as the exponent or power of the base value, that is, the third parameter is used to calculate the power of the base value. For example, if the base value is b, then the power of the base value is b^k.

[0238] Step S903: Determine whether the modulus value, base value and third parameter meet the preset rules;

[0239] Specifically, obtain the third parameter k, and determine whether the modulus value n, the base value b and the third parameter k meet the preset rules, wherein the preset rule is that the power of the base value is greater than the modulus value, that is, b^k>n. If the modulus value n, the base value b and the third parameter k do not meet the preset rules, return to step S902, that is: re-acquire the third parameter until the modulus value n, the base value b and the third parameter k meet the preset rules; if the modulus value n, the base value b and the third parameter k meet the preset rules, enter step S904.

[0240] Step S904: Calculate the fourth parameter according to the third parameter and the base value;

[0241] Specifically, the fourth parameter is the power of the third parameter of the base value. According to the third parameter and the base value, the formula for calculating the fourth parameter is as follows:

[0242] ρ=b^k,

[0243] Among them, ρ is the fourth parameter, b is the base value, and k is the third parameter.

[0244] Step S905: Calculate the first pre-calculation parameter and the second pre-calculation parameter according to the fourth parameter;

[0245] Specifically, the first pre-calculated parameter is calculated according to the fourth parameter and the modulus value, and then the first pre-calculated parameter is modulo-operated (mod b) according to the first pre-calculated parameter, the base value and the modulus value to obtain a modulo result, and then the modulo result is multiplied by the modulus value to calculate the second pre-calculated parameter. The specific calculation formula is as follows:

[0246] w=ρ-n^(ρ-1)(modρ),

[0247] wn=(wmodb)*n,

[0248] Among them, w is the first pre-calculated parameter, ρ is the fourth parameter, n is the modulus value, wn is the second pre-calculated parameter, and b is the base value.

[0249] Step S906: Calculate the first Montgomery domain data and the second Montgomery domain data;

[0250] Specifically, according to the first parameter, the second parameter and the fourth parameter, the first parameter is multiplied by the fourth parameter and then a modulo operation is performed to obtain the first Montgomery domain data, and the second parameter is multiplied by the fourth parameter and then a modulo operation is performed to obtain the second Montgomery domain data. The specific calculation formula for calculating the first Montgomery domain data and the second Montgomery domain data is as follows:

[0251] x=x1*ρ(modn),

[0252] y=y1*ρ(modn),

[0253] Wherein, x is the first Montgomery domain data, x1 is the first parameter, ρ is the fourth parameter, n is the module value, y is the second Montgomery domain data, and y1 is the second parameter.

[0254] Step S907: Determine whether the number of loop calculations is less than the bit width of the modulus value;

[0255] Specifically, determine whether the current number of loop calculations is less than the bit width value of the modulus value. If the current number of loop calculations is greater than or equal to the bit width value of the modulus value, proceed to step S911; if the current number of loop calculations is less than the bit width value of the modulus value, proceed to step S908.

[0256] Step S908: Increase the number of loop calculations by one:

[0257] Step S909: Calculate a first calculation result and a first addition result;

[0258] Specifically, the formula for calculating the first calculation result and the first addition result is as follows:

[0259] u=r i (mod b)*(w(mod b)*n),

[0260] r i+1 =(r i +u) / b+y i *x,

[0261] Among them, the value of i ranges from 0 to N-1, r0 is the initial value of r, r0=0, u is the first calculation result, r i is the first addition result of this round, r i (mod b) is r i The low-order data of w(mod b)*n is the second pre-calculated parameter, b is the base value, n is the modulus value, r i+1 is the first addition result of the next round, x is the first Montgomery domain data, y is the second Montgomery domain data, y i is the i-th data of y.

[0262] In the embodiment of the present application, when i=N, that is, when the number of loop calculations is equal to the bit width value of the modulus value, the first calculation result and the first addition result are calculated according to the following formula:

[0263] u=(r i (mod b)*w(mod b))(mod b)*n,

[0264] r i+1 =(r i +u) / b,

[0265] Where i=N, u is the first calculation result, ri is the first addition result of this round, w(mod b) is the first pre-calculated parameter, b is the base value, n is the modulus value, r i+1 This is the first addition result for the next round.

[0266] Step S910: performing a modulo operation on the first addition result to obtain a modular multiplication result;

[0267] Specifically, the modulo operation refers to mod n. At this time, the bit width of the first addition result is one bit wider than the bit width of the modulus value n, so only one modulo operation is required. The first addition result is subjected to a modulo operation to obtain a modular multiplication result.

[0268] Step S911: performing a reduction calculation on the modular multiplication operation result to obtain a reduced operation result;

[0269] Specifically, the Montgomery modular multiplication operation is called, the first Montgomery field data of the Montgomery modular multiplication operation is set to 1, and the second Montgomery field data is set to the modular multiplication operation result, and the reduction calculation is replaced by the Montgomery modular multiplication operation. Therefore, the modular multiplication array performs a Montgomery modular multiplication operation according to the above-mentioned preset modular multiplication algorithm to obtain the reduction operation result, and the expression of the reduction operation result is x1*y1(modn).

[0270] In an embodiment of the present application, a data processing method is provided and applied to a processing terminal. The data processing method includes: obtaining pre-calculated parameters and Montgomery domain data, wherein the Montgomery domain data includes first Montgomery domain data and second Montgomery domain data; based on the pre-calculated parameters and the Montgomery domain data, performing a Montgomery modular multiplication operation on a preset modular multiplication algorithm to obtain a modular multiplication operation result; calling the Montgomery modular multiplication operation to perform a simplification operation on the modular multiplication operation result to obtain a simplification operation result. The present application can perform a Montgomery modular multiplication operation on a preset modular multiplication algorithm based on the pre-calculated parameters and the Montgomery domain data, thereby better improving the efficiency of the modular multiplication operation and further improving the encryption efficiency.

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

[0272] like Fig.10 As shown, the processing terminal 100 includes a modular multiplication array 200. The modular multiplication array 200 is Figure 2 The modular multiplication array 200 shown. For details, please refer to the relevant contents mentioned in the above embodiments and Figure 2 The modular multiplication array 200 shown is not described in detail here.

[0273] In an embodiment of the present application, the processing terminal 100 includes a modular multiplication array 200. The modular multiplication array performs pre-calculation in advance before executing a preset modular multiplication algorithm by modifying the algorithm structure and the hardware design of the pipeline to obtain a first pre-calculation parameter and a second pre-calculation parameter. The first pre-calculation parameter and the second pre-calculation parameter are then applied to the preset modular multiplication algorithm, so that one multiplication operation is reduced in each cycle. The processing terminal 100 in the present application can increase the speed of modular multiplication operations, thereby improving the efficiency of modular multiplication operations, and thereby improving encryption efficiency.

[0274] Please refer to Fig.11 , Fig.11 is a structural diagram of a processing terminal provided in an embodiment of the present application;

[0275] like Fig.11 As shown, the processing terminal 100 includes one or more processors 101 and a memory 102. Fig.11 A processor 101 is taken as an example.

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

[0277] The processor 101 is used to provide computing and control capabilities to control the processing terminal 100 to perform corresponding tasks, for example, to control the processing terminal 100 to perform a data processing method in any of the above-mentioned method embodiments, which is applied to the processing terminal. The data processing method includes: obtaining pre-calculated parameters and Montgomery domain data, wherein the Montgomery domain data includes first Montgomery domain data and second Montgomery domain data; based on the pre-calculated parameters and the Montgomery domain data, performing a Montgomery modular multiplication operation on a preset modular multiplication algorithm to obtain a modular multiplication operation result; calling the Montgomery modular multiplication operation to perform a simplification operation on the modular multiplication operation result to obtain a simplification operation result.

[0278] By performing Montgomery modular multiplication operations on a preset modular multiplication algorithm based on pre-calculated parameters and Montgomery field data, the present application can better improve the efficiency of modular multiplication operations, thereby improving encryption efficiency.

[0279] The processor 101 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.

[0280] The memory 102, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory 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 101 can implement the data processing method in any of the following method embodiments by running the non-transitory software programs, instructions and modules stored in the memory 102. Specifically, the memory 102 may include a volatile memory (volatile memory, VM), such as a random access memory (random access memory, RAM); the memory 102 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-transitory solid-state storage devices; the memory 102 may also include a combination of the above-mentioned types of memory.

[0281] The memory 102 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 device. In some embodiments, the memory 102 may optionally include a memory remotely arranged relative to the processor 101, and these remote memories may be connected to the processor 101 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.

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

[0283] In the embodiment of the present application, the processing terminal 100 may also have components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output. The processing terminal 100 may also include other components for realizing device functions, which will not be described in detail here.

[0284] In the embodiment of the present application, the processing terminal 100 may include a modular multiplication array 200, a processor 101, and a memory 102. For the relevant contents of the modular multiplication array 200, the processor 101, and the memory 102, reference may be made to the contents mentioned in the above embodiment, which will not be repeated here.

[0285] 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.

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

[0287] 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.

[0288] Through the description of the above implementation methods, a person of ordinary skill 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, can also be implemented by hardware. A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0289] 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 mentioned 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 modular multiplication array, characterized in that: Applied to the field of data encryption and decryption, the modular multiplication array is used to perform N rounds of cyclic calculations on a preset modular multiplication algorithm, and the modular multiplication array includes: a multiplication unit and an addition unit, wherein the multiplication unit includes a plurality of first multipliers and a plurality of second multipliers, and the addition unit includes a plurality of first adders, and the plurality of first multipliers and the plurality of first adders operate in parallel during each round of cyclic calculation; wherein, In the 0th clock cycle, the first multiplier in the multiplication unit is used to calculate a first multiplication result according to the Montgomery domain data; In the 1st to N-1th clock cycles, the first adder in the adding unit is used to obtain a first addition result according to the first multiplication result, and perform a low-bit operation on the first addition result to obtain first low-bit data; the second multiplier in the multiplication unit is used to multiply the first low-bit data with the second pre-calculated parameter to obtain a first calculation result; the first adder is also used to add the first addition result to the first calculation result to obtain a second addition result, and perform a shift operation on the second addition result to obtain a first shift result, and then add the first shift result to the first multiplication result to obtain a third addition result, and the first multiplier in the multiplication unit is used to calculate the second multiplication result according to the Montgomery domain data; thereafter, the third addition result of this round is used as the first addition result of the next round, and the second multiplication result is used as the first multiplication result of the next round, and the above steps are repeated for loop calculation until the number of loop calculations is greater than or equal to N; In the Nth clock cycle, the first adder in the addition unit is used to obtain a fourth addition result according to the third addition result obtained in the N-1th clock cycle and the first calculation result, and the second multiplier in the multiplication unit is used to perform a shift operation on the fourth addition result to obtain a second shift result, obtain a fifth addition result according to the second shift result and the second multiplication result, and then perform a low-order operation on the fifth addition result to obtain second low-order data, and obtain a third multiplication result according to the second low-order data and the first pre-calculated parameter; In the N+1th clock cycle, the first multiplier in the multiplication unit is used to perform a low-order operation on the third multiplication result to obtain third low-order data, and obtain a fourth multiplication result according to the third low-order data and the modulus value; In the N+2th clock cycle, the first adder in the adding unit is used to obtain a sixth addition result according to the fourth addition result and the fourth multiplication result, and perform a shift operation on the sixth addition result to obtain a third shift result; In the N+3th clock cycle, the first adder in the adding unit is used to perform a modulo operation on the third shift result to obtain a modular multiplication result, wherein the modular multiplication result is used to perform data encryption or decryption.

2. The modular multiplication array according to claim 1, characterized in that: The preset modular multiplication algorithm includes a Montgomery modular multiplication operation, the input data of the modular multiplication algorithm includes first Montgomery domain data and second Montgomery domain data, and the modular multiplication array is further used to call the preset modular multiplication algorithm, wherein the preset modular multiplication algorithm is: The value of i ranges from 0 to N-1, where r O =0, loop and execute the following steps: u=r i (mod b)*(w(mod b)*n), r i+1 =(r i +u) / b+y i *x, Among them, r0 is the initial value of r, u is the first calculation result, r i is the first addition result of this round, r i (mod b) is r i The low-order data of w(mod b)*n is the second pre-calculated parameter, b is the base value, n is the modulus value, r i+1 is the first addition result of the next round, x is the first Montgomery domain data, y is the second Montgomery domain data, y i is the i-th data of y.

3. The modular multiplication array according to claim 2, characterized in that: The modular multiplication array is further used to call the Montgomery modular multiplication operation after obtaining the modular multiplication operation result, so as to perform a reduction operation on the modular multiplication operation result to obtain a reduced operation result, including: Calling the Montgomery modular multiplication operation, setting the first Montgomery field data of the Montgomery modular multiplication operation to 1, and setting the second Montgomery field data to the modular multiplication operation result; The modular multiplication result is reduced according to the first Montgomery field data and the second Montgomery field data to obtain a reduced result.

4. The modular multiplication array according to any one of claims 1 to 3, characterized in that: The pre-calculation parameters include a first pre-calculation parameter and a second pre-calculation parameter, and the modular multiplication array is further used to obtain the first pre-calculation parameter and the second pre-calculation parameter, including: Obtaining input parameters, wherein the input parameters include a first parameter, a second parameter, a modulus value, and a base value; Determine a third parameter according to the modulus value and the base value; Calculating a fourth parameter according to the third parameter and the base value specifically includes: ρ=b^k, Among them, ρ is the fourth parameter, b is the base value, and k is the third parameter; Calculating the first pre-calculation parameter and the second pre-calculation parameter according to the fourth parameter specifically includes: w=ρ-n^(ρ-1)(modρ), wn=(wmodb)*n, Among them, w is the first pre-calculated parameter, ρ is the fourth parameter, n is the modulus value, wn is the second pre-calculated parameter, and b is the base value.

5. The modular multiplication array according to claim 4, characterized in that: The modular multiplication array is also used to calculate the first Montgomery field data and the second Montgomery field data, including: Calculating first Montgomery domain data and second Montgomery domain data according to the first parameter, the second parameter and the fourth parameter specifically includes: x=x1*ρ(modn), y=y1*ρ(modn), Wherein, x is the first Montgomery domain data, x1 is the first parameter, ρ is the fourth parameter, n is the module value, y is the second Montgomery domain data, and y1 is the second parameter.

6. A data processing method, characterized in that: Applied to the modular multiplication array according to any one of claims 1 to 5, the data processing method comprises: Acquire pre-calculated parameters and Montgomery domain data, wherein the Montgomery domain data includes first Montgomery domain data and second Montgomery domain data; Based on the pre-calculated parameters and the Montgomery domain data, performing a Montgomery modular multiplication operation on a preset modular multiplication algorithm to obtain a modular multiplication operation result; The Montgomery modular multiplication operation is called, and a reduction operation is performed on the modular multiplication operation result to obtain a reduced operation result.

7. The method according to claim 6, characterized in that The method of performing a Montgomery modular multiplication operation on a preset modular multiplication algorithm based on the pre-calculated parameters and the Montgomery domain data to obtain a modular multiplication operation result includes: According to the pre-calculation parameter and the Montgomery domain data, a first calculation result and a first addition result are cyclically calculated, specifically including: u=r i (modb)*(w(modb)*n), r i+1 =(r i +u) / b+y i *x, Among them, the value of i ranges from 0 to N-1, r0 is the initial value of r, r0=0, u is the first calculation result, r i is the first addition result of this round, r i (mod b) is r i The low-order data of w(mod b)*n is the second pre-calculated parameter, b is the base value, n is the modulus value, r i+1 is the first addition result of the next round, x is the first Montgomery domain data, y is the second Montgomery domain data, y i is the i-th data of y; The bit width value of the modulus value is obtained. If the number of loop calculations is greater than or equal to the bit width value of the modulus value, a modulus operation is performed according to the first calculation result and the first addition result to obtain a modular multiplication result.

8. The method according to claim 6, characterized in that The input data of the Montgomery modular multiplication operation includes the first Montgomery domain data and the second Montgomery domain data, and the calling of the Montgomery modular multiplication operation and performing a reduction calculation on the modular multiplication operation result to obtain a reduced operation result include: Invoke a Montgomery modular multiplication operation, set the first Montgomery field data of the Montgomery modular multiplication operation to 1, and set the second Montgomery field data to the result of the modular multiplication operation; The modular multiplication result is reduced according to the first Montgomery field data and the second Montgomery field data to obtain a reduced result.

9. The method according to claim 8, characterized in that The pre-calculation parameters include a first pre-calculation parameter and a second pre-calculation parameter, and obtaining the pre-calculation parameters and Montgomery domain data includes: Obtaining input parameters, wherein the input parameters include a first parameter, a second parameter, a modulus value, and a base value; Determine a third parameter according to the modulus value and the base value; Calculating a fourth parameter according to the third parameter and the base value specifically includes: ρ=b^k, Among them, ρ is the fourth parameter, b is the base value, and k is the third parameter; Calculating the first pre-calculation parameter and the second pre-calculation parameter according to the fourth parameter specifically includes: w=ρ-n^(ρ-1)(modρ), wn=(wmodb)*n, Wherein, w is the first pre-calculated parameter, ρ is the fourth parameter, n is the modulus value, wn is the second pre-calculated parameter, and b is the base value; Calculating the first Montgomery domain data and the second Montgomery domain data according to the first parameter, the second parameter, and the fourth parameter specifically includes: x=x1*ρ(modn), y=y1*ρ(modn), Wherein, x is the first Montgomery domain data, x1 is the first parameter, ρ is the fourth parameter, n is the module value, y is the second Montgomery domain data, and y1 is the second parameter.

10. A processing terminal, characterized in that: include: The modular multiplication array according to any one of claims 1 to 5; 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 so that the at least one processor can execute the data processing method according to any one of claims 6 to 9.

Citation Information

Cited By

  • Data processing method and device based on Montgomery algorithm and computer equipment

    CN121277472A