JP2003233309A - Greatest common divisor arithmetic unit, inverse element arithmetic unit, arithmetic program recording medium - Google Patents

Greatest common divisor arithmetic unit, inverse element arithmetic unit, arithmetic program recording medium

Info

Publication number
JP2003233309A
JP2003233309A JP2002356532A JP2002356532A JP2003233309A JP 2003233309 A JP2003233309 A JP 2003233309A JP 2002356532 A JP2002356532 A JP 2002356532A JP 2002356532 A JP2002356532 A JP 2002356532A JP 2003233309 A JP2003233309 A JP 2003233309A
Authority
JP
Japan
Prior art keywords
gcd
arithmetic
extended
calculation
bit
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
JP2002356532A
Other languages
Japanese (ja)
Other versions
JP3673785B2 (en
Inventor
Tetsutaro Kobayashi
鉄太郎 小林
Hikari Morita
光 森田
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nippon Telegraph and Telephone Corp
Original Assignee
Nippon Telegraph and Telephone Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nippon Telegraph and Telephone Corp filed Critical Nippon Telegraph and Telephone Corp
Priority to JP2002356532A priority Critical patent/JP3673785B2/en
Publication of JP2003233309A publication Critical patent/JP2003233309A/en
Application granted granted Critical
Publication of JP3673785B2 publication Critical patent/JP3673785B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Landscapes

  • Complex Calculations (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To decrease the number of times of an arithmetic operation by realizing binary gcd calculation based upon arithmetic bit units (w) of a computer. <P>SOLUTION: For inputs X and Y, gcd(X, Y)=gcd(U<SB>0</SB>, V<SB>0</SB>)2<SP>z0</SP>and such U<SB>0</SB>and V<SB>0</SB>that gcd (U<SB>0</SB>, V<SB>0</SB>) is not divisible by 2 are initially computed (S1) and it is judged whether U<SB>0</SB>=1 or whether V<SB>0</SB>=1; when neither one is 1, a value (i) having a larger bit size between U<SB>0</SB>and V<SB>0</SB>is found (S3). Then it is judged whether i≤w and when (i) is larger than (w), u<SB>u</SB>, u<SB>v</SB>, v<SB>v</SB>, and v<SB>u</SB>satisfying gcd (|u<SB>u</SB>U<SB>0</SB>-u<SB>v</SB>V<SB>0</SB>|/2<SP>w</SP>' and |u<SB>v</SB>V<SB>0</SB>-v<SB>u</SB>U<SB>0</SB>|/2<SP>w</SP>') are computed (S5) and then U<SB>1</SB>=|u<SB>u</SB>U<SB>0</SB>-u<SB>v</SB>V<SB>0</SB>|/2<SP>w</SP>' and V<SB>1</SB>=|v<SB>v</SB>V<SB>0</SB>-v<SB>u</SB>U<SB>0</SB>|/2<SP>w</SP>' are found to let U<SB>1</SB>→U<SB>0</SB>and V<SB>1</SB>→V<SB>0</SB>(S6); and it is judged whether V<SB>0</SB>=0 and when not, a return to the step (S3) is made. When V<SB>0</SB>=0, gcd is found as to U<SB>0</SB>and V<SB>0</SB>and multiplied by 2<SP>z0</SP>and outputted. <P>COPYRIGHT: (C)2003,JPO

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【発明の属する技術分野】この発明は、有限体上の演算
に関し、特に誤り訂正符号(代数幾何符号など)や情報
セキュリティ技術(暗号鍵生成、ディジタル署名、ブラ
インド署名、楕円暗号など)を実現するために用いられ
る最大公約数演算装置、剰余逆元演算、演算装置、及び
そのプログラム記録媒体に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to operations on finite fields, and particularly realizes error correction codes (algebraic geometric codes, etc.) and information security technologies (encryption key generation, digital signatures, blind signatures, elliptic codes, etc.). The present invention relates to a greatest common divisor arithmetic device, a remainder inverse element arithmetic device, an arithmetic device, and a program recording medium thereof.

【0002】[0002]

【従来の技術】最大公約数(gcd)を求める方法とし
て、(1) Euclidの互除法、(2) 2進gcd算法、(3) 算
法Lが知られている。算法Lは大きい数に対するEuclid
の互除法を効率化した方法である。 (1) Euclidの互除法 Euclidの互除法は Xi= QiYi+ Ri (1) としたときに、 gcd(Xi,Yi)= gcd(Yi,Ri) (2) が成り立っていることを利用する。 Xi+1= Yi, Yi+1= Ri (3) として、式(1)を繰り返し適用して、X0,Y0からXi,Yi
を求め、式(2)を用いて、 gcd(X0,Y0)= gcd(X1,Y1)=…= gcd(Xj,0)=Xj (4) であることから、 gcd(X0,Y0)を求めることが出来る。
(文献「D.E.Knuth(中川桂介訳):“準数値算法/算
術演算(THE ART OF COMPUTER PROGRAMMING 第4分
冊)”pp.157,算法A,サイエンス社,1986」を参
照) 具体例をあげる。Euclidの互除法では、整数 X0 =24, Y0 =9 に対して、以下のような演算を行なう。 X1 ← Y0=9, Y1 ← X0 mod Y0=6 X2 ← Y1=6, Y2 ← X1 mod Y1=3 X3 ← Y2=3, Y3 ← X2 mod Y2=0 この結果、 gcd(X0,Y0)=gcd(X3,Y3)=gcd(3,0)=3
が求まる。Euclidの互除法を行なう装置は、除算装置と
減算装置の組合せによって構成することができる。
2. Description of the Related Art As methods for obtaining the greatest common divisor (gcd), (1) Euclid's mutual division method, (2) binary gcd arithmetic method, and (3) arithmetic method L are known. Algorithm L is Euclid for large numbers
It is a method in which the mutual division method of is efficient. (1) Euclid's mutual division method Euclid's mutual division method is gcd (X i , Y i ) = gcd (Y i , R i ) (2) when X i = Q i Y i + R i (1) We use the fact that X i + 1 = Y i , Y i + 1 = R i (3), and the formula (1) is repeatedly applied to obtain X 0 , Y 0 to X i , Y i.
And gcd (X 0 , Y 0 ) = gcd (X 1 , Y 1 ) = ・ ・ ・ = gcd (X j , 0) = X j (4) by using equation (2) (X 0 , Y 0 ) can be obtained.
(See the document “DEKnuth (Translated by Keisuke Nakagawa):“ Quasi-Numerical Arithmetic / Arithmetic Operation (THE ART OF COMPUTER PROGRAMMING 4th Volume) ”pp. 157, Arithmetic A, Science Co., 1986”). In the Euclid mutual division method, the following operations are performed on integers X 0 = 24 and Y 0 = 9. X 1 ← Y 0 = 9, Y 1 ← X 0 mod Y 0 = 6 X 2 ← Y 1 = 6, Y 2 ← X 1 mod Y 1 = 3 X 3 ← Y 2 = 3, Y 3 ← X 2 mod Y 2 = 0 As a result, gcd (X 0 , Y 0 ) = gcd (X 3 , Y 3 ) = gcd (3, 0) = 3
Is required. The Euclid mutual division apparatus can be configured by a combination of a division apparatus and a subtraction apparatus.

【0003】(2) 2進gcd算法 2進gcd算法は、 Xが奇数、Yが偶数のとき: gcd(X,Y)=gcd(X,Y/2)
Xが偶数、Yが奇数のとき: gcd(X,Y)=gcd(X/2,Y)
Xが奇数、Yが奇数のとき: gcd(X,Y)=gcd(X,Y−
X) Xが偶数、Yが偶数のとき: gcd(X,Y)=2gcd(X/2,Y
/2) が成り立っていることを利用してgcdを求める方法で
ある。即ち、Xi,Yiのいずれかが奇数であるときに、次
の処理、 (A) Xiが奇数、Yiが偶数のとき: Xi+1←Xi; Yi+1
←Yi/2 (B) Xiが偶数、Yiが奇数のとき: Xi+1←Xi/2; Yi+1
←Yi (C) Xiが奇数、Yiが奇数のとき: Xi+1←Xi; Yi+1
←Xi−Yi を行うことにより得られるXi+1,Yi+1について次式、 gcd(Xi+1,Yi+1)= gcd(Xi,Yi) (5) が成り立っていることを利用する。上記処理(A), (B)
及び(C) を繰り返し適用して、X0,Y0からXi,Yiを求
め、式(5)を用いて、 gcd(X0,Y0)=gcd(X1,Y1)=…=gcd(Xj,0)=Xj であることから、 gcd(X0,Y0)を求めることが出来る。
(文献「D.E.Knuth(中川桂介訳):“準数値算法/算
術演算(THE ART OF COMPUTER PROGRAMMING 第4分
冊)”pp.158,算法B,サイエンス社,1986」を参
照) 具体例をあげる。2進gcd 算法では、整数 X0=24, Y0=9 に対して、以下のような演算を行なう。 X1 ← X0/23=3; Y1 ← Y0=9 X2 ← X1=3; Y2 ← (Y1−X1)/2=3 X3 ← X2=3; Y3 ← (Y2−X2)/2=0 この結果、 gcd(X0,Y0)=gcd(X3,Y3)=gcd(3,0)=3
が求まる。
(2) Binary gcd algorithm The binary gcd algorithm is: when X is an odd number and Y is an even number: gcd (X, Y) = gcd (X, Y / 2)
When X is even and Y is odd: gcd (X, Y) = gcd (X / 2, Y)
When X is odd and Y is odd: gcd (X, Y) = gcd (X, Y−
X) When X is an even number and Y is an even number: gcd (X, Y) = 2gcd (X / 2, Y
/ 2) is a method to obtain gcd by utilizing the fact that That is, when either X i or Y i is an odd number, the following processing is performed. (A) When X i is an odd number and Y i is an even number: X i + 1 ← X i ; Y i + 1
← Y i / 2 (B) When X i is even and Y i is odd: X i + 1 ← X i / 2; Y i + 1
← Y i (C) When X i is odd and Y i is odd: X i + 1 ← X i ; Y i + 1
← For X i + 1 and Y i + 1 obtained by performing X i −Y i , the following equation, gcd (X i + 1 , Y i + 1 ) = gcd (X i , Y i ) (5) Take advantage of what is made up. Above processing (A), (B)
And (C) are repeatedly applied to obtain X i and Y i from X 0 and Y 0 , and gcd (X 0 , Y 0 ) = gcd (X 1 , Y 1 ) = Since == gcd (X j , 0) = X j , gcd (X 0 , Y 0 ) can be obtained.
(See the document “DEKnuth (Translated by Keisuke Nakagawa):“ Quasi-Numerical Arithmetic / Arithmetic Operation (THE ART OF COMPUTER PROGRAMMING 4th Volume) ”pp. 158, Arithmetic B, Science Co., 1986”). In the binary gcd arithmetic method, the following operations are performed on integers X 0 = 24 and Y 0 = 9. X 1 ← X 0/2 3 = 3; Y 1 ← Y 0 = 9 X 2 ← X 1 = 3; Y 2 ← (Y 1 −X 1 ) / 2 = 3 X 3 ← X 2 = 3; Y 3 ← (Y 2 −X 2 ) / 2 = 0 As a result, gcd (X 0 , Y 0 ) = gcd (X 3 , Y 3 ) = gcd (3, 0) = 3
Is required.

【0004】2進 gcd算法は、例えば図1に示すような
処理で実現できる。この例では入力X,Yに対応して変
数U,Vを使用して以下のように処理を行う。 ステップS1: X,Yをそれぞれ初期値としてU,V
に設定し、シフト計数zに初期値1を設定する。 ステップS2: U,Vが共に偶数か判定する、即ち、
最下位ビットが"0" であるか判定する。 ステップS3: U,Vが共に偶数の場合、U/2,V/2を
それぞれU,Vに設定してシフト計数を2倍(1ビット
シフト)し、ステップS2に戻る。 ステップS4: Vが偶数であるか判定する。 ステップS5: Vが偶数の場合、V/2 をVに設定して
ステップS4に戻る。 ステップS6: Vが奇数の場合、Uが偶数であるか判
定する。 ステップS7: Uが偶数の場合、U/2 をUに設定して
ステップS6に戻る。 ステップS8: U,Vが共に奇数の場合、U>V である
か判定する。 ステップS9: U>Vの場合、(U-V)/2 をVに設定して
ステップS4に戻る。 ステップS10: U≦Vの場合、(V-U)/2 をVに設定す
る。 ステップS11: V=0か判定し、0でなければステッ
プS4に戻る。 ステップS12: V=0であればU×zをgcd(X, Y) の演
算結果として出力する。
The binary gcd arithmetic method can be realized by a process as shown in FIG. 1, for example. In this example, the processing is performed as follows using the variables U and V corresponding to the inputs X and Y. Step S1: U and V with X and Y as initial values respectively
And the initial value 1 is set to the shift count z. Step S2: It is determined whether both U and V are even, that is,
Determine if the least significant bit is "0". Step S3: When both U and V are even numbers, U / 2 and V / 2 are set to U and V, respectively, and the shift count is doubled (1 bit shift), and the process returns to step S2. Step S4: It is determined whether V is an even number. Step S5: If V is an even number, set V / 2 to V and return to step S4. Step S6: When V is an odd number, it is determined whether U is an even number. Step S7: If U is an even number, set U / 2 to U and return to step S6. Step S8: When both U and V are odd numbers, it is determined whether U> V. Step S9: If U> V, set (UV) / 2 to V and return to step S4. Step S10: If U ≦ V, set (VU) / 2 to V. Step S11: It is determined whether V = 0, and if it is not 0, the process returns to step S4. Step S12: If V = 0, U × z is output as the calculation result of gcd (X, Y).

【0005】2進 gcd算法を行なう装置は、2による除
算と減算のみで構成することができる。2による乗除算
は1ビットシフトと等価であるため、電子回路や電子計
算機で実装しやすいという利点がある。上記Euclidの互
除法、2進gcd算法では、入力値X,Yが大きい整数
の場合、大きい整数のビットシフトや減算、除算を複数
回行なう。例えば、512 ビットで表すことができる整数
X,Yに対し、2進gcd算法を行なう場合を考える。
2進gcd算法のループ回数kは入力値のサイズからそ
の2倍(この場合は512 〜1024回)となり、k回のビッ
トシフトと、最大k回(平均k/2 回)の減算を行う(図
1のステップS9又はS10に対応)。また、1回のビ
ットシフト及び加減算にかかる時間も演算する値(この
場合はU,V)のビットサイズに比例して大きくなる。
このため、大きい整数の演算の回数を減らすことがgc
d演算の高速化につながる。大きい整数の演算の回数を
減らすための方法のひとつに、以下に説明する疑似算法
を利用する演算方法がある。これは、ループ中で、大き
い整数を使った演算をする代わりに、小さい整数を使っ
た演算により疑似的にgcd算法を行ない、その後疑似
算法で得られた値を用いて、大きい整数の演算をまとめ
て行なう方法である。
An apparatus for performing the binary gcd arithmetic can be configured only by division by 2 and subtraction. Since multiplication and division by 2 is equivalent to 1-bit shift, there is an advantage that it can be easily implemented in an electronic circuit or computer. In the Euclid mutual division method and the binary gcd arithmetic method, when the input values X and Y are large integers, the large integers are bit-shifted, subtracted, and divided a plurality of times. For example, consider the case of performing binary gcd arithmetic on integers X and Y that can be represented by 512 bits.
The number of loops k of the binary gcd algorithm is twice the size of the input value (512 to 1024 times in this case), and k bit shifts and maximum k times (average k / 2 times) are subtracted ( (Corresponding to step S9 or S10 in FIG. 1). Further, the time required for one bit shift and addition / subtraction also increases in proportion to the bit size of the calculated value (U, V in this case).
For this reason, it is possible to reduce the number of times a large integer is calculated.
This leads to faster d-calculation. One of the methods for reducing the number of operations on a large integer is an operation method using the pseudo-calculation method described below. This is to perform a pseudo gcd arithmetic method by an operation using a small integer instead of performing an operation using a large integer in a loop, and then use a value obtained by the pseudo arithmetic method to perform an operation on a large integer. It is a method to carry out collectively.

【0006】(3) 算法L 従来、Euclidの互除法に対して、疑似算法を適用した方
法があった。(例えば文献「D.E.Knuth(中川桂介
訳):“準数値算法/算術演算(THE ART OF COMPUTER
PROGRAMMING 第4分冊)”pp.166,算法L,サイエン
ス社,1986」を参照) 具体例をあげる。算法Lでは、大きい整数 X0 =91234567890123456789 Y0 =2000000000000000001 に対し、それらの上位例えば4桁の値と、それらの4桁
の値に1をそれぞれ加算した値を以下のように小さい整
数 x00 =9123 x10 =9124 y00 =2000 y10 =2001 として決める。 Xi+1 =Yi; Yi+1 =XimodYi x0i+1 =y1i; y1i+1 =x0imody1i x1i+1 =y0i; y0i+1 =x1imody0i とすると、 x0i/y1i < Xi/Yi < x1i/y0i (6) が成り立つ。算法Lでは、Xi,Yiを用いてEuclidの互除
法を行うのではなく、x0 i,y1i,x1i,y0iを用いてEucl
idの互除法を行う。即ち、式(6)の右辺と左辺の整数部
分の値が同じである間だけ小さい整数x0i,y1i,x1i,y
0iを求める。これを疑似演算と呼ぶ。その後に、疑似演
算により得られた値を用いて大きい整数Xi,Yiの演算を
行なう。これにより、大きい整数の演算をまとめて行な
うことと同等の効果を得ることができる(例えば、x
0i,x1i,y0i,y1iが10桁の場合、約12回分の演算
を1度にまとめることができる)。また、この方法を2
進gcd算法へ適用することも可能である。
(3)Algorithm L Those who have applied pseudo arithmetic to Euclid's mutual division method
There was a law. (For example, the document “D.E.Knuth (Keisuke Nakagawa
Translated by: "The quasi-numerical method / arithmetic operation (THE ART OF COMPUTER
PROGRAMMING 4th volume) ”pp.166, Algorithm L, Cayenne
S., 1986 ") Here is a specific example. In arithmetic L, a large integer X0= 91234567890123456789 Y0= 2000000000000000001 For example, the upper 4 of them and their 4 digits
The value obtained by adding 1 to the value of
number x00= 9123 x10= 9124 y00= 2000 y10= 2001 Decide as. Xi + 1= Yi; Yi + 1= XimodYi x0i + 1= Y1i; Y1i + 1= X0imody1i x1i + 1= Y0i; Y0i + 1= X1imody0i Then,       x0i/ y1i<Xi/ Yi<X1i/ y0i                      (6) Holds. In arithmetic L, Xi, YiUsing Euclid to divide
X0 instead of doing the law i, Y1i, X1i, Y0iWith Eucl
Perform id division method. That is, the integer parts on the right and left sides of equation (6)
An integer x0 that is small as long as the minutes have the same valuei, Y1i, X1i, Y
0iAsk for. This is called a pseudo operation. After that, the performance
A large integer X using the value obtained by arithmetici, YiCalculation of
To do. This allows large integer operations to be performed together.
You can get the same effect as saying (for example, x
0i, X1i, Y0i, Y1iIf is 10 digits, calculation of about 12 times
Can be summarized at once). In addition, this method
It is also possible to apply to the base gcd algorithm.

【0007】[0007]

【発明が解決しようとする課題】算法Lの問題点は、疑
似演算において、x0i,y1iをもちいたEuclidの互除法と
x1i,y0iをもちいたEuclidの互除法を両方とも行なう必
要があることと、一度にまとめることが出来る演算の回
数がその時によって異なることである。通常の計算機は
Mビット(Mは8、16、32等)の単位で読み書き可
能な記憶装置を有している(条件1)。このことから、
Mビット単位で演算を行なうと効率が良い。例えば、2
進gcd算法では、大きい整数の1ビットシフトを行な
っている。しかし、条件1の下では、1ビットのシフト
はMビットまとめてシフトを行なうのと同じか、より多
くのコストがかかる。更に、現代の計算機はMビット
(Mは8、16、32等)のシフタ、加減算器、乗算器
などを有している(条件2)。この場合は、Mビット未
満の演算を1回行なうのと、Mビットの演算を1回行な
うのは同じ時間がかかる。このことから、Mビット単位
で演算を行なうのが効率が良い。一方、算法Lでは、ま
とめて行なえる演算のビット数がその時によって変わっ
てしまうため、まとめ演算のメリット(効果)が減って
しまう。
The problem of the algorithm L is that the Euclid's mutual division method using x0 i and y1 i is used in the pseudo operation.
It is necessary to perform both Euclid's mutual division methods using x1 i and y0 i, and the number of operations that can be combined at one time varies. An ordinary computer has a readable / writable storage device in units of M bits (M is 8, 16, 32, etc.) (condition 1). From this,
It is efficient to perform the operation in units of M bits. For example, 2
In the base gcd arithmetic method, a large integer is shifted by 1 bit. However, under condition 1, a shift of 1 bit is the same as or more costly to shift M bits at a time. Furthermore, modern computers have M-bit (M is 8, 16, 32, etc.) shifters, adder-subtractors, multipliers, and the like (condition 2). In this case, it takes the same time to perform an operation of less than M bits once and an operation of M bits once. For this reason, it is efficient to perform the operation in units of M bits. On the other hand, in the arithmetic method L, the number of bits of the calculation that can be performed collectively changes depending on the time, so that the merit (effect) of the collective calculation decreases.

【0008】[0008]

【課題を解決するための手段】この発明では2進gcd
算法に対して疑似算法を用いるが、以下に詳細に説明す
るように誤差範囲を求めないで実現する。算法Lでは、
Xi,Yiの代わりに、小さい整数x0i,x1i,y0i,y1iを用
いて疑似演算を行なう。x0iとx1iがそれぞれXiの取り得
る値の下限と上限とを代表し、y0 iとy1iがそれぞれYi
取り得る値の下限と上限とを代表する。上限と下限の差
(誤差範囲)がある程度開くまで疑似演算を続ける。こ
の発明では、Xiの値を代表する小さい整数を、上限と下
限の中間の値xa のみにする。また、誤差範囲を求め
ず、予め定められた回数w'回の疑似演算を行なう。
In the present invention, the binary gcd is used.
A pseudo algorithm is used for the algorithm, which will be described in detail below.
It is realized without calculating the error range. In algorithm L,
Xi, YiInstead of a small integer x0i, X1i, Y0i, Y1iFor
And perform a pseudo operation. x0iAnd x1iRespectively XiProfitable
Represents the lower and upper limits of the value iAnd y1iIs Yiof
It represents the lower and upper limits of possible values. The difference between the upper and lower limits
Pseudo operation is continued until (error range) opens to some extent. This
Invention, XiA small integer representing the value of
The middle value of the limit xaOnly Also, calculate the error range
Instead, the pseudo operation is performed a predetermined number of times w '.

【0009】これによる利点は2つある。 (1) 誤差範囲を用いる方法に比べ、一度に多くの疑似演
算を行なえるため、多倍長の演算の回数が減る。 (2) 一定の値w'ビットのシフト演算を行なうことができ
る。 これらによって2進gcd算法の高速化を可能にする。
算法LはEuclid互除法や2進gcd演算法の動作と同等
の演算を行なうが、この発明では、同等の動作をしない
場合もある。例えば、2進gcd演算法では、ループ中
でUとVの大小比較を行なう。U,Vの値が離れていれ
ば、上位数桁のみを見ることによって大小比較が出来
る。ところが、U,Vの値が近い場合には、U,Vの演
算のシミュレートを行なっている小さい整数ua,v
a(U,Vの上位数桁に相当する)だけではどちらが大
きいか判別不能な場合がある。このような場合、算法L
では一度疑似演算を終了し、U,Vの値を計算しなおし
てから大小判定をしていた。この発明では、その場合で
も疑似演算を続行する。従って、この発明では大小関係
を誤る場合もある。大小関係を誤ると、U,Vが負の値
になる(算法Lではそういうことは起こらない)。しか
し、gcd(U,V)=gcd(|U|,|V|)とすることによっ
て、この発明が誤った答えが出力されることを防いでい
る。これにより、この発明は算法Lよりも一度にまとめ
る演算数を増やし、多倍長の演算の回数を減らした。ま
た、この発明は予め決められたビット数(w'ビット)ず
つの演算を行なうことが可能となる。
There are two advantages to this. (1) Compared with the method using the error range, many pseudo operations can be performed at one time, and the number of operations of multiple precision is reduced. (2) A fixed value w'bit shift operation can be performed. These enable speeding up of the binary gcd algorithm.
The algorithm L performs the same operation as the operation of the Euclid mutual division method or the binary gcd operation method, but in the present invention, the same operation may not be performed. For example, in the binary gcd arithmetic method, the magnitude of U and V is compared in a loop. If the U and V values are far apart, the magnitude comparison can be made by looking only at the upper few digits. However, when the values of U and V are close to each other, a small integer u a , v that simulates the operation of U and V.
It may not be possible to determine which is larger only by a (corresponding to the upper digits of U and V). In such cases, the algorithm L
Then, the pseudo operation was once ended, the values of U and V were recalculated, and then the magnitude was judged. In the present invention, the pseudo operation is continued even in that case. Therefore, in the present invention, the magnitude relationship may be erroneous. If the magnitude relation is wrong, U and V will take negative values (these cases do not occur in the algorithm L). However, by setting gcd (U, V) = gcd (| U |, | V |), the present invention prevents an incorrect answer from being output. As a result, the present invention increases the number of operations to be put together at one time and reduces the number of multiple precision operations, as compared with the algorithm L. Further, according to the present invention, it is possible to perform an operation for each predetermined number of bits (w 'bits).

【0010】gcd演算アルゴリズム 以下にこの発明による拡張2進gcd演算装置の理解を
容易にするため、まずこの発明の原理を通常の2進gc
d演算に適用した場合のアルゴリズムを示す。 ステップS1(多倍長値初期設定): U←Y;V←X;S←0;T←1。 ステップS2(単精度値初期設定): i←max(Vのサイズ;Uのサイズ) va←Vの上位wビット;ua←Uの上位wビット vx←Vの下位wビット;ux←Uの下位wビット
Gcd arithmetic algorithm In order to facilitate understanding of the extended binary gcd arithmetic device according to the present invention, first, the principle of the present invention will be described with reference to a normal binary gc arithmetic device.
The algorithm when applied to d operation is shown. Step S1 (initial setting of multiple length value): U ← Y; V ← X; S ← 0; T ← 1. Step S2 (initial setting of single precision value): i ← max (size of V; size of U) v a ← upper w bit of V; u a ← upper w bit of U v x ← lower w bit of V; u x ← Lower w bit of U

【数1】 もしi≦wならばステップS5へ。 ステップS3(単精度演算ループ): 以下をw回繰り
返す: (1) uxが偶数ならば
[Equation 1] If i ≦ w, go to step S5. Step S3 (single precision operation loop): The following is repeated w times: (1) If u x is an even number

【数2】 (2) vxが偶数ならば[Equation 2] (2) If v x is even

【数3】 (3) vx, ux が奇数かつua>vaならば[Equation 3] (3) If v x , u x are odd and u a > v a

【数4】 (4) vx, ux が奇数かつua≦vaならば[Equation 4] (4) If v x , u x are odd and u a ≤ v a

【数5】 ステップS4(多倍長値再計算):[Equation 5] Step S4 (multi-precision value recalculation):

【数6】 U ← |U'|/2w; V ←|V'|/2w もしV=0ならばステップS5へ、それ以外はステップS
2へ。 ステップS5(最終処理演算): V=0ならば Uを出力。 V≠0ならば gcd(U, V)を求めて出力(単精度wビット
以下の演算) 上記アルゴリズムの妥当性 命題1:上記アルゴリズムが終了すれば、gcd(X, Y)を
出力する。 証明:上記アルゴリズムでは常にgcd(U, V)=gcd(X, Y)
が成り立っている。 これを帰納法により証明する。
[Equation 6] U ← | U '| / 2 w ; V ← | V' | / 2 w If V = 0, go to step S5; otherwise, go to step S5.
Go to 2. Step S5 (final processing calculation): If V = 0, output U. If V ≠ 0, gcd (U, V) is obtained and output (operation with single precision w bits or less) Proposition of validity of the above algorithm Proposition 1: When the above algorithm ends, gcd (X, Y) is output. Proof: gcd (U, V) = gcd (X, Y) always in the above algorithm
Is established. We will prove this by induction.

【0011】1.ステップS1ではU=X,V=Yであるか
ら、gcd(U, V)=gcd(X, Y)が成り立つ。 2.ステップS3及びS4では Uが偶数の場合:U←U/2 Vが偶数の場合:V←V/2 U, V が共に奇数でU>Vの場合:U←(U-V)/2 U, V が共に奇数でU≦Vの場合:V←(V-U)/2 のうちのいずれかに相当する演算が行われる。即ち、ス
テップS3開始時にgcd(U, V)=gcd(X, Y)ならば、ステ
ップS4終了時にもgcd(U,V)=gcd(X, Y)が成り立って
いる。ただし、ここではgcd(U, V)=gcd(|U|, |V|)
とする。上記1、2より、上記アルゴリズムが終了すれ
ばgcd(X, Y)を出力する。上記アルゴリズム終了の根拠 命題2:w≧4ならば上記アルゴリズムは有限時間で終
了する。 証明:上記ステップS2の時点でのU,Vの値をU0, V0
とし、ステップS4において再計算されるU,VをU1,
V1とする。このとき、 U0+V0>U1+V1 を示せばよい。上記アルゴリズム中でU+Vは単調減少と
なり、U+V<2wとなった時点でステップS5が実行さ
れ、終了する。発明者は上記式が成り立つことを証明す
ることができるが、ここでは省略する。
1. In step S1, since U = X and V = Y, gcd (U, V) = gcd (X, Y) holds. 2. In steps S3 and S4, if U is even: U ← U / 2 If V is even: V ← V / 2 If both U and V are odd and U> V: U ← (UV) / 2 U, V If both are odd and U ≦ V: An operation corresponding to one of V ← (VU) / 2 is performed. That is, if gcd (U, V) = gcd (X, Y) at the start of step S3, gcd (U, V) = gcd (X, Y) holds at the end of step S4. However, here gcd (U, V) = gcd (| U |, | V |)
And From the above 1 and 2, gcd (X, Y) is output when the above algorithm is completed. Grounds for ending the above algorithm Proposition 2: If w ≧ 4, the above algorithm ends in a finite time. Proof: The values of U and V at the time of step S2 are U 0 and V 0
And U and V recalculated in step S4 are U 1 ,
V 1 At this time, it is sufficient to show U 0 + V 0 > U 1 + V 1 . In the above algorithm, U + V monotonically decreases, and when U + V <2 w , step S5 is executed and the process ends. The inventor can prove that the above equation holds, but it is omitted here.

【0012】[0012]

【発明の実施の形態】gcd演算装置 図2及び図3を参照してgcd演算装置1000を説明す
る。この装置1000は入力部101によりX,Yが入力さ
れ、出力部102からgcd(X, Y) を出力する装置であっ
て、gcd演算初期設定部110と、gcd演算疑似演
算部120と、gcd演算多倍長演算部130と、gc
d演算最終演算部140と制御装置150と、記憶手段
160とを備え、以下のように演算が実行される。 ステップS1: gcd演算初期設定部110は、入力
X,Yに対して gcd(X,Y)=2Z0gcd(U,V) (7) を満たすU,V,z0のうち、z0が最大となるものを求
め、その時のU,VをそれぞれU0,V0として、制御装置
150へ渡し、制御装置150を介してz0をgcd演算
最終処理部140へ渡す。 ステップS2: 制御装置150は、入力U0,V0に対
し、U0=1又はV0=1であるかどうかを検査する。検査に合
格した場合、即ち、U0=1又はV0=1の場合は、gcd演算
最終処理部140にU0,V0を渡す。 ステップS3: そうでない場合、制御装置150は、
入力U0,V0に対し、そのビットサイズの大きい方の値i
を求める。 ステップS4: ビットサイズiがwビット以下である
かどうかを検査する。検査に合格した場合は、gcd演
算最終処理部140にU0,V0を渡す。ビットサイズiが
w以下でなかった場合は、 va=V0の上位wビット(第iビット目から第i-w+1ビッ
ト目まで) ua=U0の上位wビット(第iビット目から第i-w+1ビッ
ト目まで) vx=V0の下位wビット ux=U0の下位wビット の各値をgcd演算疑似演算部120へ渡し、U0,V0
gcd演算多倍長演算部130へ渡す。
BEST MODE FOR CARRYING OUT THE INVENTION gcd arithmetic unit A gcd arithmetic unit 1000 will be described with reference to FIGS. 2 and 3. This device 1000 is a device for inputting X and Y from the input unit 101 and outputting gcd (X, Y) from the output unit 102. The device 1000 includes a gcd calculation initial setting unit 110, a gcd calculation pseudo calculation unit 120, and a gcd calculation pseudo calculation unit 120. Multiplication arithmetic unit 130, gc
The d operation final operation unit 140, the control device 150, and the storage unit 160 are provided, and the operation is performed as follows. Step S1: gcd calculation initial setting unit 110, input X, Y relative gcd (X, Y) = 2 Z0 gcd (U, V) U satisfying (7), V, of the z 0, the z 0 The maximum value is obtained, and U and V at that time are set as U 0 and V 0 , respectively, and passed to the control device 150, and z 0 is passed to the gcd operation final processing unit 140 via the control device 150. Step S2: The control device 150 checks whether the inputs U 0 and V 0 are U 0 = 1 or V 0 = 1. When the inspection is passed, that is, when U 0 = 1 or V 0 = 1 is passed, U 0 and V 0 are passed to the gcd operation final processing unit 140. Step S3: If not, the control device 150
For the inputs U 0 and V 0 , the larger value i of the bit size
Ask for. Step S4: Check whether the bit size i is w bits or less. If the inspection is passed, U 0 and V 0 are passed to the gcd operation final processing unit 140. If the bit size i is not equal to or smaller than w, upper w bits of v a = V 0 (i-th bit to i-w + 1th bit) u a = upper w bits of U 0 (i-th bit) From the eye to the i-w + 1th bit) v x = V 0 lower w bits u x = U 0 lower w bits each value is passed to the gcd operation pseudo operation unit 120, and U 0 and V 0 are gcd It is passed to the arithmetic multiple precision arithmetic unit 130.

【0013】ステップS5: gcd演算疑似演算部1
20は、U0,V0の上下位wビット分であるva,ua,vx
uxの各値を用いて、図6,7を参照して後述するように
gcd演算をシミュレートする。結果の値uu,uv,vu
vvをgcd演算多倍長演算部130へ渡す。 ステップS6: gcd演算多倍長演算部130は、 U0←|uuU0−uvV0|/2w; V0←|vvV0−vuU0|/2w を計算し、それぞれを更新されたU0,V0として、制御装
置150へ渡す。 ステップS7: 制御装置150はV0=0 かを検査し、
0でなければ、ステップS3に戻り、V0=0であれば
U0,V0をgcd演算最終演算部140へ渡す。 ステップS8: gcd演算最終演算部140は、入力
U0,V0,z0に対して2 Z0gcd(U0,V0)を求めて出力す
る。V0=0の場合は、2z0gcd(U0, 0)=U02z0を出力するこ
とになる。従って制御装置150には、U0=1又はV0
1を検査する初期判定手段1-20、V0,U0のビットサイズ
の大きな方の値iを求めるビットサイズ取得手段1-30、
ビットサイズiがwより小さいかを検査するビットサイ
ズ検査手段1-40、V0=0かを検査する最終検査手段1-7
0、前記ステップ4でV0,U0から各上位wビット、各下
位wビットを取出す演算ビット取出し手段1-41を備え、
またこのgcd演算装置1000には、各種データや演算、
制御、処理上必要とするデータなどを記憶する記憶部1
60が設けられている。
Step S5: gcd operation pseudo operation unit 1
20 is U0, V0Upper and lower w bits of va, Ua, Vx
uxAs will be described later with reference to FIGS.
Simulate the gcd operation. The resulting value uu, Uv, Vu
vvIs passed to the gcd operation multiple precision operation unit 130. Step S6: The gcd arithmetic multiple precision arithmetic unit 130 U0← | uuU0−uvV0| / 2w; V0← | vvV0−vuU0| / 2w Calculate and update each U0, V0As a control device
Pass it to the storage 150. Step S7: The control device 150 is V0= 0 is checked,
If it is not 0, the process returns to step S3 and V0If = 0
U0, V0Is passed to the gcd operation final operation unit 140. Step S8: The gcd operation final operation unit 140 inputs
U0, V0, Z0Against 2 Z0gcd (U0, V0) And output
It V0If = 0, then 2z0gcd (U0, 0) = U02z0Can be output
Becomes Therefore, the control device 150 has a U0= 1 or V0=
Initial determination means for inspecting 1 1-20, V0, U0Bit size
Bit size acquisition means 1-30 for obtaining the larger value i of
Bit size to check if bit size i is smaller than w
Inspection means 1-40, V0Final inspection means 1-7
0, V in step 4 above0, U0To each upper w bit, each lower
Equipped with operation bit extracting means 1-41 for extracting the position w bits,
In addition, this gcd arithmetic unit 1000 has various data and arithmetic,
Storage unit 1 for storing data required for control and processing
60 is provided.

【0014】gcd演算初期設定部110 図4及び図5を参照してgcd演算初期設定部110の
動作を説明する。 ステップS1: 数えあげ部111及び112は、入力
X,Yそれぞれの最下位ビットから連続するゼロの個数を
数えて、その値x0,y0を比較部113へ出力する(例え
ば入力の2進数表現が101000ならば、出力は3であ
る)。 ステップS2: 比較部113は、入力された値x0,y0
を比較し、より小さい方をz0として出力する。 ステップS3: 2のべきによる除算部114及び11
5は、それぞれ入力X,Yとz0が入力され、入力された
値X,Yに対してそれぞれ2Z0による除算を行ない、そ
の除算結果U0,V0を出力する。gcd演算初期設定11
0はU0,V0,z0を出力する。
[0014] gcd calculation initialization unit 110 FIG. 4 and with reference to FIG. 5 for explaining the operation of the gcd calculation initial setting unit 110. Step S1: The counting units 111 and 112 input
The number of consecutive zeros from the least significant bit of each of X and Y is counted, and the values x 0 and y 0 are output to the comparison unit 113 (for example, if the binary representation of the input is 101000, the output is 3). . Step S2: The comparison unit 113 inputs the input values x 0 , y 0.
Are compared and the smaller one is output as z 0 . Step S3: Division parts 114 and 11 by powers of 2
Input 5 inputs inputs X, Y and z 0 , respectively, performs division by 2 Z0 on the input values X and Y, and outputs the division results U 0 and V 0 . gcd calculation initial setting 11
0 outputs U 0 , V 0 and z 0 .

【0015】gcd演算疑似演算部120 図6,図7を参照して、gcd演算疑似演算部120の
動作を説明する。 ステップS1: 制御装置150からva,ua,vx,ux
各値が制御部121に入力されると、メモリ122は、
決められたuu,uv,vu,vv,cの初期値を制御部121
へ送る。 ステップS2: 制御部121は、データα={va
ua,vx,ux,uu,uv,vu,vv,c}が入力されると、ux
が偶数かどうかを検査する。偶数ならば、場合1ユニッ
ト123へデータα={va,ua,vx,ux,uu,uv,vu
vv,c}を送る。 ステップS3: uxが偶数の場合、場合1ユニット12
3は、 ua ← [ua/2]; ux ← ux/2 vu ← 2vu; vv ← 2vv の演算を行ない、制御部121へデータα'={va
ua,vx,ux,uu,uv,vu,v v,c}を送る。 ステップS4: uxが偶数でない場合、制御部121
は、vxが偶数かどうかを検査する。偶数ならば、場合2
ユニット124へデータα={va,ua,vx,ux,uu
uv,vu,vv,c}を送る。 ステップS5: uxが奇数でvxが偶数の場合、場合2ユ
ニット124は、 va ← [va/2]; vx ← vx/2 uu ← 2uu; uv ← 2uv の演算を行ない、制御部121へデータα'={va
ua,vx,ux,uu,uv,vu,vv,c}を送る。
[0015]gcd operation pseudo operation unit 120 Referring to FIG. 6 and FIG. 7, the gcd operation pseudo operation unit 120
The operation will be described. Step S1: From controller 150a, Ua, Vx, Uxof
When each value is input to the control unit 121, the memory 122
Decided uu, Uv, Vu, Vv, C to the initial value of the control unit 121
Send to. Step S2: The control unit 121 controls the data α = {va
ua, Vx, Ux, Uu, Uv, Vu, Vv, C} is input, ux
Check if is even. If even, case 1
To the data 123 to α = {va, Ua, Vx, Ux, Uu, Uv, Vu
vv, C} is sent. Step S3: uxIf is an even number, case 1 unit 12
3 is ua← [ua/ 2] ; ux← ux/ 2 vu← 2vu; Vv← 2vv Of the data α ′ = {va
ua, Vx, Ux, Uu, Uv, Vu, V v, C} is sent. Step S4: uxIs not an even number, the control unit 121
Is vxCheck if is even. If even, case 2
Data to the unit 124 α = {va, Ua, Vx, Ux, Uu
uv, Vu, Vv, C} is sent. Step S5: uxIs an odd number vxIf is even, 2 cases
The knit 124 is va← [va/ 2]; vx← vx/ 2 uu← 2uu; Uv← 2uv Of the data α ′ = {va
ua, Vx, Ux, Uu, Uv, Vu, Vv, C} is sent.

【0016】ステップS6: 制御部121は、ux,vx
が共に奇数の場合、uaとvaの大小比較を行なう。ua>va
ならば、場合3ユニット125へデータα={va,ua
vx,ux,uu,uv,vu,vv,c}を送り、ux,vxともに奇
数かつua≦vaならば、場合4ユニット126へデータα
={va,ua,vx,ux,uu,uv,vu,vv,c}を送る。 ステップS7: ux, vxが奇数で、ua>vaの場合、場合
3ユニット装置125は、 ua ← [(ua−va)/2]; ux ← (ux−vx)/2 uu ← uu+vu; uv ← uv+vv vu ← 2vu; vv ← 2vv の演算を行ない、制御部121へデータα'={va
ua,vx,ux,uu,uv,vu,v v,c}を送る。 ステップS8: ux, vxが奇数でua≦vaの場合、場合4
ユニット126は、 va ← [(va−ua)/2]; vx ← (vx−ux)/2 vu ← vu+uu; vv ← vv+uv uu ← 2uu; uv ← 2uv の演算を行ない、制御部121へデータα'={va
ua,vx,ux,uu,uv,vu,v v,c}を送る。 ステップS9: 場合1ユニット123乃至場合4ユニ
ット126の何れかでデータαの処理がなされてデータ
α' として制御部121に戻されると、制御部121は
cの値を1増やす。
Step S6: The control unit 121 makes ux, Vx
If both are odd, uaAnd vaCompare the size of. ua> Va
If so, the data α = {va, Ua
vx, Ux, Uu, Uv, Vu, Vv, C}, ux, VxBoth strange
Number and ua≤vaIf so, the data α to the case 4 unit 126
= {Va, Ua, Vx, Ux, Uu, Uv, Vu, Vv, C} is sent. Step S7: ux, vxIs an odd number, ua> VaIf, if
The 3-unit device 125 ua← [(ua−va) / 2]; ux← (ux−vx) / 2 uu← uu+ vu; Uv← uv+ vv vu← 2vu; Vv← 2vv Of the data α ′ = {va
ua, Vx, Ux, Uu, Uv, Vu, V v, C} is sent. Step S8: ux, vxIs odd and ua≤vaIf, case 4
Unit 126 is va← [(va−ua) / 2]; vx← (vx−ux) / 2 vu← vu+ uu; Vv← vv+ uv uu← 2uu; Uv← 2uv Of the data α ′ = {va
ua, Vx, Ux, Uu, Uv, Vu, V v, C} is sent. Step S9: Case 1 Unit 123 to Case 4 Uni
The data α has been processed by one of the
When it is returned to the control unit 121 as α ′, the control unit 121
Increase the value of c by 1.

【0017】ステップS10: そのcとw'とを比較
し、c<w'であればステップS2に戻り、c=w'ならば
{uu,uv,vu,vv}をgcd演算疑似演算部120から
gcd演算多倍長演算部130へ出力する。制御部12
1は入力されたux,vx,ua,vaの状態から場合1ユニッ
ト123〜場合4ユニット126の何れで処理させるか
の状態判定手段6-21、場合ユニット123〜126で処
理した結果を記憶する処理結果記憶手段6-22、処理回数
cを計数する計数手段6-23、処理を終了とするか、つま
りc=w'か否かを判定する処理終了判定手段6-24を備え
ている。このgcd演算疑似演算部120はU0,V0の各
下位wビットの値ux,vxにより、それぞれU0,V0が偶数
か否かの判定を行い、U0,V0の各上位wビットの値ua
vaによりU0とV0の大小比較を行い、これらにもとづい
て、従来の2進gcd算法と同様の処理を行っている。
このことは図7の処理手順と、図1に示した従来の2進
gcd算法の処理手順とを比較すれば直ちに理解されよ
う。またここでは次式 gcd(U0,V0)=gcd(|uuU0−uvV0|/2w',|vvV0−vuU0|/2w') (8) を満たすuu,uv,vu,vvを求めていることになる。
Step S10: Compare the c and w ', and if c <w', return to step S2. If c = w ', {u u , u v , v u , v v } are calculated by gcd. The pseudo calculation unit 120 outputs the gcd calculation multiple length calculation unit 130. Control unit 12
1 is processed by the state determination means 6-21, which of the case 1 unit 123 to the case 4 unit 126, and the case units 123 to 126, from the input states of u x , v x , u a , and v a . A processing result storage means 6-22 for storing the result, a counting means 6-23 for counting the number of times of processing c, and a processing end judging means 6-24 for judging whether the processing is ended, that is, whether c = w '. I have it. The gcd calculation pseudo computing section 120 U 0, V 0 the lower w bits of the value u x of the v x, a judgment U 0, V 0 is whether an even number, respectively, each of U 0, V 0 Value u a of the upper w bits,
U 0 and V 0 are compared by v a , and based on these, the same processing as the conventional binary gcd arithmetic method is performed.
This can be immediately understood by comparing the processing procedure of FIG. 7 with the processing procedure of the conventional binary gcd algorithm shown in FIG. In addition, the following equation gcd (U 0 , V 0 ) = gcd (| u u U 0 −u v V 0 | / 2 w ′ , | v v V 0 −v u U 0 | / 2 w ′ ) (8 ), U u , u v , v u , and v v are satisfied.

【0018】gcd多倍長演算部130 図8を参照してgcd多倍長演算部130の動作を説明
する。図8において、gcd多倍長演算部130には制
御装置150からU0,V0が、gcd演算疑似演算部12
0からuu,uv,vu,vvをそれぞれ入力される。乗算器1
3a〜13dはそれぞれ積uuU0,uvVv,vuU0,vvV0を計
算して出力する。減算器13e及び13fはそれぞれ差
U1=uuU0−uvV0及びV1=vvV0−vuU0を計算して絶対値器1
3g及び13hに出力する。絶対値器13g及び13h
はそれぞれ入力U1及びV1の絶対値を計算して2のべきに
よる除算器13i及び13jに出力する。2のべきによ
る除算器13i及び13jはそれぞれ入力|U1|及び|
V1|の2 w'による除算を計算しこれをU0及びV0としてg
cd多倍長演算部130の出力とする。図8のgcd多
倍長演算部130の処理を以下にまとめて示す。 ステップS1: V1=(-vuU0+vvV0)/2w' U1=(uuU0−uvV0)/2w' を演算する。 ステップS2: V1 ←|V1|; U1 ←|U1| ステップS3: V0 ← V1 ; U0 ← U1 図8においては、2w' による除算を、絶対値を求めた後
に行っているが、上記ステップS1に示すように2w'
よる除算を、絶対値を求める前に行ってもよい。得られ
たU0,V0は制御装置150に入力され、図3で説明した
ようにV0=0かのチェックが行われる。
[0018]gcd multiple precision arithmetic unit 130 The operation of the gcd multiple precision arithmetic unit 130 will be described with reference to FIG.
To do. In FIG. 8, the gcd multiple precision arithmetic unit 130 is controlled.
Control device 150 to U0, V0Is a gcd operation pseudo operation unit 12
0 to uu, Uv, Vu, VvAre input respectively. Multiplier 1
3a to 13d are the product uuU0, UvVv, VuU0, VvV0Total
Calculate and output. The subtracters 13e and 13f are different from each other.
U1= uuU0−uvV0And V1= vvV0−vuU0Calculate the absolute value 1
Output to 3g and 13h. Absolute value gauge 13g and 13h
Respectively input U1And V1Calculate the absolute value of
To the dividers 13i and 13j. Power of 2
The dividers 13i and 13j are respectively input | U1| and |
V1| Of 2 w 'Calculate division by0And V0As g
The output of the cd multiple precision arithmetic unit 130. 8 gcd many
The processing of the double arithmetic unit 130 is summarized below. Step S1: V1= (-VuU0+ vvV0) / 2w ' U1= (UuU0−uvV0) / 2w ' Is calculated. Step S2: V1← | V1|; U1← | U1| Step S3: V0 ← V1   ; U0 ← U1 In FIG. 8, 2w ' After obtaining the absolute value by dividing by
However, as shown in step S1 above, 2w ' To
The division by may be performed before obtaining the absolute value. Obtained
U0, V0Is input to the control device 150 and described in FIG.
Like V0= 0 is checked.

【0019】gcd演算最終処理部140 図9を参照してgcd演算最終処理部140の動作を説
明する。gcd演算最終処理部140には制御装置15
0からU0,V0が、初期設定部110からz0 がそれぞれ
入力される。小さい数のgcd演算部141は入力U0
V0のgcdを計算して2のべき乗倍部142に出力す
る。2のべき乗倍部142は入力gcd(U0,V0) とz0を用
いて2z0gcd(U0,V0)を計算してこの最終処理部140の
出力とする。つまりgcd演算装置1000の出力となる。
このgcd演算最終処理装置140はその処理手順を図
10に示すように、最後のステップS10で2Z0を乗算
補正する以外は図1に示した従来の2進gcd算法と基
本的に同一手順である。更に詳細にみれば、図10のス
テップS1〜S9は、図7のステップS1〜S9におけ
るux, uu, vx, vu, vvに対する処理と同じである。以上
のようにして入力X,Yの最大公約数を求めることがで
きる。しかも、gcd演算最終処理部140を除いて
は、全て演算単位がw又はw'ビットであり、全体として
少ない処理で行うことができる。なお図2,図3につい
ての説明から理解されるように、図2中の各部は順次処
理されるものであり、従って図6では説明の便宜上制御
部121を設けたが、この制御部121は制御装置15
0で行うことができ、その他の各部も制御装置150に
より制御され、また各部において各処理上必要とする記
憶部(メモリ)は図2中の記憶部160を利用すること
ができる。
[0019] Referring to the gcd calculation final processing unit 140 FIG. 9 for explaining the operation of the gcd calculation final processing unit 140. The gcd calculation final processing unit 140 includes a control device 15
0 to U 0 and V 0 are input, and z 0 is input from the initial setting unit 110. The small number of gcd calculators 141 inputs U 0 ,
The gcd of V 0 is calculated and output to the power of 2 multiplication unit 142. The power-of-two multiplication unit 142 calculates 2 z0 gcd (U 0 , V 0 ) using the inputs gcd (U 0 , V 0 ) and z 0, and outputs it as the output of the final processing unit 140. In other words, it is the output of the gcd arithmetic unit 1000.
As shown in FIG. 10, the gcd arithmetic final processing device 140 basically has the same procedure as the conventional binary gcd arithmetic method shown in FIG. 1 except that the final step S10 is performed by multiplying and correcting 2 Z0 . is there. More specifically, steps S1 to S9 of FIG. 10 are the same as the processing for u x , u u , v x , v u , v v in steps S1 to S9 of FIG. As described above, the greatest common divisor of inputs X and Y can be obtained. In addition, except for the gcd operation final processing unit 140, all the operation units are w or w'bits, so that it is possible to carry out with a small amount of processing as a whole. As will be understood from the description of FIGS. 2 and 3, each unit in FIG. 2 is sequentially processed. Therefore, in FIG. 6, the control unit 121 is provided for convenience of description. Controller 15
0, the other units are also controlled by the control device 150, and the storage unit (memory) required for each process in each unit can use the storage unit 160 in FIG.

【0020】拡張2進gcd演算装置2000 図11を参照して拡張2進gcd演算装置2000を説明す
る。この装置2000はX,Yの入力に対して、gcd(X,Y)
と、S=2kX-1modY及びkを出力する。この装置2000は
拡張gcd演算初期設定部210、拡張gcd演算疑似
演算部220、拡張gcd演算多倍長演算部230、拡
張gcd演算最終演算部240、制御装置250からな
り、図12に示すように以下の演算が実行される。 ステップS1: 拡張gcd演算初期設定部210は、
入力X,Yに対して gcd(X,Y)=2z0gcd(U0,V0) (9) を満たすU0,V0,z0のうち、z0が最大となるものを求め
る。S,T,kの初期値S0=0、T0=1,k=0ととも
にU0,V0を制御装置250へ渡し、制御装置250を介
してz0を拡張gcd演算最終処理部240へ渡す。 ステップS2: 制御装置250は、入力U0,V0,S0
T0,kに対し、U0=1またはV0=1であるかどうかを検
査する。検査に合格した場合は、拡張gcd演算最終処
理部240にU0,V0,S0,T0,kを渡す。 ステップS3: 制御装置250は、U0=1又はV0=1でな
かった場合、入力U0,V0,S0,T0,kに対し、U0とV0
ビットサイズ中の大きい方のビットサイズ値iを求め
る。 ステップS4: 制御装置250はその値iがwビット
以下であるかどうかを検査する。検査に合格した場合、
拡張gcd演算最終処理部240に、U0,V0,S0,T0
kを渡す。上記いずれの検査にも合格しなかった場合
は、 va =V0 の上位wビット(第iビット目から第i-w+1ビ
ット目まで) ua =U0 の上位wビット(第iビット目から第i-w+1ビ
ット目まで) vx =V0 の下位wビット ux =U0 の下位wビット の各値を拡張gcd演算疑似演算部220へ渡し、U0
V0,S0,T0を拡張gcd演算多倍長演算部230へ渡
す。kにw'を加算する。
Extended Binary gcd Arithmetic Unit 2000 The extended binary gcd arithmetic unit 2000 will be described with reference to FIG. This device 2000 accepts gcd (X, Y) for X, Y inputs.
And S = 2 k X -1 mod Y and k are output. This device 2000 includes an extended gcd operation initial setting unit 210, an extended gcd operation pseudo operation unit 220, an extended gcd operation multiple length operation unit 230, an extended gcd operation final operation unit 240, and a control device 250, and as shown in FIG. The following operations are performed. Step S1: The extended gcd calculation initial setting unit 210
For inputs X and Y, gcd (X, Y) = 2 z0 gcd (U 0 , V 0 ) (9) is satisfied. Among U 0 , V 0 , and z 0 , the one with the maximum z 0 is obtained. The initial values S 0 = 0, T 0 = 1 and k = 0 of S, T and k are passed together with U 0 and V 0 to the control device 250, and z 0 is expanded through the control device 250 to the final gcd calculation final processing unit 240. Hand over to. Step S2: The controller 250 inputs U 0 , V 0 , S 0 ,
For T 0 , k, check if U 0 = 1 or V 0 = 1. If the inspection is passed, U 0 , V 0 , S 0 , T 0 , k are passed to the extended gcd operation final processing unit 240. Step S3: The control device 250, if U 0 = 1 or V 0 = 1 is not satisfied, with respect to the inputs U 0 , V 0 , S 0 , T 0 , k, the bit size of U 0 and V 0 is larger. The bit size value i of one is calculated. Step S4: The controller 250 checks if the value i is less than or equal to w bits. If the inspection passed,
In the extended gcd calculation final processing unit 240, U 0 , V 0 , S 0 , T 0 ,
pass k. The case did not pass in either test, v a = (from the i-th bit to the i-w + 1 bit) upper w bits of V 0 u a = upper U 0 w bits (the i From the bit to the i-w + 1th bit) v x = V 0 lower w bits u x = U 0 lower w bits each value is passed to the extended gcd operation pseudo operation unit 220, and U 0 ,
V 0 , S 0 , and T 0 are passed to the extended gcd arithmetic multiple precision arithmetic unit 230. Add w'to k.

【0021】ステップS5: 拡張gcd演算疑似演算
部220は、U0,V0の上下位wビット分であるva,ua
vx,uxの各値を用いて、拡張gcd演算をシミュレート
する。その結果の値uu,uv,vu,vvの各値を拡張gcd
演算多倍長演算部230へ渡す。 ステップS6: 拡張gcd演算多倍長演算部230
は、図13を参照して後述するように U'=(uuU0−uvV0)/2w', V'=(vvV0−vuU0)/2w', S'=uuS0+uvT0, T'=vvT0+vuS0 を計算する。ここで、V'が負ならばV'とT'の符号を反転
し、U'が負ならばU'とS'の符号を反転する。演算の結果
得られたU',V',S',T'をU0,V0,S0,T0として制御装
置250へ渡す。 ステップS7: 制御装置250はV0=0かを検査し、
0でなければステップS3に戻り、0であれば拡張gc
d演算最終演算部240の処理に移る。 ステップS8: 拡張gcd演算最終演算部240は、
V0≠0なら入力U0,V0,z0に対して2Z0gcd(U0,V0)を求
めて出力する。また、V0=0ならS=2kX-1modYなる
S,kを求め、出力する。
Step S5: The extended gcd operation pseudo operation unit 220 has v a , u a , which are upper and lower w bits of U 0 , V 0 .
Simulate the extended gcd operation using each value of v x and u x . The resulting values u u , u v , v u , and v v are extended gcd
It is passed to the arithmetic multiple precision arithmetic unit 230. Step S6: Extended gcd arithmetic multiple precision arithmetic unit 230
U ′ = (u u U 0 −u v V 0 ) / 2 w ′ , V ′ = (v v V 0 −v u U 0 ) / 2 w ′ , as will be described later with reference to FIG. Calculate S ′ = u u S 0 + u v T 0 , T ′ = v v T 0 + v u S 0 . If V'is negative, the signs of V'and T'are reversed, and if U'is negative, the signs of U'and S'are reversed. U ′, V ′, S ′, T ′ obtained as a result of the calculation are passed to the control device 250 as U 0 , V 0 , S 0 , T 0 . Step S7: The control device 250 checks whether V 0 = 0,
If not 0, the process returns to step S3, and if 0, the extended gc
The operation of the d operation final operation unit 240 is performed. Step S8: The extended gcd operation final operation unit 240
If V 0 ≠ 0, 2 Z0 gcd (U 0 , V 0 ) is calculated for the inputs U 0 , V 0 , and z 0 and output. Further, if V 0 = 0, S, k that satisfies S = 2 k X -1 mod Y is obtained and output.

【0022】図11には特に示していないが、この拡張
gcd演算装置2000にも、図2中に示した初期判定手段
1-20、ビットサイズ取得手段1-30、ビットサイズ検査手
段1-40、演算ビット取出手段1-41、最終判定手段1-70、
記憶部160に対応するものが設けられている。拡張g
cd演算初期設定部210は、図2中のgcd演算初期
設定部110と同様に図4に示した機能構成を有し、図
5に示した処理を行うが、これらと異なる点は記憶部に
記憶されているS,T,kの各初期値S0=0,T0=1,
k=0を出力して制御装置250へ渡す。拡張gcd演
算疑似演算部220の機能構成は図6に示したgcd演
算疑似演算部120のそれとほぼ同一であり、またその
処理も図7に示した処理とほぼ同一であるが、異なる点
は図7中のステップS9に括弧書きで示しているように
kの値を1増加させる処理も行っている。つまり疑似演
算部120で求めたuu,uv,vu,vvを出力すると共にk
にwを加算して出力することになる。従って拡張gcd
演算疑似演算部220の制御部にはkを計数する手段も
設けられる。ステップS9でkを+1する代りに、ステ
ップS10でc=wとなった時に、k+w=kとしても
よい。
Although not particularly shown in FIG. 11, the extended gcd arithmetic unit 2000 also has the initial judgment means shown in FIG.
1-20, bit size acquisition means 1-30, bit size inspection means 1-40, operation bit extraction means 1-41, final determination means 1-70,
A unit corresponding to the storage unit 160 is provided. Expansion g
The cd calculation initial setting unit 210 has the functional configuration shown in FIG. 4 similarly to the gcd calculation initial setting unit 110 in FIG. 2 and performs the processing shown in FIG. 5, but the points different from these are stored in the storage unit. Stored initial values of S, T, k S 0 = 0, T 0 = 1,
Output k = 0 and pass it to the controller 250. The functional configuration of the extended gcd operation pseudo operation unit 220 is almost the same as that of the gcd operation pseudo operation unit 120 shown in FIG. 6, and its processing is almost the same as the process shown in FIG. In step S9 of 7, the process of increasing the value of k by 1 is also performed as shown in parentheses. That is, u u , u v , v u , and v v obtained by the pseudo operation unit 120 are output and k
Is added with w to output. Therefore extended gcd
The control unit of the arithmetic pseudo arithmetic unit 220 is also provided with a unit for counting k. Instead of incrementing k + 1 by 1 in step S9, k + w = k may be set when c = w in step S10.

【0023】拡張gcd多倍長演算部230 図13,図14を参照して拡張gcd多倍長演算部23
0の動作を説明する。この演算部230には図11にお
ける制御装置250からU0,V0,S0,T0が、また拡張g
cd演算疑似演算部220からuu,uv,vu,vvが入力さ
れる。乗算器23a〜23hはそれぞれ積uuU0,uvV0
vuU0,vvV0,uuS0,uvT0,vuS0,vvT0を計算して出力す
る。減算器23i及び23jはそれぞれ差U'=uuU0−uv
V0及びV'=vuV0−uvU0を計算して出力する。加算器23
k及び23lはそれぞれ和S'=uuS0+uvT0及びT'=vvT0
+vuS0を計算して出力する。制御部23mは入力U',S'
に対して、U'<0ならば、符号反転器23oにU',S'を
出力し、符号反転器23oから、−U',−S'を新たな入
力U",S"として受ける。U'≧0ならば、U'を2のべきに
よる除算器23qに出力し、S'をS0として演算部230
より出力する。制御部23nは入力V',T'に対して、V'
<0ならば、符号反転器23pにV',T'を出力し、符号
反転器23pから、−V',−T'を新たな入力V",T"とし
て受ける。V'≧0ならば、V'を2のべきによる除算器2
3rに出力し、T'をT0として演算部230から出力す
る。
Extended gcd multiple precision arithmetic unit 230 Referring to FIGS. 13 and 14, extended gcd multiple precision arithmetic unit 23
The operation of 0 will be described. The arithmetic unit 230 receives U 0 , V 0 , S 0 and T 0 from the control device 250 in FIG.
u u , u v , v u , and v v are input from the cd operation pseudo operation unit 220. Multipliers 23a to 23h have products u u U 0 , u v V 0 , and
Calculate and output v u U 0 , v v V 0 , u u S 0 , u v T 0 , v u S 0 , v v T 0 . Subtracter 23i and 23j each difference U '= u u U 0 -u v
Calculate and output V 0 and V ′ = v u V 0 −u v U 0 . Adder 23
k and 23l are sums S ′ = u u S 0 + u v T 0 and T ′ = v v T 0, respectively.
Calculate + v u S 0 and output. The control unit 23m receives inputs U'and S '
On the other hand, if U '<0, U'and S'are output to the sign inverter 23o, and -U' and -S 'are received as new inputs U "and S" from the sign inverter 23o. If U ′ ≧ 0, U ′ is output to the power of 2 divider 23q, and S ′ is set to S 0 , and the arithmetic unit 230
Output more. The control unit 23n receives V'for input V'and T '
If <0, V'and T'are output to the sign inverter 23p, and -V 'and -T' are received as new inputs V "and T" from the sign inverter 23p. If V ′ ≧ 0, V ′ is a power of 2 divider 2
3 ′, and T ′ is output from the arithmetic unit 230 as T 0 .

【0024】2のべきによる除算器23qは入力U'の2
w'による商U1を計算してU0として演算部230の出力と
する。2のべきによる除算器23rは入力V'の2w'によ
る商V1を計算してV0として演算部230の出力とする。
以上の拡張gcd多倍長演算部230の処理をまとめて
図14に示す。 を演算する。 ステップS2: V1が0より小か判定し、0より小でな
かったらそのままステップS4に移る。 ステップS3: V1が0より小であれば、V1← -V1及び
T1← -T1により符号を変える。 ステップS4: U1が0より小か判定し、0より小でな
ければそのままステップS6に移る。 ステップS5: U1が0より小であれば、U1← -U1及び
S1← -S1により符号を変える。 ステップS6: 得られたV1, U1, S1, T1を更新された
V0, U0, S0, T0として出力する。 この拡張gcd演算多倍長演算部230の出力は制御装
置250に入力される。
The divider 23q by the power of 2 has a value of 2 at the input U '.
The quotient U 1 based on w ′ is calculated and used as U 0 as the output of the calculation unit 230. Divider according to powers of 2 23r is an output of the arithmetic unit 230 as V 0 by calculating the quotient V 1 by '2 w' of the input V.
The processing of the extended gcd multiple precision arithmetic unit 230 described above is shown in FIG. Is calculated. Step S2: It is determined whether V 1 is smaller than 0, and if it is not smaller than 0, the process directly proceeds to step S4. Step S3: If V 1 is smaller than 0, V 1 ← -V 1 and
The sign is changed by T 1 ← -T 1 . Step S4: It is determined whether U 1 is smaller than 0, and if it is not smaller than 0, the process directly proceeds to step S6. Step S5: If U 1 is smaller than 0, U 1 ← -U 1 and
The sign is changed by S 1 ← -S 1 . Step S6: The obtained V 1 , U 1 , S 1 , T 1 are updated
Output as V 0 , U 0 , S 0 , T 0 . The output of the extended gcd operation multiple precision arithmetic unit 230 is input to the control device 250.

【0025】拡張gcd演算最終処理部240 拡張gcd演算最終処理部240は図9に示した最終処
理部140とほぼ同様の機能構成をとり、入力されU0
V0を初期値として、gcd(U,V) を演算し、その演算結果
とgcd(U,V) とz0を用いて2z0gcd(U,V)が計算されて出
力される。最終処理部140と異なる点は、この最終処
理部240にはS0,T0,kも入力され、図10に示した
gcd演算処理の一部を図15に示すようにステップS
3、S5、S7、S8の次にkを+1するステップS8-1
の処理を行ってステップS9に移る。またステップS9
でvx=0であれば、ステップS9-1でS=(uuS0+uvT0) を
演算し、その結果Sと、kを出力する。このSはS=2kX
-1modYの演算結果と一致する。この拡張gcd演算装
置2000も、gcd演算装置1000と同様に1つの制御装置
250で各部を処理することができ、またこれら演算処
理をプログラムの解読実行により行うこともできる。そ
の場合は各演算処理に当り、必要なデータを記憶手段か
ら読出したり、一時的に蓄えたバッファから取出した
り、また演算結果を記憶手段に書込んだり、バッファへ
一時的に蓄えたりするステップを供することになる。こ
の実施例では、入力X,Yが、共に偶数の場合は gcd
(X,Y)=2z0ux を出力し、X,Yの一方が奇数かつ、 g
cd(X,Y)=1の場合はSとkを出力させるようにした。
従って、拡張gcd演算初期設定部210では、X,Y
の何れが奇数かをまず判断し、奇数の場合はz0を求める
ことなく、XをU0,YをV0とし、w,S0=0,T0=1,
k=0を出力するようにしてもよい。しかし、例えば逆
元を求める場合はX、Yの一方が奇数でないと求められ
ない。つまり、予め、入力値の一方が奇数であることが
わかっている場合は、拡張gcd演算初期設定部210
では、単にU0=X,V0=Y,S0=0,T0=1,k=0とす
る初期設定のみを行えばよい。つまりXをU0として、Y
をV0として、またS0=0,T0=1,k=0をメモリから
読出して出力すればよい。
[0025]Extended gcd operation final processing unit 240 The extended gcd calculation final processing section 240 is the final processing shown in FIG.
It has almost the same functional configuration as that of the science unit 140, and the input U0
V0Gcd (U, V) is calculated with the initial value of, and the calculation result
And gcd (U, V) and z0Using 2z0gcd (U, V) is calculated and output
I will be forced. The difference from the final processing unit 140 is that this final processing is performed.
S in the science department 2400, T0, K are also input and are shown in FIG.
As shown in FIG. 15, a part of the gcd calculation process is performed in step S
Step S8-1 for incrementing k by 1 after 3, S5, S7, S8
Is performed and then the process proceeds to step S9. Step S9
At vx= 0, S = (uuS0+ uvT0)
It calculates and outputs the result S and k. This S is S = 2kX
-1It matches the calculation result of modY. This extended gcd calculator
The device 2000 is also a single control device like the gcd arithmetic device 1000.
250 can process each part,
The reason can also be performed by deciphering and executing the program. So
In the case of
Read from, or retrieved from the buffer that was temporarily stored
Moreover, the calculation result can be written in the storage means or in the buffer.
It will provide a step to temporarily store. This
In this embodiment, when the inputs X and Y are both even, gcd
(X, Y) = 2z0ux Is output, and one of X and Y is odd and g
When cd (X, Y) = 1, S and k are output.
Therefore, in the extended gcd calculation initial setting unit 210, X, Y
First, which is an odd number, and if it is an odd number, z0Ask for
U without X0, Y to V0And w, S0= 0, T0= 1,
You may make it output k = 0. But for example the reverse
If you want to find the element, it is required that one of X and Y is not an odd number.
Absent. That is, one of the input values must be odd in advance.
If it is known, the extended gcd calculation initial setting unit 210
Then just U0= X, V0= Y, S0= 0, T0= 1 and k = 0
Only the initial settings need to be made. That is, X to U0As Y
To V0As well as S0= 0, T0= 1 and k = 0 from memory
It may be read and output.

【0026】上述では一度に演算することのできるビッ
ト数をw及びw'としたが、疑似演算部(120,22
0)で一度に計算する量w'と多倍長演算部(130,2
30)とで一度に計算する量wとを同じ値としてもよ
い。先に述べたように拡張2進gcd演算装置は2のべ
きによる除算装置と組み合わせて剰余環Z/NZ上の逆元演
算装置を構成することができる。図16はこの発明の拡
張2進gcd演算装置を使って通常逆元演算装置を構成
した場合である。図に示すように、整数XとNがこの装
置3000に入力され、まず図11で説明した拡張2進gc
d演算装置315で拡張2進gcd演算がなされ、S=X
-12kmodN とkとが出力され、このS,kとNがZ/NZ上
の2のべきによる除算装置318に入力されS・2-kmodN
が演算され、その演算結果としてX-1modN、つまりX
のZ/NZ上の逆元演算結果が得られる。
In the above description, the number of bits that can be calculated at one time is w and w ', but the pseudo calculation unit (120, 22)
0) the amount w'calculated at once and the multiple precision arithmetic unit (130, 2
30) and the amount w calculated at one time may be the same value. As described above, the extended binary gcd arithmetic unit can be combined with the division unit by the power of 2 to form an inverse element arithmetic unit on the remainder ring Z / NZ. FIG. 16 shows a case where a normal inverse element arithmetic unit is constructed using the extended binary gcd arithmetic unit of the present invention. As shown in the figure, integers X and N are input to this device 3000, and first, the extended binary gc described in FIG.
An extended binary gcd operation is performed by the d operation unit 315, and S = X
-1 2 k mod N and k are output, and these S, k and N are input to the division unit 318 by the power of 2 on Z / NZ, and S · 2 -k mod N
Is calculated, and as a result of the calculation, X −1 mod N, that is, X
The inverse element operation result on Z / NZ of is obtained.

