Montgomery modular multiplication implementation apparatus and method, starting method, electronic device and storage medium

The Montgomery modular multiplication scheme, which decomposes large number multiplication using a modular design and the Karatsuba algorithm, solves the problems of low bit width compatibility and low resource utilization in existing technologies. It achieves efficient and flexible modular multiplication operations and is applicable to a variety of public-key cryptography algorithms.

CN122363656APending Publication Date: 2026-07-10THEO END (SHENZHEN) COMPUTING TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610376198.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-03-25
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

Existing hardware acceleration solutions for Montgomery modular multiplication suffer from problems such as fixed bit width design, incompatibility with different public-key cryptographic algorithms, waste of CPU offloading computing resources, and complex hardware circuitry with low resource utilization.

Method used

A modular Montgomery modular multiplication implementation device is provided, including a control module and a calculation module. It supports multi-word and single-word operations, controls the operation process through a finite state machine, uses the Karatsuba algorithm to decompose large number multiplication, and combines multiplication-addition and reduction modules to achieve efficient modular multiplication operations.

Benefits of technology

It implements modular multiplication operations that can adapt to arbitrary bit widths, improves the versatility and computational efficiency of the hardware, reduces resource consumption, is applicable to a variety of public-key cryptography algorithms, and meets the needs of high-performance computing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122363656A_ABST
    Figure CN122363656A_ABST
Patent Text Reader

Abstract

This invention discloses a Montgomery modular multiplication implementation apparatus and method, a chip startup method, an electronic device, and a storage medium. The Montgomery modular multiplication implementation apparatus includes: a control module configured to output control signals based on the operational logic of modular multiplication to manage the execution flow of modular multiplication operations; and a calculation module configured to read source operands from a storage module in response to the control signals from the control module to perform corresponding operational operations. The calculation module includes: a multiply-add module configured to perform high-radix multiplication and multi-level accumulation operations on the source operands to generate intermediate modular multiplication results; and a reduction module configured to perform reduction operations on the intermediate modular multiplication results to generate a final modular multiplication result within a predetermined range. This invention can adapt to modular multiplication operations of arbitrary bit widths, effectively improving the accuracy and efficiency of modular multiplication operations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of public-key cryptography, and in particular to a Montgomery modular multiplication implementation device and method, a chip startup method, an electronic device, and a storage medium. Background Technology

[0002] With the rapid development of information security technology, public-key cryptography is widely used in scenarios such as data encryption, data signing, and key exchange. In public-key cryptographic algorithms (such as RSA, ECC, SM2, etc.), a large number of operations are implemented based on modular arithmetic over finite fields. Among them, modular multiplication is a fundamental operator, and its computational efficiency directly determines the overall performance of the cryptographic system. Public-key cryptographic algorithms are all based on finite field expansions, requiring numerous modulo operations on prime numbers. However, traditional modulo algorithms are usually implemented through division or iterative subtraction, which not only consumes a lot of computational resources but is also extremely slow. While some existing fast modulo algorithms can improve efficiency, the fast modulo algorithms for different prime numbers vary significantly, making it difficult to form a unified solution. Against this backdrop, the Montgomery modular multiplication algorithm provides a solution. It maps values ​​from the integer field to the Montgomery field, allowing computation within this field to avoid a large number of complex modulo operations. After computation, the results are mapped back from the Montgomery field to the integer field, thus effectively improving computational efficiency. Therefore, the hardware acceleration design of Montgomery modular multiplication, as a core underlying operator, has always been a hot research topic.

[0003] However, existing hardware acceleration solutions for Montgomery modular multiplication still have significant shortcomings: 1) Most solutions are only designed for a single fixed bit width (such as SM2-256bit) and cannot be compatible with public key cryptography algorithms with other bit width requirements such as ECC-384 and RSA-2K, lacking flexible scalability; 2) Some multi-word scalable solutions require the CPU to offload computation at the word level, resulting in a large number of Load / Store instructions being used. This not only causes a serious waste of CPU computing resources, but also significantly restricts overall computing performance due to bus path latency. 3) The partially scalable Montgomery modular multiplication algorithm design lacks extended support for reduction operations, and the hardware circuit control logic is complex. In high-radix multiplication scenarios, the redundant expression of the carry-save adder (CSA) will consume a lot of register resources, affecting the resource utilization and stability of the hardware implementation.

[0004] Therefore, there is an urgent need for a hardware acceleration solution for Montgomery modular multiplication that can combine high scalability, high computational efficiency, and low resource consumption. Summary of the Invention

[0005] The purpose of this invention is to propose a Montgomery modular multiplication scheme, which at least partially solves one of the aforementioned technical problems.

[0006] To achieve the above objectives, a first aspect of the present invention provides a Montgomery modular multiplication implementation apparatus for public-key cryptographic computation, comprising: a control module configured to output control signals based on the operational logic of the modular multiplication operation to manage the execution flow of the modular multiplication operation; and a calculation module configured to read the source operands from the storage module in response to the control signals of the control module to perform corresponding operational operations; wherein the calculation module comprises: a multiply-add module configured to perform high-radix multiplication and multi-level accumulation operations on the source operands to generate intermediate modular multiplication results; and a reduction module configured to perform reduction operations on the intermediate modular multiplication results to generate a final modular multiplication result within a predetermined range.

[0007] According to an embodiment of the present invention, the execution flow of the modular multiplication operation includes an outer loop stage, an inner loop stage, and a post-processing stage; the control module is further configured to: respond to the start signal of the protocol layer and control the modular multiplication operation to enter the outer loop stage; after the outer loop stage is completed, determine whether to enter the inner loop stage based on the word length of the operand: if the word length of the operand is multi-word, control the modular multiplication operation to enter the inner loop stage; if the word length of the operand is single-word, control the modular multiplication operation to skip the inner loop stage and directly enter the post-processing stage; obtain the operation result of the post-processing loop stage; and when the operation result meets the predetermined range, send a signal indicating that the operation has been completed to the protocol layer.

[0008] According to one embodiment of the present invention, the control module includes a finite state machine, wherein the finite state machine has multiple preset states, each state corresponding to an operation to be performed by the computing module; the finite state machine is configured to trigger a jump from the current state to the next state based on the execution status of the operation corresponding to the current state and predefined jump logic, so as to control the computing module to execute the operation corresponding to the next state.

[0009] According to one embodiment of the present invention, the states include an idle state, an outer loop multiplication-addition state, an outer loop parameter calculation state, an outer loop reduction-subtraction state, an inner loop multiplication-addition state, an inner loop accumulation state, an outer loop carry processing state, a post-processing subtraction operation state, a post-processing addition operation state, and an operation completion state.

