Montgomery reduction

The Montgomery algorithm, which processes data word by word, uses an auxiliary number N' and input C to perform modular multiplication, calculating only the high-order part of the approximate product. This solves the problem of low efficiency in Montgomery multiplication and achieves more efficient Montgomery multiplication operations.

CN121742798APending Publication Date: 2026-03-27INFINEON TECHNOLOGIES AG
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511318137.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2024-09-26
Filing Date
2025-09-16
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing techniques suffer from inefficiency when performing Montgomery multiplication, especially when dealing with large number modular multiplication operations, where performance loss is significant.

Method used

The Montgomery algorithm, which uses word-by-word processing, performs Montgomery reduction modulo N through a processing device. It only calculates the high-order part of the approximate product, uses an auxiliary number N' and input C for modular multiplication, and combines carry processing to realize Montgomery multiplication.

Benefits of technology

It reduces the complexity of Montgomery multiplication from 3m² to 2m² + O(m), improving computational efficiency and making it particularly suitable for modular multiplication of large numbers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121742798A_ABST
    Figure CN121742798A_ABST
Patent Text Reader

Abstract

The invention relates to a device and a method for performing a Montgomery reduction on an input C, in particular in the scope of Montgomery multiplications modulo N, comprising: (i) performing a multiplication based on a value D and modulo N to obtain an approximate product Y, wherein only the higher part of the approximated product Y is calculated and / or approximated according to the incomplete implementation of the multiplication, and wherein the value D is derived from the input C and the auxiliary number N'of the Montgomery reduction; (ii) determining a sum value by adding the word or partial word of the input C to the word or partial word of the approximate product Y; (iii) determining a carry according to the sum value; and (iv) adding the carry to the input C or to a value derived from the input C.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to Montgomery reduction, and more particularly to Montgomery multiplication. Summary of the Invention

[0002] The aim is, in particular, to improve known schemes and, especially, to achieve more effective feasibility for performing Montgomery reduction.

[0003] The objective is achieved according to the features of the invention. Preferred embodiments will be particularly evident in the following description.

[0004] The examples presented herein can be based on at least one of the following solutions. In particular, combinations of the following features can be used to achieve the desired results. Features of the device can be combined with features of the method, or vice versa.

[0005] To achieve this, for example, a device is proposed for performing Montgomery reduction with modulus N as input C, particularly within the scope of Montgomery multiplication, wherein the device includes a processing unit configured to:

[0006] - Perform multiplication based on the value D and the modulus N to obtain an approximate product Y.

[0007] -Where, due to the incomplete implementation of multiplication, only the higher-order parts of the approximate product Y are calculated and / or approximated.

[0008] -The value D is derived from the Montgomery reduction of the input C and the auxiliary number N'.

[0009] - The sum value is determined by adding the words or parts of the input C to the words or parts of the approximate product Y.

[0010] - Determine the carry based on the sum.

[0011] - Add the carry to input C or to the value derived from input C.

[0012] It should be noted that the higher-order portions of the approximate product Y include, in particular, the most significant bit (MSB).

[0013] One improvement is that the processing device is configured such that the value D is obtained from the input C and the auxiliary number N' in 2... n It is derived from the modulo multiplication, where n is determined by the word width and word count of the numeric representation.

[0014] It should be noted here that the footnote "with 2" n The modulus determines only the lower half of the product consisting of the input C and the auxiliary number N'.

[0015] One improvement is that the processing device is configured such that an approximate product Y or a value derived from the approximate product, a carry, and an input C or a value derived from the input are added together.

[0016] One improvement is that the processing device is configured such that the value Y' derived from the approximate product Y is determined according to the following formula:

[0017] Y′=Y div W.

[0018] One improvement is that the processing device is configured such that the value Y” derived from the approximate product Y is determined according to the following formula:

[0019] Y″=Y div W 2 .

[0020] One improvement is that the processing device is configured such that the value C' derived from the input C is determined according to the following formula:

[0021] C′=C div W m-1 .

[0022] One improvement is that the processing device is configured such that the value C” derived from the input C is determined according to the following formula:

[0023] C″=C div W m .

[0024] One improvement is to configure the processing device such that the input C is the long number to be reduced, which is determined by multiplying the long numbers of two numbers.

[0025] An improved approach is to determine the auxiliary number N' as follows:

[0026] N′:=-N -1 mod W m .

[0027] One improvement is to determine the carry as 0, 1, or 2.