【0027】図17に剰余環Z/NZ上の半モンゴメリ(Ka
liski)逆元演算にこの発明の拡張gcd演算装置を適
用した場合の逆元演算装置3100を示す。この装置3100に
整数X,Nが入力され、X,Nについて図11を参照し
て説明した拡張gcd演算装置315による演算がなさ
れ、その結果のS=X-12kmodN とkと入力NとがZ/NZ上
の2のべきによる除算装置320に入力されて、S・2
-(k-n)modN が演算され(nはNのビット数)、結果と
してX-12nmodNが得られる。図18はZ/NZ上のMontgome
ry逆元演算にこの発明の拡張2進gcd演算装置を適用
した場合の逆元演算装置3200を示す。図に示すように、
入力された整数X,Nについて拡張gcd演算装置31
5でS=X-12kmodN 及びkを求め、これに対しZ/NZ上の
2のべき乗倍装置325でS・22n-kmodNを演算してX-12
2nmodNを得ることもできる。
In FIG. 17, half Montgomery (Ka
liski) shows an inverse element arithmetic unit 3100 when the extended gcd arithmetic unit of the present invention is applied to the inverse element arithmetic. The integers X and N are input to this device 3100, and the operation is performed on the X and N by the extended gcd operation device 315 described with reference to FIG. 11, and the result S = X −1 2 k mod N and k and the input N are input. And are input to the division device 320 by the power of 2 on Z / NZ, and S ・ 2
-(kn) modN is calculated (n is the number of bits of N), and X -1 2 n modN is obtained as a result. Figure 18 shows Montgome on Z / NZ
The inverse element arithmetic unit 3200 when the extended binary gcd arithmetic unit of the present invention is applied to the ry inverse element arithmetic is shown. As shown in the figure,
Extended gcd arithmetic unit 31 for input integers X and N
In step 5, S = X -1 2 k modN and k are obtained, and on the other hand, in the power-of-two multiplier 325 on Z / NZ, S · 2 2n-k mod N is calculated to calculate X -1 2
It is also possible to obtain 2n mod N.

