Encryption and decryption device, encryption method, decryption method and related products

By optimizing the Montgomery modular multiplication algorithm and adopting a two-stage computation process and pre-calculated parameters, the problem of low efficiency in the traditional Montgomery modular multiplication algorithm is solved, and efficient operation of ECC encryption and decryption is achieved.

CN121036982AActive Publication Date: 2025-11-28上海芯联芯智能科技有限公司
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202511566412.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-30
Publication Date
2025-11-28
Estimated Expiration
2045-10-30

AI Technical Summary

Technical Problem

The traditional Montgomery modular multiplication algorithm suffers from high computational overhead and low efficiency in ECC encryption and decryption, which limits the overall performance of ECC.

Method used

By optimizing the Montgomery modular multiplication algorithm, a two-stage computation process is adopted: first, initial multiplication and Montgomery reduction are performed, and then subsequent multiplication and reduction are performed in combination with pre-calculated parameters. The modular multiplication operation can be completed with only two Montgomery reductions, reducing the field transformation operations.

Benefits of technology

It significantly improves the overall operational efficiency of ECC encryption and decryption, reduces computational overhead, accelerates the ECC operation process, and enhances the performance of ECC encryption and decryption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121036982A_ABST
    Figure CN121036982A_ABST
Patent Text Reader

Abstract

The invention discloses an encryption and decryption device, an encryption method, a decryption method and a related product. The device comprises an encryption / decryption module and a modular multiplication operation module. The encryption / decryption module is used for sending first data and second data of a constant domain to the modular multiplication module; the modular multiplication module is used for multiplying the first data and the second data to obtain a first multiplication result, performing Montgomery reduction on the first multiplication result to obtain third data, multiplying the third data and a pre-calculation parameter to obtain a second multiplication result, performing Montgomery reduction on the second multiplication result to obtain a modular multiplication result of a constant domain, and returning the modular multiplication result; and the encryption / decryption module executes ECC operation based on the modular multiplication operation result to obtain a secret key, and encrypts / decrypts the data by using the secret key. The modular multiplication calculation can be realized through the modular multiplication operation module only through twice reduction, the calculation process of the Montgomery modular multiplication algorithm is optimized, the calculation overhead is reduced, and the overall operation efficiency of ECC encryption and decryption is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data processing, in particular to an encryption and decryption device, an encryption method, a decryption method and related products. BACKGROUND

[0002] With the increasing demand for network communication security and data protection, encryption technology has become the cornerstone of information security. Among them, elliptic curve cryptography (ECC) is widely used in data encryption and digital signature due to its high security and short key length. The core operation of ECC is elliptic curve point multiplication, which highly depends on the underlying large number modular multiplication operation. Therefore, the efficiency of modular multiplication operation directly determines the overall performance of ECC encryption and decryption.

[0003] Currently, Montgomery modular multiplication algorithm is the mainstream technology for implementing large number modular multiplication, which converts the operation to Montgomery domain to avoid time-consuming division operation. However, the traditional Montgomery modular multiplication algorithm has obvious efficiency bottleneck: to complete a complete modular multiplication operation from constant domain input to constant domain output, four Montgomery reductions are needed, twice for converting input data to Montgomery domain, once for domain multiplication, and the last time for converting the result back to constant domain.

[0004] Such frequent reduction and domain conversion operations result in huge computational overhead, which becomes the bottleneck of ECC encryption and decryption efficiency. Therefore, how to optimize Montgomery modular multiplication algorithm to improve the overall operation efficiency of ECC encryption and decryption has become a technical problem to be solved. SUMMARY

[0005] Based on the above problems, the present application provides an encryption and decryption device, an encryption method, a decryption method and related products, aiming to optimize the calculation process of Montgomery modular multiplication algorithm, reduce the computational overhead, and thus improve the overall operation efficiency of ECC encryption and decryption.

[0006] The embodiments of the present application disclose the following technical solutions: The first aspect of the present application provides an encryption and decryption device, which comprises an encryption / decryption module and a modular multiplication operation module connected with the encryption / decryption module; The encryption / decryption module is configured to send first data and second data to the modular multiplication operation module; the first data and the second data belong to the constant domain; The modular multiplication operation module is configured to perform multiplication operation on the first data and the second data to obtain a first multiplication result, and perform Montgomery reduction on the first multiplication result to obtain third data; The Montgomery multiplication module is further configured to perform multiplication operation on the third data and a pre-computed parameter to obtain a second multiplication result, perform Montgomery reduction on the second multiplication result, and obtain a Montgomery multiplication result; the pre-computed parameter is calculated based on a modulus and a base value in a preset elliptic curve parameter; and the Montgomery multiplication result belongs to a constant field. The Montgomery multiplication module is further configured to send the Montgomery multiplication result to the encryption / decryption module. The encryption / decryption module is further configured to perform elliptic curve cryptography operation based on the Montgomery multiplication result, obtain a key, and encrypt or decrypt data by using the key.