[0010] According to one embodiment of the present invention, the multiply-add module includes: a multiplication unit configured to perform a multiplication operation of a base bit width within a single clock cycle; a logic unit configured to decompose the actual bit width of the operand to the base bit width step by step using a multi-level Karatsuba algorithm, and to schedule the multiplication unit to perform multiple multiplication operations of the base bit width; and a combination unit configured to combine the results of the multiple multiplication operations step by step using a multi-level accumulation operation to generate an intermediate modular multiplication result of the actual bit width.

[0011] According to one embodiment of the present invention, the multiplication unit includes: an encoding subunit configured to bootstrap the input operands of a basic bit width to reduce the number of partial products generated in the multiplication operation; a compression subunit configured to receive the partial products output by the encoding subunit and compress the partial products through multi-level compression logic to generate a carry vector and a sum vector; and a full addition subunit configured to perform a summation operation on the carry vector and the sum vector to output the multiplication result of the basic bit width.

[0012] According to one embodiment of the present invention, the reduction module includes multiple cascaded single-word-length addition units, and the reduction operation includes modular addition or modular subtraction operation; the single-word-length addition unit is configured to: perform multiple rounds of modular subtraction operation on the intermediate result of modular multiplication under the scheduling of the control module; if the result of the modular subtraction in the last round is non-negative, then determine the modular subtraction result as the final modular multiplication result output; if the result of the modular subtraction in the last round is negative, then continue to perform multiple rounds of modular addition operation to correct the modular subtraction result to the predetermined range.

[0013] To achieve the above objectives, a second aspect of the present invention provides a Montgomery modular multiplication implementation method applied to public-key cryptographic computation, comprising: outputting a control signal based on the operational logic of the modular multiplication operation to manage the execution flow of the modular multiplication operation; and, in response to the control signal, acquiring source operands related to the public-key cryptographic computation to perform corresponding operational operations; wherein the operational operations include: performing high-radix multiplication and multi-level accumulation operations on the source operands to generate intermediate modular multiplication results; and performing reduction operations on the intermediate modular multiplication results to generate a final modular multiplication result within a predetermined range.

[0014] According to an embodiment of the present invention, the execution flow of the modular multiplication operation includes an outer loop stage, an inner loop stage, and a post-processing stage; the management of the execution flow of the modular multiplication operation includes: responding to the start signal of the protocol layer and controlling the modular multiplication operation to enter the outer loop stage; after the outer loop stage is completed, determining whether to enter the inner loop stage based on the word length of the operand: if the word length of the operand is multi-word, controlling the modular multiplication operation to enter the inner loop stage; if the word length of the operand is single-word, controlling the modular multiplication operation to skip the inner loop stage and directly enter the post-processing stage; obtaining the operation result of the post-processing loop stage; and when the operation result meets the predetermined range, feeding back an operation completion signal to the protocol layer.

[0015] According to an embodiment of the present invention, the method further includes: setting multiple states according to the multiple computational operations to be performed; triggering a jump from the current state to the next state based on the execution status of the computational operations corresponding to the current state and a predefined jump logic, so as to control the computing module to execute the computational operations corresponding to the next state.

[0016] According to one embodiment of the present invention, the states include an idle state, an outer loop multiplication and addition state, an outer loop parameter calculation state, an outer loop reduction and subtraction state, an inner loop multiplication and addition state, an inner loop accumulation state, an outer loop carry processing state, a post-processing subtraction operation state, a post-processing addition operation state, and an operation completion state.

[0017] According to an embodiment of the present invention, performing high-radix multiplication and multi-level accumulation operations on the source operand includes: performing a multiplication operation of the base bit width within a single clock cycle; decomposing the actual bit width of the operand into the base bit width using a multi-level Karatsuba algorithm, and performing multiple multiplication operations of the base bit width; and combining the results of the multiple multiplication operations step by step through a multi-level accumulation operation to generate an intermediate modular multiplication result of the actual bit width.

[0018] According to an embodiment of the present invention, performing a multiplication operation of a base bit width within a single clock cycle includes: bootsing the input base bit width operands to reduce the number of partial products generated in the multiplication operation; obtaining the reduced partial products; compressing the partial products through multi-level compression logic to generate a carry vector and a sum vector; performing a summation operation on the carry vector and the sum vector; and outputting the multiplication result of the base bit width.

[0019] According to one embodiment of the present invention, the reduction operation includes modular addition or modular subtraction operations. The step of performing a reduction operation on the intermediate modular multiplication result to generate a final modular multiplication result within a predetermined range includes: performing multiple rounds of modular subtraction operations on the intermediate modular multiplication result; if the modular subtraction result of the last round is non-negative, then determining the modular subtraction result as the final modular multiplication result output; if the modular subtraction result of the last round is negative, then continuing to perform multiple rounds of modular addition operations to correct the modular subtraction result to the predetermined range.

[0020] To achieve the above objectives, a third aspect of the present invention provides a chip boot method that employs the Montgomery modular multiplication implementation method described in any of the second aspects, for accelerating modular multiplication operations in public-key cryptography algorithms to support digital signature verification in the secure boot process.

[0021] To achieve the above objectives, a fourth aspect of the present invention provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are configured to cause the computer to perform the modular multiplication implementation method of any one of the second aspects or to perform the chip secure boot method of claim 15.

[0022] To achieve the above objectives, a fifth aspect of the present invention provides an electronic device, characterized in that it includes a processor, a memory, and a Montgomery modular multiplication implementation device as described in any one of the first aspects; wherein the Montgomery modular multiplication implementation device is configured to perform Montgomery modular multiplication operations under the control of the processor to complete public-key cryptographic calculations.

[0023] It is evident that the present invention has the following advantages compared to the prior art: 1) This invention provides an extensible Montgomery modular multiplication algorithm, which breaks through the limitation of fixed bit width in traditional hardware implementation. It can adapt to modular multiplication operations of arbitrary bit width and is suitable for the application of many public key encryption algorithms such as SM2, ECC256, ECC384, ECC521, RSA-1K, RSA-2K, RSA-3K, RSA-4K, RSA-6K, and RSA-CRT-1K, significantly improving the versatility and reusability of the hardware. 2) It can support the hardware implementation of high-radix-256, which significantly reduces the number of iterations required for modular multiplication operations and effectively meets the computing needs of high-performance computing scenarios; 3) The computing module can be built based on reusable single-word-length arithmetic circuits. By reusing the basic arithmetic circuits, it avoids designing dedicated circuits for different operations, which greatly saves hardware resources. 4) By adopting a multi-level decomposition strategy based on the Karatsuba algorithm, the complex high-bit-width multiplication is decomposed into a combination of low-bit-width operations. This not only enables high-bit-width multiplication to be completed in a single cycle under high-frequency timing constraints, but also enables efficient reuse of the basic bit-width calculation unit under different bit-width requirements. 5) Introduce a finite state machine to achieve precise control over the entire modular multiplication process by setting states, thereby ensuring the accuracy of modular multiplication.