[0028] One improvement is that the processing device is configured such that...

[0029] - If the sum is 0, then the carry is 0.

[0030] - If the sum is greater than 0 and less than or equal to the radix of the numeric representation, then the carry is set to 1.

[0031] - If the sum is greater than the radix of the numeric representation, then the carry is set to 2.

[0032] One improvement is to configure the processing device such that the carry of 0, 1, or 2 is determined by rounding based on the following formula:

[0033] (C+Y+m)div W,

[0034] in

[0035] -m indicates the number of words in the modulus N, and

[0036] -W indicates the radix of the numeric representation.

[0037] One improvement is to configure the processing device to perform cryptographic operations, particularly encryption, decryption, signature creation, and / or signature verification.

[0038] One improvement is that the processing device includes one of the following or is designed as one of the following:

[0039] -processor

[0040] -chip

[0041] - Cryptographic module.

[0042] To achieve this, a method for performing Montgomery reduction on input C modulo N is also proposed, particularly within the scope of Montgomery multiplication, a method for performing Montgomery reduction on input C modulo N, the method comprising:

[0043] - Perform multiplication based on the value D and the modulus N to obtain an approximate product Y.

[0044] -Where, due to the incomplete implementation of multiplication, only the higher-order parts of the approximate product Y are calculated and / or approximated.

[0045] -The value D is derived from the Montgomery reduction of the input C and the auxiliary number N'.

[0046] - The sum value is determined by adding the words or parts of the input C to the words or parts of the approximate product Y.

[0047] - Determine the carry based on the sum.

[0048] - Add the carry to input C or to the value derived from input C.

[0049] One improved approach is to divide the value D from the input C and the auxiliary number N' by 2. n It is derived from the modulo multiplication, where n is determined by the word width and word count of the numeric representation.

[0050] One improvement is to add the approximate product Y or the value derived from the approximate product, the carry, and the input C or the value derived from the input.

[0051] An improved approach is to determine the value Y' derived from the approximate product Y according to the following formula:

[0052] Y′=Y div W.

[0053] An improved approach is to determine the value Y” derived from the approximate product Y according to the following formula:

[0054] Y″=Y div W 2 .

[0055] An improved approach is to determine the value C' derived from the input C according to the following formula:

[0056] C′=C div W m-1 .

[0057] An improved approach is to determine the value C” derived from the input C according to the following formula:

[0058] C″=C divW m .

[0059] One improvement is that the input C is the length to be reduced, which is determined by multiplying the lengths of the two numbers.

[0060] An improved approach is to determine the auxiliary number N' as follows:

[0061] N′:=-N - 1 mod W m .

[0062] In one improved scheme, the carry is determined to be 0, 1, or 2.

[0063] One improvement is,

[0064] - If the sum is 0, then the carry is 0.

[0065] - If the sum is greater than 0 and less than or equal to the radix of the numeric representation, then the carry is set to 1.

[0066] - If the sum is greater than the radix of the numeric representation, then the carry is set to 2.

[0067] One improvement is to determine the carry (0, 1, or 2) by rounding down based on the following formula:

[0068] (C+Y+m)div W,

[0069] in

[0070] -m indicates the number of words in the modulus N, and

[0071] -W indicates the radix of the numeric representation. Attached Figure Description

[0072] The above-described features, characteristics, and advantages of the present invention, and the ways and methods by which such features, characteristics, and advantages are realized, are described below in conjunction with illustrative descriptions of embodiments, which are illustrated in more detail with reference to the accompanying drawings. Here, for the sake of overview, the same or equivalent elements may be given the same reference numerals.

[0073] Figure 1 The diagram shows the calculation of F:=A* n An exemplary implementation of B's ​​Montgomery algorithm.

[0074] Figure 2 An exemplary notation is shown for the algorithm used to calculate F:=A*nB word by word.

[0075] Figure 3 Show Figure 1 An exemplary implementation of step 3 of the Montgomery algorithm.

[0076] Figure 4 Show Figure 1 An exemplary implementation of an alternative to step 3 of the Montgomery algorithm.

[0077] Figure 5 Show Figure 1 Another exemplary implementation of step 3 of the Montgomery algorithm.

[0078] Figure 6 An exemplary arrangement is shown including a processing apparatus that provides cryptographic output based on input.

[0079] Figure 7 A processing apparatus for implementing a cryptographic solution by means of at least one cryptographic module is shown. Detailed Implementation