[0007] In an optional implementation, the apparatus further includes a pre-computation module. The pre-computation module is configured to perform modulus operation on a square of the base value on the modulus to obtain the pre-computed parameter.

[0008] In an optional implementation, the Montgomery multiplication module includes a plurality of parallel multipliers.

[0009] In an optional implementation, the encryption / decryption module is specifically configured to send a local private key and a public key of a communication peer end to the Montgomery multiplication module. The Montgomery multiplication module is configured to perform calculation by using the local private key and the public key of the communication peer end to obtain a shared key, and return the shared key to the encryption / decryption module.

[0010] In an optional implementation, the encryption / decryption module is further configured to send a local private key and the base point to the Montgomery multiplication module. The Montgomery multiplication module is further configured to perform calculation by using the local private key and the base point to obtain a local public key, and return the local public key to the encryption / decryption module.

[0011] The second aspect of the application provides an encryption method applied to a first communication device, wherein the first communication device includes the encryption and decryption apparatus in any implementation of the first aspect, and the method includes the following steps: The first communication device obtains a first key by using the encryption and decryption apparatus. The first communication device encrypts data by using the first key to obtain ciphertext data. The first communication device sends the ciphertext data to a second communication device.

[0012] The third aspect of the application provides a decryption method applied to a second communication device, wherein the second communication device includes the encryption and decryption apparatus in any implementation of the first aspect, and the method includes the following steps: The second communication device receives ciphertext data sent by a first communication device. The second communication device obtains a second key by using the encryption and decryption device; The second communication device decrypts the ciphertext data by using the second key to obtain plaintext data.

[0013] The fourth aspect of the present application provides a communication device, which comprises the encryption and decryption device of any one of the implementations of the first aspect.

[0014] The fifth aspect of the present application provides a computer storage medium, which stores a computer program, and the computer program is executed by a processor to implement the steps of the encryption method or the decryption method in the second aspect or the third aspect.

[0015] The sixth aspect of the present application provides a computer program product, which comprises computer readable instructions for implementing the encryption method or the decryption method in the second aspect or the third aspect.

[0016] Compared with the prior art, the present application has the following beneficial effects: The encryption and decryption device provided by the present application comprises an encryption / decryption module, a modular multiplication operation module, the encryption / decryption module is configured to send first data and second data to the modular multiplication operation module, the first data and the second data belong to a constant domain, the modular multiplication operation module is configured to perform multiplication operation on the first data and the second data to obtain a first multiplication result, and perform Montgomery reduction on the first multiplication result to obtain third data, wherein the modular multiplication operation module is further configured to perform multiplication operation on the third data and a pre-computed parameter to obtain a second multiplication result, and perform Montgomery reduction on the second multiplication result to obtain a modular multiplication operation result, the pre-computed parameter is calculated based on a modulus and a base value in a preset elliptic curve parameter, and the modular multiplication operation result belongs to the constant domain, the modular multiplication operation module is further configured to send the modular multiplication operation result to the encryption / decryption module, and the encryption / decryption module is further configured to perform elliptic curve cryptography operation based on the modular multiplication operation result to obtain a key, and encrypt or decrypt data by using the key. The encryption and decryption device provided by the present application realizes fundamental improvement of calculation efficiency through the optimization design of the modular multiplication operation module. The module performs two-stage calculation: the first stage performs initial multiplication and reduction, and the second stage performs subsequent multiplication and reduction in combination with the pre-computed parameter, and only two Montgomery reductions are required to complete one complete modular multiplication operation from the constant domain input to the constant domain output. The modular multiplication operation module can avoid the additional reduction step which is necessary in the traditional Montgomery modular multiplication operation and is specially used for domain conversion. The encryption / decryption module directly calls the modular multiplication operation module to efficiently perform core modular multiplication calculation, significantly speeds up the process of ECC operation, reduces the calculation cost, and further improves the overall operation efficiency of ECC encryption and decryption. BRIEF DESCRIPTION OF DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced as follows. Obviously, the accompanying drawings in the following description only constitute some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained from these drawings without creative labor.

[0018] Figure 1 A flowchart of Montgomery modular multiplication provided by an embodiment of the present application is shown in the figure. Figure 2 A structure diagram of an encryption and decryption device provided by an embodiment of the present application is shown in the figure. Figure 3 A flowchart of optimized Montgomery modular multiplication provided by an embodiment of the present application is shown in the figure. Figure 4 A structure diagram of parallel multiplication operation provided by an embodiment of the present application is shown in the figure. Figure 5 A structure diagram of another parallel multiplication operation provided by an embodiment of the present application is shown in the figure. Figure 6 A flowchart of an encryption method provided by an embodiment of the present application is shown in the figure. Figure 7 A flowchart of a decryption method provided by an embodiment of the present application is shown in the figure. DETAILED DESCRIPTION