[0024] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description

[0025] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein: Figure 1 This is a schematic block diagram illustrating a Montgomery modular multiplication implementation apparatus according to an exemplary embodiment; Figure 2 This is a schematic block diagram illustrating another Montgomery modular multiplication implementation apparatus according to an exemplary embodiment; Figure 3 This is a schematic diagram of a finite state machine according to an exemplary embodiment; Figure 4 This is a circuit diagram illustrating a single-word long multiply-add unit according to an exemplary embodiment; and Figure 5 This is a schematic diagram of a multi-word length reduction logic according to an exemplary embodiment. Detailed Implementation

[0026] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.

[0027] Before introducing the technical solution of this invention, a brief introduction to the basic content and application of modular multiplication algorithm will be given here to better understand this invention.

[0028] In public-key cryptography (such as RSA, ECC, SM2, etc.), core operations (such as modular exponentiation UN) require frequent large integer modular multiplication operations, i.e., calculating Z = X × Y mod N. The operands (X, Y, N) are typically very large integers with hundreds or even thousands of digits. Using traditional modular arithmetic methods, such as division or iterative subtraction, is computationally inefficient, severely impacting the performance of public-key cryptographic algorithms. Therefore, the Montgomery modular multiplication algorithm proposes a fast modular multiplication method that avoids complex operations through mathematical transformations. The core idea of ​​the Montgomery modular multiplication algorithm is to transform the value from the integer field to the Montgomery field, perform calculations in the Montgomery field to avoid numerous complex modulo operations, and then transform the value back from the Montgomery field to the integer field to obtain the result. Thus, the Montgomery algorithm can be roughly divided into two parts: 1. with Performing Montgomery modular multiplication will Transmitting from an integer field to a Montgomery field: ; 2. Perform a Montgomery modular multiplication with 1. Returning from the Montgomery field to the integer field: ; The following is an integer modular multiplication Complete calculation process: Step 1, put Switch to the Montgomery domain: ; ; Step 2, calculate in the Montgomery domain: ; Step 3: Convert the calculation result from Step 2 back to the integer field: ; This calculation process avoids complex reduction operations in the integer field, but it does require additional field transformation operations in steps 1 and 3. However, when the computational cost of step 2 is very high, steps 1 and 3 can be disregarded.

[0029] Considering that existing modular multiplication operations have problems such as the inability to implement Montgomery modular multiplication with other bit widths, reliance on CPU offloading for computation, and complex hardware control circuits, this invention provides a scalable Montgomery modular multiplication scheme that can achieve scalable operations with arbitrary bit widths and can be implemented in a highly efficient hardware manner, thereby improving computational performance.

[0030] refer to Figure 1 The Montgomery modular multiplication implementation device, applied to public-key cryptography computation, includes: a control module 10 configured to output control signals based on the operational logic of the modular multiplication operation to manage the execution flow of the modular multiplication operation; and a calculation module configured to read the source operands from the storage module in response to the control signals of the control module to perform corresponding operational operations; wherein the calculation module includes: a multiply-add module 20 configured to perform high-radix multiplication and multi-level accumulation operations on the source operands to generate intermediate modular multiplication results; and a reduction module 30 configured to perform reduction operations on the intermediate modular multiplication results to generate a final modular multiplication result within a predetermined range.

[0031] For example, the control module 10, as the control core of the entire modular multiplication implementation device, can precisely schedule each step of the modular multiplication operation. The calculation module, as the functional unit that performs arithmetic operations, performs corresponding operations according to the control signals under the scheduling of the control module 10. Among them, the multiply-add module 20 is responsible for performing single-word multiply-add and accumulation operations on the source operands; the reduction module 30 performs reduction processing on the intermediate modular multiplication results output by the multiply-add module 20. For example, when the modulus is N, the intermediate modular multiplication result obtained by the multiply-add module 20 is between [0, 2N], and the reduction module 130 corrects it to the predetermined range between [0, N] through reduction operations.

[0032] It should be noted that the source operands and modular multiplication results mentioned above are usually stored in units with storage capabilities so that relevant data can be easily obtained in real time during the modular multiplication operation. Figure 2 A schematic diagram showing the connection between the modular multiplication device and the storage module is provided, such as... Figure 2As shown, the storage module 40 is connected to the control module 10, the multiply-accumulate module 20, and the reduce / subtract module 30, respectively. The control module 20 receives a start signal and controls the execution of the operation flow to control the multiply-accumulate module 20 or the reduce / subtract module 30 to perform the corresponding modular multiplication operation. Specifically, the multiply-accumulate module 20 obtains the source operand from the storage module 40, performs multiplication-accumulation and accumulation operations, and writes the intermediate modular multiplication result back to the storage module 40. The reduce / subtract module 30 reads the intermediate modular multiplication result from the storage module 40, performs reduce / subtract processing, and writes the final operation result back to the storage module 40. The control module 10 can also read intermediate data from the storage module 40 to trigger control signals to the multiply-accumulate module 20 or the reduce / subtract module 30 based on the intermediate data, so that the controller can perform different operation. The storage module 40 can be a register, static random access memory (SRAM), or other types of storage devices, and it can communicate with the protocol layer to receive source operands issued by the protocol layer. The source operands include, but are not limited to, the multiplicand (X), the multiplier (Y), the modulus (N), and the modular inverse (w). The modular multiplication result can include intermediate results (Z) generated during the modular multiplication operation and the final modular multiplication result (R).

[0033] As can be seen, the embodiments of the present invention provide an efficient, controllable and scalable modular multiplication operation implementation device through modular hardware design, which can adapt to modular multiplication operations of arbitrary bit width and meet the acceleration requirements of various public key cryptographic algorithms.

[0034] The following section, in conjunction with the accompanying drawings, provides a further detailed description of each module of the above-mentioned modular multiplication implementation device and its specific implementation.

[0035] In a preferred embodiment, the execution flow of the modular multiplication operation includes an outer loop stage, an inner loop stage, and a post-processing stage; the control module is further configured to: respond to the start signal of the protocol layer and control the modular multiplication operation to enter the outer loop stage; after the outer loop stage is completed, determine whether to enter the inner loop stage based on the word length of the operand: if the word length of the operand is multi-word, control the modular multiplication operation to enter the inner loop stage; if the word length of the operand is single-word, control the modular multiplication operation to skip the inner loop stage and directly enter the post-processing stage; obtain the operation result of the post-processing loop stage; and when the operation result meets the predetermined range, send a signal indicating that the operation has been completed to the protocol layer.

