Background of the Invention
1. Field of the Invention
The present invent ion relates to a modulo reduction method using a precomputed table to increase a reduction speed by reducing the number of addition operations during the execution of ordinary operational processes using computers.
2. Description of the Prior Art
The recent increasing need for information protection has brought to us the need of implementation of a mechanism for information protection, whose characteristics requires modulo arithmetic of very large numbers. Particularly, the need of high speed modulo reduction algorithms has increased in proportion to the increasing need of involution operations.
Most information protection mechanisms need to be implemented on smart cards under various limited operational conditions, in terms of the size of the memory and the speed of processors, or the like, used on the smart cards.
For this reason, we can consider operational techniques, which use a precomputed table stored in an appropriate size of a memory, to convert all of the muliplications needed for reduction operations into additions. Conventional reduction techniques have drawbacks in that they require many operations and are not efficient.
Modulo arithmetic refers to an operation that obtains a remainder from the division of a number X, which is greater than N by N, for a given modulo N. Modulo arithmetic used in an information protection mechanism, where N is an ordinary number having more than 512 bits, which can not be handled at one time, requires a multi-precision operation.
The most essential part of a modulo operation method or algorithm is the part which performs the modulo arithmetic. There are, in general, two methods for performing a modulo reduction. One is a method that uses real division in performing a reduction, the other is the method that uses addition only, i.e., not division. The method that uses division does not need to use a precomputed table, while the method which does not use division needs a precomputed table.
Conventional modulo reduction algorithms using precomputed tables can be explained with references to FIG. 1, FIG. 2, and FIG. 3. as follows:
FIG. 1 shows a table configuration used in conventional modulo reduction algorithms; FIG. 2 illustrates a structure for inputting data into a modulo reduction algorithm; and FIG. 3 shows a flow of a modulo reduction algorithm using a table.
In this application, X represents an input (2.sup.n .ltoreq.X<2.sup.n +log.sub.2 t), X.sub.-- R an upper log.sub.2 t bit number of X, X.sub.-- R a lower n bit number of X and N also modulo, respectively.
The reference number 1, in FIG. 1, represents the ith content (1.ltoreq.i.ltoreq.t-1) stored in the table, the number 2, in FIG. 2, represents an upper (r-n) bit of the reference number, which consists of maximum r bits (n<r.ltoreq.n +log.sub.2 t), and is to be reduced, and the number 3 represents a lower n bits, which need not be reduced respectively, while the number 4, in FIG. 3, represents a modulo reduction process of a conventional algorithm, and the number 5 represents the checking of an overflow.
Letting N be an n bit number, an algorithm using the conventional table will operate as shown in FIG. 3. First, assume a number, which is constructed as shown in FIG. 2, is to be inputted. Let the inputted number be X where X can be divided such that X=X.sub.-- 0.multidot.2.sup.2 +X.sub.-- R, and with reference to the n bit, such that X(mod N)=(X.sub.-- 0.multidot.2 .sup.n (mod N)+X.sub.-- R)(mod N). Here, the results stored previously in the table , as shown in FIG. 1, can be searched for with an index of X.sub.-- 0.multidot.2.sup.n (mod N). The X.sub.-- 0.multidot.2.sup.n (mod N) found in this way can be added to X.sub.-- R to make a new X'. In this case, an overflow bit can occur in the (n+1)th bit, since X.sub.-- 0.multidot.2.sup.n (mod N) and X.sub.-- R are maximum n bit numbers respectively. If an overflow occurs, the above process will be repeated with the X' being inputted. If not, the reduction process will be finished. However, a subtraction may be needed after comparing the final result with N, since the final result can be greater than N, even though it has n bits.
As explained above, the Prior Art requires repetition of the reduction process, which refers to the table, when overflows occur. Since the maximum number of times an execution of the reduction process is not fixed, there exists a problem in that the reduction operation has to be executed many times.
Summary of the Invention
To provide a method which can increase the reduction speed by reducing the number of addition operations and, at the same time, the number of executions for an average addition operation, by fixing the number of addition operations at 2 times for one time of the execution of the reduction algorithm. The present invention comprises a first step, which searches out an index of an upper bit number and adds the value stored in the table to a lower bit number; a second step, which if the result obtained from the addition of said lower bit number to the number searched out from the table at said first step produces an overflow (1 bit), eliminates said overflow and finishes the execution of the operation; and a third step, which if said overlow does not occur at said second step, adds N on a modulo N to the result obtained form said first step and finishes the execution of the operation.
Brief Description of the Drawings
The above and other objects, features and advantages of the present invention will be more clearly understood from the following detailed description taken in conjunction with the accompanying drawings, in which:
FIG. 1 shows a table configuration used in conventional modulo reduction algorithms;
FIG. 2 illustrates a structure for inputting data into a modulo reduction algorithm;
FIG. 3 shows a flow of a modulo reduction algorithm using a table:
FIG. 4 shows the content stored in a table which is used in the present invention;
FIG. 5 shows an optimization process for the table shown in FIG. 4; and
FIG. 6 shows a configuration of the reduction algorithm proposed in the present invention.
Detailed Description of the Preferred Embodiments
FIG. 4 shows the content stored in a table which is used in the present invention. Index values range from 1 to t-1 (RT2[1] to RT2[t-1]), each content has n (e.g., n.gtoreq.512) bits. It should be noted that the value to be stored in an index i is (i+1).multidot.2.sup.n (mod N). Provided that n is 512 bits and t is 16 to 32 bits, the size of the table is about 1 kbytes to 2 kbytes. The reference number 6 represents the ith (1.ltoreq.i.ltoreq.t-1) content stored in the table, which is used in the reduction method or algorithm according to the present invention. The structure of the input data, which is used for the reduction algorithm proposed in the present invention, is the same as shown in FIG. 2, where X is composed of more than n bits and its maximum size is n+log.sub.2 t bits.
FIG. 5 shows an optimization of the table shown in FIG. 4. The optimization here involves a process where, if the content of the table is a number smaller than 2.sup.n -N, N is added to it, that is, a process for making an overflow occur faster by making MSB become 1, if possible. Adding N here does not induce any influence upon its results, according to the laws of modulo arithmetic and only makes the overflow occur faster.
In FIG. 5, the reference number 7 shows the process in which RT2[i]+N, is stored instead of RT2[i], when RT2[i]+N<2.sup.n.
FIG. 6 shows a flow chart of the reduction algorithm proposed in the present invention. In FIG. 6, the reference number 8 is a the first reduction process step of the reduction algorithm proposed in the present invention, reference number 9 is a step for checking whether an overflow occurs or not, and reference number 10 is a further the reduction process step, which comes after the first reduction process step 8.
First, in step 8 the value stored in the table needs to be searched for with an index of X.sub.-- O, which is an upper log.sub.2 t bit number, and then added to a lower n bit number. However, the stored value should be subtracted by 2.sup.n, since it is a value corresponding to a log.sub.2 t bit number +1. When the result of the adddition of the lower n bit number to the number searched for in the table has produced an overflow (1bit), the algorithm should be finished, since neglecting the overflow is the same as subtracting 2.sup.n.
If an overflow has not occured here (step 9), the algorithm should be finished, after adding N (step 10). The result should not be affected by adding N here, because its the same as adding 0 to (mod N). Adding N will produce an overflow, since the table is already optimized as described above. Therefore, the maximum number of operations in the proposed algorithm will not exceed 2 times.
<The first embodiment of the present invention>
The result of the comparison made by applying a conventional reduction algorithm and this reduction algorithm is as follows; The major operations of the reduction operation using the precomputed table are additions, and the times of the additions are compared in the following results.
[1]the results producing and testing 300random moduli Ns
(1) probability that the proposed algorithm is superior to the conventional one: 76%(228 times/300 times)
Note-1:B=A(mod N) in this operation
2:A is the random number of 1024 bits, and N is the random number of 512 bits.
3:B=A(mod N) is operated by 100 times for one N
4:the number of table contents is 32
(2) the number of addition operations used at one time in the reduction operation when this algorithm is superior to the conventional one: 134.32 additions/reduction
(3) the number of addition operations used at one time in the reduction operation when the conventional is superior to this: 137.53 additions/reduction
In table, "*" means the case where the conventional method is superior.
<The analysis of the results>
In the case where both the conventional reduction algorithm and the reduction algorithm, of the present invention, have table contents of 32, and are executed at their fastest speed, the number of addition operations will be 103 in reduction of a 1024 bit number. ##EQU1## From the above results, there is a 76% probability that the proposed algorithm is superior to the conventional one for an arbitrary N. Also, in the case where the conventional one is better, an average of 137.53 additions are required.
<The second embodiment of the present invention>
The second embodiment of the present invention is the result of the execution of 10,000 reductions for a fixed N. The proposed algorithm needed 1,268,663 addition operations for the execution of 10,000 reductions, while the conventional algorithm needed 1,315,858 addition operations for the execution of 10,000 reductions.
<The analysis of the results>
In the case where both the conventional reduction algorithm and the reduction algorithm, of the present invention, are executed at their fastest speeds, the number of n bit addition operations will be 1 when the reduction algorithm is being called up one time. Accordingly, more than 10,300 n bit addition operations will be executed, since calling up the reduction algorithm for each number of the embodiment of the present invention is 10,3000 times.
The embodiment of the present invention shows the superiority of the algorithm of the present invention for most of the N's produced arbitrarily.
Once N has been determined, it will be used characteristically for a considerable amount of time. N will be replaced only when N is the product of two prime numbers, which are more than 256 bits, and when the information on the prime factor resolution of N is known. However, if N is more than 512 bits, N would be considered safe and not have to be replaced periodically.
76% is the probability that the proposed algorithm is superior to the conventional one for an arbitrary N. Accordingly, it can be safely said that the proposed algorithm is better than the conventional one.
The above second embodiment is the result of the execution of 10,000 reductions for any fixed N. It has been proven that for such fixed N one of the two algorithm is faster than the other for almost all cases.
As mentioned above, the present invention has an advantage of executing reduction operations at a higher speed, in comparison to a conventional reduction algorithm using the same size precomputed table, as the conventional one, by reducing the number of addition operations during a modulo reduction operation.
Although the preferred embodiments of the present invention have been disclosed for illustrative purpose, those skilled in the art will appreciate that various modifications, additions and substitutions are possible, without departing from the scope and spirit of the invention as disclosed in the accompanying claims.