[0019] As described above, as an important modern public key cryptography system, Elliptic Curve Cryptography (ECC) is widely used in security scenarios such as digital signature and key exchange due to its high security strength and short key length. Compared with the traditional RSA (Rivest-Shamir-Adleman) encryption algorithm, ECC requires a shorter key length under the same security strength, for example, the security strength of a 256-bit ECC key is equivalent to that of a 3072-bit RSA key, which makes ECC have a significant advantage in the environment of Internet of Things devices, mobile terminals and other computing resource limited devices.

[0020] The security of ECC is based on the difficulty of solving the elliptic curve discrete logarithm problem, and the core operation is the point multiplication operation on the elliptic curve. The point multiplication operation needs to be realized through a series of point addition and point doubling operations. Specifically, for two different points P=(x1,y1) and Q=(x2,y2) on the elliptic curve, P≠Q, the coordinates of the point addition result R of P and Q are (x3,y3), and the calculation process is as follows: Slope where is the inverse element under the modulus N.

[0021] Horizontal coordinate .

[0022] Vertical coordinate .

[0023] For a point on an elliptic curve , the coordinates of the double point result Z = 2W of W are (x5, y5), and the calculation process is as follows: Slope , where a is an elliptic curve parameter, is The inverse element under the module N.

[0024] Horizontal coordinate .

[0025] Vertical coordinate .

[0026] It can be understood that the bottom of these point addition and doubling operations is actually a large number of arithmetic operations on a finite field, and the modular multiplication operation accounts for most of the calculation overhead. Therefore, the efficiency of the modular multiplication operation directly determines the overall performance of the ECC encryption and decryption.

[0027] In order to speed up the modular multiplication operation, the Montgomery modular multiplication algorithm is widely used. This algorithm avoids time-consuming division operations by converting the operation to the Montgomery domain. In the Montgomery domain, data u is represented in the form of uR mod N, where N is the modulus, R is a base value coprime with N, and is usually taken as 2 k , k is the bit width of N.

[0028] The core of Montgomery modular multiplication is the Montgomery reduction operation, that is: ; Where satisfies , which replaces the traditional modular operation with simple multiplication and shift operations.

[0029] For example, when AxB mod N needs to be calculated, the Montgomery algorithm can be used to decompose the modular multiplication operation into REDC(REDC(AxB)). Where REDC is Montgomery reduction, and the essence is the step of quickly calculating the remainder.

[0030] However, the current Montgomery modular multiplication algorithm has a significant efficiency bottleneck: to complete a complete modular multiplication operation from the constant domain input to the constant domain output, such as AxB mod N, where A and B both belong to the constant domain, four Montgomery reductions need to be performed. Specifically, see Figure 1 , Figure 1 is a flowchart of a Montgomery modular multiplication provided by an embodiment of the present application.

[0031] like Figure 1 As shown, converting the input constant-domain data A to the Montgomery domain requires one Montgomery reduction, as does converting the input constant-domain data B to the Montgomery domain. Performing operations on the converted Montgomery-domain data A and B within the Montgomery domain requires another Montgomery reduction to obtain the result belonging to the Montgomery domain. Finally, converting the result belonging to the Montgomery domain back to the constant domain requires another Montgomery reduction. Reduction operations are the most time-consuming operations in the entire encryption / decryption process. Therefore, such frequent Montgomery reduction operations lead to huge computational overhead, becoming a key bottleneck restricting ECC performance.

[0032] To address the aforementioned problems, the inventors have developed an encryption / decryption device, encryption method, decryption method, and related products.

[0033] The encryption / decryption device includes: an encryption / decryption module for sending first data and second data to a modular multiplication module, wherein the first data and second data belong to the constant domain; a modular multiplication module for performing multiplication operations using the first data and second data to obtain a first multiplication result, and performing Montgomery reduction on the first multiplication result to obtain a third data; wherein the modular multiplication module is further used for: performing multiplication operations using the third data and pre-calculated parameters to obtain a second multiplication result, and performing Montgomery reduction on the second multiplication result to obtain a modular multiplication result, wherein the pre-calculated parameters are calculated based on the modulus and base values ​​in the preset elliptic curve parameters, and the modular multiplication result belongs to the constant domain; the modular multiplication module is further used for: sending the modular multiplication result to the encryption / decryption module; the encryption / decryption module is further used for: performing elliptic curve cryptography operations based on the modular multiplication result to obtain a key, and using the key to encrypt or decrypt data.

[0034] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.