[0080] Montgomery multiplication is a scheme for implementing modular arithmetic based on long numbers. For example, long numbers are suitable for elliptic curve cryptography and the RSA algorithm. This can be discussed in [2]. 160 ,2 4096 Numbers within a range of 1, 2, 3, 4, or larger. Modular addition and subtraction can be easily implemented, but modular multiplication is significantly more expensive. Modular multiplication is the following operation:

[0081] F: = A·B mod N

[0082] Where N is less than 2 n Let A and B be odd positive integers, and let A, B ∈ [0, N] be any integers. Let F represent an explicitly defined integer in the interval [0, N] such that...

[0083] A·BF

[0084] It is divisible by N. Therefore, F can also be determined by the following constraint:

[0085] F = A·BQ·N, where

[0086] Therefore, subtracting the largest multiple of N from A·B results in a multiple that is still less than or equal to the number. If applicable:

[0087]

[0088] Then Q is exactly the largest integer factor that forms the multiple.

[0089] Montgomery multiplication is a variation of modular multiplication. It is defined as follows:

[0090] A*nB:=A·B·2 -n mod N (2)

[0091] Here, 2 -n It is determined to be the modular inverse of 2n modulo N. If the value n is clear from this relation, n can be omitted in the statement.

[0092] The following provides an exemplary description of how Montgomery multiplication can be implemented on a processor with a word width of w. In particular, implementation methods applicable to specific implementation schemes are presented.

[0093] The following notation applies:

[0094] -W is the radix of the numeric representation.

[0095] - The base W is a power of two, i.e., w = 2 w w is the word width in the numeric representation, which can be, for example, the width of a processor word (in bits). Exemplary values ​​for w are 8, 16, 32, 64, or 128. In the binary representation, w can also be equal to 2.

[0096] - The length of the modulus N is exactly m (≥1) words. We can assume the following applies:

[0097] W m-1 <N<W m (3)

[0098] The left-hand side of the inequality is not strict, but this assumption is made for the sake of simplicity. For the sake of completeness, it is mentioned that N < W can also be applied. m-1 Therefore, the simplified representation applies as follows:

[0099] n = m·w or 2 n =W m (4)

[0100] Mathematical implementation of Montgomery multiplication

[0101] The purpose of Montgomery multiplication includes the implementation of constant modular multiplication. Therefore, modular multiplication cannot be used to implement Montgomery multiplication itself.

[0102] The known algorithm of PL Montgomery uses auxiliary numbers.

[0103] N′:=-N -1 mod 2″ (5)

[0104] Here, N' is the interval [0, 2]. n The number of single-valued numbers in [the list] that have the following characteristics:

[0105] (N·N′+1) mod 2 n =0.

[0106] Figure 1 The five steps 1 through 5 are illustrated using common notation for calculating F:=A*. n An exemplary implementation of B's ​​Montgomery algorithm. The value N' can be pre-computed.

