Encrypted data processing method, device, electronic device and storage medium
Through the Montgomery step method of a specific window length, the encryption calculation process is optimized, the problem of low computing efficiency in the existing technology is solved, and more efficient encryption calculation is achieved.
Patent Information
- Application Number
- CN202210945567.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-22
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2042-04-22
AI Technical Summary
The prior art uses the Montgomery ladder method to perform encryption operations, and the computing efficiency is low, especially in ultra-high-speed cryptographic chips and cloud applications, and the number of modular exponentiation operations has not decreased, resulting in an increase in time consumption.
The Montgomery ladder method with a specific window length is used to obtain the coordinates and bit vectors of the specified curve, and perform multiplication and addition calculations window by window, including multiple points and point addition operations, and optimize the modular exponentiation operation process.
The calculation efficiency of the Montgomery ladder method is improved, the number of clock cycles is reduced, and the computing performance is improved.
Smart Images

Figure CN115276994B_ABST
Abstract
Description
[0001] This application is a divisional application of the invention patent application with the application date of April 22, 2022, application number 202210429372.0, and invention name "Data encryption method, device, electronic device using the method and storage medium". Technical Field
[0002] The present disclosure relates to the field of data processing, and in particular to a method, device, electronic device, and storage medium for processing encrypted data. Background Art
[0003] In fields such as data processing and computer communications, specific curves and RSA algorithms are widely used for encryption.
[0004] In encryption operations using specific curves, point multiplications at non-fixed points take the longest time. Currently, the mainstream optimization method for this on standard processors is the windowing method, which consumes relatively few resources and is suitable for most applications. However, for ultra-high-speed cryptographic chips and future cloud applications, which require more resources, the Montgomery ladder method is more suitable. However, there are currently few optimizations for the Montgomery ladder method.
[0005] In cryptographic calculations such as RSA, the Montgomery ladder method is also used to perform modular exponentiation, that is, the Montgomery ladder method is used to calculate M for the input base M and exponent binary vector e. e . The specific implementation of modular exponentiation includes modular multiplication. The prior art optimizes the Montgomery ladder method by first performing integer operations, and then optimizing the two modular multiplication operations into one modular operation during modular multiplication. However, the number of multiplication operations in the prior art does not decrease, and the length of the data to be modularized is doubled due to two consecutive multiplications, so the time for one modular operation is also longer. In the existing Montgomery ladder methods used for elliptic curve encryption and modular exponentiation calculations, for example, calculations need to be performed bit by bit, and the calculation efficiency is low.
[0006] Those skilled in the art will appreciate that, in addition to the RSA algorithm, modular exponentiation operations of other encryption algorithms also face the same problem. The Montgomery ladder method used in other encryption fields also faces the same problem. Summary of the Invention
[0007] In order to solve the corresponding technical problems in the above technical field, the embodiments of the present disclosure provide an encrypted data processing method, device, electronic device and storage medium.
[0008] According to a first aspect of the present disclosure, an embodiment of the present disclosure provides an encryption method for a specified curve, characterized by comprising:
[0009] Get the first coordinate and first bit vector of the specified curve;
[0010] Obtaining a reference coordinate group based on the first coordinate of the specified curve, wherein the reference coordinate group includes a first reference coordinate, a second reference coordinate, a third reference coordinate, and a reference multiple coordinate;
[0011] Splitting the first bit vector into a second bit vector, where the length of the second bit vector is a specific window length greater than 1 bit;
[0012] A second coordinate is obtained by performing multiplication and addition calculations on a window-by-window basis based on the reference coordinates in the reference coordinate group and according to the value of the second bit vector, where the second coordinate is encrypted data obtained by encrypting the first bit vector based on the specified curve.
[0013] In conjunction with the first aspect of the present disclosure, in a first implementation of the first aspect,
[0014] The multiplication and addition calculation includes: doubling point calculation and point addition calculation; and / or
[0015] The first reference coordinate in the reference coordinate group is the coordinate of the point at infinity; and / or
[0016] The second reference coordinate in the reference coordinate group is the first coordinate of the specified curve; and / or
[0017] The third reference coordinate in the reference coordinate group is obtained by subtracting the second reference coordinate from the first reference coordinate; and / or
[0018] The reference multiple coordinates in the reference coordinate group are calculated from integer multiples of the third reference coordinate.
[0019] In conjunction with the first implementation of the first aspect of the present disclosure, in the second implementation of the first aspect,
[0020] Under the condition that the specific window length is 2 bits, the reference multiple coordinate is calculated by the third reference coordinate and the negative 1 times point of the third reference coordinate; and / or
[0021] Under the condition that the specific window length is 4 bits, the reference multiple coordinates are composed of the following calculation results: the calculation result from the negative 8 times point to the 8 times point of the third reference coordinate.
[0022] In combination with the second implementation of the first aspect of the present disclosure, in the third implementation of the first aspect,
[0023] Under the condition that the specific window length is 2 bits, the multiplication and addition calculation includes:
[0024] In the window,
[0025] Under the condition that the value of the second bit vector is "00" or "11",
[0026] Performing double point calculation twice on the first reference coordinate or the second reference coordinate to obtain a first output coordinate within the window;
[0027] Performing point addition calculation on the first output coordinate in the window and the reference multiple coordinate to obtain the second output coordinate in the window;
[0028] The first output coordinate in the window and the second output coordinate in the window are used as inputs for calculation of a next window, and values are assigned to the first reference coordinate and the second reference coordinate in the next window respectively.
[0029] In combination with the third implementation of the first aspect of the present disclosure, in the fourth implementation of the first aspect,
[0030] Under the condition that the specific window length is 2 bits, the multiplication and addition calculation further includes:
[0031] In the window,
[0032] Under the condition that the value of the second bit vector is "01" or "10",
[0033] Performing point addition calculation on the first reference coordinate and the second reference coordinate;
[0034] Performing a doubling calculation on the result of the point addition calculation to obtain a third output coordinate within the window;
[0035] Performing a point addition calculation on the third output coordinate in the window and the reference multiple coordinate to obtain a fourth output coordinate in the window;
[0036] The third output coordinate in the window and the fourth output coordinate in the window are used as inputs for calculation of a next window, and values are assigned to the first reference coordinate and the second reference coordinate in the next window respectively.
[0037] In conjunction with the fourth implementation of the first aspect of the present disclosure, in a fifth implementation of the first aspect, the multiplication and addition calculation further includes:
[0038] After the calculation of all windows is completed, the first output coordinate in the last window or the third output coordinate in the last window is used as the second coordinate.
[0039] In combination with the second implementation of the first aspect of the present disclosure, in a sixth implementation of the first aspect,
[0040] Under the condition that the specific window length is 4 bits, the multiplication and addition calculation includes:
[0041] In the window, performing four doubling point calculations on the first reference coordinate or the second reference coordinate;
[0042] Performing point addition calculation on the results of the four dot-multiplication calculations and the reference multiple coordinates to obtain a fifth output coordinate in the window and a sixth output coordinate in the window;
[0043] The fifth output coordinate in the window and the sixth output coordinate in the window are used as inputs for calculation of a next window, and values are assigned to the first reference coordinate and the second reference coordinate in the next window respectively.
[0044] In conjunction with the sixth implementation of the first aspect of the present disclosure, in a seventh implementation of the first aspect, the multiplication-addition calculation further includes:
[0045] After the calculation of all windows is completed, the fifth output coordinate in the last window is used as the second coordinate.
[0046] In combination with the sixth implementation of the first aspect of the present disclosure, in the eighth implementation of the first aspect,
[0047] The four doubling point calculations are implemented by continuous doubling point calculations.
[0048] In conjunction with the first aspect of the present disclosure, in a ninth implementation of the first aspect,
[0049] The specified curve is an elliptic curve.
[0050] In a second aspect, an embodiment of the present disclosure provides an encrypted data processing method, characterized by comprising:
[0051] Get the first base and first exponent vector for modular exponentiation calculation;
[0052] Initializing a reference variable group based on the first base number, the reference variable group including: a first variable, a second variable, a third variable, and a fourth variable;
[0053] Splitting the first exponential vector into a second exponential vector, where the length of the second exponential vector is a specific window length greater than 1 bit, and the first exponential vector and the second exponential vector are bit vectors;
[0054] Perform multiple square calculations on the first variable or the second variable in the benchmark variable group according to the value of the second exponential vector in each window, and perform modular multiplication operations on the results of the multiple square calculations and the third variable or the fourth variable in the benchmark variable group to obtain an output variable, which is used to encrypt the data.
[0055] In conjunction with the second aspect of the present disclosure, in a first implementation of the second aspect,
[0056] The specific window length is 4 bits.
[0057] In conjunction with the first implementation of the second aspect of the present disclosure, in a second implementation of the second aspect, initializing the reference variable group based on the first base number includes:
[0058] Initialize a first variable, initialize a second variable according to the first base, and calculate a third variable and a fourth variable using the first variable and the second variable.
[0059] In conjunction with the second implementation of the second aspect of the present disclosure, in a third implementation of the second aspect,
[0060] Calculating a third variable and a fourth variable using the first variable and the second variable includes:
[0061] Calculating the inverse variable of the first variable, and calculating the third variable using the result of the power calculation of the inverse variable of the first variable and the result of the power calculation of the second variable,
[0062] The inverse variable of the second variable is calculated, and the fourth variable is calculated using the result of the power calculation of the first variable and the result of the power calculation of the inverse variable of the second variable.
[0063] In combination with the first implementation of the second aspect of the present disclosure, in a fourth implementation of the second aspect,
[0064] The step of performing multiple square calculations on the first variable or the second variable in the benchmark variable group according to the value of the second exponential vector in each window, and performing modular multiplication operations on the results of the multiple square calculations and the third variable or the fourth variable in the benchmark variable group to obtain output variables includes:
[0065] In the window,
[0066] Under the condition that the second index vector takes a value from "0000" to "0111",
[0067] Performing a fourth square calculation on the first variable in the reference variable group, and performing a modular multiplication operation on the result of the fourth square calculation and the third variable or the fourth variable in the reference variable group to obtain a first output variable in the window and a second output variable in the window;
[0068] Using the first output variable and the second output variable in the window as inputs for calculation in the next window, assigning values to the first variable and the second variable in the next window, and / or
[0069] Under the condition that the second index vector takes a value from "1000" to "1111",
[0070] Performing a fourth square calculation on the second variable in the reference variable group, and performing a modular multiplication operation on the result of the fourth square calculation and the third variable or the fourth variable in the reference variable group to obtain a third output variable in the window and a fourth output variable in the window;
[0071] The third output variable in the window and the fourth output variable in the window are used as inputs for calculation in the next window, and the first variable and the second variable in the next window are assigned values.
[0072] In combination with the fourth implementation of the second aspect of the present disclosure, in the fifth implementation of the second aspect,
[0073] The step of performing multiple square calculations on the first variable or the second variable in the benchmark variable group according to the values of the second exponential vector on a window-by-window basis, and performing modular multiplication operations on the results of the multiple square calculations and the third variable or the fourth variable in the benchmark variable group to obtain an output variable further includes:
[0074] After the calculations for all windows are completed, the first output variable in the last window or the third output variable in the last window is used as the output variable.
[0075] In a third aspect, an embodiment of the present disclosure provides an encryption device for a specified curve, characterized by comprising:
[0076] A first coordinate and bit vector acquisition module, configured to acquire a first coordinate and a first bit vector of a specified curve;
[0077] A first initialization module is configured to obtain a reference coordinate group based on the first coordinate of the specified curve, wherein the reference coordinate group includes a first reference coordinate, a second reference coordinate, a third reference coordinate, and a reference multiple coordinate;
[0078] A first bit vector segmentation module, configured to segment the first bit vector into a second bit vector, wherein the length of the second bit vector is a specific window length greater than 1 bit;
[0079] A multiplication and addition calculation module is used to perform multiplication and addition calculations on a window-by-window basis based on the reference coordinates in the reference coordinate group and according to the value of the second bit vector to obtain second coordinates, where the second coordinates are encrypted data obtained by encrypting the first bit vector based on the specified curve.
[0080] In conjunction with the third aspect of the present disclosure, in a first implementation of the third aspect,
[0081] The multiplication and addition calculation includes: doubling point calculation and point addition calculation; and / or
[0082] The first reference coordinate in the reference coordinate group is the coordinate of the point at infinity; and / or
[0083] The second reference coordinate in the reference coordinate group is the first coordinate of the specified curve; and / or
[0084] The third reference coordinate in the reference coordinate group is obtained by subtracting the second reference coordinate from the first reference coordinate; and / or
[0085] The reference multiple coordinates in the reference coordinate group are calculated from integer multiples of the third reference coordinate.
[0086] In combination with the first implementation of the third aspect of the present disclosure, in the second implementation of the third aspect,
[0087] Under the condition that the specific window length is 2 bits, the reference multiple coordinate is calculated by the third reference coordinate and the negative 1 times point of the third reference coordinate; and / or
[0088] Under the condition that the specific window length is 4 bits, the reference multiple coordinates are composed of the following calculation results: the calculation result from the negative 8 times point to the 8 times point of the third reference coordinate.
[0089] In conjunction with the second implementation of the third aspect of the present disclosure, in the third implementation of the third aspect,
[0090] Under the condition that the specific window length is 2 bits, the multiplication and addition calculation module is further used to:
[0091] In the window,
[0092] Under the condition that the value of the second bit vector is "00" or "11",
[0093] Performing double point calculation twice on the first reference coordinate or the second reference coordinate to obtain a first output coordinate within the window;
[0094] Performing point addition calculation on the first output coordinate in the window and the reference multiple coordinate to obtain the second output coordinate in the window;
[0095] The first output coordinate in the window and the second output coordinate in the window are used as inputs for calculation of a next window, and values are assigned to the first reference coordinate and the second reference coordinate in the next window respectively.
[0096] In combination with the third implementation of the third aspect of the present disclosure, in a fourth implementation of the third aspect,
[0097] Under the condition that the specific window length is 2 bits, the multiplication and addition calculation module is further used to:
[0098] In the window,
[0099] Under the condition that the value of the second bit vector is "01" or "10",
[0100] Performing point addition calculation on the first reference coordinate and the second reference coordinate;
[0101] Performing a doubling calculation on the result of the point addition calculation to obtain a third output coordinate within the window;
[0102] Performing a point addition calculation on the third output coordinate in the window and the reference multiple coordinate to obtain a fourth output coordinate in the window;
[0103] The third output coordinate in the window and the fourth output coordinate in the window are used as inputs for calculation of a next window, and values are assigned to the first reference coordinate and the second reference coordinate in the next window respectively.
[0104] In conjunction with the fourth implementation of the third aspect of the present disclosure, in a fifth implementation of the third aspect, the multiplication and addition calculation module is further configured to:
[0105] After the calculation of all windows is completed, the first output coordinate in the last window or the third output coordinate in the last window is used as the second coordinate.
[0106] In combination with the second implementation of the third aspect of the present disclosure, in a sixth implementation of the third aspect,
[0107] Under the condition that the specific window length is 4 bits, the multiplication and addition calculation module is used to:
[0108] In the window, performing four doubling point calculations on the first reference coordinate or the second reference coordinate;
[0109] Performing point addition calculation on the results of the four dot-multiplication calculations and the reference multiple coordinates to obtain a fifth output coordinate in the window and a sixth output coordinate in the window;
[0110] The fifth output coordinate in the window and the sixth output coordinate in the window are used as inputs for calculation of a next window, and values are assigned to the first reference coordinate and the second reference coordinate in the next window respectively.
[0111] In conjunction with the sixth implementation of the third aspect of the present disclosure, in a seventh implementation of the third aspect, the multiplication and addition calculation module is further configured to:
[0112] After the calculation of all windows is completed, the fifth output coordinate in the last window is used as the second coordinate.
[0113] In combination with the fifth implementation of the third aspect of the present disclosure, in an eighth implementation of the third aspect,
[0114] The four doubling point calculations are implemented by continuous doubling point calculations.
[0115] In conjunction with the third aspect of the present disclosure, in a ninth implementation of the third aspect,
[0116] The specified curve is an elliptic curve.
[0117] In a fourth aspect, an embodiment of the present disclosure provides an encrypted data processing device, characterized by comprising:
[0118] A first base and exponent bit vector acquisition module, configured to acquire a first base and a first exponent vector for modular exponentiation calculation;
[0119] A second initialization module is configured to initialize a reference variable group based on the first base number, wherein the reference variable group includes: a first variable, a second variable, a third variable, and a fourth variable;
[0120] A first exponential vector segmentation module, configured to segment the first exponential vector into a second exponential vector, wherein the length of the second exponential vector is a specific window length greater than 1 bit, and the first exponential vector and the second exponential vector are bit vectors;
[0121] The squaring and modular multiplication operation module is used to perform multiple square calculations on the first variable or the second variable in the reference variable group according to the value of the second exponential vector in each window, and perform modular multiplication operations on the results of the multiple square calculations and the third variable or the fourth variable in the reference variable group to obtain an output variable, which is used to encrypt data.
[0122] In conjunction with the fourth aspect of the present disclosure, in a first implementation of the fourth aspect,
[0123] The specific window length is 4 bits.
[0124] In combination with the first implementation of the fourth aspect of the present disclosure, in the second implementation of the fourth aspect,
[0125] The second initialization module is used for:
[0126] Initialize a first variable, initialize a second variable according to the first base, and calculate a third variable and a fourth variable using the first variable and the second variable.
[0127] In combination with the second implementation of the fourth aspect of the present disclosure, in the third implementation of the fourth aspect,
[0128] Calculating a third variable and a fourth variable using the first variable and the second variable includes:
[0129] Calculating the inverse variable of the first variable, and calculating the third variable using the result of the power calculation of the inverse variable of the first variable and the result of the power calculation of the second variable,
[0130] The inverse variable of the second variable is calculated, and the fourth variable is calculated using the result of the power calculation of the first variable and the result of the power calculation of the inverse variable of the second variable.
[0131] In combination with the first implementation of the fourth aspect of the present disclosure, in a fourth implementation of the fourth aspect,
[0132] The square and modular multiplication operation module is used for:
[0133] In the window,
[0134] Under the condition that the second index vector takes a value from "0000" to "0111",
[0135] Performing a fourth square calculation on the first variable in the reference variable group, and performing a modular multiplication operation on the result of the fourth square calculation and the third variable or the fourth variable in the reference variable group to obtain a first output variable in the window and a second output variable in the window;
[0136] Using the first output variable and the second output variable in the window as inputs for calculation in the next window, assigning values to the first variable and the second variable in the next window, and / or
[0137] Under the condition that the second index vector takes a value from "1000" to "1111",
[0138] Performing a fourth square calculation on the second variable in the reference variable group, and performing a modular multiplication operation on the result of the fourth square calculation and the third variable or the fourth variable in the reference variable group to obtain a third output variable in the window and a fourth output variable in the window;
[0139] The third output variable in the window and the fourth output variable in the window are used as inputs for calculation in the next window, and the first variable and the second variable in the next window are assigned values.
[0140] In combination with the fourth implementation of the fourth aspect of the present disclosure, in a fifth implementation of the fourth aspect,
[0141] The square and modular multiplication operation module is further used for:
[0142] After the calculations for all windows are completed, the first output variable in the last window or the third output variable in the last window is used as the output variable.
[0143] In a fifth aspect, an embodiment of the present disclosure provides an electronic device comprising a memory and a processor, wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement a method as described in any one of the first aspect, the first implementation manner of the first aspect to the ninth implementation manner of the first aspect, and the second aspect, the first implementation manner of the second aspect to the fifth implementation manner of the second aspect.
[0144] In the sixth aspect, a computer-readable storage medium is provided in an embodiment of the present disclosure, on which computer instructions are stored, and the computer instructions are executed by a processor to implement the methods described in the first aspect, the first implementation of the first aspect to the ninth implementation of the first aspect, and the second aspect, the first implementation of the second aspect to the fifth implementation of the second aspect.
[0145] In a seventh aspect, an embodiment of the present disclosure provides a chip, comprising a device according to any one of the third aspect or the fourth aspect.
[0146] The technical solutions provided by the embodiments of the present disclosure may have the following beneficial effects:
[0147] According to the technical solution provided by the embodiment of the present disclosure, the first coordinate and the first bit vector of the specified curve are obtained; a reference coordinate group is obtained based on the first coordinate of the specified curve, the reference coordinate group including the first reference coordinate, the second reference coordinate, the third reference coordinate, and the reference multiple coordinate; the first bit vector is divided into a second bit vector, the length of the second bit vector being a specific window length greater than 1 bit; and multiplication and addition calculations are performed window by window based on the reference coordinates in the reference coordinate group according to the value of the second bit vector to obtain the second coordinate, the second coordinate being encrypted data obtained by encrypting the first bit vector based on the specified curve, thereby improving the computational efficiency of the Montgomery ladder method.
[0148] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0149] Other features, objects and advantages of the present disclosure will become more apparent from the following detailed description of non-limiting embodiments taken in conjunction with the accompanying drawings.
[0150] Figure 1 A flowchart of an encryption method for a specified curve according to an embodiment of the present disclosure is shown.
[0151] Figure 2 Show the basis Figure 1This is a flowchart when step S104 of the embodiment is 00 or 11 in the 2-bit window.
[0152] Figure 3 Show the basis Figure 1 This is a flowchart when step S104 of the embodiment is 01 or 10 in the 2-bit window.
[0153] Figure 4 Show the basis Figure 1 The flowchart of step S104 of the embodiment is implemented using a 4-bit window.
[0154] Figure 5 A flowchart of a method for processing encrypted data according to an embodiment of the present disclosure is shown.
[0155] Figure 6 Show the basis Figure 5 This is a flowchart when step S504 of the embodiment is from 0000 to 0111 in the 4-bit window.
[0156] Figure 7 Show the basis Figure 5 This is a flowchart when step S504 of the embodiment is 1000 to 1111 in a 4-bit window.
[0157] Figure 8 A structural block diagram of an encryption device for a specified curve according to an embodiment of the present disclosure is shown.
[0158] Figure 9 A structural block diagram of an encrypted data processing device according to an embodiment of the present disclosure is shown.
[0159] Figure 10 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown.
[0160] Figure 11 A schematic diagram showing the structure of a computer system suitable for implementing the method according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0161] Hereinafter, exemplary embodiments of the present disclosure will be described in detail with reference to the accompanying drawings so that those skilled in the art can easily implement them. In addition, for the sake of clarity, parts not related to the description of the exemplary embodiments are omitted in the accompanying drawings.
[0162] It should also be noted that, in the absence of conflict, the embodiments and labels in the embodiments of the present disclosure can be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0163] In the fields of communications and computers, elliptic curves and RSA algorithms are widely used for encryption.
[0164] In encryption operations using specific curves, point multiplications at non-fixed points take the longest time. Currently, the mainstream optimization method for this on standard processors is the windowing method, which consumes relatively few resources and is suitable for most applications. However, for ultra-high-speed cryptographic chips and future cloud applications, which require more resources, the Montgomery ladder method is more suitable. However, there are currently few optimizations for the Montgomery ladder method.
[0165] In cryptographic calculations such as RSA, the Montgomery ladder method is also used to perform modular exponentiation, that is, the Montgomery ladder method is used to calculate M for the input base M and exponent binary vector e. e . The specific implementation of modular exponentiation includes modular multiplication. The prior art optimizes the Montgomery ladder method by first performing integer operations, and then optimizing the two modular multiplication operations into one modular operation during modular multiplication. However, the number of multiplication operations in the prior art has not been reduced, and the length of the data to be modularized is doubled due to two consecutive multiplications, and the time for one modular operation is also longer. In the existing Montgomery ladder methods used for elliptic curve encryption and modular exponentiation calculations, calculations need to be performed bit by bit, and the calculation efficiency is low.
[0166] Those skilled in the art will appreciate that, in addition to the RSA algorithm, modular exponentiation operations of other encryption algorithms also face the same problem. The Montgomery ladder method used in other encryption fields also faces the same problem.
[0167] To solve the above problems, the present disclosure proposes a data encryption method, device, electronic device and storage medium using the method.
[0168] In the embodiment of the present disclosure, for example, in the encryption of the RSA method, the input is the base M and the exponent binary vector e with a length of 1024 bits, and the Montgomery ladder method with a specific window length of 4 bits is used to calculate M. e .
[0169] Those skilled in the art will appreciate that the exponential binary vector e may have other bit lengths, such as 256 bits or 512 bits, and the specific window length may also have other lengths, such as 2 bits or 8 bits, which is not limited in this disclosure.
[0170] In the embodiment of the present disclosure, first, initialization is performed and the following calculations are performed:
[0171] t 0,0 =1
[0172] t 1,0 =M
[0173] Calculate t0,0 -1 ,
[0174] X = t 0,0 -1 t 1,0
[0175] X 2 = t 0,0 -2 t 1,0 2
[0176] X 3 = X * X 2 = t 0,0 -3 t 1,0 3
[0177] X 4 = (X 2 ) 2 = t 0,0 -4 t 1,0 4
[0178] X 5 = X 2 * X 3 = t 0,0 -5 t 1,0 5
[0179] X 6 = (X 3 ) 2 = t 0,0 -6 t 1,0 6
[0180] X 7 = X 3 * X 4 = t 0,0 -7 t 1,0 7
[0181] X 8 = (X 4 ) 2 = t 0,0 -8 t<00
[0183] Y=t 0,0 t 1,0 -1
[0184] Y 2 =t 0,0 2 t 1,0 -2
[0185] Y 3 =Y*Y 2 =t 0,0 3 t 1,0 -3
[0186] Y 4 =(Y 2 ) 2 =t 0,0 4 t 1,0 -4
[0187] Y 5 =Y 2 *Y 3 =t 0,0 5 t 1,0 -5
[0188] Y 6 =(Y 3 ) 2 =t 0,0 6 t 1,0 -6
[0189] Y 7 =Y 3 *Y 4 =t 0,0 7 t 1,0 -7
[0190] Y 8 =(Y 4 ) 2 =t 0,0 8 t 1,0 -8 .
[0191] In the embodiment of the present disclosure, the initialized reference variable group t 0,0 , t 1,0 , t 0,0 -1 、X~X8 , t 1,0 -1 、Y~Y 8 It can be directly used for subsequent window operations to improve the efficiency of the operation. The initialization process only uses two inverse operations, which improves the initialization efficiency.
[0192] In the embodiment of the present disclosure, for the i-th window (0≤i≤255), the 4 bits of e are (e 4i+3 ,e 4i+2 ,e 4i+1 ,e 4i ). For different (e 4i+3 ,e 4i+2 ,e 4i+1 ,e 4i ) values and perform the following operations respectively: 0000:
[0194] t 0,1 =t 0,0 2
[0195] t 0,2 =t 0,1 2
[0196] t 0,3 =t 0,2 2
[0197] t 0,4 =t 0,3 2
[0198] t 0,5 =t 0,4 ;t 1,1 =t 0,4 *X 0001:
[0200] t 0,1 =t 0,0 2
[0201] t 0,2 =t 0,1 2
[0202] t 0,3 =t 0,2 2
[0203] t 0,4 =t 0,3 2
[0204] t0,5 =t 0,4 *X;t 1,1 =t 0,4 *X 2 0010:
[0206] t 0,1 =t 0,0 2
[0207] t 0,2 =t 0,1 2
[0208] t 0,3 =t 0,2 2
[0209] t 0,4 =t 0,3 2
[0210] t 0,5 =t 0,4 *X 2 ;t 1,1 =t 0,4 *X 3 0011:
[0212] t 0,1 =t 0,0 2
[0213] t 0,2 =t 0,1 2
[0214] t 0,3 =t 0,2 2
[0215] t 0,4 =t 0,3 2
[0216] t 0,5 =t 0,4 *X 3 ;t 1,1 =t 0,4 *X 4 0100:
[0218] t 0,1 =t 0,0 2
[0219] t0,2 =t 0,1 2
[0220] t 0,3 =t 0,2 2
[0221] t 0,4 =t 0,3 2
[0222] t 0,5 =t 0,4 *X 4 ;t 1,1 =t 0,4 *X 5 0101:
[0224] t 0,1 =t 0,0 2
[0225] t 0,2 =t 0,1 2
[0226] t 0,3 =t 0,2 2
[0227] t 0,4 =t 0,3 2
[0228] t 0,5 =t 0,4 *X 5 ;t 1,1 =t 0,4 *X 6 0110:
[0230] t 0,1 =t 0,0 2
[0231] t 0,2 =t 0,1 2
[0232] t 0,3 =t 0,2 2
[0233] t 0,4 =t 0,3 2
[0234] t 0,5 =t 0,4 *X 6 ;t 1,1 =t 0,4 *X 7 0111:
[0236] t 0,1 =t 0,0 2
[0237] t 0,2 =t 0,1 2
[0238] t 0,3 =t 0,2 2
[0239] t 0,4 =t 0,3 2
[0240] t 0,5 =t 0,4 *X 7 ;t 1,1 =t 0,4 *X 8 1000:
[0242] t 1,1 =t 1,0 2
[0243] t 1,2 =t 1,1 2
[0244] t 1,3 =t 1,2 2
[0245] t 1,4 =t 1,3 2
[0246] t 0,1 =t 1,4 *Y 8 ;t 1,5 =t 1,4 *Y 7 1001:
[0248] t 1,1 =t 1,0 2
[0249] t 1,2 =t 1,1 2
[0250] t 1,3 =t 1,2 2
[0251] t 1,4 =t 1,3 2
[0252] t 0,1 =t 1,4 *Y 7 ;t 1,5 =t 1,4 *Y 6 1010:
[0254] t 1,1 =t 1,0 2
[0255] t 1,2 =t 1,1 2
[0256] t 1,3 =t 1,2 2
[0257] t 1,4 =t 1,3 2
[0258] t 0,1 =t 1,4 *Y 6 ;t 1,5 =t 1,4 *Y 5 1011:
[0260] t 1,1 =t 1,0 2
[0261] t 1,2 =t 1,1 2
[0262] t 1,3 =t 1,2 2
[0263] t 1,4 =t 1,32
[0264] t 0,1 =t 1,4 *Y 5 ;t 1,5 =t 1,4 *Y 4 1100:
[0266] t 1,1 =t 1,0 2
[0267] t 1,2 =t 1,1 2
[0268] t 1,3 =t 1,2 2
[0269] t 1,4 =t 1,3 2
[0270] t 0,1 =t 1,4 *Y 4 ;t 1,5 =t 1,4 *Y 3 1101:
[0272] t 1,1 =t 1,0 2
[0273] t 1,2 =t 1,1 2
[0274] t 1,3 =t 1,2 2
[0275] t 1,4 =t 1,3 2
[0276] t 0,1 =t 1,4 *Y 3 ;t 1,5 =t 1,4 *Y 2 1110:
[0278] t 1,1 =t1,0 2
[0279] t 1,2 =t 1,1 2
[0280] t 1,3 =t 1,2 2
[0281] t 1,4 =t 1,3 2
[0282] t 0,1 =t 1,4 *Y 2 ;t 1,5 =t 1,4 *Y 1111:
[0284] t 1,1 =t 1,0 2
[0285] t 1,2 =t 1,1 2
[0286] t 1,3 =t 1,2 2
[0287] t 1,4 =t 1,3 2
[0288] t 0,1 =t 1,4 *Y;t 1,5 =t 1,4 .
[0289] In the embodiment of the present disclosure, for different (e 4i+3 ,e 4i+2 ,e 4i+1 ,e 4i In each of the above operations, the first four square operations are serial square operations, and the subsequent two modular multiplication operations are parallel modular multiplication operations. Parallel modular multiplication operations can save clock cycles and increase computing speed.
[0290] In the embodiment of the present disclosure, the square operation can use the same operation unit as the modular multiplication operation to save costs; the square operation and the modular multiplication operation can also be implemented separately to improve efficiency.
[0291] In the embodiment of the present disclosure, t0,0 , t 0,1 ......t 0,5 The same storage space can be reused, t 1,0 , t 1, 1......t 1,5 The same storage space can be reused. By reusing the storage space, the result of the previous window operation can be used as the input of the next window operation. After all windows are calculated, in the window corresponding to i=255, if (e 4i+3 ,e 4i+2 ,e 4i+1 ,e 4i )=0000~0111, then t 0,5 Output as the return value of the Montgomery ladder method; if (e 4i+3 ,e 4i+2 ,e 4i+1 ,e 4i )=1000~1111, then t 0,1 Output as the return value of the Montgomery ladder method.
[0292] In the embodiment of the present disclosure, in the modular exponentiation Montgomery ladder method for RSA encryption algorithm, the output variable, i.e., the return value M, is obtained by initializing and performing window-by-window Montgomery ladder method based on the first base M and the first exponent vector e. e , the return value M e The technical solution of the present invention is to efficiently implement the Montgomery ladder method in a manner including initialization and window-by-window operation.
[0293] In the disclosed embodiment, compared with the original bit-by-bit Montgomery ladder method for modular exponentiation calculation, the number of clock cycles of the Montgomery ladder method with a specific window length of 4 bits is reduced from 2048 to 1536, and the calculation performance is improved by 25%.
[0294] In the embodiment of the present disclosure, for the Montgomery ladder method applicable to elliptic curve encryption, the input is the first coordinate X0 on the elliptic curve, which can be any coordinate on the elliptic curve, and an L-bit bit vector K, which is used to calculate KX0.
[0295] In the embodiment of the present disclosure, K is a 256-bit vector, that is, L=256.
[0296] In the embodiment of the present disclosure, 2 is used as a specific window length, K is divided into 128 windows, and operations are performed window by window.
[0297] In the embodiment of the present disclosure, initialization is first performed:
[0298] Y 0,0 =O
[0299] Y 1,0 =X0
[0300] Among them, Y 0,0 =O in the "O" is the coordinate point at infinity. 1,0 and Y 0,0 Perform point subtraction to get
[0301] X=Y 1,0 -Y 0,0
[0302] -X=-(Y 1,0 -Y 0,0 ).
[0303] Among them, -(Y 1,0 -Y 0,0 ) is (Y 1,0 -Y 0,0 ) is calculated as minus 1 times the point.
[0304] In the embodiment of the present disclosure, the reference coordinate group Y obtained by initialization 0,0 、Y 1,0 ,X,-X can be directly used in subsequent window operations to improve operation efficiency.
[0305] In the embodiment of the present disclosure, for the i-th window (0≤i≤127), the 2 bits of K are (k 2i+1 ,k 2i ). For different (k 2i+1 ,k 2i ) values and perform the following operations respectively: 00:
[0307] Y 0,1 =2Y 0,0
[0308] Y 0,2 =2Y 0,1
[0309] Y 1,1 =2Y 0,2 +X 11:
[0311] Y 1,1 =2Y 1,0
[0312] Y 1,2 =2Y 1,1
[0313] Y 0,1 =2Y 1,2 +X 01:
[0315] Y 0,1 =Y 0,0 +Y 1,0
[0316] Y 0,2 =2Y 0,1 10:
[0318] Y 1,1 =Y 0,0 +Y 1,0
[0319] Y 1,2 =2Y 1,1
[0320] Y 0,1 =2Y 1,2 +X.
[0321] In the embodiment of the present disclosure, Y 0,1 =2Y 0,0 、Y 0,2 =2Y 0,1 Equal to double the point calculation, Y 1,1 =Y 0,2 +X, Y 0,1 =Y 1,2 +X and other numbers are point addition calculations.
[0322] In the embodiment of the present disclosure, X0 and X can reuse the same storage space, and Y 0,0 、Y 0,1 、Y 0,2 The same storage space can be reused, Y 1,0 、Y 1,1 、Y 1,2 The same storage space can be reused. By reusing the storage space, the result of the previous window operation can be used as the input of the next window operation. After all windows are calculated, in the window corresponding to i=127, if (k 2i+1 ,k 2i )=00 or 01, then Y 0,2 Output as the return value of the Montgomery ladder method; if (k 2i+1 ,k 2i )=11 or 10, then Y 0,1 Output as the return value of the Montgomery ladder method.
[0323] In the Montgomery ladder method of the present embodiment, a coordinate X0 on an elliptic curve and an L-bit bit vector K are used to obtain a second coordinate, namely, a return value KX0, through the Montgomery ladder method, which includes initialization and window-by-window operations. This return value KX0 is used for elliptic curve encryption. The technical solution of the present invention is to efficiently implement the Montgomery ladder method using a method that includes initialization and window-by-window operations.
[0324] In the embodiment of the present disclosure, for the Montgomery ladder method applicable to the elliptic curve, 4 can also be used as the specific window length, K can be divided into 64 windows, and operations can be performed window by window.
[0325] In the embodiment of the present disclosure, initialization is first performed:
[0326] Y 0,0 =0
[0327] Y 1,0 =X0
[0328] Among them, Y 0,0 =O in the "O" is the coordinate point at infinity. 1,0 and Y 0,0 Perform point subtraction to get
[0329] X=Y 1,0 -Y 0,0
[0330] 2X=2(Y 1,0 -Y 0,0 ) ......
[0332] 8X=8(Y 1,0 -Y 0,0 )
[0333] -X=-(Y 1,0 -Y 0,0 )
[0334] -2X=22(Y 1,0 -Y 0,0 ) ......
[0336] -8X=-8(Y 1,0 -Y 0,0 ).
[0337] Among them, -8(Y 1,0 -Y 0,0 ) is (Y 1,0 -Y 0,0 ) is calculated as the negative 8 times of the point, 8(Y 1,0 -Y 0,0 ) is (Y 1,0-Y 0,0 ) is calculated as 8 times the point.
[0338] In the embodiment of the present disclosure, the reference coordinate group Y obtained by initialization 0,0 、Y 1,0 , X~8X, -X~-8X can be directly used for subsequent window operations to improve operation efficiency.
[0339] In the embodiment of the present disclosure, for the i-th window (0≤i≤63), the 4 bits of K are (k 4i+3 ,k 4i+2 ,k 4i+1 ,k 4i ). For different (k 4i+3 ,k 4i+2 ,k 4i+1 ,k 4i ) values and perform the following operations respectively: 0000:
[0341] Y 0,1 =2Y 0,0
[0342] Y 0,2 =2Y 0,1
[0343] Y 0,3 =2Y 0,2
[0344] Y 0,4 =2Y 0,3
[0345] Y 0,5 =2Y 0,4 ; Y 1,1 =Y 0,4 +X 0001:
[0347] Y 0,1 =2Y 0,0
[0348] Y 0,2 =2Y 0,1
[0349] Y 0,3 =2Y 0,2
[0350] Y 0,4 =2Y 0,3
[0351] Y 0,5 =2Y 0,4 +X;Y 1,1 =Y 0,4 +2X<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr"> 0010:<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0353] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,1 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,0 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0354] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,2 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,1 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0355] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,3 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,2 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0356] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,4 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,3 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0357] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,5 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,4 <h2 style=";text-align:left;direction:ltr"> +2X;Y<h2 style=";text-align:left;direction:ltr"> 1,1 <h2 style=";text-align:left;direction:ltr"> =Y<h2 style=";text-align:left;direction:ltr"> 0,4 <h2 style=";text-align:left;direction:ltr"> +3X<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr"> 0011:<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0359] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,1 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,0 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0360] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,2 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,1 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0361] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,3 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,2 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0362] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,4 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,3 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0363] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,5 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,4 <h2 style=";text-align:left;direction:ltr"> +3X;Y<h2 style=";text-align:left;direction:ltr"> 1,1 <h2 style=";text-align:left;direction:ltr"> =Y<h2 style=";text-align:left;direction:ltr"> 0,4 <h2 style=";text-align:left;direction:ltr"> +4X<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr"> 0100:<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0365] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,1 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,0 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0366] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,2 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,1 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0367] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,3 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,2 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0368] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,4 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,3 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0369] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,5 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,4 <h2 style=";text-align:left;direction:ltr"> +4X;Y<h2 style=";text-align:left;direction:ltr"> 1,1 <h2 style=";text-align:left;direction:ltr"> =Y<h2 style=";text-align:left;direction:ltr"> 0,4 <h2 style=";text-align:left;direction:ltr"> +5X<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr"> 0101:<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0371] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,1 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,0 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0372] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,2 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,1 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0373] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,3 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,2 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0374] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,4 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,3 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0375] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,5 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,4 <h2 style=";text-align:left;direction:ltr"> +5X;Y<h2 style=";text-align:left;direction:ltr"> 1,1 <h2 style=";text-align:left;direction:ltr"> =Y<h2 style=";text-align:left;direction:ltr"> 0,4 <h2 style=";text-align:left;direction:ltr"> +6X<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr"> 0110:<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0377] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,1 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,0 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0378] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,2 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,1 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0379] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,3 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,2 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0380] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,4 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,3 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0381] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,5 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,4 <h2 style=";text-align:left;direction:ltr"> +6X;Y<h2 style=";text-align:left;direction:ltr"> 1,1 <h2 style=";text-align:left;direction:ltr"> =Y<h2 style=";text-align:left;direction:ltr"> 0,4 <h2 style=";text-align:left;direction:ltr"> +7X<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr"> 0111:<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0383] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,1 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,0 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0384] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,2 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,1 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0385] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,3 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,2 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0386] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,4 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,3 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0387] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,5 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 0,4 <h2 style=";text-align:left;direction:ltr"> +7X;Y<h2 style=";text-align:left;direction:ltr"> 1,1 <h2 style=";text-align:left;direction:ltr"> =Y<h2 style=";text-align:left;direction:ltr"> 0,4 <h2 style=";text-align:left;direction:ltr"> +8X<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr"> 1000:<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0389] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,1 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,0 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0390] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,2 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,1 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0391] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,3 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,2 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0392] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,4 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,3 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0393] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,1 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,4 <h2 style=";text-align:left;direction:ltr"> -8X;Y<h2 style=";text-align:left;direction:ltr"> 1,5 <h2 style=";text-align:left;direction:ltr"> =Y<h2 style=";text-align:left;direction:ltr"> 1,4 <h2 style=";text-align:left;direction:ltr"> -7X<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr"> 1001:<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0395] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,1 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,0 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0396] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,2 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,1 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0397] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,3 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,2 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0398] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,4 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,3 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0399] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,1 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,4 <h2 style=";text-align:left;direction:ltr"> -7X;Y<h2 style=";text-align:left;direction:ltr"> 1,5 <h2 style=";text-align:left;direction:ltr"> =Y<h2 style=";text-align:left;direction:ltr"> 1,4 <h2 style=";text-align:left;direction:ltr"> -6X<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr"> 1010:<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0401] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,1 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,0 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0402] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,2 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,1 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0403] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,3 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,2 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0404] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,4 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,3 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0405] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,1 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,4 <h2 style=";text-align:left;direction:ltr"> -6X;Y<h2 style=";text-align:left;direction:ltr"> 1,5 <h2 style=";text-align:left;direction:ltr"> =Y<h2 style=";text-align:left;direction:ltr"> 1,4 <h2 style=";text-align:left;direction:ltr"> -5X<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr"> 1011:<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0407] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,1 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,0 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0408] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,2 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,1 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0409] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,3 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,2 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0410] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,4 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,3 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0411] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,1 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,4 <h2 style=";text-align:left;direction:ltr"> -5X;Y<h2 style=";text-align:left;direction:ltr"> 1,5 <h2 style=";text-align:left;direction:ltr"> =Y<h2 style=";text-align:left;direction:ltr"> 1,4 <h2 style=";text-align:left;direction:ltr"> -4X<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr"> 1100:<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0413] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,1 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,0 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0414] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,2 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,1 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0415] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,3 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,2 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0416] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,4 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,3 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0417] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,1 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,4 <h2 style=";text-align:left;direction:ltr"> -4X;Y<h2 style=";text-align:left;direction:ltr"> 1,5 <h2 style=";text-align:left;direction:ltr"> =Y<h2 style=";text-align:left;direction:ltr"> 1,4 <h2 style=";text-align:left;direction:ltr"> -3X<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr"> 1101:<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0419] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,1 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,0 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0420] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,2 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,1 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0421] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,3 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,2 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0422] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 1,4 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,3 <h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr">
[0423] <h2 style=";text-align:left;direction:ltr"> Y<h2 style=";text-align:left;direction:ltr"> 0,1 <h2 style=";text-align:left;direction:ltr"> <2Y<h2 style=";text-align:left;direction:ltr"> 1,4 <h2 style=";text-align:left;direction:ltr"> -3X;Y<h2 style=";text-align:left;direction:ltr"> 1,5 <h2 style=";text-align:left;direction:ltr"> =Y<h2 style=";text-align:left;direction:ltr"> 1,4 <h2 style=";text-align:left;direction:ltr"> -2X 1110:
[0425] Y 1,1 =2Y 1,0
[0426] Y 1,2 =2Y 1,1
[0427] Y 1,3 =2Y 1,2
[0428] Y 1,4 =2Y 1,3
[0429] Y 0,1 =2Y 1,4 -2X;Y 1,5 =Y 1,4 -X 1111:
[0431] Y 1,1 =2Y 1,0
[0432] Y 1,2 =2Y 1,1
[0433] Y 1,3 =2Y 1,2
[0434] Y 1,4 =2Y 1,3
[0435] Y 0,1 =2Y 1,4 -X;Y 1,5 =Y 1,4 .
[0436] In the embodiment of the present disclosure, for different (k 4i+3 ,k 4i+2 ,k 4i+1 ,k 4i ) value, the first four dot-multiplication operations are serial dot-multiplication operations, and the subsequent two dot-addition operations are parallel dot-addition operations. Parallel dot-addition operations can save clock cycles and increase computing speed.
[0437] In the embodiment of the present disclosure, X0 and X can reuse the same storage space, and Y 0,0 、Y 0,1 ......Y 0,5 The same storage space can be reused, Y 1,0 、Y 1,1 ......Y 1,5The same storage space can be reused. By reusing the storage space, the result of the previous window operation can be used as the input of the next window operation. After all windows are calculated, in the window corresponding to i=63, if (k 4i+3 ,k 4i+2 ,k 4i+1 ,k 4i )=0000~0111, then Y 0,5 Output as the return value of the Montgomery ladder method; if (k 4i+3 ,k 4i+2 ,k 4i+1 ,k 4i )=1000~1111, then Y 0,1 Output as the return value of the Montgomery ladder method.
[0438] In the Montgomery ladder method of the present embodiment, a coordinate X0 on an elliptic curve and an L-bit bit vector K are used to obtain a second coordinate, namely, a return value KX0, through the Montgomery ladder method, which includes initialization and window-by-window operations. This return value KX0 is used for elliptic curve encryption. The technical solution of the present invention is to efficiently implement the Montgomery ladder method using a method that includes initialization and window-by-window operations.
[0439] In the embodiment of the present disclosure, for the Montgomery ladder method applicable to elliptic curve encryption, the specific window length is 4 bits and is divided into 64 windows. For the i-th window (0≤i≤63), the 4 bits of K are (k 4i+3 ,k 4i+2 ,k 4i+1 ,k 4i ). For different (k 4i+3 ,k 4i+2 ,k 4i+1 ,k 4i ) value, the four serial doubling operations can be converted into continuous doubling operations to save clock cycles and improve the operation speed, and the following operations are performed respectively: 0000:
[0441] Y 0,1 =2 4 Y 0,0
[0442] Y 0,2 =Y 0,1 ; Y 1,1 =Y 0,2 +X 0001:
[0444] Y 0,1 =2 4 Y 0,0
[0445] AND 0,2 =And 0,1 +X;Y 1,1 =And 0,2 +2X 0010:
[0447] AND 0,1 =2 4 AND 0,0
[0448] AND 0,2 =And 0,1 +2X;Y 1,1 =And 0,2 +3X 0011:
[0450] AND 0,1 =2 4 AND 0,0
[0451] AND 0,2 =And 0,1 +3X;Y 1,1 =And 0,2 +4X 0100:
[0453] AND 0,1 =2 4 AND 0,0
[0454] AND 0,2 =And 0,1 +4X;Y 1,1 =And 0,2 +5X 0101:
[0456] AND 0,1 =2 4 AND 0,0
[0457] AND 0,2 =And 0,1 +5X;Y 1,1 =And 0,2 +6X 0110:
[0459] AND 0,1 =2 4 AND 0,0
[0460] AND 0,2 =And 0,1 +6X;Y 1,1 =And 0,2 +7X 0111:
[0462] AND 0,1 =2 4 AND 0,0
[0463] AND 0,2 =And 0,1 +7X;Y 1,1 =And 0,2 +8X 1000:
[0465] AND 1,1 =2 4 AND 1,0
[0466] AND 0,1 =And 1,1 -8X;Y 1,2 =And 1,1 -7X 1001:
[0468] AND 1,1 =2 4 AND 1,0
[0469] AND 0,1 =And 1,1 -7X;Y 1,2 =And 1,1 -6X 1010:
[0471] AND 1,1 =2 4 AND 1,0
[0472] AND 0,1 =And 1,1 -6X;Y 1,2 =And 1,1 -5X 1011:
[0474] AND 1,1 =2 4 AND 1,0
[0475] AND 0,1 =And 1,1 -5X;Y 1,2 =And 1,1 -4X 1100:
[0477] AND 1,1 =2 4 AND 1,0
[0478] AND 0,1 =And 1,1-4X;Y 1,2 =Y 1,1 -3X 1101:
[0480] Y 1,1 =2 4 Y 1,0
[0481] Y 0,1 =Y 1,1 -3X;Y 1,2 =Y 1,1 -2X 1110:
[0483] Y 1,1 =2 4 Y 1,0
[0484] Y 0,1 =Y 1,1 -2X;Y 1,2 =Y 1,1 -X 1111:
[0486] Y 1,1 =2 4 Y 1,0
[0487] Y 0,1 =Y 1,1 -X;Y 1,2 =Y 1,1 .
[0488] In the embodiment of the present disclosure, Y 0,0 、Y 0,1 、Y 0,2 The same storage space can be reused, Y 1,0 、Y 1,1 、Y 1,2 The same storage space can be reused. By reusing the storage space, the result of the previous window operation can be used as the input of the next window operation. After all windows are calculated, in the window corresponding to i=63, if (k 4i+3 ,k 4i+2 ,k 4i+1 ,k 4i )=0000~0111, then Y 0,2 Output as the return value of the Montgomery ladder method; if (k 4i+3 ,k 4i+2 ,k 4i+1 ,k 4i )=1000~1111, then Y 0,1 Output as the return value of the Montgomery ladder method. The return value of the Montgomery ladder method is used for elliptic curve cryptography.
[0489] In the embodiments of the present disclosure, the following table shows the number of clocks of the traditional bit-by-bit calculation Montgomery ladder method, the 2-bit window method, the 4-bit window method, and the 4-bit window method using continuous doubling operation, as well as the improved efficiency of the 2-bit window method, the 4-bit window method, and the 4-bit window method using continuous doubling operation compared to the bit-by-bit calculation Montgomery ladder method.
[0490]
[0491] In the embodiment of the present disclosure, when the storage space is insufficient, a 2-bit window method can be used to save storage space with slightly slower computing performance; and when the storage space is relatively sufficient, a 4-bit window method can be used to improve computing performance.
[0492] Those skilled in the art will appreciate that the vector K may be of other bit lengths, such as 512 bits, 1024 bits, etc., and the specific window length may also be of other lengths, such as 8 bits, 16 bits, etc., and this disclosure does not limit this.
[0493] Figure 1 A flowchart of an encryption method for a specified curve according to an embodiment of the present disclosure is shown.
[0494] like Figure 1 As shown, the encryption method for a specified curve includes steps S101, S102, S103, and S104.
[0495] In step S101 , a first coordinate and a first bit vector of a specified curve are obtained.
[0496] In step S102 , a reference coordinate group is obtained based on the first coordinate of the designated curve, the reference coordinate group including a first reference coordinate, a second reference coordinate, a third reference coordinate, and a reference multiple coordinate.
[0497] In step S103, the first bit vector is divided into second bit vectors, where the length of the second bit vector is a specific window length greater than 1 bit.
[0498] In step S104, multiplication and addition calculations are performed window by window based on the reference coordinates in the reference coordinate group according to the value of the second bit vector to obtain second coordinates, where the second coordinates are encrypted data obtained by encrypting the first bit vector based on the specified curve.
[0499] According to an embodiment of the present disclosure, the specified curve may be an elliptic curve. For the convenience of explanation, the following description will be made using an elliptic curve as an example.
[0500] In the embodiment of the present disclosure, as described above, for the Montgomery ladder method applicable to elliptic curves, the input is the first coordinate X0 on the elliptic curve, which can be any coordinate on the elliptic curve, and an L-bit bit vector K, which is used to calculate KX0.
[0501] In the embodiment of the present disclosure, K is a 256-bit vector, that is, L=256.
[0502] In the embodiment of the present disclosure, K is divided into 128 windows with a specific window length of 2; or K is divided into 64 windows with a specific window length of 4.
[0503] In the embodiment of the present disclosure, during initialization, the reference coordinate set Y obtained from X0 0,0 、Y 1,0 , X~8X, -X~-8X can be directly used for subsequent window operations to improve operation efficiency.
[0504] In the embodiment of the present disclosure, the reference coordinate Y 0,0 、Y 1,0 , X~8X, -X~-8X, perform doubling and point addition calculations to obtain the second coordinate.
[0505] According to an embodiment of the present disclosure, a first coordinate and a first bit vector of a specified curve are obtained; a reference coordinate group is obtained based on the first coordinate of the specified curve, the reference coordinate group including a first reference coordinate, a second reference coordinate, a third reference coordinate, and a reference multiple coordinate; the first bit vector is divided into a second bit vector, the length of the second bit vector being a specific window length greater than 1 bit; and a multiplication and addition calculation is performed window by window based on the reference coordinates in the reference coordinate group according to the value of the second bit vector to obtain a second coordinate, the second coordinate being encrypted data obtained by encrypting the first bit vector based on the specified curve, thereby improving the operational efficiency of the Montgomery ladder method.
[0506] In the embodiment of the present disclosure, the multiplication and addition calculation includes: doubling point calculation and point addition calculation.
[0507] In the embodiment of the present disclosure, as mentioned above, the first reference coordinate Y 0,0 =O, "O" is the coordinate of the point at infinity. The second reference coordinate Y 1,0 =X0, X0 is the first coordinate. The third reference coordinate X=Y 1,0 -Y 0,0 The result of point subtraction between the second reference coordinate and the first reference coordinate. The reference multiple coordinates X to 8X and -X to -8X are the results of point calculation on integer multiples of the third reference coordinate X.
[0508] According to an embodiment of the present disclosure, the multiplication and addition calculation includes: doubling point calculation and point addition calculation; and / or the first reference coordinate in the reference coordinate group is the coordinate of the point at infinity; and / or the second reference coordinate in the reference coordinate group is the first coordinate of the specified curve; and / or the third reference coordinate in the reference coordinate group is obtained by point subtraction calculation of the second reference coordinate and the first reference coordinate; and / or
[0509] The reference multiple coordinates in the reference coordinate group are calculated from integer multiples of the third reference coordinate, thereby performing pre-calculation of various coordinates, which is suitable for calculations in subsequent windows and improves overall efficiency.
[0510] In the embodiment of the present disclosure, as described above, under the condition that the specific window length is 2 bits, the reference multiple coordinates are X and -X; under the condition that the specific window length is 4 bits, the reference multiple coordinates are 8X to -8X.
[0511] According to an embodiment of the present disclosure, under the condition that the specific window length is 2 bits, the reference multiple coordinates are calculated by the third reference coordinates and the negative 1 times point of the third reference coordinates; and / or under the condition that the specific window length is 4 bits, the reference multiple coordinates are composed of the following calculation results: from the negative 8 times point calculation result of the third reference coordinate to the 8 times point calculation result, thereby performing reasonable initialization and improving calculation efficiency.
[0512] Figure 2 Show the basis Figure 1 This is a flowchart when step S104 of the embodiment is 00 or 11 in the 2-bit window.
[0513] like Figure 2 As shown, when step S104 is 00 or 11 in the 2-bit window, the process includes steps S201 to S203.
[0514] In step S201, doubling calculation is performed twice on the first reference coordinate or the second reference coordinate to obtain a first output coordinate in the window.
[0515] In step S202, a point addition calculation is performed on the first output coordinate in the window and the reference multiple coordinate to obtain a second output coordinate in the window.
[0516] In step S203, the first output coordinates in the window and the second output coordinates in the window are used as inputs for calculation of the next window, and values are assigned to the first reference coordinates and the second reference coordinates in the next window respectively.
[0517] Figure 3 Show the basis Figure 1This is a flowchart when step S104 of the embodiment is 01 or 10 in the 2-bit window.
[0518] like Figure 3 As shown, when step S104 is 01 or 10 in the 2-bit window, the process includes steps S301 to S304.
[0519] In step S301, a point addition calculation is performed on the first reference coordinate and the second reference coordinate.
[0520] In step S302, a doubling calculation is performed on the result of the point addition calculation to obtain a third output coordinate in the window.
[0521] In step S303, a point addition calculation is performed on the third output coordinate in the window and the reference multiple coordinate to obtain a fourth output coordinate in the window.
[0522] In step S304, the third output coordinate in the window and the fourth output coordinate in the window are used as inputs for calculation of the next window, and values are assigned to the first reference coordinate and the second reference coordinate in the next window respectively.
[0523] In the embodiment of the present disclosure, as mentioned above, under the condition that the specific window length is 2 bits, for different (k 2i+1 ,k 2i ) values and perform the following operations respectively: 00:
[0525] Y 0,1 =2Y 0,0
[0526] Y 0,2 =2Y 0,1
[0527] Y 1,1 =2Y 0,2 +X 11:
[0529] Y 1,1 =2Y 1,0
[0530] Y 1,2 =2Y 1,1
[0531] Y 0,1 =2Y 1,2 +X 01:
[0533] Y 0,1 =Y 0,0 +Y 1,0
[0534] Y 0,2 =2Y 0,1 10:
[0536] Y 1,1 =Y 0,0 +Y 1,0
[0537] Y 1,2 =2Y 1,1
[0538] Y 0,1 =2Y 1,2 +X.
[0539] In the embodiment of the present disclosure, Y 0,1 =2Y 0,0 、Y 0,2 =2Y 0,1 Equal to double the point calculation, Y 1,1 =Y 0,2 +X, Y 0,1 =Y 1,2 +X and other numbers are point addition calculations.
[0540] In the embodiment of the present disclosure, X0 and X can reuse the same storage space, and Y 0,0 、Y 0,1 、Y 0,2 The same storage space can be reused, Y 1,0 、Y 1,1 、Y 1,2 The same storage space can be reused. By reusing the storage space, the result of the previous window operation can be used as the input of the next window operation.
[0541] According to an embodiment of the present disclosure, under the condition that the specific window length is 2 bits, the multiplication and addition calculation includes: in the window, under the condition that the value of the second bit vector is "00" or "11", the first reference coordinate or the second reference coordinate is doubled twice to obtain the first output coordinate in the window; the first output coordinate in the window and the reference multiple coordinate are added to obtain the second output coordinate in the window; the first output coordinate in the window and the second output coordinate in the window are used as inputs for the next window calculation, and the first reference coordinate and the second reference coordinate in the next window are assigned values respectively, thereby realizing window-by-window operation and improving operation efficiency.
[0542] According to an embodiment of the present disclosure, under the condition that the specific window length is 2 bits, the multiplication and addition calculation also includes: in the window, under the condition that the value of the second bit vector is "01" or "10", performing point addition calculation on the first reference coordinate and the second reference coordinate; performing point multiplication calculation on the result of the point addition calculation to obtain the third output coordinate in the window; performing point addition calculation on the third output coordinate in the window and the reference multiple coordinate to obtain the fourth output coordinate in the window; using the third output coordinate in the window and the fourth output coordinate in the window as input for the next window calculation, and assigning values to the first reference coordinate and the second reference coordinate in the next window respectively, thereby realizing window-by-window operation and improving operation efficiency.
[0543] In the embodiment of the present disclosure, after all windows are calculated, in the window corresponding to i=127, if (k 2i+1 ,k 2i )=00 or 01, then Y 0,2 Output as the return value of the Montgomery ladder method; if (k 2i+1 ,k 2i )=11 or 10, then Y 0,1 Output as the return value of the Montgomery ladder method.
[0544] According to an embodiment of the present disclosure, the multiplication and addition calculation further includes: after the calculation of all windows is completed, using the first output coordinate in the last window or the third output coordinate in the last window as the second coordinate, thereby improving the operation efficiency.
[0545] Figure 4 Show the basis Figure 1 The flowchart of step S104 of the embodiment is implemented using a 4-bit window.
[0546] like Figure 4 As shown, the process of implementing step S104 using a 4-bit window includes steps S401, S402, and S403.
[0547] In step S401, in the window, four doubling calculations are performed on the first reference coordinate or the second reference coordinate.
[0548] In step S402, a point addition calculation is performed on the results of the four dot-doubling calculations and the reference multiple coordinates to obtain the fifth output coordinate in the window and the sixth output coordinate in the window.
[0549] In step S403, the fifth output coordinate in the window and the sixth output coordinate in the window are used as inputs for calculation of the next window, and values are assigned to the first reference coordinate and the second reference coordinate in the next window respectively.
[0550] In the embodiment of the present disclosure, as described above, for the i-th window (0≤i≤63), the 4 bits of K are (k 4i+3 ,k 4i+2 ,k 4i+1 ,k 4i ). For different (k 4i+3 ,k 4i+2 ,k 4i+1 ,k 4i ) values and perform the following operations respectively: 0000:
[0552] Y 0,1 =2Y 0,0
[0553] Y 0,2 =2Y 0,1
[0554] Y 0,3 =2Y 0,2
[0555] Y 0,4 =2Y 0,3
[0556] Y 0,5 =2Y 0,4 ; Y 1,1 =Y 0,4 +X 0001:
[0558] Y 0,1 =2Y 0,0
[0559] Y 0,2 =2Y 0,1
[0560] Y 0,3 =2Y 0,2
[0561] Y 0,4 =2Y 0,3
[0562] Y 0,5 =2Y 0,4 +X;Y 1,1 =Y 0,4 +2X ...... 1110:
[0565] Y 1,1 =2Y 1,0
[0566] Y 1,2 =2Y 1,1
[0567] Y 1,3 =2Y 1,2
[0568] Y 1,4 =2Y 1,3
[0569] Y 0,1 =2Y 1,4 -2X;Y 1,5 =Y 1,4 -X 1111:
[0571] Y 1,1 =2Y 1,0
[0572] Y 1,2 =2Y 1,1
[0573] Y 1,3 =2Y 1,2
[0574] Y 1,4 =2Y 1,3
[0575] Y 0,1 =2Y 1,4 -X;Y 1,5 =Y 1,4 .
[0576] In the embodiment of the present disclosure, for different (k 4i+3 ,k 4i+2 ,k 4i+1 ,k 4i ) value, the first four dot-multiplication operations are serial dot-multiplication operations, and the subsequent two dot-addition operations are parallel dot-addition operations. Parallel dot-addition operations can save clock cycles and increase computing speed.
[0577] In the embodiment of the present disclosure, X0 and X can reuse the same storage space, and Y 0,0 、Y 0,1 ......Y 0,5 The same storage space can be reused, Y 1,0 、Y 1,1 ......Y 1,5 The same storage space can be reused. By reusing the storage space, the result of the previous window operation can be used as the input of the next window operation.
[0578] According to an embodiment of the present disclosure, under the condition that the specific window length is 4 bits, the multiplication and addition calculation includes: in the window, performing four doubling calculations on the first reference coordinate or the second reference coordinate; performing point addition calculations on the results of the four doubling calculations and the reference multiple coordinates to obtain the fifth output coordinate in the window and the sixth output coordinate in the window; using the fifth output coordinate in the window and the sixth output coordinate in the window as inputs for the next window calculation, and assigning values to the first reference coordinate and the second reference coordinate in the next window respectively, thereby realizing window-by-window operation and improving operation efficiency.
[0579] In the embodiment of the present disclosure, after all windows are calculated, in the window corresponding to i=63, if (k 4i+3 ,k 4i+2 ,k 4i+1 ,k 4i )=0000~0111, then Y 0,5 Output as the return value of the Montgomery ladder method; if (k 4i+3 ,k 4i+2 ,k 4i+1 ,k 4i )=1000~1111, then Y 0,1 Output as the return value of the Montgomery ladder method.
[0580] According to an embodiment of the present disclosure, the multiplication and addition calculation further includes: after the calculation of all windows is completed, using the fifth output coordinate in the last window as the second coordinate, thereby improving the operation speed.
[0581] In the embodiment of the present disclosure, under the condition that the specific window length is 4 bits, the doubling operation of 4 serial calculations can be converted into continuous doubling operation to save clock cycles and improve the operation speed.
[0582] According to the embodiment of the present disclosure, continuous doubling of points is achieved through four doubling of points calculations, thereby improving the operation speed.
[0583] According to the embodiment of the present disclosure, the specified curve is an elliptic curve, thereby improving the operation speed.
[0584] Figure 5 A flowchart of a method for processing encrypted data according to an embodiment of the present disclosure is shown.
[0585] like Figure 5 As shown, the process of the encrypted data processing method includes: steps S501, S502, S503, and S504.
[0586] In step S501 , a first base and a first exponent vector for modular exponentiation calculation are obtained.
[0587] In step S502 , a reference variable group is initialized based on the first base number, where the reference variable group includes: a first variable, a second variable, a third variable, and a fourth variable.
[0588] In step S503, the first exponential vector is divided into a second exponential vector, the length of the second exponential vector is a specific window length greater than 1 bit, and the first exponential vector and the second exponential vector are bit vectors.
[0589] In step S504, multiple square calculations are performed on the first variable or the second variable in the benchmark variable group according to the value of the second exponential vector in each window, and modular multiplication operations are performed on the results of the multiple square calculations and the third variable or the fourth variable in the benchmark variable group to obtain output variables, which are used to encrypt data.
[0590] As previously mentioned, in the embodiment of the present disclosure, for example, the modular exponentiation operation of the RSA method, the input is M and a binary vector e of, for example, a length of 1024 bits, and the Montgomery ladder method with a specific window length of 4 bits is used to calculate M. e .
[0591] In the embodiment of the present disclosure, first, initialization is performed and the following calculations are performed:
[0592] t 0,0 =1
[0593] t 1,0 =M
[0594] Calculate t 0,0 -1 ,
[0595] X=t 0,0 -1 t 1,0
[0596] X 2 =t 0,0 -2 t 1,0 2
[0597] X 3 =X*X 2 =t 0,0 -3 t 1,0 3
[0598] X 4 =(X 2 ) 2 =t 0,0 -4 t 1,04
[0599] X 5 = X 2 * X 3 = t 0,0 -5 t 1,0 5
[0600] X 6 = (X 3 ) 2 = t 0,0 -6 t 1,0 6
[0601] X 7 = X 3 * X 4 = t 0,0 -7 t 1,0 7
[0602] X 8 = (X 4 )<5 =Y 2 *Y 3 =t 0,0 5 t 1,0 -5
[0609] Y 6 =(Y 3 ) 2 =t 0,0 6 t 1,0 -6
[0610] Y 7 =Y 3 *Y 4 =t 0,0 7 t 1,0 -7
[0611] Y 8 =(Y 4 ) 2 =t 0,0 8 t 1,0 -8 .
[0612] In the embodiment of the present disclosure, the initialized reference variable group t 0,0 , t 1,0 , t 0,0 -1 、X~X 8 , t 1,0 -1 、Y~Y 8 It can be directly used for subsequent window operations to improve the efficiency of operations. In the benchmark variable group, t 0,0 is the first variable, t 1,0 is the second variable, X~X 8 is the third variable, Y~Y 8 is the fourth variable.
[0613] In the embodiment of the present disclosure, for the i-th window (0≤i≤255), the 4 bits of e are the second exponent vector (e 4i+3 ,e 4i+2 ,e 4i+1 ,e 4i ). For different (e 4i+3 ,e 4i+2 ,e 4i+1 ,e 4i ) values and perform the following operations respectively: 0000:
[0615] t0,1 =t 0,0 2
[0616] t 0,2 =t 0,1 2
[0617] t 0,3 =t 0,2 2
[0618] t 0,4 =t 0,3 2
[0619] t 0,5 =t 0,4 ;t 1,1 =t 0,4 *X 0001:
[0621] t 0,1 =t 0,0 2
[0622] t 0,2 =t 0,1 2
[0623] t 0,3 =t 0,2 2
[0624] t 0,4 =t 0,3 2
[0625] t 0,5 =t 0,4 *X;t 1,1 =t 0,4 *X 2 ...... 1110:
[0628] t 1,1 =t 1,0 2
[0629] t 1,2 =t 1,1 2
[0630] t 1,3 =t 1,2 2
[0631] t 1,4=t 1,3 2
[0632] t 0,1 =t 1,4 *Y 2 ;t 1,5 =t 1,4 *Y 1111:
[0634] t 1,1 =t 1,0 2
[0635] t 1,2 =t 1,1 2
[0636] t 1,3 =t 1,2 2
[0637] t 1,4 =t 1,3 2
[0638] t 0,1 =t 1,4 *Y;t 1,5 =t 1,4 .
[0639] In the embodiment of the present disclosure, for different (e 4i+3 ,e 4i+2 ,e 4i+1 ,e 4i ) values, the first four square operations are serial square operations, and the subsequent two modular multiplication operations are parallel modular multiplication operations. Parallel modular multiplication operations can save clock cycles and increase computing speed.
[0640] In the embodiment of the present disclosure, the square operation can use the same operation unit as the modular multiplication operation to save costs; the square operation and the modular multiplication operation can also be implemented separately to improve efficiency.
[0641] In the embodiment of the present disclosure, t 0,0 , t 0,1 ......t 0,5 The same storage space can be reused, t 1,0 , t 1, 1......t 1,5 The same storage space can be reused. By reusing the storage space, the result of the previous window operation can be used as the input of the next window operation. After all windows are calculated, in the window corresponding to i=255, if (e 4i+3 ,e4i+2 ,e 4i+1 ,e 4i )=0000~0111, then t 0,5 Output as the return value of the Montgomery ladder method; if (e 4i+3 ,e 4i+2 ,e 4i+1 ,e 4i )=1000~1111, then t 0,1 Output as the return value of the Montgomery ladder method.
[0642] According to an embodiment of the present disclosure, a first base and a first exponent vector for modular exponentiation calculation are obtained; a reference variable group is initialized based on the first base, the reference variable group including: a first variable, a second variable, a third variable, and a fourth variable; the first exponent vector is divided into a second exponent vector, the length of the second exponent vector being a specific window length greater than 1 bit; multiple square calculations are performed on the first variable or the second variable in the reference variable group window by window according to the value of the second exponent vector, and modular multiplication operations are performed on the results of the multiple square calculations and the third variable or the fourth variable in the reference variable group to obtain output variables, which are used to encrypt data, thereby improving the operation speed of the Montgomery ladder method for modular exponentiation calculation.
[0643] According to the embodiment of the present disclosure, a specific window length of 4 bits is used to implement window-by-window operations, thereby improving operation efficiency.
[0644] In the embodiment of the present disclosure, first, initialization is performed and the following calculations are performed:
[0645] t 0,0 =1
[0646] t 1,0 =M
[0647] Calculate t 0,0 -1 ,
[0648] X=t 0,0 -1 t 1,0
[0649] X 2 =t 0,0 -2 t 1,0 2
[0650] X 3 =X*X 2 =t 0,0 -3 t 1,0 3
[0651] X 4 = (X 2 ) 2 = t 0,0 -4 t 1,0 4
[0652] X 5 = X 2 * X 3 = t 0,0 -5 t 1,0 5
[0653] X 6 = (X 3 ) 2 = t 0,0 -6 t 1,0 6
[0654] X 7 = X 3 * X 4 = t 0,0 -7 t 1,0 7
[0655] X 8 = (X 4 ) 2 = t 0,0 -8 t 1,0 8
[0656] Calculate t 1,0 -1 ,
[0657] Y = t 0,0 t 1,0 -1
[0658] Y 2 = t 0,0 2 t 1,0 -2
[0659] Y 3 = Y * Y 2 = t 0,0 3 t 1,0 -3
[0660] Y 4 = (Y2 ) 2 =t 0,0 4 t 1,0 -4
[0661] Y 5 =Y 2 *Y 3 =t 0,0 5 t 1,0 -5
[0662] Y 6 =(Y 3 ) 2 =t 0,0 6 t 1,0 -6
[0663] Y 7 =Y 3 *Y 4 =t 0,0 7 t 1,0 -7
[0664] Y 8 =(Y 4 ) 2 =t 0,0 8 t 1,0 -8 .
[0665] In the embodiment of the present disclosure, the initialized reference variable group includes the first variable t 0,0 , the second variable t 1,0 , t 0,0 -1 , t 1,0 -1 , the third variable X~X 8 、The fourth variable Y~Y 8 It can be directly used for subsequent operations within the window to improve operation efficiency.
[0666] According to an embodiment of the present disclosure, initializing the benchmark variable group based on the first base number includes: initializing the first variable, initializing the second variable according to the first base number, and calculating the third variable and the fourth variable using the first variable and the second variable, thereby facilitating subsequent operations within the window and improving operation efficiency.
[0667] According to an embodiment of the present disclosure, calculating the third variable and the fourth variable using the first variable and the second variable includes: calculating the inverse variable of the first variable, calculating the third variable using the result of the power calculation of the inverse variable of the first variable and the result of the power calculation of the second variable, calculating the inverse variable of the second variable, calculating the fourth variable using the result of the power calculation of the first variable and the result of the power calculation of the inverse variable of the second variable, thereby providing initialization efficiency.
[0668] Figure 6 Show the basis Figure 5 This is a flowchart when step S504 of the embodiment is from 0000 to 0111 in the 4-bit window.
[0669] like Figure 6 As shown, the process when step S504 is 0000 to 0111 in the 4-bit window includes: step S601 and step S602.
[0670] In step S601, a fourth square calculation is performed on the first variable in the reference variable group, and a modular multiplication operation is performed on the result of the fourth square calculation and the third variable or the fourth variable in the reference variable group to obtain a first output variable in the window and a second output variable in the window.
[0671] In step S602, the first output variable in the window and the second output variable in the window are used as inputs for calculation in the next window, and values are assigned to the first variable and the second variable in the next window.
[0672] Figure 7 Show the basis Figure 5 This is a flowchart when step S504 of the embodiment is 1000 to 1111 in a 4-bit window.
[0673] like Figure 7 As shown, the process when step S504 is 1000 to 1111 in the 4-bit window includes: step S701 and step S702.
[0674] In step S701, a fourth square calculation is performed on the second variable in the reference variable group, and a modular multiplication operation is performed on the result of the fourth square calculation and the third variable or the fourth variable in the reference variable group to obtain a third output variable in the window and a fourth output variable in the window.
[0675] In step S702, the third output variable in the window and the fourth output variable in the window are used as inputs for calculation in the next window, and values are assigned to the first variable and the second variable in the next window.
[0676] In the embodiment of the present disclosure, for the i-th window (0≤i≤255), the 4 bits of e are (e4i+3 ,e 4i+2 ,e 4i+1 ,e 4i ). For different (e 4i+3 ,e 4i+2 ,e 4i+1 ,e 4i ) values and perform the following operations respectively: 0000:
[0678] t 0,1 =t 0,0 2
[0679] t 0,2 =t 0,1 2
[0680] t 0,3 =t 0,2 2
[0681] t 0,4 =t 0,3 2
[0682] t 0,5 =t 0,4 ;t 1,1 =t 0,4 *X 0001:
[0684] t 0,1 =t 0,0 2
[0685] t 0,2 =t 0,1 2
[0686] t 0,3 =t 0,2 2
[0687] t 0,4 =t 0,3 2
[0688] t 0,5 =t 0,4 *X;t 1,1 =t 0,4 *X 2 ...... 1110:
[0691] t 1,1 =t 1,02
[0692] t 1,2 =t 1,1 2
[0693] t 1,3 =t 1,2 2
[0694] t 1,4 =t 1,3 2
[0695] t 0,1 =t 1,4 *Y 2 ;t 1,5 =t 1,4 *Y 1111:
[0697] t 1,1 =t 1,0 2
[0698] t 1,2 =t 1,1 2
[0699] t 1,3 =t 1,2 2
[0700] t 1,4 =t 1,3 2
[0701] t 0,1 =t 1,4 *Y;t 1,5 =t 1,4 .
[0702] In the embodiment of the present disclosure, t 0,0 , t 0,1 ......t 0,5 The same storage space can be reused, t 1,0 , t 1, 1......t 1,5 The same storage space can be reused. By reusing the storage space, the result of the previous window operation can be used as the input of the next window operation.
[0703] According to an embodiment of the present disclosure, performing multiple square calculations on the first variable or the second variable in the reference variable group according to the value of the second exponent vector on a window-by-window basis, and performing modular multiplication operations on the results of the multiple square calculations and the third variable or the fourth variable in the reference variable group to obtain an output variable includes: in the window, under the condition that the value of the second exponent vector is "0000" to "0111", performing a fourth square calculation on the first variable in the reference variable group, and performing modular multiplication operations on the result of the fourth square calculation and the third variable or the fourth variable in the reference variable group to obtain a first output variable and a second output variable in the window; The first output variable and the second output variable in the window are used as inputs for the next window calculation, and values are assigned to the first variable and the second variable in the next window. And / or under the condition that the value of the second exponent vector is "1000" to "1111", a fourth square calculation is performed on the second variable in the benchmark variable group, and a modular multiplication operation is performed on the result of the fourth square calculation and the third variable or the fourth variable in the benchmark variable group to obtain the third output variable in the window and the fourth output variable in the window; the third output variable in the window and the fourth output variable in the window are used as inputs for the next window calculation, and values are assigned to the first variable and the second variable in the next window, thereby improving computational efficiency.
[0704] In the embodiment of the present disclosure, after all windows are calculated, in the window corresponding to i=255, if (e 4i+3 ,e 4i+2 ,e 4i+1 ,e 4i )=0000~0111, then t 0,5 Output as the return value of the Montgomery ladder method; if (e 4i+3 ,e 4i+2 ,e 4i+1 ,e 4i )=1000~1111, then t 0,1 Output as the return value of the Montgomery ladder method.
[0705] According to an embodiment of the present disclosure, performing multiple square calculations on the first variable or the second variable in the benchmark variable group according to the value of the second exponential vector on a window-by-window basis, performing modular multiplication operations on the results of the multiple square calculations and the third variable or the fourth variable in the benchmark variable group to obtain the output variable also includes: after the calculations in all windows are completed, using the first output variable in the last window or the third output variable in the last window as the output variable, thereby improving computational efficiency.
[0706] Figure 8 A structural block diagram of an encryption device for a specified curve according to an embodiment of the present disclosure is shown.
[0707] like Figure 8 As shown, the encryption device 800 for a specified curve includes: a first coordinate and bit vector acquisition module 801 , a first initialization module 802 , a first bit vector segmentation module 803 , and a multiplication and addition calculation module 804 .
[0708] The first coordinate and bit vector acquisition module 801 is used to acquire the first coordinate and the first bit vector of a specified curve.
[0709] The first initialization module 802 is used to obtain a reference coordinate group based on the first coordinate of the specified curve, where the reference coordinate group includes a first reference coordinate, a second reference coordinate, a third reference coordinate, and a reference multiple coordinate.
[0710] The first bit vector segmentation module 803 is configured to segment the first bit vector into second bit vectors, where the length of the second bit vector is a specific window length greater than 1 bit.
[0711] The multiplication and addition calculation module 804 is used to perform multiplication and addition calculations on a window-by-window basis based on the reference coordinates in the reference coordinate group and according to the value of the second bit vector to obtain second coordinates, which are used to encrypt the specified curve.
[0712] According to an embodiment of the present disclosure, a first coordinate and bit vector acquisition module is used to obtain the first coordinate and the first bit vector of a specified curve; a first initialization module is used to obtain a reference coordinate group based on the first coordinate of the specified curve, wherein the reference coordinate group includes a first reference coordinate, a second reference coordinate, a third reference coordinate, and a reference multiple coordinate; a first bit vector segmentation module is used to segment the first bit vector into a second bit vector, wherein the length of the second bit vector is a specific window length greater than 1 bit; a multiplication and addition calculation module is used to perform multiplication and addition calculations on the basis of the reference coordinates in the reference coordinate group window by window according to the value of the second bit vector to obtain a second coordinate, wherein the second coordinate is used to encrypt the specified curve, thereby improving the computational efficiency of the Montgomery ladder method.
[0713] According to an embodiment of the present disclosure, the multiplication and addition calculation includes: point doubling calculation and point addition calculation; and / or the first reference coordinate in the reference coordinate group is the coordinate of the point at infinity; and / or the second reference coordinate in the reference coordinate group is the first coordinate of the specified curve; and / or the third reference coordinate in the reference coordinate group is obtained by point subtraction calculation of the second reference coordinate and the first reference coordinate; and / or the reference multiple coordinate in the reference coordinate group is obtained by point calculation of the integer multiple of the third reference coordinate, thereby performing pre-calculation of various coordinates, which is suitable for operations in subsequent windows and improves overall efficiency.
[0714] According to an embodiment of the present disclosure, under the condition that the specific window length is 2 bits, the reference multiple coordinates are calculated by the third reference coordinates and the negative 1 times point of the third reference coordinates; and / or under the condition that the specific window length is 4 bits, the reference multiple coordinates are composed of the following calculation results: from the negative 8 times point calculation result of the third reference coordinate to the 8 times point calculation result, thereby performing reasonable initialization and improving calculation efficiency.
[0715] According to an embodiment of the present disclosure, under the condition that the length of the specific window is 2 bits, the multiplication and addition calculation module is used to: in the window, under the condition that the value of the second bit vector is "00" or "11", perform two doubling calculations on the first reference coordinate or the second reference coordinate to obtain the first output coordinate in the window; perform point addition calculation on the first output coordinate in the window and the reference multiple coordinate to obtain the second output coordinate in the window; use the first output coordinate in the window and the second output coordinate in the window as input for the next window calculation, and assign values to the first reference coordinate and the second reference coordinate in the next window respectively, thereby realizing window-by-window operation and improving operation efficiency.
[0716] According to an embodiment of the present disclosure, under the condition that the specific window length is 2 bits, the multiplication and addition calculation module is also used to: in the window, under the condition that the value of the second bit vector is "01" or "10", perform point addition calculation on the first reference coordinate and the second reference coordinate; perform point multiplication calculation on the result of the point addition calculation to obtain the third output coordinate in the window; perform point addition calculation on the third output coordinate in the window and the reference multiple coordinate to obtain the fourth output coordinate in the window; use the third output coordinate in the window and the fourth output coordinate in the window as input for the next window calculation, and assign values to the first reference coordinate and the second reference coordinate in the next window respectively, thereby realizing window-by-window operation and improving operation efficiency.
[0717] According to an embodiment of the present disclosure, the multiplication and addition calculation module is further used to:
[0718] After the calculation of all windows is completed, the first output coordinate in the last window or the third output coordinate in the last window is used as the second coordinate, thereby improving the calculation efficiency.
[0719] According to an embodiment of the present disclosure, under the condition that the specific window length is 4 bits, the multiplication and addition calculation module is used to: perform four doubling calculations on the first reference coordinate or the second reference coordinate in the window; perform point addition calculations on the results of the four doubling calculations and the reference multiple coordinates to obtain the fifth output coordinate in the window and the sixth output coordinate in the window; use the fifth output coordinate in the window and the sixth output coordinate in the window as inputs for the next window calculation, and assign values to the first reference coordinate and the second reference coordinate in the next window respectively, thereby realizing window-by-window operations and improving operation efficiency.
[0720] According to an embodiment of the present disclosure, the multiplication and addition calculation module is further configured to: after calculations of all windows are completed, use the fifth output coordinate in the last window as the second coordinate, thereby improving the operation speed.
[0721] According to the embodiment of the present disclosure, continuous doubling calculation is achieved through four doubling calculations, thereby improving the operation speed.
[0722] According to the embodiment of the present disclosure, the specified curve is an elliptic curve, thereby improving the operation speed.
[0723] Figure 9 A structural block diagram of an encrypted data processing device according to an embodiment of the present disclosure is shown.
[0724] like Figure 9 As shown, the encrypted data processing device 900 includes: a first base and exponent bit vector acquisition module 901, a second initialization module 902, a first exponent vector segmentation module 903, and a square and modular multiplication operation module 904.
[0725] The first base and exponent bit vector acquisition module 901 is configured to acquire a first base and a first exponent vector for modular exponentiation calculation.
[0726] The second initialization module 902 is configured to initialize a reference variable group based on the first base number, where the reference variable group includes: a first variable, a second variable, a third variable, and a fourth variable.
[0727] The first exponential vector segmentation module 903 is configured to segment the first exponential vector into a second exponential vector, where the length of the second exponential vector is a specific window length greater than 1 bit, and the first exponential vector and the second exponential vector are bit vectors.
[0728] The squaring and modular multiplication operation module 904 is used to perform multiple square calculations on the first variable or the second variable in the benchmark variable group according to the value of the second exponential vector in each window, and perform modular multiplication operations on the results of the multiple square calculations and the third variable or the fourth variable in the benchmark variable group to obtain an output variable, which is used to encrypt data.
[0729] According to an embodiment of the present disclosure, a first base and exponent bit vector acquisition module is used to obtain a first base and a first exponent vector for modular exponentiation calculation; a second initialization module is used to initialize a reference variable group based on the first base, wherein the reference variable group includes: a first variable, a second variable, a third variable, and a fourth variable; a first exponent vector segmentation module is used to segment the first exponent vector into a second exponent vector, wherein the length of the second exponent vector is a specific window length greater than 1 bit; a square and modular multiplication operation module is used to perform multiple square calculations on the first variable or the second variable in the reference variable group according to the value of the second exponent vector on a window-by-window basis, and perform modular multiplication operations on the results of the multiple square calculations and the third variable or the fourth variable in the reference variable group to obtain an output variable, wherein the output variable is used to encrypt data, thereby improving the operation speed of the Montgomery ladder method for modular exponentiation calculation.
[0730] According to the embodiment of the present disclosure, a specific window length of 4 bits is used to implement window-by-window operations, thereby improving operation efficiency.
[0731] According to an embodiment of the present disclosure, the second initialization module is used to: initialize the first variable, initialize the second variable according to the first base, and calculate the third variable and the fourth variable using the first variable and the second variable, thereby facilitating subsequent operations within the window and improving operation efficiency.
[0732] According to an embodiment of the present disclosure, calculating the third variable and the fourth variable using the first variable and the second variable includes: calculating the inverse variable of the first variable, calculating the third variable using the result of the power calculation of the inverse variable of the first variable and the result of the power calculation of the second variable, calculating the inverse variable of the second variable, calculating the fourth variable using the result of the power calculation of the first variable and the result of the power calculation of the inverse variable of the second variable, thereby providing initialization efficiency.
[0733] According to an embodiment of the present disclosure, the squaring and modular multiplication operation module is configured to: within the window, under the condition that the value of the second exponent vector ranges from "0000" to "0111", perform a fourth square calculation on the first variable in the reference variable group, perform a modular multiplication operation on the result of the fourth square calculation and the third variable or the fourth variable in the reference variable group to obtain a first output variable and a second output variable within the window; use the first output variable and the second output variable within the window as inputs for a next window calculation, and assign values to the first variable and the second variable in the next window; and / or, under the condition that the value of the second exponent vector ranges from "1000" to "1111", perform a fourth square calculation on the second variable in the reference variable group, perform a modular multiplication operation on the result of the fourth square calculation and the third variable or the fourth variable in the reference variable group to obtain a third output variable and a fourth output variable within the window; use the third output variable and the fourth output variable within the window as inputs for a next window calculation, and assign values to the first variable and the second variable in the next window, thereby improving computational efficiency.
[0734] According to an embodiment of the present disclosure, the square and modular multiplication operation module is further used to: after the calculation of all windows is completed, use the first output variable in the last window or the third output variable in the last window as the output variable, thereby improving the operation efficiency.
[0735] Figure 10 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown.
[0736] like Figure 10 As shown, the electronic device 1000 includes a memory 1001 and a processor 1002, wherein the memory 1001 is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor 1002 to implement the following steps:
[0737] Get the first coordinate and first bit vector of the specified curve;
[0738] Obtaining a reference coordinate group based on the first coordinate of the specified curve, wherein the reference coordinate group includes a first reference coordinate, a second reference coordinate, a third reference coordinate, and a reference multiple coordinate;
[0739] Splitting the first bit vector into a second bit vector, where the length of the second bit vector is a specific window length greater than 1 bit;
[0740] A multiplication and addition calculation is performed window by window based on the reference coordinates in the reference coordinate group according to the value of the second bit vector to obtain second coordinates, where the second coordinates are used to encrypt the specified curve.
[0741] In the embodiments of the present disclosure,
[0742] The multiplication and addition calculation includes: doubling point calculation and point addition calculation; and / or
[0743] The first reference coordinate in the reference coordinate group is the coordinate of the point at infinity; and / or
[0744] The second reference coordinate in the reference coordinate group is the first coordinate of the specified curve; and / or
[0745] The third reference coordinate in the reference coordinate group is obtained by subtracting the second reference coordinate from the first reference coordinate; and / or
[0746] The reference multiple coordinates in the reference coordinate group are calculated from integer multiples of the third reference coordinate.
[0747] In the embodiments of the present disclosure,
[0748] Under the condition that the specific window length is 2 bits, the reference multiple coordinate is calculated by the third reference coordinate and the negative 1 times point of the third reference coordinate; and / or
[0749] Under the condition that the specific window length is 4 bits, the reference multiple coordinates are composed of the following calculation results: the calculation result from the negative 8 times point to the 8 times point of the third reference coordinate.
[0750] In the embodiments of the present disclosure,
[0751] Under the condition that the specific window length is 2 bits, the multiplication and addition calculation includes:
[0752] In the window,
[0753] Under the condition that the value of the second bit vector is "00" or "11",
[0754] Performing double point calculation twice on the first reference coordinate or the second reference coordinate to obtain a first output coordinate within the window;
[0755] Performing point addition calculation on the first output coordinate in the window and the reference multiple coordinate to obtain the second output coordinate in the window;
[0756] The first output coordinate in the window and the second output coordinate in the window are used as inputs for calculation of a next window, and values are assigned to the first reference coordinate and the second reference coordinate in the next window respectively.
[0757] In the embodiments of the present disclosure,
[0758] Under the condition that the specific window length is 2 bits, the multiplication and addition calculation further includes:
[0759] In the window,
[0760] Under the condition that the value of the second bit vector is "01" or "10",
[0761] Performing point addition calculation on the first reference coordinate and the second reference coordinate;
[0762] Performing a doubling calculation on the result of the point addition calculation to obtain a third output coordinate within the window;
[0763] Performing a point addition calculation on the third output coordinate in the window and the reference multiple coordinate to obtain a fourth output coordinate in the window;
[0764] The third output coordinate in the window and the fourth output coordinate in the window are used as inputs for calculation of a next window, and values are assigned to the first reference coordinate and the second reference coordinate in the next window respectively.
[0765] In an embodiment of the present disclosure, the multiplication and addition calculation further includes:
[0766] After the calculation of all windows is completed, the first output coordinate in the last window or the third output coordinate in the last window is used as the second coordinate.
[0767] In the embodiments of the present disclosure,
[0768] Under the condition that the specific window length is 4 bits, the multiplication and addition calculation includes:
[0769] In the window, performing four doubling point calculations on the first reference coordinate or the second reference coordinate;
[0770] Performing point addition calculation on the results of the four dot-multiplication calculations and the reference multiple coordinates to obtain a fifth output coordinate in the window and a sixth output coordinate in the window;
[0771] The fifth output coordinate in the window and the sixth output coordinate in the window are used as inputs for calculation of a next window, and values are assigned to the first reference coordinate and the second reference coordinate in the next window respectively.
[0772] In an embodiment of the present disclosure, the multiplication and addition calculation further includes:
[0773] After the calculation of all windows is completed, the fifth output coordinate in the last window is used as the second coordinate.
[0774] In the embodiments of the present disclosure,
[0775] The four doubling point calculations are implemented by continuous doubling point calculations.
[0776] In the embodiments of the present disclosure,
[0777] The specified curve is an elliptic curve.
[0778] The one or more computer instructions are further executed by the processor 1002 to implement the following steps:
[0779] Get the first base and first exponent vector for modular exponentiation calculation;
[0780] Initializing a reference variable group based on the first base number, the reference variable group including: a first variable, a second variable, a third variable, and a fourth variable;
[0781] Splitting the first exponential vector into a second exponential vector, where the length of the second exponential vector is a specific window length greater than 1 bit, and the first exponential vector and the second exponential vector are bit vectors;
[0782] Perform multiple square calculations on the first variable or the second variable in the benchmark variable group according to the value of the second exponential vector in each window, and perform modular multiplication operations on the results of the multiple square calculations and the third variable or the fourth variable in the benchmark variable group to obtain an output variable, which is used to encrypt the data.
[0783] In the embodiments of the present disclosure,
[0784] The specific window length is 4 bits.
[0785] In an embodiment of the present disclosure, initializing the reference variable group based on the first base number includes:
[0786] Initialize a first variable, initialize a second variable according to the first base, and calculate a third variable and a fourth variable using the first variable and the second variable.
[0787] In the embodiments of the present disclosure,
[0788] Calculating a third variable and a fourth variable using the first variable and the second variable includes:
[0789] Calculating the inverse variable of the first variable, and calculating the third variable using the result of the power calculation of the inverse variable of the first variable and the result of the power calculation of the second variable,
[0790] The inverse variable of the second variable is calculated, and the fourth variable is calculated using the result of the power calculation of the first variable and the result of the power calculation of the inverse variable of the second variable.
[0791] In the embodiments of the present disclosure,
[0792] The step of performing multiple square calculations on the first variable or the second variable in the benchmark variable group according to the value of the second exponential vector in each window, and performing modular multiplication operations on the results of the multiple square calculations and the third variable or the fourth variable in the benchmark variable group to obtain output variables includes:
[0793] In the window,
[0794] Under the condition that the second index vector takes a value from "0000" to "0111",
[0795] Performing a fourth square calculation on the first variable in the reference variable group, and performing a modular multiplication operation on the result of the fourth square calculation and the third variable or the fourth variable in the reference variable group to obtain a first output variable in the window and a second output variable in the window;
[0796] Using the first output variable and the second output variable in the window as inputs for calculation in the next window, assigning values to the first variable and the second variable in the next window, and / or
[0797] Under the condition that the second index vector takes a value from "1000" to "1111",
[0798] Performing a fourth square calculation on the second variable in the reference variable group, and performing a modular multiplication operation on the result of the fourth square calculation and the third variable or the fourth variable in the reference variable group to obtain a third output variable in the window and a fourth output variable in the window;
[0799] The third output variable in the window and the fourth output variable in the window are used as inputs for calculation in the next window, and the first variable and the second variable in the next window are assigned values.
[0800] In the embodiment of the present disclosure, performing multiple square calculations on the first variable or the second variable in the benchmark variable group according to the values of the second exponential vector on a window-by-window basis, and performing modular multiplication operations on the results of the multiple square calculations and the third variable or the fourth variable in the benchmark variable group to obtain the output variable further includes:
[0801] After the calculations for all windows are completed, the first output variable in the last window or the third output variable in the last window is used as the output variable.
[0802] Figure 11 A schematic diagram showing the structure of a computer system suitable for implementing the method according to an embodiment of the present disclosure is shown.
[0803] like Figure 11As shown, the computer system 1100 includes a processing unit 1101, which can execute various processes in the above-mentioned embodiments according to a program stored in a read-only memory (ROM) 1102 or a program loaded from a storage unit 1108 into a random access memory (RAM) 1103. Various programs and data required for the operation of the computer system 1100 are also stored in the RAM 1103. The processing unit 1101, the ROM 1102, and the RAM 1103 are connected to each other via a bus 1104. An input / output (I / O) interface 1105 is also connected to the bus 1104.
[0804] The following components are connected to the I / O interface 1105: an input section 1106 including a keyboard, a mouse, etc.; an output section 1107 including a cathode ray tube (CRT), a liquid crystal display (LCD), a speaker, etc.; a storage section 1108 including a hard disk, etc.; and a communication section 1109 including a network interface card such as a LAN card, a modem, etc. The communication section 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to the I / O interface 1105 as needed. A removable medium 1111, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1110 as needed so that a computer program read therefrom can be installed into the storage section 1108 as needed. Among them, the processing unit 1101 can be implemented as a processing unit such as a CPU, a GPU, a TPU, an FPGA, or an NPU.
[0805] In particular, according to embodiments of the present disclosure, the methods described above can be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising computer instructions that, when executed by a processor, implement the method steps described above. In such embodiments, the computer program product can be downloaded and installed from a network via communication portion 1109 and / or installed from removable media 1111.
[0806] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment or part of code, and the module, program segment or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or can be implemented using a combination of dedicated hardware and computer instructions.
[0807] The units or modules involved in the embodiments described in this disclosure may be implemented by software or programmable hardware. The units or modules described may also be provided in a processor, and the names of these units or modules do not, in certain circumstances, constitute limitations on the units or modules themselves.
[0808] As another aspect, the present disclosure further provides a computer-readable storage medium. This computer-readable storage medium may be included in the electronic device or computer system described in the above embodiments, or may be a standalone computer-readable storage medium not incorporated into the device. The computer-readable storage medium stores one or more programs, which are used by one or more processors to execute the methods described in the present disclosure.
[0809] In the present disclosure, it should be understood that terms such as "including" or "having" are intended to indicate the presence of labels, numbers, steps, actions, components, parts, or combinations thereof disclosed in the present specification, and are not intended to exclude the possibility that one or more other labels, numbers, steps, actions, components, parts, or combinations thereof exist or are added.
[0810] Meanwhile, the above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also encompasses other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the inventive concept. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in the present disclosure.
Claims
1. A method for processing encrypted data, characterized in that: include: Get the first base and first exponent vector for modular exponentiation calculation; Initializing a reference variable group based on the first base number, the reference variable group including: a first variable, a second variable, a third variable, and a fourth variable; Splitting the first exponential vector into a second exponential vector, where the length of the second exponential vector is a specific window length greater than 1 bit, and the first exponential vector and the second exponential vector are bit vectors; performing multiple square calculations on the first variable or the second variable in the benchmark variable group according to the value of the second exponential vector in each window, performing modular multiplication operations on the results of the multiple square calculations and the third variable or the fourth variable in the benchmark variable group to obtain an output variable, wherein the output variable is used to encrypt the data; Initializing the reference variable group based on the first base number includes: Initializing a first variable, and initializing a second variable according to the first base; Calculating the inverse variable of the first variable, and calculating the third variable using a result of the power calculation of the inverse variable of the first variable and a result of the power calculation of the second variable; The inverse variable of the second variable is calculated, and the fourth variable is calculated using the result of the power calculation of the first variable and the result of the power calculation of the inverse variable of the second variable.
2. The method according to claim 1, characterized in that The specific window length is 4 bits.
3. The method according to claim 2, characterized in that The step of performing multiple square calculations on the first variable or the second variable in the benchmark variable group according to the value of the second exponential vector in each window, and performing modular multiplication operations on the results of the multiple square calculations and the third variable or the fourth variable in the benchmark variable group to obtain output variables includes: In the window, Under the condition that the second index vector takes a value from "0000" to "0111", Performing a fourth square calculation on the first variable in the reference variable group, and performing a modular multiplication operation on the result of the fourth square calculation and the third variable or the fourth variable in the reference variable group to obtain a first output variable in the window and a second output variable in the window; Using the first output variable and the second output variable in the window as inputs for calculation in the next window, assigning values to the first variable and the second variable in the next window, and / or Under the condition that the value of the second exponent vector is "1000" to "1111", Performing a fourth square calculation on the second variable in the reference variable group, and performing a modular multiplication operation on the result of the fourth square calculation and the third variable or the fourth variable in the reference variable group to obtain a third output variable in the window and a fourth output variable in the window; The third output variable in the window and the fourth output variable in the window are used as inputs for calculation in the next window, and the first variable and the second variable in the next window are assigned values.
4. The method according to claim 3, characterized in that The step of performing multiple square calculations on the first variable or the second variable in the benchmark variable group according to the values of the second exponential vector on a window-by-window basis, and performing modular multiplication operations on the results of the multiple square calculations and the third variable or the fourth variable in the benchmark variable group to obtain an output variable further includes: After the calculations for all windows are completed, the first output variable in the last window or the third output variable in the last window is used as the output variable.
5. An encrypted data processing device, characterized in that: include: A first base and exponent bit vector acquisition module, configured to acquire a first base and a first exponent vector for modular exponentiation calculation; A second initialization module is configured to initialize a reference variable group based on the first base number, wherein the reference variable group includes: a first variable, a second variable, a third variable, and a fourth variable; Initializing the reference variable group based on the first base number includes: Initializing a first variable, and initializing a second variable according to the first base; Calculating the inverse variable of the first variable, and calculating the third variable using a result of the power calculation of the inverse variable of the first variable and a result of the power calculation of the second variable; Calculating the inverse variable of the second variable, and calculating the fourth variable using the result of the power calculation of the first variable and the result of the power calculation of the inverse variable of the second variable; A first exponential vector segmentation module, configured to segment the first exponential vector into a second exponential vector, wherein the length of the second exponential vector is a specific window length greater than 1 bit, and the first exponential vector and the second exponential vector are bit vectors; The squaring and modular multiplication operation module is used to perform multiple square calculations on the first variable or the second variable in the reference variable group according to the value of the second exponential vector in each window, and perform modular multiplication operations on the results of the multiple square calculations and the third variable or the fourth variable in the reference variable group to obtain an output variable, which is used to encrypt data.
6. The device according to claim 5, characterized in that The specific window length is 4 bits.
7. The device according to claim 6, characterized in that The square and modular multiplication operation module is used for: In the window, Under the condition that the second index vector takes a value from "0000" to "0111", Performing a fourth square calculation on the first variable in the reference variable group, and performing a modular multiplication operation on the result of the fourth square calculation and the third variable or the fourth variable in the reference variable group to obtain a first output variable in the window and a second output variable in the window; Using the first output variable and the second output variable in the window as inputs for calculation in the next window, assigning values to the first variable and the second variable in the next window, and / or Under the condition that the value of the second exponent vector is "1000" to "1111", Performing a fourth square calculation on the second variable in the reference variable group, and performing a modular multiplication operation on the result of the fourth square calculation and the third variable or the fourth variable in the reference variable group to obtain a third output variable in the window and a fourth output variable in the window; The third output variable in the window and the fourth output variable in the window are used as inputs for calculation in the next window, and the first variable and the second variable in the next window are assigned values.
8. The device according to claim 7, characterized in that The square and modular multiplication operation module is further used for: After the calculations for all windows are completed, the first output variable in the last window or the third output variable in the last window is used as the output variable.
9. An electronic device comprising a memory and a processor; wherein: The memory is used to store one or more computer instructions, and the one or more computer instructions are executed by the processor to implement the method steps according to any one of claims 1 to 4.
10. A readable storage medium having computer instructions stored thereon, wherein the computer instructions are executed by a processor to implement the method steps according to any one of claims 1 to 4.
11. A chip comprising the encrypted data processing device according to any one of claims 5 to 8.
Citation Information
Patent Citations
Key processing method and device
CN108242994A
Paillier decryption system, chip and method
CN112988237A