[0036] For example, this embodiment of the invention is based on the core principle of high-radix Montgomery modular multiplication and divides the overall process of modular multiplication into fine stages. Table 1 shows a Montgomery modular multiplication algorithm, in which the execution stage is divided into an outer loop stage, an inner loop stage, and a post-processing stage. The post-processing stage is further divided into a post-processing addition stage (POSTS Loop) and a post-processing subtraction stage (POSTA Loop).

[0037] Table 1: Montgomery modular multiplication algorithm The outer loop phase iterates through the multiplicand at the radix level, performing single-word multiplication and addition operations and calculating intermediate parameters. The purpose of this phase is to break down the multiplicand into radix units, laying the foundation for subsequent multi-word operations, while reducing the resource consumption of a single operation through single-word operations.

[0038] In the inner loop phase, the multiplier and modulus are traversed at word length granularity, and multiply-add coordination and carry propagation are performed in multi-word length scenarios.

[0039] The post-processing stage can include a post-processing subtraction stage and a post-processing addition stage. Both stages traverse the intermediate modular multiplication results at the word length granularity, correcting the intermediate results to a predetermined range through reduction operations. Specifically, the post-processing subtraction stage is executed first, calling the reduction module to perform multiple rounds of modular subtraction operations to obtain a preliminary reduction result. The control module determines whether the reduction result is within the predetermined range. If it is, the final modular multiplication result is obtained directly. If it is not within the predetermined range, the control module triggers the entry into the post-processing addition stage, calling the reduction module to perform multiple rounds of modular addition operations to correct the result obtained in the post-processing subtraction stage to the predetermined range. Therefore, in the post-processing stage, this embodiment of the invention further divides the operation into two specific operations, ensuring the accuracy of the final modular multiplication result while reducing unnecessary computational steps and improving the overall efficiency of the modular multiplication operation.

[0040] As can be seen, in this embodiment of the invention, based on the operational characteristics of the high-radix Montgomery modular multiplication algorithm, a hierarchical execution logic is employed, which involves decomposing the multiplicand in the outer loop stage, adapting to multi-word length operations in the inner loop stage, and correcting the operation results in the post-processing stage. This ensures the integrity and accuracy of the modular multiplication algorithm execution. Simultaneously, this embodiment adjusts the execution stage of the operation according to the word length, effectively avoiding redundant operations in single-word length scenarios, further enhancing the flexibility and efficiency of the operation. It can meet the modular multiplication operation requirements of different word lengths and radixes, and is suitable for public-key cryptographic algorithms with different bit width requirements.

[0041] In a preferred embodiment, the control module includes a finite state machine, wherein the finite state machine has multiple preset states, each state corresponding to an operation to be performed by the computing module; the finite state machine is configured to trigger a jump from the current state to the next state based on the execution status of the operation corresponding to the current state and predefined jump logic, so as to control the computing module to execute the operation corresponding to the next state.

[0042] For example, a Finite State Machine (FSM) is a model that manages complex processes through state definitions and state transition logic. In this embodiment of the invention, the FSM maps the multiple steps decomposed in the Montgomery modular multiplication algorithm to a series of states. Each state drives the modular multiplication to complete only one or a set of operations, avoiding logical confusion caused by multiple mixed operations. During actual computation, the FSM continuously monitors the completion status of the operations in the current state (e.g., whether they have been completed), and combines this with preset jump logic (e.g., determining whether to enter the inner loop stage or whether all loop iterations have been completed), controlling the computation module to jump from the current state to the next state, so that the computation module executes the operation corresponding to the next state, thereby driving the computation module to execute each step of the modular multiplication operation in an orderly manner.

[0043] The jump logic of FSM can include: 1) Loop control: For loop operations in modular multiplication, FSM uses a counter to determine the current loop number to determine whether to jump to the next state or continue the loop to execute the next round of operation; 2) Condition judgment: For reduction operations, FSM will check the carry output (sign bit) of the loop calculation result to determine whether to further modify the result; 3) Operand judgment: FSM will check the length of the operand (single word or non-single word) to determine whether to perform a loop jump or perform a loop termination operation.

[0044] As can be seen, by configuring FSM, the complex computational process of Montgomery modular multiplication is decomposed into multiple execution stages and multiple states for control. The orderly transitions between states enable the automation and streamlining of the modular multiplication process, which is easy to control and verify, ensuring high-performance and reliable computation in practical public-key cryptography applications.

[0045] More preferably, the states include an idle state, an outer loop multiply-accumulate state, a parameter calculation state, an outer loop reduce-subtract state, an inner loop multiply-accumulate state, an inner loop accumulate state, a carry processing state, a post-processing subtract state, a post-processing add state, and a completion state.

[0046] For example, the following is combined with Figure 3Tables 2 and 3 provide a detailed explanation of the role of each state in the execution flow. It should be noted that... Figure 3 Tables 2 and 3 are based on the Montgomery modular multiplication algorithm shown in Table 1 above. The states and transitions involved are merely examples, and the present invention is not limited to them.

[0047] Table 2: FSM State Machine State List Table 3: FSM State Machine Transition Table The Idle state (IDLE) is the initial state of the device and can also be the reset state after each operation. In this state, the FSM monitors the protocol layer signals, receiving source operands from the protocol layer and storing them in the storage module, while waiting for the protocol layer to issue a signal to start computation. Once the instruction is received, it immediately jumps to the next state, entering the outer loop multiply-accumulate state (OUTCA).

[0048] The Outer Loop Multiply-Accumulate (OUTCA) state marks the beginning of the outer loop's calculations. It completes the first round of single-word multiply-accumulate operations, providing the foundational data for subsequent intermediate parameter calculations. In this state, the FSM controls the multiply-accumulate module to execute single-word multiply-accumulate operations. For example, using the single-word multiplication of the multiplicand X currently being iterated by the outer loop... Based on the baseline, calculate The lowest single word of the multiplier Y The product of the two terms is added to the lowest word of the intermediate result Z. In the middle. Carry signals are generated synchronously during the operation. (Used for subsequent carry propagation), ultimately resulting in the updated... With carry Once the multiplication-addition operation is complete, the FSM triggers a state transition, entering the parameter calculation state (OUTT).