[0107] It should be noted that the correctness of the result can be identified as follows: the product C = A·B is modified only in multiples of N, and then divided by 2. n This corresponds to A* n The definition of B. Furthermore, estimation of the value yields that E∈[0, 2N[, thus F∈[0, N[].

[0108] Calculate in step 2 with 2 n Modulo operation is performed using the modulo operator. Note that, with 2... n Modulo operations correspond only to regular non-modulo operations, ignoring bit positions beyond the nth position.

[0109] In step 4, since N' or D is chosen, the value C + D·N can be 2 n Divisible by 2. In other words, the lowest n bits of C + D · N are all 0. n This corresponds to ignoring the lowest n bits or shifting the number down (by bit shifting) n bits.

[0110] All steps from step 2 onwards, and especially steps 2 and 3, can be referred to as Montgomery reduction. If the output should be restricted from the range [0, 2N] to [0, N] (e.g., for subsequent multiplication), then step 4 can be part of Montgomery reduction.

[0111] Implementation Plan

[0112] Montgomery multiplication can be implemented using common mechanisms in processor units (such as CPUs) because all operations can be reduced to regular non-modular operations. Therefore, the operations consist of non-modular addition, subtraction, and multiplication of long numbers. These operations are composed of corresponding short operations that can be directly implemented using the CPU.

[0113] However, the simple implementation of the above algorithm results in a significant performance loss.

[0114] For the exemplary implementation, a processor with a word width of w bits is applicable. For a long integer A, the following representation is derived:

[0115] A = a m-1 ·W m-1 ...+a1·W+a0,,where ai∈[0,W[ (6)

[0116] This applies correspondingly to all other numbers. Two representations can be used: the representation according to equation (6) and the simple representation, as well as a combination thereof. In one implementation, such a number can be represented as an array of m words. Or a[m] for storage and use.

[0117] Integer A of length m

[0118] A = a m-1 ·W m-1 +…+a1·W+a0, where a i ∈[0, W[

[0119] Integer B with word length m'

[0120] B = b m′-1 ·W m′-1 +…+b1·W+b0, where b j Multiplication of ∈[0, W[] can be described as follows:

[0121]

[0122] This operation has a time complexity of m·m′: here we only calculate the relevant basic multiplication a. i ·b j .

[0123] The following operations, which can typically be executed directly on the CPU, are called basic multiplication, and are preferably performed in the following form:

[0124]

[0125] Or in written form:

[0126]

[0127] Therefore, in order to calculate C = A·B, m must be applied. 2 The mul process is repeated. Additionally, additions with carry-behandlungen are performed if the exact number of carry-behandlungens is not determined.

[0128] This also applies correspondingly to the multiplication D·N in step 3 and the multiplication C·N′ in step 2. It should be noted that although C is a number of length 2m, it applies to:

[0129] C·N′mod 2 n = (C mod 2) n )·N′mod2 n ,

[0130] Therefore, it is effectively multiplied by m′=m.

[0131] Overall, the preliminary estimate of the complexity of Montgomery multiplication is determined to be 3m. 2 A basic multiplication. However, the estimation is suboptimal. Therefore, in step 2, it is unnecessary to perform the multiplication C·N′ completely as follows:

[0132]

[0133] Because when i+j≥m, the value c i ·n′ j ·W i+j Completely lost through the following operation:

[0134] mod 2 n ≡modW m .

[0135] Therefore, calculating the following is sufficient:

[0136]

[0137] This only corresponds to This involves basic multiplication. The aforementioned method reduces the complexity of Montgomery multiplication from 3·m⁻¹. 2 Reduce to

[0138] The following details how the complexity of Montgomery multiplication can be further reduced.

[0139] A word-by-word implementation of Montgomery's multiplication method

[0140] The following implementation scheme is proposed, which considers from the outset that long numbers consist of single words. Representing numbers as arrays of words, especially tuples, is further given by the following formula.

[0141] A = a m-1 ·W m-1+…+a1·W+a0, where a i ∈[0,W[ (9)

[0142] This also applies to all other numbers. Both notations can be used in the same and mixed ways.

[0143] Use auxiliary numbers

[0144] n′:=-N -1 mod 2 w (10)

[0145] Therefore, n' comes from the interval [0, 2]. w Single-valued numbers have the following characteristics

[0146] (N·n'+1)mod 2 w =0.

[0147] Figure 2 The six steps 1 through 6 illustrate the word-by-word calculation of F:=A*. n An exemplary notation for B's algorithm. The value n' can be pre-computed.

[0148] Additionally, see [A.J. Menezes et al., Handbook of Applied Cryptography, 2nd edition, 1997, CRC Press, Boca Raton, Chapter 14.3.2 Barrett reduction, pp. 600-603].

[0149] The operations in step 3 are performed only on words. Therefore, these operations can be performed directly on the CPU, requiring two CPU multiplications (and additions). The result is again a word.

[0150] The operations in step 4 include distinguishing words (a i ,u i This involves two long number multiplications (B, N) with a word length m. The operation requires a total of 2m CPU multiplications (and CPU additions).

[0151] The version of Montgomery's multiplication presented here has the added advantage that the pre-computed number n' is only one word and the corresponding pre-computed number can be easily performed on the CPU, whereas N' is a much longer number that is more computationally expensive.

[0152] The algorithm has m·(2m+2)=2m 2 The complexity is equivalent to +2m basic multiplications.

[0153] The complexity can be further reduced to 2m 2 +m: Operation a in step 3i • b0 can be calculated in step 4. i • Reuse in B. Alternatively, E+a can be calculated before step 3. i ·B, the result already contains the value needed in step 3 (e0+a) thanks to e0. i ·b0)mod W.

[0154] The Montgomery reduction described here can generally be referred to as the modulo reduction. Figure 6 An exemplary arrangement is shown including a processing device 401, which, for example, receives input 402, performs cryptographic methods such as encryption, decryption, signature creation, or signature verification, and provides a corresponding output 403 as a result (e.g., encrypted data, decrypted data, signature, verified signature, error, etc.). The processing device 401 may be implemented as a chip, cryptographic module, or processor, or may include at least one chip, cryptographic module, and / or processor. The cryptographic methods performed on the processing device 401 utilize modular multiplication. Modular reduction as described herein can be used within the scope of modular multiplication.

[0155] Figure 7 A processing device 500 is shown, which includes a CPU 501, RAM 502, non-volatile memory 503 (NVM), a cryptographic module 504, an analog module 506, an input / output interface 507, and a hardware random number generator 512.

[0156] In the example, CPU 501 accesses at least one cryptographic module 504 via a common bus 505 to which each cryptographic module 504 is connected. Specifically, each cryptographic module 504 may include one or more cryptographic cores to perform specific cryptographic operations. An exemplary cryptographic core is:

[0157] - AES core 509 (AES: Advanced Encryption Standard, German fortschrittlicher Verschlüsselungsstandard),

[0158] -SHA kernel 510 (SHA: Secure Hash Algorithm, Sicherer Hash-Algorithm)

[0159] -ECC core 511 (ECC: Error Checking and Correcting, Fehlererkennung und Fehlerkorrektur) and

[0160] -RSA core 508 (RSA: Rivest-Shamir-Adleman, referring to the core that implements the RSA algorithm).

[0161] CPU 501, hardware random number generator 512, NVM 503, cryptographic module 504, RAM 502, and input / output interface 507 are connected to bus 505. Input / output interface 507 may have connections to other devices similar to those in processing device 500.

[0162] The cryptographic module 504 may or may not be equipped with hardware-based security features.

[0163] Bus 505 itself can be masked or exposed. Instructions for performing the steps described herein can be stored in NVM 503 and processed by CPU 501. Processed data can be stored in NVM 503 or RAM 502. Support functions can be provided by cryptographic module 504.

[0164] The steps of the method described herein may be performed, either alone or at least in part, on cryptographic module 504. In particular, at least one modular multiplication, including the Montgomery reduction described herein, may be performed on cryptographic module 504.

[0165] In the example, long number multiplication can be performed in cryptographic module 504 or at least partially in CPU 501. In another example, non-modular integer multiplication is always performed in cryptographic module 504.

[0166] Processing device 500 may be, for example, a chip card that operates via direct electrical contact or an electromagnetic field. Processing device 500 may be fixed circuitry or based on reconfigurable hardware (e.g., a field-programmable gate array, FPGA). Processing device 500 may connect to a personal computer, microcontroller, FPGA, or smartphone. Alternatively, processing device 500 may be implemented as a cryptographic core, a hardware security module (HSM), or other hardware module.

[0167] Features of the implementation scheme

[0168] The word-for-word Montgomery algorithm described above has many advantages when implemented on a CPU: the individual steps can be executed on a CPU, and the algorithm is optimized for the number of basic multiplications required.

[0169] However, evaluating the actual performance of an algorithm implemented on a CPU depends on several additional factors:

[0170] The algorithm consists not only of multiplication, but also of addition / subtraction with or without carry handling. How it is implemented on the CPU appears to depend on the available instructions.

[0171] For example, a CPU is equipped with a small memory, called a register bank, and a large memory, RAM. The register bank consists of multiple (typically 16 or 32) words (Registers) of width w. Fast basic arithmetic operations (multiplication, etc.) are possible only on these registers.

[0172] - Data movement between RAM and registers is accomplished using instructions (if implemented in software). If arithmetic operations work only on registers, then the algorithm (or software) must also be responsible for providing the corresponding input values ​​for the operation in the registers in a timely manner. Loading and storing register values ​​additionally takes time, which is especially true for purely software implementations. In certain hardware implementations, this data movement can be performed in the background if necessary, but then complex logic is required.

[0173] In modern CPUs, basic multiplication typically requires only one clock cycle to perform. Therefore, basic multiplication can take only as much time as basic addition when necessary, and potentially less than a load or store procedure. Consequently, it's possible that algorithms optimized for minimizing basic multiplication, but requiring numerous load / store procedures and additions, become slower.

[0174] In the following text, it is exemplarily assumed that the basic operations require only one clock cycle. Therefore, the implementation time for Montgomery multiplication is at least 2m. 2 +m clock cycles.

[0175] The implementation time of the solution depends on how many basic multiplications the algorithm uses, how many additions it requires, and how flexibly the register library is used.

[0176] If m is small enough that all the required input values ​​A, B, N, n' for, for example, Montgomery multiplication can be kept in the register library, then the execution time is dominated by multiplication and addition, and additionally only the loading time of A and B and the time for replying to the result must be considered.

[0177] If m is in a medium range, such that only a portion of the values ​​can be kept in the register bank, e.g., only B, N, n', then by flexibly reloading a in the background at the right time... i It is still possible to achieve good performance of the implementation scheme.

[0178] However, if m exceeds the size of the register library, making it impossible even to keep one of the participating numbers intact in the register library, then in a simple implementation, runtime is dominated by load and store procedures. If the data is no longer in the register library, the basic operations utilize two load procedures and possibly a store procedure.

[0179] Traditional optimization introduces a significant increase in complexity to software or hardware process control. Optimization becomes significantly more difficult again if a more complex literal variation of Montgomery multiplication should be performed instead of non-modular multiplication.

[0180] Improved solution

[0181] For example, assume m is a large number. This exemplarily relates to an implementation of the RSA algorithm. Here, the running time of Montgomery multiplication is determined by the square factor m. 2 Dominant, linear factors should more precisely be ignored. The following example assumes that two numbers of word length m can be implemented with m... 2 +O(m) non-modular multiplication cycles.

[0182] In this case, for example, we can assume the original global implementation of Montgomery multiplication, where only non-modular multiplication is used. This variant of Montgomery multiplication has approximately 3m... 2 The complexity is equivalent to one clock cycle. Therefore, it has a complexity of 3m. 2 An implementation with a time complexity of +O(m) is realistic. However, this implies at least a 50% performance penalty.

[0183] Step 2

[0184] To return to 2m 2 The region with a complexity of +O(m) requires further improvement. As mentioned above, all that is needed is to perform the multiplication according to step 2 only in the lower half, see equation (8).

[0185] This half-multiplication can be implemented using the same method as full multiplication, and can be achieved with the help of 0.5m 2 This is achieved with a runtime of +O(m). This yields 2.5m for Montgomery multiplication. 2 The total running time is +O(m) clock cycles.

[0186] Step 3

[0187] The further reduction in complexity from a factor of 2.5 to 2 is more costly and is performed in step 3. The calculations are done there.

[0188]

[0189] By choosing D, we ensure that C + D·N can be 2 n =W m Divisible by, or E is an integer. For the reasons stated above, it is sufficient to calculate only the upper half in the sum C + D·N.

[0190] Therefore, only the upper half of D·N can be calculated and added to the upper half of C. This roughly corresponds to approximately m. 2 The computational cost is / 2, not m. 2 The basic multiplication or clock cycle. In this case, the total runtime can be reduced to 2m. 2 +O(m).

[0191] Alternatively, a solution can be established as follows:

[0192] Solution: E←C div 2 n +(D·N)div 2 n (12)

[0193] The "div" symbol represents integer division without a remainder.

[0194] In most cases, C cannot be divided by 2. n If divisible by 2, then the value (C mod 2) is... n It must pass through (D·N mod 2) n (Add to value 2) n Therefore, the correct solution is

[0195]

[0196] The proposed solution still has the following problems:

[0197] - C mod 2 must be checked. n =0, therefore the entire lower half of C must be checked.

[0198] -Item (D·N)div 2 n It would require fully calculating D·N, but this contradicts the cost optimization described herein.

[0199] The following items

[0200]

[0201] It can be done

[0202]

[0203] approximate.

[0204] The item includes

[0205]

[0206] Basic multiplication. Applicable here.

[0207]

[0208] (*): Note that rounding should be done when rounding to the nearest whole number. i =n j When =W, terms with i+j<m-1 are received through terms with i+j=m-1.

[0209] A further improved approximation is:

[0210]

[0211] The item includes

[0212]

[0213] Basic multiplication. Applicable here.

[0214]

[0215] value X / 2 n and X” / 2 n Here, the difference can also be close to m. The next approximation is:

[0216]

[0217] The item now includes

[0218]

[0219] Basic multiplication, and applicable

[0220]

[0221] thereby

[0222]

[0223] In the case of m-2 < W, this causes

[0224] X div 2 n -X"'div 2 n ∈{0,1} (15)

[0225] thereby

[0226] E←(C div 2 n )+(X″′div2 n )+ε, where ε∈{0,1,2} (16)

[0227] Applicable. In a specific implementation, the following criteria are required, based on which the value of ε can be determined. The following estimation can be used for this purpose:

[0228]

[0229] Since equation (14) applies:

[0230]

[0231] Therefore, the overall conclusion is:

[0232]

[0233] In other words, It is a good approximation of E, and differs from E by less than (m-1) / W. Therefore, it is applicable to:

[0234]

[0235] Or it has rounding error

[0236]

[0237] or

[0238]

[0239] Therefore, under the premise that m < W, we can conclude that:

[0240] E=(C'+(Y div W)+m)div W (23)

[0241] Figure 3 Show Figure 1 An exemplary implementation of step 3 of the Montgomery algorithm. The algorithm requires... A basic multiplication. Instead of +m in step 3, it is also possible to add each integer in the interval [m, Wm].

[0242] If we consider that in step 2, we are not interested in the value e'0 of the lowest word in E', but only in the carry-over to the next higher word, then we arrive at step 3 of the Montgomery algorithm. Figure 4 The alternative implementation scheme is shown in the figure. Here, ε in the algorithm corresponds to ε in equation (16). It can take only the values ​​0, 1, and 2.

[0243] In the above algorithm, the following criteria apply to ε:

[0244]

[0245] The standard has the following advantages: the value m no longer appears. Although m < W still applies, the implementation of the standard does not need to know m. Another advantage is its favorable implementation on the CPU.

[0246] Based on this Figure 5An alternative for implementing step 3 of the Montgomery algorithm is shown.

[0247] It should be further noted that in step 2, any other criterion is acceptable, which maps the ranges {0}, [Wm,W], and [2W-m,2W] to the values ​​0, 1, and 2.

[0248] Advantages and other aspects

[0249] The solution described herein has several advantages. Therefore, if a literal implementation of Montgomery multiplication incurs a performance penalty, the solution described herein can be used. This could be the case where:

[0250] - The long numbers involved are too large to be stored in the register library.

[0251] - Loading and storing data in the register bank (from / to RAM) takes longer than the actual underlying computation, or

[0252] - The logic for managing data in the register bank becomes complex and, when necessary, uncontrollable.

[0253] Another advantage is that the scheme described herein only requires a simple non-modular multiplication implementation of a long integer, which preferably can start or stop "in the middle".

[0254] The solution provides 2m 2 +O(m) runtime.

[0255] Another advantage is that the standard used to calculate ε can be implemented without knowing m. This has advantages, for example, in hardware implementation schemes.

[0256] The example described here enables the carrying-in of the value 0, 1, or 2 within the scope of Montgomery reduction or Montgomery multiplication of long integers.

[0257] In particular, at least one of the following features may be considered in one of the solutions proposed herein:

[0258] - The long integer to be reduced (C). Montgomery multiplication calculates the number to be reduced by multiplying two given long numbers, while Montgomery reduction gives the number to be reduced directly.

[0259] - Long number multiplication (Y), which calculates only or approximates the upper half of the product through an incomplete implementation of the multiplication.

[0260] - Add the (partial) words of the number to be reduced (c'0) and the approximate product (y'0).

[0261] - Determine the carry as 0, 1, or 2 based on the value of the sum. This can be done, for example, directly according to equation (24) or by a type of rounding, such as ε:=(c′0+y′0+m)div W.

[0262] - Add the carry to the number to be reduced or the value derived from it (C”). For example, this is done indirectly, for example, according to the preceding... Figure 4 The variant shown is performed via C″+Y″+ε.

[0263] - The latter two points can be used as alternatives based on... Figure 3 The following is a summary of the variant schemes shown.

Claims

1. An apparatus for performing Montgomery reduction modulo N on an input C, particularly within the scope of Montgomery multiplication, wherein the apparatus includes a processing unit configured to, - Perform multiplication based on the value D and the modulus N to obtain an approximate product Y. - Wherein, according to the incomplete implementation of the multiplication, only the higher-order parts of the approximate product Y are calculated and / or approximated. - wherein the value D is derived from the input C and the auxiliary number N' by Montgomery's subtraction. - The sum value is determined by adding the words or parts of the input C to the words or parts of the approximate product Y. - Determine the carry based on the sum. Add the carry to the input C or to the value derived from the input C.

2. The device according to claim 1, The processing device is configured such that the value D is obtained from the input C and the auxiliary number N' in 2... n It is derived from the modulo multiplication, where n is determined by the word width and word count of the numeric representation.

3. The device according to any one of claims 1 or 2, The processing device is configured to add the approximate product Y or a value derived from the approximate product, the carry, and the input C or a value derived from the input.

4. The device according to any one of claims 1 to 3, The processing device is configured such that the value Y' derived from the approximate product Y is determined according to the following formula: Y′=Y div W.

5. The device according to claim 3, The processing device is configured such that the value Y” derived from the approximate product Y is determined according to the following formula: Y″=Y div W 2 。 6. The device according to any one of claims 1 to 5, The processing device is configured such that the value C' derived from the input C is determined according to the following formula: C′=C div W m-1 。 7. The device according to any one of claims 1 to 5, The processing device is configured such that the value C” derived from the input C is determined according to the following formula: C″=C div W m 。 8. The device according to any one of claims 1 to 7, The processing device is configured such that the input C is the length to be reduced, which is determined by multiplying the lengths of two numbers.

9. The device according to any one of claims 1 to 8, The auxiliary number N' is determined as follows: N′:=-N -1 mod W m 。 10. The device according to any one of claims 1 to 9, The carry is defined as 0, 1, or 2.

11. The device according to any one of claims 1 to 10, The processing device is configured such that - If the sum is equal to 0, then the carry is determined to be 0. If the sum is greater than 0 and less than or equal to the radix of the number representation, then the carry is determined to be 1. - If the sum is greater than the base of the number representation, then the carry is determined to be 2.

12. The device according to any one of claims 1 to 10, The processing device is configured such that the carry is determined to be 0, 1, or 2 by rounding based on the following formula: (C+Y+m)div W, in -m represents the number of words in the modulus N, and -W represents the radix of the numerical representation.

13. The device according to any one of claims 1 to 12, The processing device is configured to perform cryptographic operations, particularly encryption, decryption, signature creation and / or signature verification.

14. The device according to any one of claims 1 to 13, The processing apparatus includes one of the following or is designed as one of the following: -processor, -chip, - Cryptographic module.

15. A method for performing Montgomery reduction on an input C modulo N, particularly within the scope of Montgomery multiplication, the method comprising: - Perform multiplication based on the value D and the modulus N to obtain an approximate product Y. - Wherein, according to the incomplete implementation of the multiplication, only the higher-order parts of the approximate product Y are calculated and / or approximated. - wherein the value D is derived from the input C and the auxiliary number N' by Montgomery's subtraction. - The sum value is determined by adding the words or parts of the input C to the words or parts of the approximate product Y. - Determine the carry based on the sum. Add the carry to the input C or to the value derived from the input C.

16. The method according to claim 15, The value D is derived from the input C and the auxiliary number N' by a factor of 2. n It is derived from the modulo multiplication, where n is determined by the word width and word count of the numeric representation.

17. The method according to any one of claims 15 or 16, The approximate product Y or the value derived from the approximate product, the carry, and the input C or the value derived from the input are added together.

18. The method according to claim 17, The value Y' derived from the approximate product Y is determined according to the following formula: Y′=Y div W.

19. The method according to claim 17, The value Y” derived from the approximate product Y is determined according to the following formula: Y"=Y div W 2 。 20. The method according to any one of claims 15 to 19, The value C' derived from the input C is determined according to the following formula: C′=C div W m-1 。 21. The method according to any one of claims 15 to 19, The value C” derived from the input C is determined according to the following formula: C″=C div W m 。 22. The method according to any one of claims 15 to 21, The input C is the length to be reduced, which is determined by multiplying the lengths of the two numbers.

23. The method according to any one of claims 15 to 22, The auxiliary number N' is determined as follows: N′:=-N -1 nod W m 。 24. The method according to any one of claims 15 to 23, The carry is defined as 0, 1, or 2.

25. The method according to any one of claims 15 to 24, wherein - If the sum is equal to 0, then the carry is determined to be 0. If the sum is greater than 0 and less than or equal to the radix of the number representation, then the carry is determined to be 1. - If the sum is greater than the base of the number representation, then the carry is determined to be 2.

26. The method according to any one of claims 15 to 24, wherein the carry of 0, 1, or 2 is determined by rounding based on the following formula: (C+Y+m)div W, in -m represents the number of words in the modulus N, and -W represents the radix of the numerical representation.