【0028】図19は、Z/NZ上のモンゴメリ逆元演算装
置にこの発明の拡張gcd演算装置を適用した場合の装
置5000を示す。図19に示すように、制御部510の制
御のもとに、まずZ/NZ上の2のべきによる除算装置51
4でX'=X・2-tmodN を演算し、その演算結果X'とNに
ついて拡張gcd演算装置515によりS=X-12kmodN
とkを求める。これらS,kを比較装置517に入力し
てNのビット長nとkとtとから2n-k-tの正負を判定
し、負ならばk'=-2n+k+t とS'=SをZ/NZ上の2のべき
による除算装置518Aに入力し、T=S'2-k'modNを演算す
る。2n-k-tが正ならばk'=2n-k-tとS'=SをZ/NZ上の2
のべきによる乗算装置518Bに入力し、T=S'2k'modN を
演算する。出力部519は、演算装置518Aと518Bの何れ
かのTをX-122nmodN の演算結果として出力する。上述
してきたこの発明による最大公約数又は拡張最大公約数
演算装置あるいは逆元演算装置としてコンピュータを機
能させるためのプログラムは、例えば図20に示す演算
装置10A内の主記憶装置13に格納されて使用され
る。演算装置10Aは例えばコンピュータで実現され、
CPU11と、RAM12と、主記憶装置13とか等構
成され、キーボード14と、表示装置15とが接続され
ている。CPU11として例えば1度に16ビットずつ
演算を行う16ビットのチップセットを使用した場合、
この発明の実施例で説明したように2のべきによる乗除
算を行う場合に16ビットずつまとめて行うのが好まし
い。
FIG. 19 shows an apparatus 5000 in which the extended gcd arithmetic unit of the present invention is applied to a Montgomery inverse element arithmetic unit on Z / NZ. As shown in FIG. 19, under the control of the control unit 510, first, a division device 51 by a power of 2 on Z / NZ is used.
X ′ = X · 2 −t modN is calculated in step S4, and S = X− 1 2 k modN is calculated by the extended gcd calculator 515 for the calculation results X ′ and N.
And k. These S and k are input to the comparison device 517 to determine the positive or negative of 2n-kt from the bit lengths n, k and t of N, and if negative, k '=-2n + k + t and S' = S Input to the divider 518A by the power of 2 on Z / NZ to calculate T = S'2 -k ' mod N. If 2n-kt is positive, set k '= 2n-kt and S' = S to 2 on Z / NZ.
It is input to the multiplier 518B according to the power of, and T = S'2 k ' mod N is calculated. The output unit 519 outputs one of the T of the calculation unit 518A and 518B as the operation result of the X -1 2 2n modN. The program for causing the computer to function as the greatest common divisor or extended greatest common divisor computing device or inverse element computing device according to the present invention described above is stored in the main storage device 13 in the computing device 10A shown in FIG. To be done. The arithmetic unit 10A is realized by, for example, a computer,
A CPU 11, a RAM 12, a main storage device 13 and the like are configured, and a keyboard 14 and a display device 15 are connected. When a 16-bit chip set that performs an operation 16 bits at a time is used as the CPU 11,
As described in the embodiments of the present invention, it is preferable to collectively perform 16-bit multiplication / division by powers of 2.