[0049] In the parameter calculation state (OUTT), based on the calculation result of OUTCA, a single-word multiplication operation is performed to further calculate the intermediate parameters of the Montgomery modular multiplication algorithm. This is used for subsequent outer loop reduction operations. Specifically, the FSM performs the operation through the multiply-accumulate module: updating the OUTCA state... As input, and modulo inverse parameter ( , Perform multiplication operations on a word length (e.g., 256 bits) to obtain the initial product, then truncate the lower-order bits of the result. Bits (e.g., 256 bits) as intermediate parameters For public-key cryptography applications, the length of the computation result is fixed, such as 256 bits. In this state, the product result is limited to a single word length to accommodate the hardware logic of subsequent single-word-level operations. After the calculation and truncation are completed, the FSM jumps to the outer loop reduction state (OUTCB).

[0050] The outer loop reduction state (OUTCB) uses intermediate parameters calculated by OUTT to control the multiply-accumulate module to perform reduction single-word multiply-accumulate operations to update the intermediate results. With the carry signal. Specifically, the FSM controls the multiply-accumulate module to obtain the OUTT state. The lowest single word of the modulus N ( Multiply by , and then add the accumulated multiplication to the updated OUTCA state. In the process, a new carry signal is generated simultaneously. Finally, it was updated again. With carry .

[0051] After the operation is completed, the FSM will read the word length information of the multiplier Y and determine whether Y is a single word: if Y is not a single word, it will jump to the inner loop multiply-add state (INNCA); if Y is a single word, it will skip the inner loop and jump to the carry processing state (OUTV).

[0052] In the inner loop multiply-accumulate (INNCA) state, the FSM will control the simultaneous execution of two multiply-accumulate operations in parallel: one is to calculate the current word of the multiplicand X. The current word of the multiplier Y The product of, and the current word of the intermediate result Z. Carry Accumulate, and get the updated result. With carry The other is to calculate intermediate parameters. Multiply the product of the current word with the modulus N and accumulate it. When the parallel computation is complete, the FSM jumps to the inner loop accumulation state (INNCB).

[0053] The inner loop accumulation state (INNCB) is based on the calculation result of the INNCA state, performing the accumulation of intermediate results and updating the carry synchronously. Specifically, the first multiply-accumulate module in the INNCA state will be updated. Intermediate results obtained from the second multiply-add module and carry Accumulate.

[0054] After the accumulation is complete, the FSM determines whether the inner loop has traversed all the words of Y and N, that is, whether it is the last loop. If it has not traversed all the words, it jumps back to the INNCA state and continues the next inner loop. If it has traversed all the words, it jumps to the carry processing state (OUTV) and ends the inner loop stage.

[0055] The carry processing state (OUTV) summarizes all carry values ​​from both the outer and inner loops, updates the high-order bits of intermediate results, and determines whether the outer loop has completed all iterations. Specifically, it processes the carry values ​​generated by the inner loop (or outer loop, when Y is a single character). , Advancement with history (Initially set to 0) Accumulate the bits, and use the highest bit of the accumulated result as the new historical carry. The lower bits are used to update the highest word of the intermediate result Z. (m is the number of word length groups corresponding to the base). After the summary is completed, FSM determines whether it is the last round of the outer loop: if not all outer loop rounds have been completed, it jumps back to the OUTCA state and starts the next round of the outer loop; if the last round of the outer loop has been completed, it jumps to the post-processing decrement state (POSTS) and enters the post-processing stage.

[0056] Post-processing decrement status (POSTS), which is determined by executing The operation involves preliminary reduction of the intermediate result of the modular multiplication, and a preliminary determination of whether the preliminary reduction result is within the predetermined range [0, N]. Specifically, the FSM controls the reduction module to perform the operation. First, the modulus N is sign-extended and then inverted to obtain the auxiliary parameter SN, and the carry is initialized to 1. Then, using word length as the granularity, the single-word input reduction module extracts SN and Z one by one. The first round uses the initial carry of 1, and subsequent rounds use the carry output of the previous round. After m rounds of calculation (m is the number of word length groups corresponding to the base), the result is obtained. The initial reduction result is obtained. After the operation is completed, the FSM detects the carry output c of the last round. If the carry output c is 0, it indicates that the initial reduction result is the final modular multiplication result, and then jumps to the completed state (DONE); if the carry output c is 1, it indicates that the initial reduction result is negative, and then jumps to the post-processing addition state (POSTA) to correct the result.

[0057] Post-processing added status (POSTA), which is used to correct the results of the POSTS status, through " The operation corrects the value to a predetermined range [0, N]. Specifically, during the correction process, the auxiliary parameter SN directly uses the original modulus N and initializes the carry to 0. Then, using word length as the granularity, the single-word input reduction module of SN and Z is extracted successively. The first round uses the initial carry of 0, and subsequent rounds use the carry output of the previous round. After m rounds of calculation, the value is obtained. The correction result falls within [0, N). After the correction operation is completed, FSM directly jumps to the completed state (DONE).

[0058] In the DONE state, the FSM sends a computation completion signal to the protocol layer and feeds back the computation result. Then it jumps back to the IDLE state to wait for the next computation task.

[0059] like Figure 3 As shown, the state transition process of this finite state machine is as follows (according to...). Figure 3 (in numerical order) 1: IDLE→OUTCA.

[0060] Initially in the IDLE state, upon receiving an external start signal, the FSM is triggered to jump to OUTCA and execute single-word multiplication and addition operations in the outer loop.

[0061] 2: OUTCA→OUTT After the multiplication-addition calculation is completed, FSM triggers a jump to OUTT, and performs a single-word multiplication operation based on the calculation result of OUTCA to further calculate the intermediate parameters of the Montgomery modular multiplication algorithm.

[0062] 3: OUTT→OUTCB Once the intermediate parameters are calculated and extracted, the FSM triggers a jump to OUTCB, using the intermediate parameters calculated by OUTT to control the multiply-accumulate module to perform single-word multiply-accumulate operations.

[0063] 4: OUTCB→INNCA After the OUTCB operation is completed, the FSM determines that Y is not a single word length, triggers a jump to INNCA, and controls the synchronous execution of the double multiply-add operation.

[0064] 5: INNCA→INNCB Based on the calculation results of the INNCA state, the intermediate results are accumulated.

[0065] 6: INNCB→INNCA After the accumulation is complete, the FSM determines that it is not the last round of accumulation, triggers a jump back to INNCA, and continues to execute the next round of operation.

[0066] 7: INNCB→OUTV After the accumulation is complete, FSM determines that it is the last round of accumulation, triggers a jump to OUTV, summarizes the carry from the outer loop, and updates the high-order data of the intermediate results.

[0067] 8: OUTCB→OUTV After the OUTCB operation is completed, the FSM determines that the multiplier Y is a single word and jumps directly to OUTV.

[0068] 9: OUTV→OUTCA After the OUTV summary update is completed, the FSM determines that not all outer loop rounds have been completed, triggering a jump back to OUTCA to continue the next round of outer loop operations.

[0069] 10: OUTV→POSTS After the OUTV summary update is completed, the FSM determines that all outer loop rounds have been completed, triggers a jump to POSTS, and performs post-processing reduction operations.

[0070] 11: POSTS → DONE If the FSM determines that the reduction result of POSTS is within the predetermined range, it confirms that the final modular multiplication result has been obtained, triggers a jump to DONE, and the modular multiplication operation is completed.

[0071] 12: POSTS → POSTA If the FSM determines that the reduction result of POSTS is outside the predetermined range, it will trigger a jump to POSTA to correct the result of POSTS.

[0072] 13: POSTA → DONE After POSTA correction is completed, the modular multiplication result meets the predetermined range, and FSM triggers a jump to DONE, completing the modular multiplication operation.

[0073] 14: DONE → IDLE After feeding the final modular multiplication result back to the protocol layer, the FSM triggers a jump back to IDLE to execute the next modular multiplication calculation task.

[0074] Therefore, FSM achieves the complete computational flow of Montgomery modular multiplication, which is "first multiply and add to generate intermediate results, and then reduce and correct the final result" through the flow of "idle → outer loop preparation → outer / inner loop multiplication and addition → post-processing reduction and correction → completion → return to idle". At the same time, it adapts to scenarios with single-word or multi-word operands through "conditional jump of the inner loop".

[0075] As can be seen, this embodiment of the invention divides complex modular multiplication operations into operations that are easy for hardware circuits to execute by using states, and connects them into the entire computation flow through jump logic. The FSM makes decisions based on real-time calculation results, thereby achieving high efficiency and reliability of the entire calculation process, ensuring that modular multiplication operations can be executed accurately and automatically, and effectively improving the computational performance for public-key cryptography algorithms.

[0076] In a preferred embodiment, the multiply-add module includes: a multiplication unit configured to perform a multiplication operation of the base bit width within a single clock cycle; a logic unit configured to decompose the actual bit width of the operand to the base bit width step by step using a multi-level Karatsuba algorithm, and to schedule the multiplication unit to perform multiple multiplication operations of the base bit width; and a combination unit configured to combine the results of the multiple multiplication operations step by step using a multi-level accumulation operation to generate an intermediate modular multiplication result of the actual bit width.

[0077] For example, when the operand bit width is too large, it is difficult to complete the multiplication-addition operation process directly in one clock cycle. Traditional methods result in excessively long critical path delays, failing to meet the requirements of high-frequency clocks. To complete high-bit-width multiplication in one cycle, a large number of registers are needed to segment the critical path, which significantly increases resource overhead, chip area, and resource waste. Therefore, this invention adopts a Karatsuba algorithm, which decomposes large number multiplication into smaller number multiplication. By increasing addition and subtraction operations, the number of multiplications required is reduced, thereby achieving hardware optimization in terms of area and speed. Specifically, this invention adopts a hierarchical design. First, based on the operand bit width and combined with hardware characteristics, the basic bit width of the decomposition is determined, and multiplication units are constructed for the basic bit width to ensure that the multiplication operation is completed in one clock cycle. Second, the Karatsuba algorithm is used to call multiple basic bit-width multiplication units to combine and achieve the high-bit-width multiplication requirement.

[0078] The multiplication process for n bits is shown below: Input: two bit operands : , Output: 1. 2. 3. 4. 5. 6. As can be seen, the hierarchical design based on the Karatsuba algorithm in this invention can not only overcome the latency problem of high bit-width operations, but also optimize the utilization of hardware resources and adapt to application scenarios with different hardware processes and clock frequencies.

[0079] More preferably, the multiplication unit includes: an encoding subunit configured to bootstrap the input operands of a basic bit width to reduce the number of partial products generated in the multiplication operation; a compression subunit configured to receive the partial products output by the encoding subunit and compress the partial products through multi-level compression logic to generate a carry vector and a sum vector; and a full addition subunit configured to perform a summation operation on the carry vector and the sum vector and output the multiplication result of the basic bit width.

[0080] For example, the encoding subunit (such as the Booth encoder) converts the multiplier of the basic bit width into a smaller number of partial products through Booth encoding, reducing the amount of subsequent compression operations; then the compression subunit (such as the 4-2 compressor) gradually compresses the partial products into two data paths: a carry vector and a sum vector; finally, the full adder subunit (such as the full adder) completes the accumulation of the carry and sum, and outputs the multiplication result of the basic bit width, ensuring that the operation is completed within a single clock cycle, meeting the requirements of high-frequency clocks.

[0081] If the hardware clock frequency is further increased, and the current basic bit width multiplication still cannot meet the single-cycle timing requirements, the current basic bit width can be further decomposed. For example, if the actual bit width is 256 bits and the basic bit width is 128 bits, if 128-bit multiplication cannot meet the single-cycle requirement, then the 128 bits are decomposed into 64 bits. First, the 64-bit multiplication is implemented, then the Karatsuba algorithm is used to combine them to implement 128-bit multiplication, and finally, they are further combined to form 256-bit multiplication, forming a three-level decomposition architecture of "64-bit → 128-bit → 256-bit", which can flexibly adapt to different frequency requirements.

[0082] Figure 4 A hardware schematic diagram of a multiply-accumulate unit is shown, such as... Figure 4 As shown, the hardware architecture of the multiplication unit consists of a multiplier (MULT), an adder (ADDER), a register (Register), and a subtractor (SUB). Among these, Figure 4 There are multiple MULTs in the array, each consisting of an encoder (Booth_Enc), a 4-2 Compress Tree, a Carry and Sum Register (C&S Register), a Full Adder, and a Result Register (Res Register).

[0083] In a preferred embodiment, the reduction module includes multiple cascaded single-word-length addition units, and the reduction operation includes modular addition or modular subtraction. The single-word-length addition unit is configured to perform multiple rounds of modular subtraction operations on the intermediate modular multiplication result under the scheduling of the control module. If the modular subtraction result of the last round is non-negative, the modular subtraction result is determined to be the final modular multiplication result output. If the modular subtraction result of the last round is negative, multiple rounds of modular addition operations are continued to correct the modular subtraction result to the predetermined range.

[0084] For example, an n-bit multi-word reduction operation can be decomposed into multiple single-word additions, as shown in the hardware logic. Figure 5 As shown, Adder is a single-word reduction circuit. For multi-word data, multiple rounds of iterative calculation are required. Therefore, Adder, as the basic unit of the reduction unit, can be used in a cascaded manner, such as... Figure 5 As shown, each word of Z and N (such as word 0, word 1, etc.) is sequentially fed into Adder. First, the lowest word of Z, z[0], the lowest word of SN, sn[0], and the initial carry-1 are input into the lowest-level Adder. The word result z0 after the operation is input into the next-level Adder. By reusing Adder, z[i] + sn[i] + c (where c is the carry output of the previous round) is iteratively calculated, and so on, until all words are processed. The sign of the final result is determined by the carry output c of the last round. A carry-c of 1 indicates that the result is non-negative, and a carry-c of 0 indicates that the result is negative.

[0085] In this embodiment of the invention, by using algorithm conversion and reusing single-word adders, complex multi-word reduction operations can be completed with minimal hardware cost, ensuring the accuracy of the reduction operations.

[0086] Based on the same inventive concept, this invention provides a Montgomery modular multiplication implementation method for public-key cryptography computation. The method includes: outputting a control signal based on the operational logic of the modular multiplication operation to manage the execution flow of the modular multiplication operation; responding to the control signal, reading the source operands to perform corresponding operational operations; wherein the operational operations include: performing high-radix multiplication and multi-level accumulation operations on the source operands to generate intermediate modular multiplication results; and performing reduction operations on the intermediate modular multiplication results to generate a final modular multiplication result within a predetermined range.

[0087] In a preferred embodiment, the execution flow of the modular multiplication operation includes an outer loop stage, an inner loop stage, and a post-processing stage. Managing the execution flow of the modular multiplication operation includes: responding to a start signal from the protocol layer to control the modular multiplication operation to enter the outer loop stage; after the outer loop stage is completed, determining whether to enter the inner loop stage based on the word length of the operand: if the operand has a multi-word length, controlling the modular multiplication operation to enter the inner loop stage; if the operand has a single-word length, controlling the modular multiplication operation to skip the inner loop stage and directly enter the post-processing stage; obtaining the operation result of the post-processing loop stage; and when the operation result meets the predetermined range, sending a signal indicating that the operation has been completed to the protocol layer.

[0088] In a preferred embodiment, multiple states are set according to the multiple computational operations to be performed; the method further includes: triggering a jump from the current state to the next state based on the execution status of the computational operations corresponding to the current state and predefined jump logic, so as to control the computing module to execute the computational operations corresponding to the next state.

[0089] In a preferred embodiment, the states include an idle state, an outer loop multiplication and addition state, an outer loop parameter calculation state, an outer loop reduction and subtraction state, an inner loop multiplication and addition state, an inner loop accumulation state, an outer loop carry processing state, a post-processing subtraction operation state, a post-processing addition operation state, and an operation completion state.

[0090] In a preferred embodiment, performing high-radix multiplication and multi-level accumulation operations on the source operand includes: performing a multiplication operation of the base bit width within a single clock cycle; decomposing the actual bit width of the operand into the base bit width using a multi-level Karatsuba algorithm, and performing multiple multiplication operations of the base bit width; and combining the results of the multiple multiplication operations step by step through multi-level accumulation operations to generate an intermediate modular multiplication result of the actual bit width.

[0091] In a preferred embodiment, performing a multiplication operation of the base bit width within a single clock cycle includes: bootsing the input base bit width operands to reduce the number of partial products generated in the multiplication operation; obtaining the reduced partial products; compressing the multiple partial products through multi-level compression logic to generate a carry vector and a sum vector; performing a summation operation on the carry vector and the sum vector; and outputting the multiplication result of the base bit width.

[0092] In a preferred embodiment, the reduction operation includes modular addition or modular subtraction. The step of performing a reduction operation on the intermediate modular multiplication result to generate a final modular multiplication result within a predetermined range includes: performing multiple rounds of modular subtraction operations on the intermediate modular multiplication result; if the modular subtraction result of the last round is non-negative, then determining the modular subtraction result as the final modular multiplication result output; if the modular subtraction result of the last round is negative, then continuing to perform multiple rounds of modular addition operations to correct the modular subtraction result to the predetermined range.

[0093] For details on the implementation of the Montgomery modular multiplication method of the present invention and its advantages, please refer to the embodiments of the data transmission device described above, which will not be elaborated further here.

[0094] Accordingly, the present invention also provides a chip boot method, which adopts the Montgomery modular multiplication implementation method described in the above embodiments, to accelerate modular multiplication operations in public-key cryptography algorithms, so as to support digital signature verification in the secure boot process.

[0095] Accordingly, the present invention also provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the modular multiplication implementation method described in the above embodiments or to execute the chip secure boot method described in the above embodiments.

[0096] Accordingly, the present invention also provides an electronic device, including a processor, a memory, and the Montgomery modular multiplication implementation device described in the above embodiments; wherein the Montgomery modular multiplication implementation device is configured to perform Montgomery modular multiplication operations under the control of the processor to complete public-key cryptographic calculations.

[0097] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0098] The units described in the embodiments of the present invention can be implemented in software or in hardware. The name of a unit does not necessarily limit the unit itself; for example, the first acquisition unit can also be described as "a unit that acquires at least two Internet Protocol addresses".

[0099] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), and so on.