[0035] It should be noted that, unless otherwise defined, technical terms or scientific terms used in the embodiments of the present application shall have the common meaning understood by one of ordinary skill in the art to which the embodiments of the present application belong. The terms "first", "second", and similar terms used in the embodiments of the present application do not denote any order, quantity, or importance, but are merely used to distinguish different components. The terms "include", "contain", and similar terms mean that the elements or objects before the terms encompass the elements or objects listed after the terms and their equivalents, and do not exclude other elements or objects. The terms "connect" or "connected" and similar terms do not mean only physical or mechanical connections, but can include electrical connections, whether direct or indirect. The terms "upper", "lower", "left", "right", and the like are merely used to represent relative positional relationships, and when the absolute positions of the described objects change, the relative positional relationships can also change accordingly.

[0036] The encryption and decryption device provided in the embodiments of the present application is applied to the field of ECC encryption and decryption, and is adapted to the core operation requirement of elliptic curve point multiplication. In ECC, the implementation of point multiplication operation highly depends on a large number of large number modular multiplication operations, and the encryption and decryption device provided in the embodiments of the present application directly serves the efficiency improvement of ECC operation through the specifically optimized modular multiplication operation module.

[0037] Referring to Figure 2 , the figure is a structural schematic diagram of an encryption and decryption device provided in the embodiments of the present application, as Figure 2 shown, the encryption and decryption device provided in the embodiments of the present application comprises an encryption / decryption module 201 and a modular multiplication operation module 202 connected with the encryption / decryption module 201.

[0038] In the embodiments of the present application, the encryption / decryption module 201 and the modular multiplication operation module 202 can be connected through a bus or other manners.

[0039] The encryption / decryption module 201 undertakes the ECC operation flow control, such as data transceiving, key generation, data encryption or decryption, and the like.

[0040] Specifically, the encryption / decryption module 201 is configured to send first data and second data to the modular multiplication operation module 202.

[0041] In the embodiments of the present application, the encryption / decryption module 201 determines the first data and the second data to be subjected to modular multiplication operation according to the ECC operation scene (such as public key generation and shared key calculation), and sends the first data and the second data to the modular multiplication operation module 202, wherein the first data and the second data both belong to the constant field.

[0042] For example, in the ECC operation scenario, constant domain data A and constant domain data B need to be multiplied modulo, at this time, the constant domain data A is taken as the first data and the constant domain data B is taken as the second data, and the add / descramble module 201 sends the first data and the second data to the multiplication modulo module 202.

[0043] The multiplication modulo module 202 is the core of the encryption and decryption device provided in the embodiments of the present application, and is configured to perform the optimized Montgomery multiplication operation. The multiplication modulo module 202 is configured to perform the following operations: performing multiplication operation on the first data and the second data to obtain a first multiplication result, and performing Montgomery reduction on the first multiplication result to obtain third data.

[0044] In the embodiments of the present application, after receiving the first data and the second data sent by the add / descramble module 201, the multiplication modulo module 202 first performs multiplication operation on the first data and the second data to obtain a first multiplication result.

[0045] After obtaining the first multiplication result, the multiplication modulo module 202 performs Montgomery reduction on the first multiplication result to obtain third data. The Montgomery reduction process is implemented based on the Montgomery algorithm.

[0046] In an example implementation, the first data is A and the second data is B, and the multiplication modulo module 202 performs multiplication operation on A and B to obtain a first multiplication result C=AxB. Then Montgomery reduction is performed on the first multiplication result C to obtain third data D=REDC(C).

[0047] The multiplication modulo module 202 is also configured to perform multiplication operation on the third data and the pre-computed parameter to obtain a second multiplication result, and perform Montgomery reduction on the second multiplication result to obtain a multiplication modulo operation result.

[0048] It can be understood that in the process of ECC encryption and decryption operation, an elliptic curve is preset, and elliptic curve parameters are also preset, including modulus N, base value R, base point G, curve coefficients a and b, etc.

[0049] In the embodiments of the present application, the pre-computed parameter is calculated based on the modulus N and the base value R in the preset elliptic curve parameters.

[0050] Optionally, in order to improve the calculation speed, the encryption and decryption device further includes a pre-computation module. The pre-computation module is configured to perform modulus operation on the square of the base value with respect to the modulus to obtain the pre-computed parameter, i.e., R 2 mod N.

[0051] After obtaining the third data, the multiplication modulo module 202 performs multiplication operation on the third data and the pre-computed parameter to obtain a second multiplication result.

[0052] After obtaining the second multiplication result, the modular multiplication module 202 performs Montgomery reduction on the second multiplication result to obtain the modular multiplication result. The Montgomery reduction process is based on the Montgomery algorithm, and the modular multiplication result belongs to the constant domain.

