The concept and principle of Montgomery algorithm

The Montgomery power model operation is an algorithm for fast calculation of a^b%k and is one of the cores of the RSA encryption algorithm.

The advantage of Montgomery modular multiplication is that it reduces the number of modulo times (in the case of large numbers) and simplifies the complexity of the division (division in the hexadecimal power of 2 requires only a left shift operation). The modular exponentiation is the core algorithm of RSA, which most directly determines the performance of the RSA algorithm.

For the topic of fast modular exponentiation, Western modern mathematicians have proposed a large number of solutions, usually converting power-module operations into multi-module operations.

Here is a summary of the essence of the entire Montgomery algorithm. The Montgomery algorithm is not an independent algorithm, but a collection of three independent and interconnected algorithms, including

Montgomery multiplication model is used to calculate xâ‹…y (mod N)

Montgomery is reduced to calculate t⋅ρ−1 (mod N)

Montgomery power model is used to calculate xy (mod N)

The Montgomery power multiplication is the core part of the RSA encryption algorithm.

basic concept

Combing several concepts and imagine that a set is obtained after the integer modulo N

ZN={0,1,2,⋯,N−1}

Note: N has lN bits in base-b. For example, decimal and 100, both belong to base-10, because 100=102, so b=10. In decimal, the set of lN=3 of 667 is called the remaining class ring of N, and any x belonging to this set Z satisfies the following two conditions:

Positive integer

2. The maximum length is lN

The Montgomery algorithm mentioned in this article is used to calculate the operation based on the ZN set. Let me briefly explain the reason, because RSA is based on large numbers, usually 1024bit or 2018bit, and our computer cannot store the complete large number because It takes up too much space and is not necessary. Therefore, this encryption system based on large numbers of operations is based on the ZN set in the calculation. Naturally, the Montgomery algorithm is also based on ZN.

On the remaining class rings, there are two important operations, one is simple operation, which is addition and subtraction, and the other is complex operation, which is multiplication. We are more familiar with the operations on the natural number set. Let's look at how to evolve from the operation of a natural number set to the operation of a residual class ring.

For addition, if x±y (mod N) (0≤x, y<N) is calculated, imagine x±y on the natural number set.

0≤x+y≤2⋅(N−1)

−(N−1)≤x−y≤(N−1) We can simply convert N from the natural number to the remaining set by adding or subtracting N

The other type is the multiplication operation, that is, x⋅y (mod N) (0≤x, y<N), then

0≤x⋅y≤(N−1)2 If under the natural number set, let t=x⋅y, then we need to calculate for modN

The t−(N⋅⌊t/N⌋) addition and subtraction operation is very simple. The specific calculation here is not elaborated. We use ZN−ADD to represent the addition operation on the remaining class rings. Since we can do addition operations, then we can extend to multiplication operations, the algorithm is as follows

The concept and principle of Montgomery algorithm

But this is not a good solution, because in general, we will not directly do the w-bit multi-bit operation, which will be replaced by Montgomery's multiplication instead.

For the modulo operation, there are generally the following methods

1, according to the following formula, to calculate the modulo operation

T−(N⋅⌊t/N⌋)

This solution has the following characteristics

The entire calculation process is based on a standard digital representation

No pre-calculation is required (that is, some variables are calculated in advance for use)

It involves a division operation, which is very time consuming and complicated

2, using the Barrett reducTIon algorithm, this article does not elaborate, but has the following characteristics

Standard-based digital representation

No pre-calculation required

Need 2â‹…(lN+1)â‹…(lN+1) times multiplication

3, with Montgomery reduction, which is the algorithm to be discussed below, has the following characteristics

Not based on a standard digital representation (mentioned later in the text, based on the Montgomery notation)

Need pre-calculation

Requires 2â‹…(lN)â‹…(lN) number multiplication

Boltless Commodity Racks

Boltless commodity racking is a type of racking that is usually assembled in a self-contained unit, without nut and bolt fasteners. The boltless shelving system is designed with a shelving unit that is easy to adjust and quick to assemble. Numerous types of boltless modular shelves are available with many different designs in assembly and basic structure, some of which rely on hardware and assembly methods to provide strength to the overall structure and simply hold the parts together. One of the most common types of boltless shelving is wire racks. At each corner of the shelf, a vertical metal cylinder is welded to the shelf structure. The legs of the device pass through these cylinders. Many restaurants, shops, garages, and warehouses have metal shelving. It is suitable for light to medium cargo, but not suitable for supporting very heavy loads.

Boltless Commodity Racks,Warehouse Storage Boltless Commodity Racks,Metal Boltless Commodity Racks,Adjustable Boltless Commodity Racks

Wuxi Lerin New Energy Technology Co.,Ltd. , https://www.lerin-tech.com