【0029】CPU11は主記憶装置13内の演算プロ
グラムに従って最大公約数又は拡張最大公約数演算ある
いは逆元演算を実行する。RAM12はこれら演算に必
要な各種パラメータの値や変数値を保持したり、演算の
途中結果や最終結果を保持する。利用者Aはキーボード
14からプログラムの実行命令を入力し、演算の実行経
過が表示装置15に表示される。ここで、この発明の逆
元演算装置がセキュリティ技術の例であるディジタル署
名において使用される場合について説明する。利用者A
の演算装置10Aは例えばネットワークNWを介して利
用者Bの演算装置10Bに接続されており、利用者Aは
文書mに対しディジタル署名Sをつけて利用者Bの演算
装置10Bに送信し、利用者Bは受信した署名Sの正当
性を検証する。ここでは、ディジタル署名として、ESIG
N 方式を使う場合で説明する。この場合、利用者AとB
は公開鍵nとシステムパラメータkを共有し、送信側利
両者Aは素数の秘密鍵p,qを秘密に保持している。た
だしn=pqである。ディジタル署名方式ESIGN を実行
するためのプログラム13Pは主記憶装置13ないに格
納されている。そのプログラム13Pの一部として、デ
ィジタル署名生成の一過程で使用される逆元演算を含む
式をこの発明の演算方法により実行する部分プログラム
13PPが設けられている。
The CPU 11 executes the greatest common divisor or extended greatest common divisor operation or inverse element operation according to the operation program in the main memory 13. The RAM 12 holds various parameter values and variable values required for these calculations, and holds intermediate and final results of the calculations. The user A inputs a program execution command from the keyboard 14, and the progress of calculation is displayed on the display device 15. Here, a case where the inverse element operation device of the present invention is used in a digital signature which is an example of security technology will be described. User A
The computing device 10A is connected to the computing device 10B of the user B via the network NW, for example, and the user A attaches the digital signature S to the document m and transmits the document m to the computing device 10B of the user B for use. Person B verifies the validity of the received signature S. Here, as a digital signature, ESIG
The case of using the N method will be described. In this case, users A and B
Shares the system parameter k with the public key n, and the transmitting side party A holds the secret keys p and q of prime numbers in secret. However, n = pq. A program 13P for executing the digital signature method ESIGN is stored in the main storage device 13. As a part of the program 13P, a partial program for executing an expression including an inverse element operation used in one process of digital signature generation by the operation method of the present invention.
13PP is provided.