[0100] In the context of this invention, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0101] The above description is merely a preferred embodiment of the present invention and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of disclosure in this invention is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-disclosed concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions disclosed in this invention.

[0102] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the invention. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.

[0103] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.

Claims

1. A Montgomery modular multiplication implementation device, characterized in that, Applied to public-key cryptographic computation, and includes: A control module is configured to output control signals based on the modular multiplication operation logic to manage the execution flow of the modular multiplication operation; A computing module is configured to, in response to a control signal from the control module, acquire source operands related to the public-key cryptographic computation to perform corresponding computational operations; The calculation module includes: The multiply-accumulate module is configured to perform high-radix multiplication and multi-level accumulation operations on the source operands to generate intermediate modular multiplication results; and A reduction module is configured to perform a reduction operation on the intermediate modular multiplication results to generate a final modular multiplication result within a predetermined range.

2. The Montgomery modular multiplication implementation apparatus according to claim 1, characterized in that, The execution flow of the modular multiplication operation includes an outer loop stage, an inner loop stage, and a post-processing stage; The control module is further configured to: In response to the start signal of the protocol layer, the modular multiplication operation is controlled to enter the outer loop stage; After the outer loop phase is completed, determine whether to enter the inner loop phase based on the word length of the operands: If the word length of the operand is multi-word, the modular multiplication operation is controlled to enter the inner loop stage; if the word length of the operand is single-word, the modular multiplication operation is controlled to skip the inner loop stage and directly enter the post-processing stage. The operation results of the post-processing loop stage are obtained. When the operation results meet the predetermined range, a signal indicating that the operation has been completed is sent back to the protocol layer.