[0053] Taking A as the first data, B as the second data, C as the first multiplication result, D as the third data, E as the pre-calculated parameter, F as the second multiplication result, and K as the modular multiplication result as an example, the following derivation process proves the correctness of the modular multiplication result obtained by the modular multiplication module 202: ; According to the fundamental properties of Montgomery fields, R' is the multiplicative inverse of R modulo N, i.e. ,therefore: ; Substituting into the above formula, we get: .

[0054] To provide a more comprehensive and clear explanation of the optimized Montgomery modular multiplication process performed by the modular multiplication module 202, the following section will combine... Figure 3 The calculation process will be introduced. Figure 3 This is a schematic diagram of an optimized Montgomery modular multiplication process provided for an embodiment of this application.

[0055] like Figure 3 As shown, the input constant domain data A and input constant domain data B are multiplied to obtain the first multiplication result C in the constant domain; Montgomery reduction is performed on the first multiplication result C to obtain the third data D in the Montgomery domain; the third data D is multiplied by the pre-computed parameter E to obtain the second multiplication result F in the Montgomery domain, where the pre-computed parameter... Performing a Montgomery reduction on the second multiplication result F yields the modular multiplication result in the constant field. This is achieved through the above formula derivation process and... Figure 3 The description demonstrates that the modular multiplication module 202 in this embodiment can correctly calculate the modular multiplication result through two Montgomery reduction operations, and the final result is directly located in the constant domain without the need for additional domain transformation operations. Compared with traditional methods, this reduces two reduction operations, significantly improving the efficiency of modular multiplication calculation. The modular multiplication module 202 is also used to send the modular multiplication result to the encryption / decryption module 201.

[0056] In this embodiment of the application, after obtaining the modular multiplication result, the modular multiplication module 202 can return the modular multiplication result to the encryption / decryption module 201 according to the actual connection method with the encryption / decryption module 201.

[0057] The encryption / decryption module 201 is further configured to perform elliptic curve cryptography operation based on the modular multiplication result to obtain a key, and encrypt or decrypt data using the key after receiving the modular multiplication result.

[0058] In the embodiment of the present application, the encryption / decryption module 201 receives the constant field modular multiplication result returned by the modular multiplication module 202, generates a key in combination with the ECC operation logic, and performs encryption or decryption operation on data using the generated key.

[0059] In the embodiment of the present application, the optimization design of the modular multiplication module realizes fundamental improvement of the calculation efficiency. The module performs two-stage calculation: the first stage performs initial multiplication and reduction, and the second stage performs subsequent multiplication and reduction in combination with pre-computed parameters, and only two Montgomery reductions are needed to complete a complete modular multiplication operation from constant field input to constant field output. The modular multiplication module can avoid the additional reduction step specially used for field conversion in the traditional Montgomery modular multiplication operation. The encryption / decryption module directly calls the modular multiplication module to efficiently perform core modular multiplication calculation, significantly speeds up the process of ECC operation, reduces the calculation overhead, and further improves the overall operation efficiency of ECC encryption / decryption.

[0060] The traditional Montgomery modular multiplication method relies on a single 32-bit multiplier and completes the calculation through iteration. The iteration number is doubled with the increase of data length by 32 bits. For example, 64-bit data needs 2x2=4 times of multiplication operation, and 256-bit data needs 8x8=64 times of multiplication operation plus 56 times of additional addition and shift operation, which is low in efficiency.

[0061] Optionally, in order to further improve the calculation efficiency of the modular multiplication operation, the modular multiplication module 202 includes a plurality of parallel multipliers.

[0062] In the embodiment of the present application, the parallel multipliers can be a plurality of parallel 32-bit basic multipliers, which can perform a plurality of 32-bit multiplication operations synchronously at a time, greatly reduce the iteration number, improve the multiplication operation efficiency, and further improve the calculation efficiency of the modular multiplication operation.

[0063] In an example implementation, the modular multiplication module 202 includes 8 parallel 32-bit basic multipliers.

[0064] Figure 4 A structure diagram of parallel multiplication operation is provided for the embodiment of the present application, which is used to realize synchronous multiplication operation of 256-bit data through 8 parallel 32-bit basic multipliers.

[0065] As Figure 4As shown, the transverse direction is marked with "0", "1", "2", …, "15", etc. The longitudinal direction is divided into 8 independent operation areas, and each area corresponds to a group of 32-bit multipliers. During operation, the 256-bit data to be multiplied is split into 8 data blocks with a granularity of 32 bits, and is input into the 8 operation areas in the figure. All multipliers are driven by the same clock signal, and 8 groups of 32-bit multiplication operations can be completed synchronously in a single clock cycle.

[0066] Figure 4 The parallel operation structure can avoid the problem of exponential growth of hardware area caused by too long bit width of the multiplier. If a single 256-bit multiplier is designed, the hardware area will be much larger than the total area of 8 groups of 32-bit multipliers. However, the parallel operation structure can reduce the hardware area by 8 times. Figure 4 The parallel operation structure can reduce the hardware area while performing multiplication operation on 256-bit data from 8 iterations to 1 synchronous operation, greatly reducing the operation time.

