JP3673785B2 - Maximum common divisor arithmetic unit, inverse element arithmetic unit, and arithmetic program recording medium - Google Patents
Maximum common divisor arithmetic unit, inverse element arithmetic unit, and arithmetic program recording medium Download PDFInfo
- Publication number
- JP3673785B2 JP3673785B2 JP2002356532A JP2002356532A JP3673785B2 JP 3673785 B2 JP3673785 B2 JP 3673785B2 JP 2002356532 A JP2002356532 A JP 2002356532A JP 2002356532 A JP2002356532 A JP 2002356532A JP 3673785 B2 JP3673785 B2 JP 3673785B2
- Authority
- JP
- Japan
- Prior art keywords
- gcd
- calculation
- extended
- arithmetic
- input
- 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.)
- Expired - Lifetime
Links
Images
Landscapes
- Complex Calculations (AREA)
Description
【0001】
【発明の属する技術分野】
この発明は、有限体上の演算に関し、特に誤り訂正符号(代数幾何符号など)や情報セキュリティ技術(暗号鍵生成、ディジタル署名、ブラインド署名、楕円暗号など)を実現するために用いられる最大公約数演算装置、剰余逆元演算、演算装置、及びそのプログラム記録媒体に関する。
【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の互除法を行なう装置は、除算装置と減算装置の組合せによって構成することができる。
【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が求まる。
【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) の演算結果として出力する。
【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)のビットサイズに比例して大きくなる。このため、大きい整数の演算の回数を減らすことがgcd演算の高速化につながる。
大きい整数の演算の回数を減らすための方法のひとつに、以下に説明する疑似算法を利用する演算方法がある。これは、ループ中で、大きい整数を使った演算をする代わりに、小さい整数を使った演算により疑似的にgcd算法を行ない、その後疑似算法で得られた値を用いて、大きい整数の演算をまとめて行なう方法である。
【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の互除法を行うのではなく、x0i,y1i,x1i,y0iを用いてEuclidの互除法を行う。即ち、式(6)の右辺と左辺の整数部分の値が同じである間だけ小さい整数x0i,y1i,x1i,y0iを求める。これを疑似演算と呼ぶ。その後に、疑似演算により得られた値を用いて大きい整数Xi,Yiの演算を行なう。
これにより、大きい整数の演算をまとめて行なうことと同等の効果を得ることができる(例えば、x0i,x1i,y0i,y1iが10桁の場合、約12回分の演算を1度にまとめることができる)。また、この方法を2進gcd算法へ適用することも可能である。
【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では、まとめて行なえる演算のビット数がその時によって変わってしまうため、まとめ演算のメリット
(効果)が減ってしまう。
【0008】
【課題を解決するための手段】
この発明では2進gcd算法に対して疑似算法を用いるが、以下に詳細に説明するように誤差範囲を求めないで実現する。
算法Lでは、Xi,Yiの代わりに、小さい整数x0i,x1i,y0i,y1iを用いて疑似演算を行なう。x0iとx1iがそれぞれXiの取り得る値の下限と上限とを代表し、y0iとy1iがそれぞれYiの取り得る値の下限と上限とを代表する。上限と下限の差(誤差範囲)がある程度開くまで疑似演算を続ける。
この発明では、Xiの値を代表する小さい整数を、上限と下限の中間の値xa のみにする。また、誤差範囲を求めず、予め定められた回数w'回の疑似演算を行なう。
【0009】
これによる利点は2つある。
(1) 誤差範囲を用いる方法に比べ、一度に多くの疑似演算を行なえるため、多倍長の演算の回数が減る。
(2) 一定の値w'ビットのシフト演算を行なうことができる。
これらによって2進gcd算法の高速化を可能にする。
算法LはEuclid互除法や2進gcd演算法の動作と同等の演算を行なうが、この発明では、同等の動作をしない場合もある。例えば、2進gcd演算法では、ループ中でUとVの大小比較を行なう。U,Vの値が離れていれば、上位数桁のみを見ることによって大小比較が出来る。ところが、U,Vの値が近い場合には、U,Vの演算のシミュレートを行なっている小さい整数ua,va(U,Vの上位数桁に相当する)だけではどちらが大きいか判別不能な場合がある。このような場合、算法Lでは一度疑似演算を終了し、U,Vの値を計算しなおしてから大小判定をしていた。
この発明では、その場合でも疑似演算を続行する。従って、この発明では大小関係を誤る場合もある。大小関係を誤ると、U,Vが負の値になる(算法Lではそういうことは起こらない)。しかし、gcd(U,V)=gcd(|U|,|V|)とすることによって、この発明が誤った答えが出力されることを防いでいる。これにより、この発明は算法Lよりも一度にまとめる演算数を増やし、多倍長の演算の回数を減らした。また、この発明は予め決められたビット数(w'ビット)ずつの演算を行なうことが可能となる。
【0010】
gcd演算アルゴリズム
以下にこの発明による拡張2進gcd演算装置の理解を容易にするため、まずこの発明の原理を通常の2進gcd演算に適用した場合のアルゴリズムを示す。
ステップ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ビット
【数1】
もしi≦wならばステップS5へ。
ステップS3(単精度演算ループ): 以下をw回繰り返す:
(1) uxが偶数ならば
【数2】
(2) vxが偶数ならば
【数3】
(3) vx, ux が奇数かつua>vaならば
【数4】
(4) vx, ux が奇数かつua≦vaならば
【数5】
ステップS4(多倍長値再計算):
【数6】
U ← |U'|/2w; V ←|V'|/2w
もしV=0ならばステップS5へ、それ以外はステップS2へ。
ステップS5(最終処理演算):
V=0ならば Uを出力。
V≠0ならば gcd(U, V)を求めて出力(単精度wビット以下の演算)
上記アルゴリズムの妥当性
命題1:上記アルゴリズムが終了すれば、gcd(X, Y)を出力する。
証明:上記アルゴリズムでは常にgcd(U, V)=gcd(X, Y)が成り立っている。これを帰納法により証明する。
【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が実行され、終了する。発明者は上記式が成り立つことを証明することができるが、ここでは省略する。
【0012】
【発明の実施の形態】
gcd演算装置
図2及び図3を参照してgcd演算装置1000を説明する。この装置1000は入力部101によりX,Yが入力され、出力部102からgcd(X, Y) を出力する装置であって、gcd演算初期設定部110と、gcd演算疑似演算部120と、gcd演算多倍長演算部130と、gcd演算最終演算部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へ渡す。
【0013】
ステップS5: gcd演算疑似演算部120は、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に対して2Z0gcd(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-70、前記ステップ4でV0,U0から各上位wビット、各下位wビットを取出す演算ビット取出し手段1-41を備え、またこのgcd演算装置1000には、各種データや演算、制御、処理上必要とするデータなどを記憶する記憶部160が設けられている。
【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及び115は、それぞれ入力X,Yとz0が入力され、入力された値X,Yに対してそれぞれ2Z0による除算を行ない、その除算結果U0,V0を出力する。gcd演算初期設定110はU0,V0,z0を出力する。
【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ユニット123は、
ua ← [ua/2]; ux ← ux/2
vu ← 2vu; vv ← 2vv
の演算を行ない、制御部121へデータα'={va,ua,vx,ux,uu,uv,vu,vv,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}を送る。
【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,vv,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,vv,c}を送る。
ステップS9: 場合1ユニット123乃至場合4ユニット126の何れかでデータαの処理がなされてデータα' として制御部121に戻されると、制御部121はcの値を1増やす。
【0017】
ステップS10: そのcとw'とを比較し、c<w'であればステップS2に戻り、c=w'ならば{uu,uv,vu,vv}をgcd演算疑似演算部120からgcd演算多倍長演算部130へ出力する。
制御部121は入力された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を求めていることになる。
【0018】
gcd多倍長演算部130
図8を参照してgcd多倍長演算部130の動作を説明する。
図8において、gcd多倍長演算部130には制御装置150からU0,V0が、gcd演算疑似演算部120からuu,uv,vu,vvをそれぞれ入力される。乗算器13a〜13dはそれぞれ積uuU0,uvVv,vuU0,vvV0を計算して出力する。
減算器13e及び13fはそれぞれ差U1=uuU0−uvV0及びV1=vvV0−vuU0を計算して絶対値器13g及び13hに出力する。
絶対値器13g及び13hはそれぞれ入力U1及びV1の絶対値を計算して2のべきによる除算器13i及び13jに出力する。
2のべきによる除算器13i及び13jはそれぞれ入力|U1|及び|V1|の2w'による除算を計算しこれをU0及びV0としてgcd多倍長演算部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かのチェックが行われる。
【0019】
gcd演算最終処理部140
図9を参照してgcd演算最終処理部140の動作を説明する。
gcd演算最終処理部140には制御装置150から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は制御装置150で行うことができ、その他の各部も制御装置150により制御され、また各部において各処理上必要とする記憶部(メモリ)は図2中の記憶部160を利用することができる。
【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'を加算する。
【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であれば拡張gcd演算最終演算部240の処理に移る。
ステップS8: 拡張gcd演算最終演算部240は、V0≠0なら入力U0,V0,z0に対して2Z0gcd(U0,V0)を求めて出力する。また、V0=0ならS=2kX-1modYなるS,kを求め、出力する。
【0022】
図11には特に示していないが、この拡張gcd演算装置2000にも、図2中に示した初期判定手段1-20、ビットサイズ取得手段1-30、ビットサイズ検査手段1-40、演算ビット取出手段1-41、最終判定手段1-70、記憶部160に対応するものが設けられている。
拡張gcd演算初期設定部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としてもよい。
【0023】
拡張gcd多倍長演算部230
図13,図14を参照して拡張gcd多倍長演算部230の動作を説明する。この演算部230には図11における制御装置250からU0,V0,S0,T0が、また拡張gcd演算疑似演算部220からuu,uv,vu,vvが入力される。
乗算器23a〜23hはそれぞれ積uuU0,uvV0,vuU0,vvV0,uuS0,uvT0,vuS0,vvT0を計算して出力する。
減算器23i及び23jはそれぞれ差U'=uuU0−uvV0及びV'=vuV0−uvU0を計算して出力する。
加算器23k及び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のべきによる除算器23rに出力し、T'をT0として演算部230から出力する。
【0024】
2のべきによる除算器23qは入力U'の2w'による商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に入力される。
【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に示すようにステップS3、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の一方が奇数かつ、 gcd(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をメモリから読出して出力すればよい。
【0026】
上述では一度に演算することのできるビット数をw及びw'としたが、疑似演算部(120,220)で一度に計算する量w'と多倍長演算部(130,230)とで一度に計算する量wとを同じ値としてもよい。
先に述べたように拡張2進gcd演算装置は2のべきによる除算装置と組み合わせて剰余環Z/NZ上の逆元演算装置を構成することができる。図16はこの発明の拡張2進gcd演算装置を使って通常逆元演算装置を構成した場合である。図に示すように、整数XとNがこの装置3000に入力され、まず図11で説明した拡張2進gcd演算装置315で拡張2進gcd演算がなされ、S=X-12kmodN とkとが出力され、このS,kとNがZ/NZ上の2のべきによる除算装置318に入力されS・2-kmodN が演算され、その演算結果としてX-1modN、つまりXのZ/NZ上の逆元演算結果が得られる。
【0027】
図17に剰余環Z/NZ上の半モンゴメリ(Kaliski)逆元演算にこの発明の拡張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上のMontgomery逆元演算にこの発明の拡張2進gcd演算装置を適用した場合の逆元演算装置3200を示す。図に示すように、入力された整数X,Nについて拡張gcd演算装置315でS=X-12kmodN 及びkを求め、これに対しZ/NZ上の2のべき乗倍装置325でS・22n-kmodNを演算してX-122nmodNを得ることもできる。
【0028】
図19は、Z/NZ上のモンゴメリ逆元演算装置にこの発明の拡張gcd演算装置を適用した場合の装置5000を示す。図19に示すように、制御部510の制御のもとに、まずZ/NZ上の2のべきによる除算装置514で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ビットずつまとめて行うのが好ましい。
【0029】
CPU11は主記憶装置13内の演算プログラムに従って最大公約数又は拡張最大公約数演算あるいは逆元演算を実行する。RAM12はこれら演算に必要な各種パラメータの値や変数値を保持したり、演算の途中結果や最終結果を保持する。利用者Aはキーボード14からプログラムの実行命令を入力し、演算の実行経過が表示装置15に表示される。
ここで、この発明の逆元演算装置がセキュリティ技術の例であるディジタル署名において使用される場合について説明する。利用者Aの演算装置10Aは例えばネットワークNWを介して利用者Bの演算装置10Bに接続されており、利用者Aは文書mに対しディジタル署名Sをつけて利用者Bの演算装置10Bに送信し、利用者Bは受信した署名Sの正当性を検証する。ここでは、ディジタル署名として、ESIGN 方式を使う場合で説明する。この場合、利用者AとBは公開鍵nとシステムパラメータkを共有し、送信側利両者Aは素数の秘密鍵p,qを秘密に保持している。ただしn=pqである。
ディジタル署名方式ESIGN を実行するためのプログラム13Pは主記憶装置13ないに格納されている。そのプログラム13Pの一部として、ディジタル署名生成の一過程で使用される逆元演算を含む式をこの発明の演算方法により実行する部分プログラム13PPが設けられている。
【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に格納され、それを使用する場合を示したが、この様なプログラムを他のどの様な形態の記録媒体に格納して使用してもよいことは明らかである。
【0031】
【発明の効果】
この発明の2進gcd演算装置では、小さい整数を使った演算により、疑似的に2進gcd算法を行なうことによって、大きい整数の演算を1/w に比例する割合で減らし、2進gcd算法を高速に行なうことを可能としている。(wは計算機が一度に扱うことができるビット数8,16,32など)
また、「実際のgcd算法を正しくシミュレートしている保証がなくても決められた回数分の疑似演算を行なう」方法の導入により、疑似演算の効率を高めた。
これにより、例えば従来法である算法Lは、32ビットの単精度整数による疑似算法で約12周分のシミュレートを行なっていたが、この発明の装置では32ビットの単精度整数による疑似算法で32周分のシミュレートすることが可能である。この場合は算法Lの半分以下の大きい整数演算の回数でgcd演算が出来る。
【図面の簡単な説明】
【図1】従来の2進gcd 算法の計算手順を示す流れ図。
【図2】この発明によるgcd演算装置の機能構成を示す図。
【図3】図2の装置の動作の流れを示す流れ図。
【図4】図2中のgcd演算初期設定部110の機能構成を示す図。
【図5】図4の初期設定部110の動作の流れを示す流れ図。
【図6】図2中のgcd演算疑似演算部120の機能構成を示す図。
【図7】図6の疑似演算部120の動作の流れを示す流れ図。
【図8】図2中のgcd演算多倍長演算部130の機能構成を示す図。
【図9】図2中のgcd演算最終演算部140の機能構成を示す図。
【図10】図9中の最終演算部140の動作の流れを示す図。
【図11】この発明の変形例である拡張2進最大公約数演算装置の機能構成を示す図。
【図12】図11の拡張2進最大公約数演算装置の動作の流れを示す図。
【図13】図11中の拡張gcd演算多倍長演算部230の機能構成を示す図。
【図14】図13の多倍長演算部230の動作の流れを示す図。
【図15】図11中の最終演算部240の動作の流れの一部を示す図。
【図16】この発明の拡張2進gcdを適用した通常逆元演算装置の機能構成を示す図。
【図17】この発明の拡張2進gcdを適用した半モンゴメリ(Kaliski)逆元演算装置の機能構成を示す図。
【図18】この発明の拡張2進gcdを適用したMontgomery逆元演算装置の機能構成を示す図。
【図19】この発明の拡張2進gcdを適用したMontgomery逆元演算装置の他の機能構成を示す図。
【図20】この発明による演算プログラム記録媒体を使用してコンピュータによりこの発明装置を機能させるための機能構成例を示すブロック図。[0001]
BACKGROUND OF THE INVENTION
The present invention relates to operations on a finite field, and in particular, the greatest common divisor used to implement error correction codes (such as algebraic geometric codes) and information security techniques (such as encryption key generation, digital signatures, blind signatures, elliptical encryption). The present invention relates to an arithmetic device, a remainder inverse operation, an arithmetic device, and a program recording medium thereof.
[0002]
[Prior art]
As a method for obtaining the greatest common divisor (gcd), (1) Euclid mutual division, (2) binary gcd arithmetic, and (3) arithmetic L are known. Arithmetic L is an efficient method of Euclid's division method for large numbers.
(1)Euclid Mutual division of
Euclid's mutual division is
Xi= QiYi+ Ri (1)
And when
gcd (Xi, Yi) = Gcd (Yi, Ri(2)
Take advantage of the fact that
Xi + 1= Yi, Yi + 1= Ri (3)
As a result, X0, Y0To Xi, YiAnd using equation (2)
gcd (X0, Y0) = Gcd (X1, Y1) =… = gcd (Xj, 0) = Xj (Four)
Gcd (X0, Y0).
(See the document "D.E.Knuth (translated by Keisuke Nakagawa):" Quasi-numerical arithmetic / arithmetic operation (THE ART OF COMPUTER PROGRAMMING, fourth volume) "pp.157, Arithmetic A, Science, 1986).)
A specific example is given. In Euclid's divisor, an integer
X0= 24, Y0= 9
For the above, the following calculation is performed.
X1← Y0= 9, Y1← X0 mod Y0= 6
X2← Y1= 6, Y2← X1mod Y1= 3
XThree← Y2= 3, YThree← X2mod Y2= 0
As a result, gcd (X0, Y0) = gcd (XThree, YThree) = Gcd (3,0) = 3.
An apparatus that performs Euclid's mutual division method can be configured by a combination of a division device and a subtraction device.
[0003]
(2)Binary gcd algorithm
The binary gcd algorithm is
When X is odd and Y is even: 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 even and Y is even: gcd (X, Y) = 2gcd (X / 2, Y / 2)
This is a method for obtaining gcd using the fact that That is, Xi, YiWhen any of these are odd numbers,
(A) XiIs odd, YiWhen is even: Xi + 1← XiYi + 1← Yi/ 2
(B) XiIs even, YiWhen is odd: Xi + 1← Xi/ 2; Yi + 1← Yi
(C) XiIs odd, YiWhen is odd: Xi + 1← XiYi + 1← Xi−Yi
X obtained by performingi + 1, Yi + 1About the following formula,
gcd (Xi + 1, Yi + 1) = Gcd (Xi, Yi) (Five)
Take advantage of the fact that Repeat the above process (A), (B) and (C)0, Y0To Xi, YiAnd using equation (5),
gcd (X0, Y0) = gcd (X1, Y1) =… = gcd (Xj, 0) = Xj
Gcd (X0, Y0).
(See the document "D.E. Knuth (translated by Keisuke Nakagawa):" Quasi-numerical arithmetic / arithmetic operations (THE ART OF COMPUTER PROGRAMMING, Volume 4) "pp. 158, Arithmetic B, Science, 1986).)
A specific example is given. In binary gcd arithmetic, an integer
X0= 24, Y0= 9
For the above, the following calculation is performed.
X1← X0/ 2Three= 3; Y1← Y0= 9
X2← X1= 3; Y2← (Y1−X1) / 2 = 3
XThree← X2= 3; YThree← (Y2−X2) / 2 = 0
As a result, gcd (X0, Y0) = gcd (XThree, YThree) = Gcd (3,0) = 3.
[0004]
The binary gcd algorithm can be realized by a process as shown in FIG. In this example, processing is performed as follows using variables U and V corresponding to inputs X and Y.
Step S1: X and Y are set to U and V as initial values, respectively, and an
Step S2: Determine whether both U and V are even numbers, that is, determine whether the least significant bit is "0".
Step S3: If U and V are both even, 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, V / 2 is set to V and the process returns 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: If U and V are both odd numbers, it is determined whether U> V.
Step S9: If U> V, set (U-V) / 2 to V and return to step S4.
Step S10: If U ≦ V, (V−U) / 2 is set to V.
Step S11: Determine whether V = 0, and if not 0, return to Step S4.
Step S12: If V = 0, U × z is output as the calculation result of gcd (X, Y).
[0005]
An apparatus that performs binary gcd arithmetic can be constructed by only division and subtraction by two. Since multiplication / division by 2 is equivalent to 1-bit shift, there is an advantage that it is easy to implement in an electronic circuit or an electronic computer. In the Euclid mutual division method and binary gcd calculation method, when the input values X and Y are large integers, bit shift, subtraction, and division of large integers are performed a plurality of times. For example, consider a case where binary gcd arithmetic is performed on integers X and Y that can be represented by 512 bits. The number of loops k in the binary gcd algorithm is twice the size of the input value (in this case, 512 to 1024 times), and k bit shifts and subtractions up to k times (average k / 2 times) are performed ( Corresponding to step S9 or S10 in FIG. 1). The time required for one bit shift and addition / subtraction also increases in proportion to the bit size of the value to be calculated (in this case, U, V). For this reason, reducing the number of large integer operations leads to faster gcd operations.
One method for reducing the number of operations for large integers is an operation method that uses a pseudo-arithmetic method described below. This is because, instead of performing an operation using a large integer in a loop, a pseudo gcd arithmetic is performed by an operation using a small integer, and then a large integer is calculated using a value obtained by the pseudo arithmetic. It is a method to perform collectively.
[0006]
(3)Arithmetic L
Conventionally, there is a method in which a pseudo-arithmetic method is applied to the Euclid mutual division method. (For example, refer to the document “D.E.
A specific example is given. In arithmetic L, a large integer
X0= 912345567890123456789
Y0= 2000000000000000001
For the upper 4 digits, for example, and the value obtained by adding 1 to the 4 digits, respectively, is a small integer as follows:
x00= 9123
x10= 9124
y00= 2000
y10= 2001
Decide as.
Xi + 1= YiYi + 1= XimodYi
x0i + 1= Y1iY1i + 1= X0imody1i
x1i + 1= Y0iY0i + 1= X1imody0i
Then,
x0i/ y1i<Xi/ Yi<X1i/ y0i (6)
Holds. In algorithm L, Xi, YiInstead of using Euclid's mutual division with x0i, Y1i, X1i, Y0iEuclid is used for mutual division. That is, an integer x0 that is small only while the values of the integer part of the right side and the left side of Equation (6) are the samei, Y1i, X1i, Y0iAsk for. This is called a pseudo operation. After that, using the value obtained by the pseudo operation, a large integer Xi, YiPerform the operation.
This can achieve the same effect as performing large integer operations together (for example, x0i, X1i, Y0i, Y1iIf is 10 digits, about 12 operations can be combined at once). It is also possible to apply this method to binary gcd arithmetic.
[0007]
[Problems to be solved by the invention]
The problem with Arithmetic L is that x0i, Y1iEuclid's mutual division method and x1i, Y0iIt is necessary to perform both Euclid's mutual division methods using, and the number of operations that can be combined at one time differs depending on the time.
A normal computer has a storage device that can read and write in units of M bits (M is 8, 16, 32, etc.) (Condition 1). For this reason, it is efficient to perform operations in units of M bits. For example, in binary gcd arithmetic, a large integer 1-bit shift is performed. However, under
On the other hand, in the calculation method L, the number of bits of operations that can be performed together changes depending on the time.
(Effect) will decrease.
[0008]
[Means for Solving the Problems]
In the present invention, a pseudo-arithmetic method is used for the binary gcd arithmetic method, but it is realized without obtaining an error range as will be described in detail below.
In algorithm L, Xi, YiSmall integer x0 instead ofi, X1i, Y0i, Y1iA pseudo operation is performed using. x0iAnd x1iEach XiRepresenting the lower and upper limits of the possible values of y0iAnd y1iEach YiRepresents the lower and upper limits of possible values. The pseudo operation is continued until the difference between the upper limit and the lower limit (error range) opens to some extent.
In this invention, XiA small integer representing the value ofaOnly. Further, the pseudo calculation is performed a predetermined number of times w ′ without obtaining the error range.
[0009]
This has two advantages.
(1) Compared to the method using the error range, many pseudo operations can be performed at one time, so the number of multiple length operations is reduced.
(2) A shift operation with a constant value w ′ bits can be performed.
These make it possible to speed up the binary gcd algorithm.
Arithmetic L performs an operation equivalent to the operation of the Euclid mutual division method or the binary gcd operation method. However, in the present invention, the operation may not be equivalent. For example, in the binary gcd calculation method, U and V are compared in size in a loop. If the values of U and V are separated, the size can be compared by looking at only the upper few digits. However, when the values of U and V are close, a small integer u simulating the operation of U and Va, VaIt may not be possible to determine which one is larger only (corresponding to the upper digits of U and V). In such a case, in the calculation method L, the pseudo operation is once terminated, and the U and V values are calculated again, and then the magnitude determination is performed.
In this invention, the pseudo-operation is continued even in that case. Therefore, in this invention, the magnitude relationship may be wrong. If the magnitude relationship is wrong, U and V become negative values (this is not the case with Arithmetic L). However, by setting gcd (U, V) = gcd (| U |, | V |), the present invention prevents an erroneous answer from being output. As a result, the present invention increases the number of operations to be summarized at once than the method L, and reduces the number of multiple-length operations. In addition, the present invention can perform an operation for each predetermined number of bits (w ′ bits).
[0010]
gcd calculation algorithm
In order to facilitate understanding of the extended binary gcd arithmetic apparatus according to the present invention, an algorithm in the case where the principle of the present invention is first applied to a normal binary gcd arithmetic will be described below.
Step S1 (Multiple-length value initial setting):
U ← Y; V ← X; S ← 0; T ← 1.
Step S2 (single precision value initial setting):
i ← max (size of V; size of U)
va← Upper w bit of V; ua← Upper w bit of U
vx← Lower w bit of V; ux← Lower w bit of U
[Expression 1]
If i ≦ w, go to step S5.
Step S3 (single precision calculation loop): The following is repeated w times:
(1) uxIf is even
[Expression 2]
(2) vxIf is even
[Equation 3]
(3) vx, ux Is odd and ua> VaIf
[Expression 4]
(4) vx, ux Is odd and ua≦ vaIf
[Equation 5]
Step S4 (multiple-length value recalculation):
[Formula 6]
U ← | U '| / 2w; V ← | V '| / 2w
If V = 0, go to step S5, otherwise go to step S2.
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)
Validity of the above algorithm
Proposition 1: When the above algorithm ends, gcd (X, Y) is output.
Proof: In the above algorithm, gcd (U, V) = gcd (X, Y) always holds. This is proved by induction.
[0011]
1. In step S1, since U = X and V = Y, gcd (U, V) = gcd (X, Y) is established.
2. In steps S3 and S4
When U is even: U ← U / 2
When V is an even number: V ← V / 2
When U and V are both odd numbers and U> V: U ← (U-V) / 2
When U and V are both odd numbers and U ≦ V: V ← (V-U) / 2
An operation corresponding to any of the above is performed. That is, if gcd (U, V) = gcd (X, Y) at the start of step S3, then gcd (U, V) = gcd (X, Y) holds at the end of step S4. However, here gcd (U, V) = gcd (| U |, | V |).
From the above 1 and 2, gcd (X, Y) is output when the above algorithm is completed.
Rationale for completion of the above algorithm
Proposition 2: If w ≧ 4, the algorithm ends in a finite time.
Proof: The values of U and V at the time of the above step S2 are expressed as U0, V0U and V recalculated in step S41, V1And At this time,
U0+ V0> U1+ V1
Can be shown. U + V decreases monotonically in the above algorithm, U + V <2wAt this point, step S5 is executed and the process ends. The inventor can prove that the above equation holds, but it is omitted here.
[0012]
DETAILED DESCRIPTION OF THE INVENTION
gcd arithmetic unit
The gcd
Step S1: The gcd calculation
gcd (X, Y) = 2Z0gcd (U, V) (7)
U, V, z satisfying0Out of z0Is the maximum, and U and V at that time are0, V0To the
Step S2: The
Step S3: Otherwise, the
Step S4: Check whether the bit size i is less than or equal to w bits. If the inspection passes, the gcd calculation
va= V0Upper w bits (from i-th bit to i-w + 1-th bit)
ua= U0Upper w bits (from i-th bit to i-w + 1-th bit)
vx= V0Lower w bits of
ux= U0Lower w bits of
Are passed to the gcd
[0013]
Step S5: The gcd
Step S6: The gcd calculation multiple
U0← | uuU0−uvV0| / 2w; V0← | vvV0−vuU0| / 2w
Calculate and update each U0, V0To the
Step S7: The
Step S8: The gcd calculation
Therefore, the
[0014]
gcd calculation
The operation of the gcd calculation
Step S1: The counting
Step S2: The
Step S3: The
[0015]
gcd
The operation of the gcd
Step S1: From control device 150 va, Ua, Vx, UxAre input to the
Step S2: The
Step S3: uxIs an even number, one unit 123 is
ua← [ua/ 2]; ux← ux/ 2
vu← 2vuVv← 2vv
And the data α ′ = {va, Ua, Vx, Ux, Uu, Uv, Vu, Vv, C}.
Step S4: uxIs not an even number, the
Step S5: uxIs odd and vxIf is even, then 2 units 124 are
va← [va/ 2]; vx← vx/ 2
uu← 2uuUv← 2uv
And the data α ′ = {va, Ua, Vx, Ux, Uu, Uv, Vu, Vv, C}.
[0016]
Step S6: The
ua← [(ua−va) / 2]; ux← (ux−vx) / 2
uu← uu+ VuUv← uv+ Vv
vu← 2vuVv← 2vv
And the data α ′ = {va, Ua, Vx, Ux, Uu, Uv, Vu, Vv, C}.
Step S8: ux, vxIs odd and ua≦ vaIn the case of 4
va← [(va−ua) / 2]; vx← (vx−ux) / 2
vu← vu+ UuVv← vv+ Uv
uu← 2uuUv← 2uv
And the data α ′ = {va, Ua, Vx, Ux, Uu, Uv, Vu, Vv, C}.
Step S9: When the data α is processed in any of the
[0017]
Step S10: The c and w ′ are compared. If c <w ′, the process returns to step S2, and if c = w ′, {uu, Uv, Vu, Vv} Is output from the gcd operation
The
This gcd
gcd (U0, V0) = gcd (| uuU0−uvV0| / 2w ', | VvV0−vuU0| / 2w ') (8)
Meet uu, Uv, Vu, VvWill be seeking.
[0018]
gcd multiple length
The operation of the gcd multiple length
In FIG. 8, the gcd multiple length
The
The
The power-of-two
The processing of the gcd multiple length
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 ' The division by is performed after the absolute value is obtained, but as shown in step S1, 2w ' The division by may be performed before the absolute value is obtained. U obtained0, V0Is input to the
[0019]
gcd calculation
The operation of the gcd calculation
The gcd calculation
As shown in FIG. 10, the gcd calculation
As described above, the greatest common divisor of the inputs X and Y can be obtained. In addition, except for the gcd calculation
[0020]
Extended binary
The extended binary
The
Step S1: The extended gcd calculation
gcd (X, Y) = 2z0gcd (U0, V0(9)
Meet U0, V0, Z0Out of z0Find the one that maximizes. Initial value S of S, T, k0= 0, T0= 1, k = 0 and U0, V0To the control device 250 and z through the control device 2500To the extended gcd calculation
Step S2: The control device 250 receives the input U0, V0, S0, T0, K, U0= 1 or V0Check if = 1. If the inspection passes, the expanded gcd calculation
Step S3: The control device 2500= 1 or V0If not = 1, enter U0, V0, S0, T0, K, U0And V0The larger bit size value i of the bit sizes is obtained.
Step S4: The controller 250 checks whether the value i is less than w bits. If the inspection is passed, the expanded gcd calculation
va= V0Upper w bits (from i-th bit to i-w + 1-th bit)
ua= U0Upper w bits (from i-th bit to i-w + 1-th bit)
vx= V0Lower w bits of
ux= U0Lower w bits of
Are passed to the extended gcd
[0021]
Step S5: The extended gcd
Step S6: The extended gcd calculation multiple
U '= (uuU0−uvV0) / 2w ',
V '= (vvV0−vuU0) / 2w ',
S '= uuS0+ UvT0,
T '= vvT0+ VuS0
Calculate Here, if V ′ is negative, the signs of V ′ and T ′ are inverted, and if U ′ is negative, the signs of U ′ and S ′ are inverted. U ', V', S ', T' obtained as a result of operation0, V0, S0, T0To the control device 250.
Step S7: The control device 250 is V0If it is 0, the process returns to step S3. If it is 0, the process proceeds to the extended gcd calculation
Step S8: The extended gcd calculation
[0022]
Although not specifically shown in FIG. 11, the extended
The extended gcd calculation
The functional configuration of the extended gcd
[0023]
Extended gcd multiple length
The operation of the extended gcd multiple length
Each of the
The
The
If U ′ <0 with respect to the inputs U ′ and S ′, the
If V ′ <0 with respect to the inputs V ′ and T ′, the
[0024]
The power-of-two
The processing of the above extended gcd multiple length
Is calculated.
Step S2: V1Is less than 0, and if not less than 0, the process proceeds to step S4.
Step S3: V1V is less than 0, V1← -V1And T1← -T1To change the sign.
Step S4: U1Is less than 0, and if not less than 0, the process proceeds to step S6.
Step S5: U1U is less than 0, U1← -U1And S1← -S1To change the sign.
Step S6: V obtained1, U1, S1, T1Updated V0, U0, S0, T0Output as.
The output of the extended gcd arithmetic multiple length
[0025]
Extended gcd calculation
The extended gcd calculation
Similarly to the gcd
[0026]
In the above description, the number of bits that can be calculated at one time is set to w and w ′. The amount w to be calculated may be the same value.
As described above, the extended binary gcd arithmetic unit can be combined with a power-of-two division unit to constitute an inverse 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 the
[0027]
FIG. 17 shows an inverse element
FIG. 18 shows an inverse element
[0028]
FIG. 19 shows an
The above-described 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 is stored in the
[0029]
The
Here, a case will be described in which the inverse operation unit of the present invention is used in a digital signature which is an example of security technology. The
A
[0030]
First, the
w = [{h (m) −xkmod n} / p ・ q] (10)
Calculate Then the following formula
S = x + {w / (k · xk-1mod p} p ・ q (11)
Ask for. W / (k ・ x in equation (11)k-1) mod p is the same as the inverse operation described above. Therefore, as explained above
y = w (k ・ xk-1)-1mod p = w ・ X-1mod p (12)
In other words, y can be obtained by the inverse element calculation processing procedure shown in the explanation of FIG. Using y obtained in this way
S = x + y · p · q (13)
And (S, m) is transmitted to the
User B's
Sk−2a≦ h (m) ≦ Sk, Where a = [(2/3) log2n] (14)
Is established, and if it is established, it is recognized that the signature S for the document m is correct.
Although the recording medium of the inverse arithmetic operation program of the present invention is stored in the
[0031]
【The invention's effect】
In the binary gcd arithmetic unit according to the present invention, by performing a pseudo binary gcd calculation by a calculation using a small integer, the calculation of a large integer is reduced at a rate proportional to 1 / w, and the binary gcd calculation is performed. It can be performed at high speed. (W is the number of bits that the computer can handle at one
In addition, the efficiency of the pseudo operation is increased by introducing a method of “performing a predetermined number of times even if there is no guarantee that the actual gcd algorithm is correctly simulated”.
Thus, for example, the conventional method L has been simulated for about 12 laps by a pseudo-arithmetic method using 32-bit single-precision integers. It is possible to simulate 32 laps. In this case, the gcd operation can be performed with a large number of integer operations less than half of the algorithm L.
[Brief description of the drawings]
FIG. 1 is a flowchart showing a calculation procedure of a conventional binary gcd algorithm.
FIG. 2 is a diagram showing a functional configuration of a gcd arithmetic device according to the present invention.
FIG. 3 is a flowchart showing an operation flow of the apparatus of FIG. 2;
4 is a diagram showing a functional configuration of a gcd calculation
5 is a flowchart showing an operation flow of the
6 is a diagram showing a functional configuration of a gcd
7 is a flowchart showing an operation flow of the
8 is a diagram showing a functional configuration of a gcd arithmetic multiple length
9 is a diagram showing a functional configuration of a gcd calculation
FIG. 10 is a diagram showing a flow of operation of a
FIG. 11 is a diagram showing a functional configuration of an extended binary greatest common divisor arithmetic device according to a modification of the present invention.
12 is a diagram showing a flow of operations of the extended binary greatest common divisor computing device of FIG. 11;
13 is a diagram showing a functional configuration of an extended gcd arithmetic multiple length
14 is a diagram showing a flow of operation of the multiple length
FIG. 15 is a diagram showing a part of the operation flow of the
FIG. 16 is a diagram showing a functional configuration of a normal inverse element arithmetic device to which the extended binary gcd of the present invention is applied.
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;
FIG. 18 is a diagram showing a functional configuration of a Montgomery inverse element computing device to which the extended binary gcd of the present invention is applied.
FIG. 19 is a diagram showing another functional configuration of the Montgomery inverse element computing device to which the extended binary gcd of the present invention is applied.
FIG. 20 is a block diagram showing an example of a functional configuration for causing a computer to function according to the present invention by using a computer program recording medium according to the present invention.
Claims (12)
これら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 を演算するgcd演算最終処理手段と、
演算の結果 gcd(X,Y)を出力する出力手段と、
上記各手段を順次動作させ、記憶手段に対する読出し書込みなどを行う制御手段、
とを含む最大公約数演算装置。Input means for inputting input values X and Y;
Storage means for storing these X and Y respectively;
Input values X, Y from the gcd (X, Y) = gcd (U 0, V 0) and gcd calculation initialization means 2 Z0 and z 0 is computed to U 0, V 0, z 0 to the maximum, gcd ( A, B) represents the greatest common divisor of A and B
From input values U 0 and V 0 , for a predetermined integer w ′ ≧ 4
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 ′ )
Gcd operation pseudo-operation means for calculating u u , u v , v v , and v u satisfying
From input values U 0 , V 0 , u u , u v , v v , v u
U '= | u u U 0 −u v V 0 | / 2 w ′
V ′ = | v v V 0 −v u U 0 | / 2 w ′
Gcd operation multiple length calculation means for calculating and outputting as U 0 and V 0 ,
Gcd calculation final processing means for calculating gcd (U 0 , V 0 ) 2 Z 0 from input values U 0 , V 0 , z 0 ;
An output means for outputting the result gcd (X, Y);
Control means for sequentially operating each of the above means and performing read / write to the storage means,
The greatest common divisor arithmetic unit.
入力値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 of claim 1, wherein the control means comprises:
A bit size obtaining means for obtaining a larger value i of the bit sizes of the input values U 0 and V 0 ;
It is determined whether or not the value i is less than or equal to w. If it is not less than w, the gcd calculation pseudo-calculation means is executed, and if it is less than or equal to w, the bit size inspection means for executing the gcd calculation final processing means; w is a predetermined integer of 4 or more,
Final determination means for determining whether or not V 0 in the output of the gcd arithmetic multiple length arithmetic means is 0;
If the determination of the final determination means is not V 0 = 0, the outputs U 0 and V 0 of the gcd operation multiple length calculation means are input to the bit size acquisition means and executed, and the V 0 = 0 is executed. Means for executing the gcd calculation final processing means,
And the greatest common divisor computing device.
上記gcd演算疑似演算手段は、
上記ua,va,ux,vxと、初期値uu=1,uv=0,vu=1,vv=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 extracts operation bits for extracting u a and v a of each upper w bit and u x and v x of each lower w bit from U 0 and V 0 , respectively. Having means,
The gcd operation pseudo-operation means is:
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 are input,
u x is or even, v x is or even, u a> v a or, determining u x, v x, u a , and v a state determining means,
u x is an even number, and u a = [u a / 2], u x = u x / 2, v u = 2v u , v v = 2v v ,
v x is an even number and v a = [v a / 2], v x = v x / 2, u u = 2u u , u v = 2u v ,
u a > v a and 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 ,
In other cases, 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 ,
An update operation means for updating u u , v v , u v , v u by executing any of the following:
Counting means for counting the number of times c calculated by the update calculating means;
Means for repeatedly executing the u x , v x , u a , and v a state determination means, the update calculation means, and the counting means until the number of times c reaches w ′;
And the greatest common divisor computing device.
これら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(modN)の演算結果として、これとkを出力する出力手段と
上記各手段を順次動作させ、記憶手段に対する読出し書込みなどを行う制御手段、とを含む拡張最大公約数演算装置。An input means for inputting an input value X, N of which one is an odd number;
Storage means for storing these X and N respectively;
Extended gcd calculation initial setting means for initial setting U 0 = X, V 0 = N, S 0 = 0, T 0 = 1, k = 0;
From input values U and V to a predetermined w '
gcd (U, V) = gcd (| u u U 0 −u v V 0 | / 2 w , | v v V 0 −v u U 0 | / 2 w ′ )
An extended gcd operation pseudo-operation means for calculating u u , u v , v v , and v u satisfying and adding w ′ to k;
From input values U, V, S, T, u u , u v , v v , v u
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 )
When,
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 an extended gcd arithmetic multiple length arithmetic means for outputting U ′, V ′, S ′, T ′ as U 0 , V 0 , S 0 , T 0 , respectively,
From 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 c = 0
U u , u v , v v , v u , c satisfying
S '= u u S 0 + u v T 0
An extended gcd calculation final processing means for calculating c and adding c to k;
The calculation result of the extended gcd calculation final processing means is set as the calculation result of S = X −1 2 k (modN), and this and the output means for outputting k and each of the above means are operated in order to read and write to the storage means. An extended greatest common divisor computing device including control means for performing the operation.
入力値U0,V0の各ビットサイズ中の大きな方の値iを求めるビットサイズ取得手段と、
上記値iがw以下か否かを判定し、w以下でなければ上記拡張gcd演算疑似演算手段を実行させ、w以下であれば上記拡張gcd演算最終処理手段を実行させるビットサイズ検査手段と、
上記拡張gcd演算多倍長演算手段の出力中のV0が0であるか否かを判定する最終判定手段と、
上記最終判定手段の判定がV0=0でなければ上記拡張gcd演算多倍長演算手段の出力U0,V0を上記ビットサイズ取得手段に入力して、これを実行させ、V0=0であれば上記拡張gcd演算最終処理手段を実行させる手段、
とを含むことを特徴とする拡張最大公約数演算装置。6. The apparatus of claim 5, wherein the control means is
A bit size obtaining means for obtaining a larger value i of the bit sizes of the input values U 0 and V 0 ;
A bit size checking means for determining whether or not the value i is less than or equal to w, and executing the extended gcd calculation pseudo-calculation means if it is not less than w, and executing the extended gcd calculation final processing means if it is less than or equal to w;
Final determining means for determining whether or not V 0 in the output of the extended gcd arithmetic multiple length arithmetic means is 0;
If the determination of the final determination means is not V 0 = 0, the outputs U 0 and V 0 of the extended gcd calculation multiple length calculation means are input to the bit size acquisition means and executed, and V 0 = 0. If so, means for executing the extended gcd calculation final processing means,
And an extended greatest common divisor computing device.
上記拡張gcd演算疑似演算手段は、上記ua,va,ux,vxと、初期値uu=1,uv=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 apparatus according to claim 5 or 6, wherein said control means includes operation bit extraction means for extracting u a and v a of each upper w bit and u x and v x of each lower w bit from U 0 and V 0 , respectively. Have
The extended gcd operation pseudo-operation means receives 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 and k. ,
u x is or even, v x is or even, and u a> v a or determines u x, v x, u a , v a state determining means,
u x is an even number, and u a = [u a / 2], u x = u x / 2, v u = 2v u , v v = 2v v ,
v x is an even number and v a = [v a / 2], v x = v x / 2, u u = 2u u , u v = 2u v ,
u a > v a and 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 ,
In other cases, 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 calculation means for updating u u , v u , u v , v v by performing any of the following:
Counting means for counting the number of times c calculated by the update calculating means;
The number c is w 'said u x until, v x, u a, and v a state determining means, and the update computing unit, to execute repeatedly a process between the counting means, the number c is w' becomes Means for updating k to k + w '
And an extended greatest common divisor computing device.
上記X ' と上記Nが入力され、これらに対し拡張2進gcd演算を行い、S=X -1 2 k mod Nとkを出力する、請求項5乃至7のいずれかに記載の拡張最大公約数演算装置と、
上記SとkとNとtが入力され、Nのビット長nとkとtとから2n−k−tが負であればk ' =2n+k+tとS ' =Sを出力し、2n−k−tが正であればk ' =2n−k−tとS ' =Sを出力する比較装置と、
上記k ' =−2n+k+tとS ' とNが入力され、T=S ' 2 -k' mod Nを演算する剰余環 Z / NZ 上の2のべきによる除算装置と、
k ' =2n−k−tとS ' とNが入力され、T=S ' 2 k mod Nを演算する剰余環 Z/NZ 上の2のべきによる乗算装置と、
上記除算装置及び上記乗算装置より出力される演算結果TをX -1 2 2n mod Nの演算結果として出力する出力部とを備えることを特徴とする逆元演算装置。A Montgomery inverse operation unit on the remainder ring Z / NZ that outputs X -1 2 2n modN for n-bit inputs X and N, and X and N are input, and X ′ = X · 2 −t mod A power-of-two division unit on the remainder ring Z / NZ that computes N and outputs X ′ and t ;
The extended maximum commitment according to any one of claims 5 to 7, wherein X ' and N are input, an extended binary gcd operation is performed on these, and S = X -1 2 k mod N and k are output. A number arithmetic unit;
If S, k, N, and t are input and 2n−kt is negative from the bit lengths n, k, and t of N, k ′ = 2n + k + t and S ′ = S are output, and 2n−k− a comparator that outputs k ′ = 2n−kt and S ′ = S if t is positive ;
K ′ = − 2n + k + t, S ′, and N are inputted, and a division unit by a power of 2 on the remainder ring Z / NZ for calculating T = S ′ 2 −k ′ mod N ;
k ′ = 2n−k−t, S ′, and N are input, and T = S ′ 2 k mod N is a multiplier by a power of 2 on the remainder ring Z / NZ ,
An inverse element computing device comprising: an output unit that outputs a computation result T output from the division device and the multiplication device as a computation result of X -1 2 2n mod N.
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 |
|---|---|---|---|
| JP30159397 | 1997-11-04 | ||
| JP31046697 | 1997-11-12 | ||
| JP9-301593 | 1998-01-27 | ||
| JP10-13574 | 1998-01-27 | ||
| JP1357498 | 1998-01-27 | ||
| JP9-310466 | 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 JP2003233309A (en) | 2003-08-22 |
| JP3673785B2 true 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) |
Families Citing this family (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP7414675B2 (en) | 2020-09-11 | 2024-01-16 | キオクシア株式会社 | Inverse element calculation device and memory system |
-
2002
- 2002-12-09 JP JP2002356532A patent/JP3673785B2/en not_active Expired - Lifetime
Also Published As
| Publication number | Publication date |
|---|---|
| JP2003233309A (en) | 2003-08-22 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| EP0917047B1 (en) | Apparatus for modular inversion for information security | |
| CN109791517B (en) | Protecting parallel multiplication operations from external monitoring attacks | |
| US20110161390A1 (en) | Modular multiplication processing apparatus | |
| Großschädl | A bit-serial unified multiplier architecture for finite fields GF (p) and GF (2m) | |
| US7603558B2 (en) | Montgomery transform device, arithmetic device, IC card, encryption device, decryption device and program | |
| CN1650254B (en) | Apparatus and method for calculating a result of a modular multiplication | |
| JP2004519017A (en) | Method and apparatus for multiplying coefficients | |
| WO2002003608A1 (en) | Method and apparatus for incomplete modular arithmetic | |
| US10057064B2 (en) | Computational method, computational device and computer software product for montgomery domain | |
| KR20040067779A (en) | Information processing means | |
| US20040054706A1 (en) | Modular arithmetic apparatus and method having high-speed base conversion function | |
| JP3673785B2 (en) | Maximum common divisor arithmetic unit, inverse element arithmetic unit, and arithmetic program recording medium | |
| Rao et al. | Aryabhata remainder theorem: relevance to public-key crypto-algorithms | |
| US7016927B2 (en) | Method and apparatus for modular multiplication | |
| Arazi et al. | On calculating multiplicative inverses modulo $2^{m} $ | |
| CN111740821A (en) | Method and apparatus for establishing shared key | |
| JPH11282351A (en) | Inverse element operation method in security technology, operation device using the method, and recording medium storing program for executing the method | |
| US8850213B2 (en) | Method for verifying an electronic signature and data processing device | |
| CN116034339A (en) | Method, random number generator, and computer readable medium for generating pseudorandom numbers | |
| RU2401513C2 (en) | Method for generating and verification electronic digital signature authenticating electronic document | |
| Wu et al. | An efficient montgomery exponentiation algorithm for cryptographic applications | |
| JP3136709B2 (en) | Exponentiation unit | |
| JP2005316038A (en) | Scalar multiplication method, apparatus and program for elliptic curve cryptography | |
| JP2002304122A (en) | Subgroup upper element determination device for rational point group on curve, program therefor, and recording medium therefor | |
| JP3768888B2 (en) | Discrete logarithm verification method, apparatus for implementing this method, program, and storage medium storing program |
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 |