3. The Montgomery modular multiplication implementation apparatus according to claim 1, characterized in that, The control module includes a finite state machine, wherein the finite state machine has multiple preset states, and each state corresponds to the computational operation to be performed by the computing module. The finite state machine is configured to trigger a jump from the current state to the next state based on the execution status of the operation corresponding to the current state and predefined jump logic, so as to control the computing module to execute the operation corresponding to the next state.

4. The Montgomery modular multiplication implementation apparatus according to claim 3, characterized in that, The states include idle state, outer loop multiplication and addition state, outer loop parameter calculation state, outer loop reduction and subtraction state, inner loop multiplication and addition state, inner loop accumulation state, outer loop carry processing state, post-processing subtraction operation state, post-processing addition operation state, and operation completion state.

5. The Montgomery modular multiplication implementation apparatus according to claim 1, characterized in that, The multiply-accumulate module includes: The multiplication unit is configured to perform multiplication operations of the base bit width within a single clock cycle; A logic unit is configured to decompose the actual bit width of the operand into the base bit width step by step using a multi-level Karatsuba algorithm, and to schedule the multiplication unit to perform multiple multiplication operations of the base bit width. A combination unit is configured to combine the results of the multiple multiplication operations step by step through multi-level accumulation operations to generate the intermediate modular multiplication result of the actual bit width.