[0067] Figure 5 Another structure diagram of parallel multiplication operation provided by the embodiment of the application is shown, which is used to realize synchronous multiplication operation on 512-bit data by calling 8 parallel 32-bit basic multipliers multiple times.

[0068] As shown in FIG. 4, Figure 5 As shown in FIG. 5, Figure 5 The combination process of multiple rounds of parallel multiplication and subsequent shifting and addition is shown by marking different areas with bit segments (such as "1", "2", …, "30", etc.). When 512-bit multiplication operation is needed, 512-bit data is split into 4 256-bit data blocks, and 8 groups of 32-bit parallel multiplication operations are called 4 times to complete multiplication operation on 4 groups of 256-bit data. Figure 4 As shown in FIG. 5,

[0069] After the multiplication operation is completed, the 4 multiplication results are respectively left shifted by a corresponding number of bits according to the bit width requirement, to ensure that all results are stacked in the same dimension. Then, the accumulation is completed through addition operation, and finally the complete multiplication result of 512 bits is obtained.

[0070] Compared with the traditional single 32-bit multiplier, Figure 5 As shown in FIG. 5, the parallel multiplication operation scheme only needs 8 multiplication and 8 addition operations, and the number of operations, data caching and reading times are greatly reduced. The longer the data is, the higher the time reduction ratio is.

[0071] Optionally, in the ECC shared key generation scenario, the encryption and decryption module 201 is specifically configured to send a local private key and a public key of a communication peer to the modular multiplication operation module 202.

[0072] The modular multiplication operation module 202 is configured to calculate the local private key and the public key of the communication peer to obtain a shared key, and return the shared key to the encryption and decryption module 201.

[0073] In the embodiment of the present application, the communication peer refers to another communication entity that needs to generate a shared key with the local communication device to establish an encrypted communication link with the local communication device, and the entity needs to have encryption and decryption capabilities compatible with the local communication device, that is, the communication peer also needs to deploy the encryption and decryption device (or equivalent device supporting the same hardware synchronization operation and Montgomery modular multiplication optimization logic) of the embodiment of the present application to ensure that both parties can complete key agreement through consistent operation logic.

[0074] For example, if the local communication device is an Internet of Things sensor (deployed with the encryption and decryption device provided by the embodiment of the present application), the communication peer can be an Internet of Things gateway (also deployed with the encryption and decryption device provided by the embodiment of the present application); if the local device is a mobile phone (integrating the encryption and decryption device provided by the embodiment of the present application), the communication peer can be a payment terminal (integrating the encryption and decryption device provided by the embodiment of the present application).

[0075] The core role of the communication peer is to generate its own ECC key pair and send the public key to the local communication device, while receiving the public key of the local communication device, and through the encryption and decryption devices deployed by both parties, to generate the same shared key.

[0076] In the embodiment of the present application, the private key is a random large integer that needs to be strictly kept secret, and the public key is a point on a preset elliptic curve determined based on the private key and preset elliptic curve parameters, which can be publicly transmitted to the communication peer.

[0077] In the embodiment of the present application, the encryption / decryption module 201 sends the local private key d A and the public key Q B of the communication peer to the modular multiplication operation module 202. The modular multiplication operation module 202 performs calculation using the local private key d A and the public key Q B of the communication peer to obtain the shared key S, wherein the shared key S is obtained by point multiplication operation of d A and Q B . The modular multiplication operation module 202 is used to perform all underlying modular multiplication operations in the point multiplication calculation to accelerate the generation of the shared key.

[0078] Optionally, in the ECC key generation scenario, the encryption / decryption module 201 is also configured to send the local private key and the base point to the modular multiplication operation module 202. The modular multiplication operation module 202 is also configured to perform calculation using the local private key and the base point to obtain the local public key, and return the local public key to the encryption / decryption module 201.

[0079] In the embodiment of the present application, the encryption / decryption module 201 sends the local private key d AThe base point G in the preset elliptic curve parameters is sent to the modular multiplication module 202. The modular multiplication module 202 uses the local private key d A Calculate with the base point G to obtain the local public key Q. A The local public key Q A For d A The dot product operation is performed on G. The modular multiplication module 202 is used to perform all the underlying modular multiplication operations in this dot product calculation to accelerate the generation of the local public key.

[0080] In this embodiment, the modular multiplication module 202 completes all the underlying modular multiplication operations involved in the ECC encryption and decryption process. The modular multiplication module 202 reduces the number of reductions in a single modular multiplication from the traditional four to two, which greatly improves the speed of the entire multiplication operation, accelerates the generation of public keys and shared keys, and thus improves the overall efficiency of ECC encryption and decryption.