【0030】まず、利用者Aの演算装置10Aでは、乱
数xを生成する。次に、文書mをハッシュ関数に入れて
h(m)を生成し、更に次式 w=[{h(m)−xkmod n}/p・q] (10) を計算する。次に次式 S= x +{w/(k・xk-1) mod p}p・q (11) を求める。式(11)中のw/(k・xk-1)mod p は先に説明した
逆元演算と同じものである。従って、先に説明したよう
に y=w(k・xk-1)-1mod p= w・X-1mod p (12) と表せば、図19の説明で示した逆元演算処理手順によ
りyを求めることができる。この様にして求めたyを使
って S=x+y・p・q (13) を計算し、(S,m)を利用者Bの演算装置10Bに送
信する。利用者Bの装置10Bでは、受信したSとmを
使って次式 Sk−2a≦h(m)≦Sk, ただしa=[(2/3)log2n] (14) が成立するか検証し、成立すれば文書mに対する署名S
は正しいものであると認める。この発明の逆元演算プロ
グラムの記録媒体が演算装置の主記憶装置13に格納さ
れ、それを使用する場合を示したが、この様なプログラ
ムを他のどの様な形態の記録媒体に格納して使用しても
よいことは明らかである。
First, the arithmetic unit 10A of the user A generates a random number x. Then put the document m into the hash function
h (m) is generated, and the following equation w = [{h (m) −x k mod n} / p · q] (10) is calculated. Next, the following equation S = x + {w / (k · x k−1 ) mod p} p · q (11) is obtained. W / (k · x k−1 ) mod p in the equation (11) is the same as the inverse element operation described above. Therefore, as described above, if expressed as y = w (k · x k−1 ) −1 mod p = w · X −1 mod p (12), the inverse element processing procedure shown in the explanation of FIG. Y can be obtained by Using y thus obtained, S = x + y · p · q (13) is calculated and (S, m) is transmitted to the arithmetic unit 10B of the user B. In the device 10B of the user B, the following equation S k −2 a ≦ h (m) ≦ S k is used by using the received S and m, where a = [(2/3) log 2 n] (14) holds. If yes, the signature S for the document m
Admit that is correct. The case where the recording medium of the inverse element calculation program of the present invention is stored in the main storage device 13 of the calculation device and is used is shown, but such a program is stored in any other form of recording medium. Obviously, it may be used.