6. The Montgomery modular multiplication implementation apparatus according to claim 5, characterized in that, The multiplication unit includes: The encoding subunit is configured to bootth encode the input operands of a basic bit width to reduce the number of partial products generated in multiplication operations; A compression subunit is configured to receive a partial product output by the encoding subunit, and compress the partial product through multi-level compression logic to generate a carry vector and a sum vector; A full adder subunit is configured to perform a summation operation on the carry vector and the sum vector, and output the multiplication result of the base bit width.

7. The Montgomery modular multiplication implementation apparatus according to claim 1, characterized in that, The reduction module includes multiple cascaded single-word-length addition units, and the reduction operation includes modular addition or modular subtraction operations; The single-word-length addition unit is configured as follows: Under the scheduling of the control module, multiple rounds of modular subtraction operations are performed on the intermediate modular multiplication results; If the modulo subtraction result of the last round is non-negative, then the modulo subtraction result is determined to be the final modulo multiplication result output; If the modulus reduction result of the last round is negative, then multiple rounds of modulus addition operation are performed to correct the modulus reduction result to the predetermined range.

8. A method for implementing Montgomery modular multiplication, characterized in that, Applied to public-key cryptographic computation, and includes: The operational logic outputs control signals based on modular multiplication to manage the execution flow of the modular multiplication operation; In response to the control signal, source operands related to the public-key cryptographic calculation are obtained to perform the corresponding computational operations; The arithmetic operations include: Perform high-radix multiplication and multi-level accumulation operations on the source operands to generate intermediate modular multiplication results; and Perform a reduction operation on the intermediate modular multiplication results to generate the final modular multiplication result within a predetermined range.

9. The Montgomery modular multiplication implementation method according to claim 8, characterized in that, The execution flow of the modular multiplication operation includes an outer loop stage, an inner loop stage, and a post-processing stage; The execution flow for managing the modular multiplication operation includes: In response to the start signal of the protocol layer, the modular multiplication operation is controlled to enter the outer loop stage; After the outer loop phase is completed, determine whether to enter the inner loop phase based on the word length of the operands: If the word length of the operand is multi-word, the modular multiplication operation is controlled to enter the inner loop stage; if the word length of the operand is single-word, the modular multiplication operation is controlled to skip the inner loop stage and directly enter the post-processing stage. The operation results of the post-processing loop stage are obtained. When the operation results meet the predetermined range, a signal indicating that the operation has been completed is sent back to the protocol layer.

10. The Montgomery modular multiplication implementation method according to claim 9, characterized in that, The method further includes: Multiple states are set according to the multiple operations that need to be performed; Based on the execution status of the computational operations corresponding to the current state and the predefined jump logic, a jump from the current state to the next state is triggered to control the computing module to execute the computational operations corresponding to the next state.

11. The Montgomery modular multiplication implementation method according to claim 10, characterized in that, The states include idle state, outer loop multiplication and addition state, outer loop parameter calculation state, outer loop reduction and subtraction state, inner loop multiplication and addition state, inner loop accumulation state, outer loop carry processing state, post-processing subtraction operation state, post-processing addition operation state, and operation completion state.

12. The Montgomery modular multiplication implementation method according to claim 8, characterized in that, The operation of high-radix multiplication and multi-level accumulation on the source operands includes: Performs a multiplication operation of the base bit width within a single clock cycle; The actual bit width of the operand is decomposed into the basic bit width using a multi-level Karatsuba algorithm, and multiple multiplication operations of the basic bit width are performed. The results of the multiple multiplication operations are combined step by step through multi-level accumulation operations to generate the intermediate modular multiplication result of the actual bit width.

13. The Montgomery modular multiplication implementation method according to claim 8, characterized in that, The multiplication operation of the base bit width within a single clock cycle includes: Booth encoding is performed on the input operands of basic bit width to reduce the number of partial products generated in multiplication operations; Obtain the reduced partial product, and compress the partial product through multi-level compression logic to generate a carry vector and a sum vector; The carry vector and the sum vector are summed to output the multiplication result of the base bit width.

14. The Montgomery modular multiplication implementation method according to claim 8, characterized in that, The reduction operation includes modular addition or modular subtraction. Performing the reduction operation on the intermediate modular multiplication result to generate the final modular multiplication result within a predetermined range includes: Perform multiple rounds of modular subtraction operations on the intermediate modular multiplication results; If the modulo subtraction result of the last round is non-negative, then the modulo subtraction result is determined to be the final modulo multiplication result output; If the modulus reduction result of the last round is negative, then multiple rounds of modulus addition operation are performed to correct the modulus reduction result to the predetermined range.

15. A chip boot method, characterized in that, The Montgomery modular multiplication implementation method as described in any one of claims 8-14 is used to accelerate modular multiplication operations in public-key cryptography algorithms to support digital signature verification in the secure boot process.

16. A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are configured to cause the computer to perform the modular multiplication implementation method as claimed in any one of claims 8-14 or to perform the chip secure boot method as claimed in claim 15.

17. An electronic device, characterized in that, Includes a processor, a memory, and the Montgomery modular multiplication implementation apparatus as described in any one of claims 1-7; The Montgomery modular multiplication implementation device is configured to perform Montgomery modular multiplication operations under the control of the processor to complete public-key cryptographic calculations.