[0081] Based on the encryption / decryption apparatus provided in the foregoing embodiments, this application also provides an encryption method, which is applied to a first communication device, the first communication device including any of the encryption / decryption apparatuses in the above-described apparatus embodiments. Figure 6 This is a flowchart illustrating an encryption method provided in an embodiment of this application. Figure 6 As shown, the method includes the following steps: S601, The first communication device obtains the first key through the encryption / decryption device.

[0082] In this embodiment of the application, the first communication device and the second communication device are communication counterparts, and the first key is a shared key obtained through a built-in encryption and decryption device.

[0083] Specifically, the first communication device sends its local private key and the second communication device's public key to the modular multiplication module through the encryption / decryption module in its built-in encryption / decryption device.

[0084] The modular multiplication module uses the local private key of the first communication device and the public key of the second communication device to perform calculations and obtain a shared key, namely the first key.

[0085] S602. The first communication device uses the first key to encrypt the data and obtain ciphertext data.

[0086] In an example implementation, the first communication device can perform key derivation processing on the first key obtained by the foregoing steps to generate a session key for symmetric encryption, specifically, valid information can be extracted from the coordinates of the first key as key material for symmetric encryption, for example, the x-coordinate of the first key is extracted, and a final symmetric encryption key is derived from the x-coordinate of the first key by using the HKDF-SHA256 algorithm. Finally, the plaintext data is encrypted by using the symmetric encryption key in the AES-GCM encryption mode to obtain encrypted ciphertext data.

[0087] S603, the first communication device sends the ciphertext data to the second communication device.

[0088] In the embodiments of the present application, the ciphertext data is transmitted through the communication link established by the first communication device and the second communication device.

[0089] In the embodiments of the present application, the first communication device can select a communication protocol according to the actual application scenario to encapsulate the ciphertext data into a protocol data unit.

[0090] Optionally, in order to prevent replay attacks and detect transmission errors, a frame sequence number and a check can be attached to the protocol data unit before transmission.

[0091] Optionally, in order to avoid communication interruption caused by channel interference, if the transmission fails, the first communication device starts a retransmission mechanism, and retransmits at most a preset number of times. The specific preset number of times can be set according to actual needs.

[0092] In an example implementation, the first communication device encapsulates the ciphertext data in the application data record of the TLS 1.3 protocol, and ensures reliable transmission of the data to the second communication device through the TCP protocol. The specific transmission process includes: after establishing a TCP connection, negotiating encryption parameters through the TLS handshake protocol; splitting the ciphertext data into appropriate size TLS records; adding a sequence number and a MAC check value to each record; and ensuring complete data arrival through a reliable transmission mechanism.

[0093] The encryption method provided by the embodiments of the present application significantly improves the ECC key generation and data processing efficiency by using the communication device integrated with the optimized encryption and decryption device, so that the overall encryption speed is significantly improved.

[0094] Based on the foregoing encryption and decryption device, correspondingly, the present application also provides an encryption method, which is applied to a second communication device, and the second communication device includes any encryption and decryption device of the foregoing device embodiments. Figure 7 A decryption method flowchart is provided for the embodiments of the present application. As shown in Figure 7 The method includes the following steps: S701, the second communication device receives the ciphertext data sent by the first communication device.

[0095] In the embodiment of the application, the ciphertext data is transmitted through the communication link established by the first communication device and the second communication device.

[0096] In an example implementation, the second communication device receives the ciphertext data encapsulated in the TLS 1.3 protocol through the TCP protocol, and the specific receiving process includes: completing the TLS handshake protocol parameter negotiation after establishing the TCP connection; receiving the TLS record and verifying the sequence number and the MAC check value; reassembling to obtain the complete ciphertext data; and storing the ciphertext data in a secure buffer for subsequent decryption.

[0097] S702, the second communication device obtains the second key by using the encryption and decryption device.

[0098] In the embodiment of the application, the second communication device uses its encryption and decryption device to obtain the same second key as the first key based on the same elliptic curve parameters and key algorithm as the first communication device.

[0099] In an example implementation, the process of obtaining the second key includes: the second communication device sends the local private key of the second communication device and the public key of the first communication device to the modular multiplication operation module through the encryption and decryption module in the built-in encryption and decryption device; the modular multiplication operation module calculates the shared key point, i.e. the second key, by using the local private key of the second communication device and the public key of the first communication device.

[0100] S703, the second communication device decrypts the ciphertext data by using the second key to obtain the plaintext data.

[0101] In the embodiment of the application, the second communication device uses the obtained second key to derive a symmetric decryption key for decryption by using the same encryption algorithm on the first communication device side, and decrypts the received ciphertext data by using the symmetric decryption key to restore the original plaintext data.

[0102] In an example implementation, the decryption process includes: using the symmetric decryption key and the AES-GCM decryption algorithm to decrypt the ciphertext data. The decrypted data is recombined into complete plaintext data.