【0031】[0031]

【発明の効果】この発明の2進gcd演算装置では、小
さい整数を使った演算により、疑似的に2進gcd算法
を行なうことによって、大きい整数の演算を1/w に比例
する割合で減らし、2進gcd算法を高速に行なうこと
を可能としている。(wは計算機が一度に扱うことがで
きるビット数8,16,32など)また、「実際のgc
d算法を正しくシミュレートしている保証がなくても決
められた回数分の疑似演算を行なう」方法の導入によ
り、疑似演算の効率を高めた。これにより、例えば従来
法である算法Lは、32ビットの単精度整数による疑似
算法で約12周分のシミュレートを行なっていたが、こ
の発明の装置では32ビットの単精度整数による疑似算
法で32周分のシミュレートすることが可能である。こ
の場合は算法Lの半分以下の大きい整数演算の回数でg
cd演算が出来る。
According to the binary gcd arithmetic unit of the present invention, a pseudo integer binary gcd arithmetic method is performed by an arithmetic operation using a small integer to reduce the arithmetic operation of a large integer at a rate proportional to 1 / w. The binary gcd algorithm can be performed at high speed. (W is the number of bits that a computer can handle at once 8, 16, 32, etc.) Also, "actual gc
The efficiency of the pseudo operation is improved by introducing the method of "performing a predetermined number of pseudo operations even if there is no guarantee that the d algorithm is correctly simulated." Thereby, for example, the conventional arithmetic method L simulates about 12 rounds by a pseudo arithmetic method using a 32-bit single precision integer, but the apparatus of the present invention uses a pseudo arithmetic method using a 32-bit single precision integer. It is possible to simulate 32 rounds. In this case, g is the number of large integer operations less than half the algorithm L.
Can perform cd calculation.