[0103] The decryption method provided by the embodiment of the application significantly improves the ECC key generation and decryption processing efficiency by using the communication device integrated with the optimized encryption and decryption device, so that the overall decryption speed is significantly improved.

[0104] In addition, the embodiment of the application also provides a communication device including any encryption and decryption device described in the device embodiment.

[0105] Further, the embodiments of the present application also provide a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program, when executed by a processor, implements the steps of the encryption method or the decryption method as any of the method embodiments.

[0106] Further, the embodiments of the present application also provide a computer program product, which comprises computer readable instructions for implementing the encryption method or the decryption method as any of the method embodiments.

[0107] It should be noted that each of the embodiments in the present specification is described in a progressive manner, and the same parts between each embodiment can be referred to each other, and each embodiment mainly describes the difference from other embodiments. Especially, the device and product embodiments are basically similar to the method embodiments, so the description is relatively simple, and the related parts can refer to the part of the method embodiments. The above-described device and product embodiments are only illustrative, and the units described as separate components can be or can not be physically separated, and the components indicated as units can be or can not be physical units, that is, they can be located in one place, or can be distributed on multiple network units. According to the actual needs, part or all of the modules can be selected to achieve the purpose of the embodiments. Those skilled in the art can understand and implement it without creative labor.

[0108] The above describes only one specific embodiment of the present application, but the protection scope of the present application is not limited to this. Any skilled person in the art can easily think of changes or replacements within the technical range disclosed in the present application, which should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. An encryption / decryption device, characterized in that, The device includes: an encryption / decryption module and a modular multiplication module connected to the encryption / decryption module; The encryption / decryption module is used to send first data and second data to the modular multiplication module; the first data and the second data belong to the constant domain; The modular multiplication module is used to perform multiplication operations using the first data and the second data to obtain a first multiplication result, and to perform Montgomery reduction on the first multiplication result to obtain the third data; The modular multiplication module is further configured to perform multiplication operations using the third data and pre-calculated parameters to obtain a second multiplication result, and to perform Montgomery reduction on the second multiplication result to obtain the modular multiplication result; the pre-calculated parameters are calculated based on the modulus and base values ​​in the preset elliptic curve parameters; the modular multiplication result belongs to the constant domain; The modular multiplication module is also used to send the modular multiplication result to the encryption / decryption module; The encryption / decryption module is also used to perform elliptic curve cryptography based on the modular multiplication result to obtain a key, and to encrypt or decrypt data using the key.

2. The apparatus according to claim 1, characterized in that, The device also includes a pre-calculation module; The pre-calculation module is used to perform a modulo operation on the square of the base value and the modulus to obtain the pre-calculation parameters.

3. The apparatus according to claim 1, characterized in that, The modular multiplication module includes multiple parallel multipliers.

4. The apparatus according to claim 1, characterized in that, The encryption / decryption module is specifically used to send the local private key and the public key of the communication peer to the modular multiplication module; The modular multiplication module is used to perform calculations using the local private key and the public key of the communication peer to obtain a shared key, and then return the shared key to the encryption / decryption module.

5. The apparatus according to claim 1, characterized in that, The encryption / decryption module is also used to send the local private key and base point to the modular multiplication module; The modular multiplication module is also used to perform calculations using the local private key and the base point to obtain the local public key, and return the local public key to the encryption / decryption module.

6. An encryption method, characterized in that, Applied to a first communication device, the first communication device comprising the encryption / decryption apparatus according to any one of claims 1-5, comprising: The first communication device obtains the first key through the encryption / decryption device; The first communication device uses the first key to encrypt the data to obtain ciphertext data; The first communication device sends the encrypted data to the second communication device.

7. A decryption method, characterized in that, Applied to a second communication device, the second communication device comprising the encryption / decryption apparatus according to any one of claims 1-5, comprising: The second communication device receives encrypted data sent by the first communication device; The second communication device obtains the second key using the encryption / decryption device; The second communication device uses the second key to decrypt the ciphertext data to obtain the plaintext data.

8. A communication device, characterized in that, Includes the encryption / decryption apparatus according to any one of claims 1-5.

9. A computer storage medium, characterized in that, It stores a computer program, which, when executed by a processor, implements the steps of the encryption method of claim 6 or the decryption method of claim 7.

10. A computer program product, characterized in that, The computer program product includes computer-readable instructions for implementing the encryption method of claim 6 or the decryption method of claim 7.

Citation Information

Patent Citations

  • Encryption method and device and electronic equipment

    CN111092718A

  • Key packaging lightweight method and system based on number-theory transformation, medium and equipment

    CN117714054A

  • Processing device, accelerator, and method for federated learning

    US20220147873A1

  • Circuit and method of cryptographic multiplication

    WO2000038047A1