【図面の簡単な説明】[Brief description of drawings]

【図1】従来の2進gcd 算法の計算手順を示す流れ図。FIG. 1 is a flowchart showing a calculation procedure of a conventional binary gcd algorithm.

【図2】この発明によるgcd演算装置の機能構成を示
す図。
FIG. 2 is a diagram showing a functional configuration of a gcd arithmetic unit according to the present invention.

【図3】図2の装置の動作の流れを示す流れ図。3 is a flow chart showing a flow of operation of the apparatus of FIG.

【図4】図2中のgcd演算初期設定部110の機能構
成を示す図。
FIG. 4 is a diagram showing a functional configuration of a gcd calculation initial setting unit 110 in FIG.

【図5】図4の初期設定部110の動作の流れを示す流
れ図。
5 is a flowchart showing a flow of operation of the initial setting section 110 in FIG.

【図6】図2中のgcd演算疑似演算部120の機能構
成を示す図。
FIG. 6 is a diagram showing a functional configuration of a gcd operation pseudo operation unit 120 in FIG.

【図7】図6の疑似演算部120の動作の流れを示す流
れ図。
7 is a flowchart showing a flow of operations of the pseudo operation unit 120 of FIG.

【図8】図2中のgcd演算多倍長演算部130の機能
構成を示す図。
FIG. 8 is a diagram showing a functional configuration of a gcd arithmetic multiple precision arithmetic unit 130 shown in FIG. 2;

【図9】図2中のgcd演算最終演算部140の機能構
成を示す図。
9 is a diagram showing a functional configuration of a gcd operation final operation unit 140 in FIG.

【図10】図9中の最終演算部140の動作の流れを示
す図。
10 is a diagram showing a flow of operations of a final calculation unit 140 in FIG.

【図11】この発明の変形例である拡張2進最大公約数
演算装置の機能構成を示す図。
FIG. 11 is a diagram showing a functional configuration of an extended binary greatest common divisor calculation device which is a modified example of the present invention.

【図12】図11の拡張2進最大公約数演算装置の動作
の流れを示す図。
FIG. 12 is a diagram showing a flow of operations of the extended binary greatest common divisor calculation device of FIG. 11;

【図13】図11中の拡張gcd演算多倍長演算部23
0の機能構成を示す図。
FIG. 13 is an extended gcd arithmetic multiple precision arithmetic unit 23 in FIG.
The figure which shows the functional structure of 0.

【図14】図13の多倍長演算部230の動作の流れを
示す図。
14 is a diagram showing the flow of operations of the multiple precision arithmetic unit 230 of FIG.

【図15】図11中の最終演算部240の動作の流れの
一部を示す図。
FIG. 15 is a diagram showing a part of the flow of operations of the final arithmetic unit 240 in FIG. 11.

【図16】この発明の拡張2進gcdを適用した通常逆
元演算装置の機能構成を示す図。
FIG. 16 is a diagram showing a functional configuration of a normal inverse element arithmetic unit to which the extended binary gcd of the present invention is applied.

【図17】この発明の拡張2進gcdを適用した半モン
ゴメリ(Kaliski)逆元演算装置の機能構成を示す図。
FIG. 17 is a diagram showing a functional configuration of a half-Montgomery (Kaliski) inverse element operation device to which the extended binary gcd of the present invention is applied.

【図18】この発明の拡張2進gcdを適用したMontgo
mery逆元演算装置の機能構成を示す図。
FIG. 18 is a Montgo to which the extended binary gcd of the present invention is applied.
The figure which shows the function structure of a mery inverse element arithmetic unit.

【図19】この発明の拡張2進gcdを適用したMontgo
mery逆元演算装置の他の機能構成を示す図。
FIG. 19 is Montgo to which the extended binary gcd of the present invention is applied.
The figure which shows the other functional structure of a mery inverse element arithmetic unit.

【図20】この発明による演算プログラム記録媒体を使
用してコンピュータによりこの発明装置を機能させるた
めの機能構成例を示すブロック図。
FIG. 20 is a block diagram showing a functional configuration example for causing a computer to operate the device of the present invention by using the arithmetic program recording medium according to the present invention.

Claims (13)

【特許請求の範囲】[Claims] 【請求項1】 入力値X,Yを入力する入力手段と、 これらX,Yをそれぞれ記憶する記憶手段と、 入力値X,Yから gcd(X,Y)=gcd(U0,V0)2Z0かつz0
最大となるU0,V0,z0を演算するgcd演算初期設定手
段と、gcd(A,B)は AとBの最大公約数を表し、 入力値U0,V0から、予め定められた整数w'≧4に対して gcd(U0,V0)=gcd(|uuU0−uvV0|/2w',|vvV0−vuU0
|/2w') を満たすuu,uv,vv,vuを演算するgcd演算疑似演算
手段と、入力値U0,V0,uu,uv,vv,vuから U'=|uuU0−uvV0|/2w' V'=|vvV0−vuU0|/2w' を演算してU0、V0として出力するgcd演算多倍長演算
手段と、 入力値U0,V0,z0から gcd(U0,V0)2Z0 を演算するgc
d演算最終処理手段と、 演算の結果 gcd(X,Y)を出力する出力手段と、 上記各手段を順次動作させ、記憶手段に対する読出し書
込みなどを行う制御手段、とを含む最大公約数演算装
置。
1. Input means for inputting input values X and Y, storage means for respectively storing these X and Y, and gcd (X, Y) = gcd (U 0 , V 0 ) from the input values X and Y. and gcd calculation initial setting means 2 Z0 and that z 0 is for calculating the U 0, V 0, z 0 to the maximum, gcd (a, B) represents the greatest common divisor of a and B, the input value U 0, V From 0 , gcd (U 0 , V 0 ) = gcd (| u u U 0 −u v V 0 | / 2 w ′ , | v v V 0 −v u for a predetermined integer w ′ ≧ 4. U 0
| / 2 w ' ) satisfying u u , u v , v v , v u, and a gcd pseudo operation means, and input values U 0 , V 0 , u u , u v , v v , v u to U '= | u u U 0 -u v V 0 | / 2 w' V '= | v v V 0 -v u U 0 | / 2 w' and calculates the U 0, is output as V 0 gcd calculation multi Gc for calculating gcd (U 0 , V 0 ) 2 Z0 from input values U 0 , V 0 , z 0
d arithmetic operation final processing means, output means for outputting the operation result gcd (X, Y), and control means for sequentially operating each of the above means to perform reading and writing to the storage means, etc. .
【請求項2】 請求項1の装置において、上記制御手段
は、 入力値U0,V0の各ビットサイズ中の大きな方の値iを求
めるビットサイズ取得手段と、 上記値iがw以下か否かを判定し、w以下でなければ上
記gcd演算疑似演算手段を実行させ、w以下であれば
上記gcd演算最終処理手段を実行されるビットサイズ
検査手段と、上記wは予め決められた4以上の整数であ
り、 上記gcd演算多倍長演算手段の出力中のV0 が0であ
るか否かを判定する最終判定手段と、 上記最終判定手段の判定がV0=0でなければ上記gcd
演算多倍長演算手段の出力U0,V0を上記ビットサイズ取
得手段に入力して、これを実行させ、上記V0=0であれ
ば上記gcd演算最終処理手段を実行させる手段、とを
含むことを特徴とする最大公約数演算装置。
2. The apparatus according to claim 1, wherein the control means is a bit size acquisition means for obtaining a larger value i of the bit sizes of the input values U 0 and V 0 , and whether the value i is w or less. It is determined whether or not, and if it is not w or less, the gcd arithmetic pseudo arithmetic means is executed, and if it is less than w, the bit size checking means for executing the gcd arithmetic final processing means, and the above w is a predetermined 4 It is the above integer, and final determination means for determining whether or not V 0 in the output of the gcd arithmetic multiple precision arithmetic means is 0, and if the determination by the final determination means is not V 0 = 0, gcd
The outputs U 0 and V 0 of the arithmetic multiple precision arithmetic means are input to the bit size acquisition means and executed, and when V 0 = 0, the gcd operation final processing means is executed. A greatest common divisor arithmetic unit characterized by including.
【請求項3】 請求項2の装置において、上記制御手段
は、上記gcd演算初期設定手段よりの入力がV0=1又
はU0=1であるかを判定し、これが成立すれば、上記入
力値U0,V0を上記gcd演算疑似演算手段へ入力するこ
となく、上記gcd演算最終処理手段へ入力する初期判
定手段を有していることを特徴とする最大公約数演算装
置。
3. The apparatus according to claim 2, wherein the control means determines whether the input from the gcd calculation initializing means is V 0 = 1 or U 0 = 1 and if this is satisfied, the input is performed. A greatest common divisor arithmetic unit having an initial judging means for inputting the values U 0 , V 0 to the gcd arithmetic final arithmetic means without inputting them to the gcd arithmetic pseudo arithmetic means.
【請求項4】 請求項1,2又は3の装置において、上
記制御手段は上記U0,V0から各上位wビットのua,va
各下位wビットのux ,vx をそれぞれを取出す演算ビ
ット取出し手段を有し、 上記gcd演算疑似演算手段は、 上記ua,va,ux,vxと、初期値uu=1,uv=0,vu=1,v
v=0とが入力されて、 uxが偶数か、vxが偶数か、ua>vaか、を判定するux
vx,ua,va状態判定手段と、 uxが偶数でua=[ua/2],ux=ux/2,vu=2vu,vv=2vv
演算、 vxが偶数でva=[va/2],vx=vx/2,uu=2uu,uv=2uv
演算、 ua>vaでua=[(ua−va)/2],ux=(ux−vx)/2,及びuu
uu+vu,uv=uv+vv,vu=2vu,vv=2vvの演算、 その他の場合でva=[(va−ua)/2],vx=(vx−ux)/2,及
びvu=vu+uu,vv=vv+uv,uu=2uu,uv=2uvの演算、
の何れかを実行してuu,vv,uv,vuを更新する更新演算
手段と、 上記更新演算手段が演算した回数cを計数する計数手段
と、 上記回数cがw'となるまで上記ux,vx,ua,va状態判定
手段と、上記更新演算手段と、上記計数手段とを繰返し
実行させる手段、とを含むことを特徴とする最大公約数
演算装置。
4. The apparatus according to claim 1, 2 or 3, wherein said control means outputs u a and v a of each upper w bit and u x and v x of each lower w bit from said U 0 and V 0 , respectively. The gcd operation pseudo operation means has an operation bit extracting means for extracting, and the gcd operation pseudo operation means has the above u a , v a , u x , v x and initial values u u = 1, u v = 0, v u = 1, v
v = 0 is input to determine whether u x is even, v x is even, or u a > v a u x ,
v x , u a , v a state determination means, and operation of u a = [u a / 2], u x = u x / 2, v u = 2v u , v v = 2v v with u x being an even number, If v x is even, v a = [v a / 2], v x = v x / 2, u u = 2u u , u v = 2u v , u a > v a u a = [(u a −v a ) / 2], u x = (u x −v x ) / 2, and u u
u u + v u , u v = u v + v v , v u = 2v u , v v = 2v v operation, otherwise v a = [(v a −u a ) / 2], v x = ( v x −u x ) / 2, and v u = v u + u u , v v = v v + u v , u u = 2u u , u v = 2u v ,
Update operation means for executing any of the above to update u u , v v , u v , v u , a counting means for counting the number of times c calculated by the update operation means, and the number of times c becomes w ′. Up to the above u x , v x , u a , v a state determination means, the update calculation means, and means for repeatedly executing the counting means, the greatest common divisor operation device.
【請求項5】 いずれか片方が奇数の入力値X,Nを入
力する入力手段と、 これらX,Nをそれぞれ記憶する記憶手段と、 U0=X,V0=N,S0=0,T0=1,k=0を初期設定する拡張
gcd演算初期設定手段と、 入力値U,Vから予め定められたw'に対して gcd(U,V)= gcd(|uuU0−uvV0|/2w,|vvV0−vuU0|/
2w') を満たすuu,uv,vv,vuを演算し、kにw'を加算する、
拡張gcd演算疑似演算手段と、 入力値U,V,S,T,uu,uv,vv,vuから U'=(uuU0−uvV0)/2w', S'=uuS0+uvT0 又は U'=−(uuU0−uvV0)/2w', S'=−(uuS0+uvT0) と、 V'=(vvV0−vuU0)/2w', T'=vvT0+vuS0 又は V'=−(vvV0−vuU0)/2w', T'=−(vvT0+vuS0) を演算してU',V',S',T'をそれぞれU0,V0,S0,T0
して出力する拡張gcd演算多倍長演算手段と、 入力値U0,V0,S0,T0から |uuU0−uvV0|/2c= gcd(U,V) |vvV0−vuU0|/2c=0 を満たすuu,uv,vv,vu,cを演算し、 S'=uuS0+uvT0 を演算し、kにcを加算する、拡張gcd演算最終処理
手段と、 拡張gcd演算最終処理手段の演算の結果をS=X-12k(m
odN)の演算結果として、これとkを出力する出力手段
と上記各手段を順次動作させ、記憶手段に対する読出し
書込みなどを行う制御手段、とを含む拡張最大公約数演
算装置。
5. An input means for inputting input values X and N, one of which is an odd number, a storage means for respectively storing these X and N, and U 0 = X, V 0 = N, S 0 = 0, Extended gcd calculation initial setting means for initializing T 0 = 1 and k = 0, and gcd (U, V) = gcd (| u u U 0 − for a predetermined w ′ from input values U and V. u v V 0 | / 2 w , | v v V 0 −v u U 0 | /
2 u ' ), u u , u v , v v , v u are calculated, and w'is added to k,
Extended gcd operation pseudo operation means and input values U, V, S, T, u u , u v , v v , v u to U ′ = (u u U 0 −u v V 0 ) / 2 w ′ , S '= U u S 0 + u v T 0 or U' =-(u u U 0 -u v V 0 ) / 2 w ' , S' =-(u u S 0 + u v T 0 ), and V '= (v v V 0 −v u U 0 ) / 2 w ′ , T ′ = v v T 0 + v u S 0 or V ′ = − (v v V 0 −v u U 0 ) / 2 w ′ , T ′ =-(V v T 0 + v u S 0 ) and outputs U ', V', S'and T'as U 0 , V 0 , S 0 and T 0 respectively Extended gcd operation Multiple precision operation Means and input values U 0 , V 0 , S 0 , T 0 | u u U 0 −u v V 0 | / 2 c = gcd (U, V) | v v V 0 −v u U 0 | / 2 Extended gcd operation final process of computing u u , u v , v v , v u , c that satisfies c = 0, computing S ′ = u u S 0 + u v T 0 , and adding c to k Means and the result of the operation of the extended gcd operation final processing means is S = X -12 k (m
An extended greatest common divisor arithmetic unit including: output means for outputting the arithmetic result of odN) and k; and control means for sequentially operating each of the above means to perform reading and writing to the storage means.
【請求項6】 請求項5の装置において、上記制御手段
は、 入力値U0,V0の各ビットサイズ中の大きな方の値iを求
めるビットサイズ取得手段と、 上記値iがw以下か否かを判定し、w以下でなければ上
記拡張gcd演算疑似演算手段を実行させ、w以下であ
れば上記拡張gcd演算最終処理手段を実行させるビッ
トサイズ検査手段と、 上記拡張gcd演算多倍長演算手段の出力中のV0が0で
あるか否かを判定する最終判定手段と、 上記最終判定手段の判定がV0=0でなければ上記拡張g
cd演算多倍長演算手段の出力U0,V0を上記ビットサイ
ズ取得手段に入力して、これを実行させ、V0=0であれ
ば上記拡張gcd演算最終処理手段を実行させる手段、
とを含むことを特徴とする拡張最大公約数演算装置。
6. The apparatus according to claim 5, wherein the control means is a bit size acquisition means for obtaining a larger value i of the bit sizes of the input values U 0 and V 0 , and whether the value i is w or less. It is determined whether or not, and if it is not w or less, the extended gcd operation pseudo operation means is executed, and if it is w or less, a bit size checking means for executing the extended gcd operation final processing means, and the extended gcd operation multiple length Final judgment means for judging whether V 0 in the output of the calculation means is 0 or not, and if the judgment by the final judgment means is not V 0 = 0, the expansion g
means for inputting the outputs U 0 , V 0 of the cd operation multi-precision arithmetic means to the bit size acquisition means for execution, and if V 0 = 0, for executing the extended gcd operation final processing means,
An extended greatest common divisor arithmetic unit characterized by including and.
【請求項7】 請求項5又は6の装置において、上記制
御手段は上記U0,V0から各上位wビットのua,vaと、各
下位wビットのux,vxをそれぞれ取出す演算ビット取出
し手段を有し、 上記拡張gcd演算疑似演算手段は、上記ua,va,ux
vxと、初期値uu=1,u v=0,vu=1,vv=0とkが入力さ
れて、 uxが偶数か、vxが偶数か、ua>vaか、判定するux,vx
ua,va状態判定手段と、 uxが偶数でua=[ua/2],ux=ux/2,vu=2vu,vv=2vv
演算、 vxが偶数でva=[va/2],vx=vx/2,uu=2uu,uv=2uv
演算、 ua>vaでua=[(ua−va)/2],ux=(ux−vx)/2,及びuu
uu+vu,uv=uv+vv,vu=2vu,vv=2vvの演算、 その他の場合でva=[(va−ua)/2],vx=(vx−ux)/2,及
びvu=vu+uu,vv=vv+uv,uu=2uu,uv=2uvの演算、
の何れかを行ってuu,vu,uv,vvを更新する更新演算手
段と、 上記更新演算手段が演算した回数cを計数する計数手段
と、 上記回数cがw'となるまで上記ux,vx,ua,va状態判定
手段と、上記更新演算手段と、上記計数手段との処理を
繰返し実行させ、回数cがw'となった状態でkをk+w'
に更新する手段、とを含むことを特徴とする拡張最大公
約数演算装置。
7. The device according to claim 5 or 6, wherein:
The above means U0, V0To u of each upper w bita, VaAnd each
U of lower w bitsx, VxOperation bit extraction
Have means, The extended gcd operation pseudo operation means is the ua, Va, Ux
vxAnd the initial value uu= 1, u v= 0, vu= 1, vv= 0 and k are entered
Is uxIs even or vxIs even or ua> VaJudge ux, Vx
ua, VaState determination means, uxIs even and ua= [Ua/ 2], ux= Ux/ 2, vu= 2vu, Vv= 2vvof
Calculation, vxIs even and va= [Va/ 2], vx= Vx/ 2, uu= 2uu, Uv= 2uvof
Calculation, ua> VaIn ua= [(Ua−va) / 2], ux= (Ux−vx) / 2, and uu=
uu+ vu, Uv= Uv+ vv, Vu= 2vu, Vv= 2vvArithmetic of, V in all other casesa= [(Va−ua) / 2], vx= (Vx−ux) / 2, and
And vu= Vu+ uu, Vv= Vv+ uv, Uu= 2uu, Uv= 2uvArithmetic of,
Do either of uu, Vu, Uv, VvUpdate operator to update
Dan, Counting means for counting the number of times c calculated by the update calculation means
When, The above u until the number of times c becomes w 'x, Vx, Ua, VaStatus judgment
Means, the update calculation means, and the counting means
Repeatedly executed, k is k + w 'when the number of times c is w'
Means for updating to, and an extended maximum public
A factor calculator.
【請求項8】 請求項1乃至4の何れかに記載した最大
公約数演算装置としてコンピュータを機能させるための
プログラムを記録したコンピュータ読み取り可能な記録
媒体。
8. A computer-readable recording medium recording a program for causing a computer to function as the greatest common divisor calculating device according to any one of claims 1 to 4.
【請求項9】 請求項5乃至7の何れかに記載した拡張
最大公約数演算装置としてコンピュータを機能させるた
めのプログラムを記録したコンピュータ読み取り可能な
記録媒体。
9. A computer-readable recording medium in which a program for causing a computer to function as the extended greatest common divisor calculating device according to any one of claims 5 to 7 is recorded.
【請求項10】 入力X,Nに対し、X-1modNを出力す
る剰余環Z/NZ上の逆元演算装置であり、請求項5乃至7
の何れかに記載の拡張最大公約数演算装置と、剰余環Z/
NZ上の2のべきによる除算装置とを有することを特徴と
する逆元演算装置。
10. An inverse element arithmetic unit on a residue ring Z / NZ for outputting X −1 mod N with respect to inputs X and N, and further comprising:
And an extended greatest common divisor arithmetic unit according to any one of
An inverse element calculation device having a division device by a power of 2 on NZ.
【請求項11】 nビットの入力X,Nに対し、X-122n
modN を出力する剰余環Z/NZ上のモンゴメリ逆元演算装
置であり、請求項5乃至7の何れかに記載の拡張最大公
約数演算装置と、剰余環Z/NZ上の2のべきによる乗算装
置と、剰余環Z/NZ上の2のべきによる除算装置を有して
いることを特徴とする逆元演算装置。
11. For n-bit inputs X and N, X −1 2 2n
A Montgomery inverse element arithmetic unit on a remainder ring Z / NZ that outputs mod N, wherein the extended greatest common divisor arithmetic unit according to any one of claims 5 to 7 and multiplication by a power of 2 on the remainder ring Z / NZ. An inverse element arithmetic unit characterized by having a unit and a division unit by a power of 2 on the remainder ring Z / NZ.
【請求項12】 nビットの入力X,Nに対し、X-12nm
odNを出力する剰余環Z/NZ上の半モンゴメリ(Kalisk
i)逆元演算装置であり、請求項5乃至7の何れかに記
載の拡張最大公約数演算装置と、剰余環Z/NZ上の2のべ
きによる除算装置とを有していることを特徴とする逆元
演算装置。
12. X- 1 2 nm for n-bit inputs X and N
Half-Montgomery (Kalisk) on the remainder ring Z / NZ that outputs odN
i) It is an inverse element operation device, and has the extended greatest common divisor operation device according to any one of claims 5 to 7 and a division device by a power of 2 on the remainder ring Z / NZ. And the inverse element calculation device.
【請求項13】 nビットの入力X,Nに対し、X-122n
modN を出力する剰余環Z/NZ上のモンゴメリ逆元演算装
置であり、請求項5乃至7の何れかに記載の拡張最大公
約数演算装置と、剰余環Z/NZ上の2のべきによる乗算装
置とを有していることを特徴とする逆元演算装置。
13. For n-bit inputs X and N, X −1 2 2n
A Montgomery inverse element arithmetic unit on a remainder ring Z / NZ that outputs mod N, wherein the extended greatest common divisor arithmetic unit according to any one of claims 5 to 7 and multiplication by a power of 2 on the remainder ring Z / NZ. An inverse element operation device comprising: a device.
JP2002356532A 1997-11-04 2002-12-09 Maximum common divisor arithmetic unit, inverse element arithmetic unit, and arithmetic program recording medium Expired - Lifetime JP3673785B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2002356532A JP3673785B2 (en) 1997-11-04 2002-12-09 Maximum common divisor arithmetic unit, inverse element arithmetic unit, and arithmetic program recording medium

Applications Claiming Priority (7)

Application Number Priority Date Filing Date Title
JP9-301593 1997-11-04
JP30159397 1997-11-04
JP9-310466 1997-11-12
JP31046697 1997-11-12
JP10-13574 1998-01-27
JP1357498 1998-01-27
JP2002356532A JP3673785B2 (en) 1997-11-04 2002-12-09 Maximum common divisor arithmetic unit, inverse element arithmetic unit, and arithmetic program recording medium

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
JP31353998A Division JP3434220B2 (en) 1997-11-04 1998-11-04 Inverse element computing device and its program recording medium

Publications (2)

Publication Number Publication Date
JP2003233309A true JP2003233309A (en) 2003-08-22
JP3673785B2 JP3673785B2 (en) 2005-07-20

Family

ID=27792215

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2002356532A Expired - Lifetime JP3673785B2 (en) 1997-11-04 2002-12-09 Maximum common divisor arithmetic unit, inverse element arithmetic unit, and arithmetic program recording medium

Country Status (1)

Country Link
JP (1) JP3673785B2 (en)

Also Published As

Publication number Publication date
JP3673785B2 (en) 2005-07-20

Similar Documents

Publication Publication Date Title
EP0917047B1 (en) Apparatus for modular inversion for information security
US7904498B2 (en) Modular multiplication processing apparatus
US6038581A (en) Scheme for arithmetic operations in finite field and group operations over elliptic curves realizing improved computational speed
US7831650B2 (en) Method for modular multiplication
US20060126830A1 (en) Montgomery transform device, arithmetic device, IC card, encryption device, decryption device and program
US20120197956A1 (en) Calculating unit for reducing an input number with respect to a modulus
US20040098436A1 (en) Method and device for constructing elliptical curves
US6430588B1 (en) Apparatus and method for elliptic-curve multiplication and recording medium having recorded thereon a program for implementing the method
US8417760B2 (en) Device and method for calculating a multiplication addition operation and for calculating a result of a modular multiplication
US20020126838A1 (en) Modular exponentiation calculation apparatus and modular exponentiation calculation method
US6480606B1 (en) Elliptic curve encryption method and system
KR20040067779A (en) Information processing means
US20080065714A1 (en) Device and method for calculating a result of a modular multiplication with a calculating unit smaller than the operands
US6609141B1 (en) Method of performing modular inversion
US8364737B2 (en) Device and method for calculating a result of a sum with a calculating unit with limited word length
JP2000511649A (en) Public key cryptography
US10057064B2 (en) Computational method, computational device and computer software product for montgomery domain
JP2003233309A (en) Greatest common divisor arithmetic unit, inverse element arithmetic unit, arithmetic program recording medium
JPH11282351A (en) Inverse element computing method in security technique, computing device using the method and recording medium recording program for executing the method
US7472154B2 (en) Multiplication remainder calculator
JP2006235416A (en) Device for computing scalar multiplication in elliptic curve cryptosystem, and program for the same
JP3136709B2 (en) Exponentiation unit
JP3966714B2 (en) Cryptographic processing method, program thereof, and recording medium thereof
JP2005316038A (en) Scalar multiple computing method, device, and program in elliptic curve cryptosystem
JP3992883B2 (en) Arithmetic apparatus and arithmetic method

Legal Events

Date Code Title Description
A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20050111

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20050221

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20050412

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20050425

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20090428

Year of fee payment: 4

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20090428

Year of fee payment: 4

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20100428

Year of fee payment: 5

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20100428

Year of fee payment: 5

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20110428

Year of fee payment: 6

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20120428

Year of fee payment: 7

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20130428

Year of fee payment: 8

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20140428

Year of fee payment: 9

S531 Written request for registration of change of domicile

Free format text: JAPANESE INTERMEDIATE CODE: R313531

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

EXPY Cancellation because of completion of term