JP3555091B2 - Method and apparatus for modular exponentiation operation - Google Patents
Method and apparatus for modular exponentiation operation Download PDFInfo
- Publication number
- JP3555091B2 JP3555091B2 JP28685394A JP28685394A JP3555091B2 JP 3555091 B2 JP3555091 B2 JP 3555091B2 JP 28685394 A JP28685394 A JP 28685394A JP 28685394 A JP28685394 A JP 28685394A JP 3555091 B2 JP3555091 B2 JP 3555091B2
- Authority
- JP
- Japan
- Prior art keywords
- data
- storage means
- bits
- data storage
- 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】
【産業上の利用分野】
本発明は、冗長2進演算方法を利用して桁数の多い羃乗剰余演算を高速に行う方法及びその装置に関するものである。
【0002】
【従来の技術】
羃乗剰余演算は乗算及び剰余算の繰返しにより実行できるが、桁数の多い乗算及び剰余算を高速に行おうとすると、桁上がり・桁借りのキャリーの伝搬遅延の問題が顕著になる。そこで、従来より、キャリーの伝搬を防ぐ工夫をなした演算方法が種々提案されているが、そのうちの一つに冗長2進演算方法がある(例えば、IEEE JOURNAL OF SOLID−STATE CIRCUITS, Vol.25, No.3, June, 1990, A.Vandemeulebroecke, E.Vanzieleghem, T.Denayer and P.G.A.Jespers“A New Carry−Free Division Algorithm and its Application to a Single−Chip 1024−b RSA Processor ”参照)。
【0003】
【発明が解決しようとする課題】
ところが、この冗長2進演算方法では、除算や剰余算を行う場合、法の最上位ビットが常に“1”でなければならないという制約があり、その結果、法のビット数が限定されてしまうという問題があった。
【0004】
本発明の目的は、法の最上位ビットが“1”でなくても冗長2進演算方法による羃乗剰余演算を可能とする方法及びその装置を提供することにある。
【0005】
【課題を解決するための手段】
本発明では、前記目的を達成するため、法Nと該法N以下の自然数からなる数A及び羃指数Bとを入力し、法Nがdビットに限定される冗長2進演算方法を利用して羃乗剰余演算R=AB mod Nを行い、少なくとも演算結果の剰余Rを出力する羃乗剰余演算方法及び装置において、法Nのデータを上位からmビット毎に入力用前段データ記憶手段に取り込むとともに該法Nのデータが何mビット入力されたかをデータカウント手段で計測し、入力用前段データ記憶手段に最初に取り込まれたデータの先頭から何ビット目に最初に“1”が現れたかを検出し、該検出したビット数をビットシフト量として決定し、入力用前段データ記憶手段内のデータを入力用後段データ記憶手段に順次転送し、入力用前段データ記憶手段内のデータを下位mビットとし入力用後段データ記憶手段内のデータを上位mビットとして、その2mビットを前記ビットシフト量だけ上位にシフトし、該シフトした後の2mビットのデータの上位mビットをmビットシフトデータ記憶手段に格納し、法Nのデータ入力完了後、データカウント手段の値とmビットシフトデータ記憶手段の容量/mとの差分をシフト量としてシフト量記憶手段に記憶し、mビットシフトデータ記憶手段のデータをシフト量記憶手段の値だけ上位にmビット単位にシフトして法記憶手段に記憶し、数Aのデータを上位からmビット毎に入力用前段データ記憶手段に取り込むとともに該数Aのデータが何mビット入力されたかをデータカウント手段で計測し、入力用前段データ記憶手段内のデータを入力用後段データ記憶手段に順次転送し、入力用前段データ記憶手段内のデータを下位mビットとし入力用後段データ記憶手段内のデータを上位mビットとして、その2mビットを前記ビットシフト量だけ上位にシフトし、該シフトした後の2mビットのデータの上位mビットをmビットシフトデータ記憶手段に格納し、数Aのデータ入力完了後、mビットシフトデータ記憶手段のデータをシフト量記憶手段の値だけ上位にmビット単位にシフトして数記憶手段に記憶し、羃指数Bのデータを羃指数記憶手段に直接取り込んで記憶するとともに該羃指数Bのデータが何ビット入力されたかをデータカウント手段で計測して記憶し、記憶された法N、数A及び羃指数Bのデータを使用して冗長2進演算手段に羃乗剰余演算を行わせ、演算結果の剰余Rを剰余記憶手段に記憶し、剰余記憶手段より剰余Rのデータを上位からmビット毎に出力用前段データ記憶手段に取り込み、出力用前段データ記憶手段内のデータを出力用後段データ記憶手段に順次転送し、出力用前段データ記憶手段内のデータを下位mビットとし出力用後段データ記憶手段内のデータを上位mビットとして、その2mビットを前記ビットシフト量だけ下位にシフトして出力することを特徴とする。
【0006】
【作用】
従来の冗長2進演算方法を利用した演算器では法の最上位ビットを“1”に制限している。そのため、法のビット数も一意に限定されてしまう。一方、本発明の羃乗剰余演算方法及び装置によれば、法を任意にシフトして入力する手段を有し、これを利用することにより法を格納する時は最上位ビットが必ず“1”になるようにすることができる。従って、法レジスタのビット長以下であればいかなるビット長でも羃乗剰余演算を実行することが可能になり、冗長2進数を利用した羃乗剰余演算を法におけるビット長を限定することなく行うことができるようになる。
【0007】
【実施例】
従来から多数ビット長で高速処理が必要な四則演算に用いられてきた冗長2進演算器に、本発明のパラメタの入出力補正部を加えることにより、法レジスタ以下のビット長であれば、法のビット長に制限のない羃乗剰余演算を行うことができる。
【0008】
まず、乗算及び剰余算を組み合わせることにより、法を任意のビット長とした羃乗剰余演算が実行可能であることを示す。
【0009】
羃乗剰余演算R=AB mod Nは、kビットの羃指数Bのデータが入力された時、k≧i≧1なるiを用いて、
B=bk ×2k−1 +bk−1 ×2k−2 +……+bi ×2i−1 +……+b2 ×21 +b1 ×20
とし、
で求めることができる。即ち、羃乗剰余演算は乗算及び剰余算の繰り返しにより求めることができる。
【0010】
この演算処理を冗長2進演算方法により実行するには、法Nのビット長が冗長2進演算器のビット長と等しくなければならないことは前述した通りであるが、法Nのビット長が冗長2進演算器のビット長より短い時、N・2j が冗長2進演算器のビット長と等しくなるようにjを決定し、
を実行すれば、目的のR=AB mod Nの演算を実行することができる。
【0011】
羃乗剰余演算としてAB mod Nの演算を行い、演算結果の剰余Rを出力する例について述べる。この例は以下のフェーズに分けることができる。
(1)演算に必要な3つのパラメタのパラメタレジスタへの入力
(2)冗長2進演算部へ各パラメタを入力するためのパラメタ変換
(3)冗長2進演算部での羃乗剰余演算
(4)演算結果の出力
以下、各フェーズ毎に説明する。
【0012】
図1は本発明の一実施例を示すもので、図中、1はパラメタ入出力補正部、2はパラメタレジスタ部、3はパラメタ変換部、4は改良型冗長2進演算部、5は状態遷移制御部である。
【0013】
図2はパラメタ入出力補正部1及びパラメタレジスタ部2の詳細を示すもので、ここではデータの入出力を8ビットのデータバスで行う例を示す。
【0014】
カウンタ部6は入力される8ビットのデータをカウントアップする。入力用前段バッファ部7は8ビットのデータを蓄積するレジスタである。第1オクテット先頭“1”検出部8は8ビットのデータの先頭から何ビット目に“1”があるかを検出する。ビットシフト量決定部9は第1オクテット先頭“1”検出部8の値からビットシフト量を決定する。入力用後段バッファ部10は8ビットのデータを蓄積するレジスタである。
【0015】
入力用ビットシフト部11は16ビット入力で上位8ビット出力のバレルレジスタであり、シフト量はビットシフト量決定部9で決まる。バイトシフト部12は8ビットデータを上位に1バイト単位で任意にシフトさせることができるレジスタである。バイトシフト量記憶部13は法N及び数A入力時のバイトシフト量を記憶しておく。
【0016】
出力用前段バッファ部14は8ビットのデータを蓄積するレジスタである。出力用後段バッファ部15は8ビットのデータを蓄積するレジスタである。出力用ビットシフト部16は16ビット入力で上位8ビット出力のバレルレジスタであり、シフト量はビットシフト量決定部9で決まる。
【0017】
法Nレジスタ21は法Nを格納しておくレジスタである。数Aレジスタ22は数Aを格納しておくレジスタである。羃指数Bレジスタ23は羃指数Bを格納しておくレジスタである。剰余Rレジスタ24は演算結果の剰余Rを格納しておくレジスタである。
【0018】
また、図3はパラメタ変換部3及び改良型冗長2進演算部4の詳細を示すものである。
【0019】
冗長2進表現の法Nレジスタ31は冗長2進表現の法Nを格納しておくレジスタである。冗長2進表現の数Aレジスタ32は冗長2進表現の数Aを格納しておくレジスタである。冗長2進表現の剰余Rレジスタ33は冗長2進表現の剰余Rを格納しておくレジスタである。初期化回路34は剰余Rレジスタ24を初期化する。レジスタ35は羃指数Bのビット長を格納する。レジスタ36は法Nのビット長(n)を格納する。
【0020】
改良型冗長2進演算部4は従来から用いられている冗長2進演算回路のパラメタ入力を改良したものである。冗長2進数乗算部41は冗長2進数による乗算を実行する。冗長2進数除算部42は冗長2進数による除算を実行する。冗長2進数乗算パラメタ入力部43は冗長2進表現の剰余Rもしくは数Aを乗数として冗長2進数乗算部41に入力する。被乗数レジスタ44は冗長2進表現の剰余Rを被乗数として冗長2進数乗算部41に入力する。被除数レジスタ45は冗長2進表現の法Nを被除数として冗長2進数除算部42に入力する。冗長2進数演算途中結果レジスタ46は冗長2進表現の演算途中結果を格納する。演算途中結果レジスタ47は通常の2進数による演算途中結果を格納する。
【0021】
図4は本実施例の全体的な動作フローチャートを、また、図5は羃乗剰余演算時の詳細な動作フローチャートを示すもので、以下、これらに従って動作を説明する。
【0022】
(1)演算に必要な3つのパラメタのパラメタレジスタへの入力
まず、演算の前にパラメタの入力を開始する(S1)。ここで、状態遷移制御部5は入力バイト数を数えるカウンタ部6の初期化を指示する。状態遷移制御部5は入力パラメタが法Nあるいは羃指数Bの入力か否か(S2)及び法Nか否か(S3)によって指示内容が異なるが、最初は法Nの入力を行うものと仮定する。また、以降、状態遷移制御部5はパラメタの入力が終了するまでカウンタ部6にカウントアップを指示する。
【0023】
状態遷移制御部5は法Nの入力であれば、ビットシフト量決定部9の初期化を指示する(S4)。なお、数Aあるいは羃指数Bの入力の場合はビットシフト量決定部9はそのままの状態を保つ。
【0024】
状態遷移制御部5は8ビットのデータバスを介して最初に入力用前段バッファ部7に入力された1バイトデータのみを第1オクテット先頭“1”検出部8に取り込むように指示し、第1オクテット先頭“1”検出部8は取り込んだ8ビットのデータの先頭から何ビット目に最初の“1”があるかを検出する。この際、検出された値(0〜7)はビットシフト量決定部9で用いられ、該ビットシフト量決定部9では第1オクテット先頭“1”検出部8からの値が「0」であればビットシフト量を「0」、「1」であればビットシフト量を「1」、……と決定する(S5)。
【0025】
入力用前段バッファ部7に格納された1バイトのデータは次の1バイトのデータが入力される前に入力用後段バッファ部10に転送される。状態遷移制御部5は転送が終了した後に2バイト目以降のデータの入力を指示する。次のデータがある場合は第2オクテットが入力用前段バッファ部7に入力される。
【0026】
入力用後段バッファ部10及び入力用前段バッファ部7の2バイトのデータが揃うと、入力用後段バッファ部10の8ビットを上位8ビット(第1オクテット)とし、入力用前段バッファ部7の8ビットを下位8ビット(第2オクテット)とした計16ビットのデータを入力用ビットシフト部11に転送する。入力用ビットシフト部11ではビットシフト量決定部9で決めたビットシフト量だけ上位にずらしたデータを出力する。
【0027】
前記出力はバイトシフト部12のLSB側から入力される。そして、入力用ビットシフト部11の出力の上位8ビットのみがバイトシフト部12に入力される。これにより、入力された第1オクテットが10進数で「1〜255」のどのような値であってもバイトシフト部12に入力される値は10進数で「128〜255」となり、先頭ビットは必ず“1”になる。
【0028】
第3オクテット目以降は、第2オクテットの後を追うように、カウンタ部6、入力用前段バッファ部7、入力用後段バッファ部10、入力用ビットシフト部11を経てバイトシフト部12に入力される。以降、全データが入力されるまでこの動作を続け、状態遷移制御部5が最後のデータの入力終了を検出する。
【0029】
法Nのデータ入力の場合、バイトシフト部12に入力された第1オクテットが最上位に移動するように1バイトづつシフトし、空いたところに“0”を補いながらパラメタの補正シフトが行われる(S8)。このようにして、パラメタ長が計測され(S6)、状態遷移制御部5からパラメタ長が格納される(S7)。このパラメタ長はバイトシフト量記憶部13に記憶される。
【0030】
法Nのデータ入力時には法Nレジスタ21へ、数Aのデータ入力時は数Aレジスタ22へパラメタの格納が行われる(S9)。法N入力時にはその後に数Aを入力することがあるので、さらに続けて数Aを入力する場合にはステップS2に戻り、そうでない場合は終了する(S10)。
【0031】
法Nのパラメタが入力された後に数Aのパラメタの入力が行われるが、その工程は法Nの場合とほぼ同じである。唯一、法Nの場合と異なる点は、入力用ビットシフト部11でのビットシフト量とバイトシフト部12でのバイトシフト量の決定方法であり、数Aの場合のビットシフト量は法Nの場合に決定した値をそのまま用いる。従って、第1オクテット先頭“1”検出部8は動作しない。数Aのデータは入力後、入力用ビットシフト部11でビットシフト量決定部9の値の分、ビットシフトされ(S11)、バイトシフト部12でバイトシフト量記憶部13の値の分、パラメタの補正シフトが行われる(S8)。
【0032】
羃指数Bの入力に関しては、法Nや数Aのようにシフトさせて入力する必要はないので、カウンタ部6の出力から直接、羃指数Bレジスタ23にパラメタ格納が行われる(S9)。
以上のようにして3つのパラメタの入力が完了する。
【0033】
(2)冗長2進演算部へパラメタを入力するためのパラメタ変換
冗長2進演算は、通常、使用する2進表現とは異なり、2ビットで通常の1ビット分のデータを示す。そこで、通常の2進表現を冗長2進表現に変換する必要がある。法Nレジスタ21及び数Aレジスタ22に格納されたパラメタは冗長2進表現に変換されて、冗長2進表現の法Nレジスタ31及び冗長2進表現の数Aレジスタ32に格納される。
【0034】
(3)冗長2進演算部での羃乗剰余演算
冗長2進乗算部41の被乗数レジスタ44には常に冗長2進表現の剰余Rレジスタ33のデータが入力される。冗長2進除算部42の被除数レジスタ45には常に冗長2進表現の法Nレジスタ31のデータが入力される。また、冗長2進除算部42の除数として、常に冗長2進乗算部41での乗算結果が入力される。
【0035】
演算が開始される(S121)と、まず、初期化回路34により剰余Rレジスタ24及び冗長2進表現の剰余Rレジスタ33が“1”に初期化される(R=1,i=k)(S122)。
【0036】
▲1▼冗長2進表現の剰余Rレジスタ33のデータを冗長2進乗算部41の冗長2進乗算数パラメタ入力部43に入力する。入力後、冗長2進乗算部41及び冗長2進除算部42において乗算及び除算が行われ(S123)、冗長2進演算途中結果レジスタ46に途中結果が出力される。
【0037】
この演算(Ri+1 ={Ri ・(Ri ・2j )}mod (N・2j ):但し、j=バイトシフト量記憶部13の値+ビットシフト量決定部9の値)の結果が冗長2進数演算途中結果レジスタ46に出力され、通常の2進数表現に戻した結果が演算途中結果レジスタ47に出力される。この値が次の剰余Rレジスタ24のデータとなる。剰余Rレジスタ24のデータは再び冗長2進表現に変換され、冗長2進表現の剰余Rレジスタ33に格納される。
【0038】
▲2▼羃指数Bレジスタ23のデータの先頭ビットを見て“1”(bi =1)でなければ(S124)、この作業は飛ばす。
【0039】
冗長2進数乗算パラメタ入力部43に冗長2進表現の数Aレジスタ32のデータを入力し、乗算・除算を行い(S125)、その演算(Ri+1 ={A・(Ri ・2j )}mod (N・2j ))の結果が冗長2進数演算途中結果レジスタ46に出力され、通常の2進数表現に戻した結果が演算途中結果レジスタ47に出力される。
【0040】
▲3▼羃指数Bレジスタ23のデータの先頭ビットの値を破棄し、次のビットを先頭ビットとする。同時に羃指数Bビット長レジスタ35の値が0(i=0)でなければ1減らし(i=i−1)、▲1▼に戻る。i=0になれば、このフェーズを終了する(S126,S127,S128)。
【0041】
(4)演算結果の出力
剰余Rレジスタ24の値が求める演算結果である。但し、この値は2j 倍されているので、パラメタ出力時に以下のようにして逆補正する。
【0042】
状態遷移制御部5の指示により、剰余Rレジスタ24内の演算結果の第1オクテットが出力用前段バッファ部14に取り込まれる。次に、出力用前段バッファ部14に取り込まれた第1オクテットが出力用後段バッファ部15に移され、第2オクテットが出力用前段バッファ部14に取り込まれる。
【0043】
出力用後段バッファ部15の8ビットを上位8ビット(第1オクテット)とし、出力用前段バッファ部14の8ビットを下位8ビット(第2オクテット)とした計16ビットのデータは、出力用ビットシフト部16にて、法Nの入力時に決定したビットシフト量決定部9からの値により下位にシフトする。そして、出力用ビットシフト部16の出力の上位8ビットのみが8ビットのデータとして出力される。出力すべきデータのオクテット数は、法Nの入力時のカウンタ部6の値を減少させて0になるまで出力する(S13〜S17)。
【0044】
なお、演算結果以外の法N、数Aのパラメタ出力は剰余Rレジスタ24からの出力の場合と全く同じである。また、羃指数Bの出力はビットシフトやバイトシフトは行われていないので、羃指数レジスタ23から直接出力する。
【0045】
【発明の効果】
以上説明したように本発明によれば、冗長2進演算方法の長所である多倍長の高速演算性を生かしつつ、短所である羃乗剰余演算の際の法の最上位ビットが“1”に限定される、即ちビット長が一定値に限定されるという制約を解決することができる。
【図面の簡単な説明】
【図1】本発明の一実施例を示す構成図
【図2】パラメタ入出力補正部及びパラメタレジスタ部の詳細を示す構成図
【図3】パラメタ変換部及び改良型冗長2進演算部の詳細を示す構成図
【図4】全体的な動作フローチャート
【図5】羃乗剰余演算時の詳細な動作フローチャート
【符号の説明】
1…パラメタ入出力補正部、2…パラメタレジスタ部、3…パラメタ変換部、4…改良型冗長2進演算部、5…状態遷移制御部。[0001]
[Industrial applications]
The present invention relates to a method and apparatus for performing a modular exponentiation operation with a large number of digits at high speed using a redundant binary operation method.
[0002]
[Prior art]
The modular exponentiation operation can be executed by repetition of multiplication and remainder calculation. However, when multiplication and remainder calculation with a large number of digits are performed at high speed, the problem of carry propagation delay of carry and borrow becomes significant. In view of this, conventionally, various arithmetic methods devised to prevent carry propagation have been proposed, and one of them is a redundant binary arithmetic method (for example, IEEE JOURNAL OF SOLID-STATE CIRCUITS, Vol. 25). , No. 3, June, 1990, A. Vandemeulebroecke, E. Vanzieleghem, T. Denayer and PGA Jespers, "A New Carry-Response Promotion Agreement Promotion Agreement. reference).
[0003]
[Problems to be solved by the invention]
However, in this redundant binary arithmetic method, when performing division or remainder arithmetic, there is a restriction that the most significant bit of the modulus must always be "1", and as a result, the number of bits of the modulus is limited. There was a problem.
[0004]
An object of the present invention is to provide a method and an apparatus for enabling a modular exponentiation operation by a redundant binary operation method even if the most significant bit of the modulus is not "1".
[0005]
[Means for Solving the Problems]
In the present invention, in order to achieve the above object, a modulus N, a number A consisting of a natural number equal to or less than the modulus N and a power exponent B are input, and a redundant binary operation method in which the modulus N is limited to d bits is used. Modular exponentiation operation R = A B mod N, and at least a remainder R of the operation result is output. The number of m bits of the data of the modulus N was input and measured by the data counting means, and the first bit in the data from the head of the data first taken into the input preceding-stage data storage means. Is detected, the detected number of bits is determined as a bit shift amount, the data in the input pre-stage data storage unit is sequentially transferred to the input post-stage data storage unit, and the data in the input pre-stage data storage unit is stored in the lower order. The data in the input post-stage data storage means is set as the upper m bits, and the 2m bits are shifted upward by the bit shift amount, and the upper m bits of the shifted 2m bits data are stored in the m bit shift data. After completion of the data input of the modulus N, the difference between the value of the data counting means and the capacity / m of the m-bit shift data storage means is stored in the shift amount storage means as the shift amount, and the m-bit shift data storage means is stored. Is shifted upward by the value of the shift amount storage means in units of m bits and stored in the modal storage means. The number of m bits of data input is measured by the data count means, and the data in the input preceding data storage means is sequentially transferred to the input subsequent data storage means. After transferring, the data in the input pre-stage data storage means is set to the lower m bits, the data in the input post-stage data storage means is set to the upper m bits, and the 2m bits are shifted upward by the bit shift amount. Is stored in the m-bit shift data storage means, and after completion of the data input of the number A, the data of the m-bit shift data storage means is shifted upward by the value of the shift amount storage means in units of m bits. The data is shifted and stored in the number storage means, the data of the exponent exponent B is directly taken and stored in the exponent exponent storage means, and how many bits of the data of the exponent exponent B are input is measured and stored by the data counting means. Using the stored data of the modulus N, the number A, and the exponent exponent B, the redundant binary arithmetic means performs a modular exponentiation operation, and stores the remainder R of the operation result in the residual storage means, The data of the remainder R is fetched from the remainder storage means into the output pre-stage data storage means for each m bits from the high order, and the data in the output pre-stage data storage means is sequentially transferred to the output post-stage data storage means, and the output pre-stage data storage is performed. The data in the means is the lower m bits and the data in the output post-data storage means is the upper m bits, and the 2m bits are shifted down by the bit shift amount and output.
[0006]
[Action]
In a conventional arithmetic unit using a redundant binary arithmetic method, the most significant bit of the modulus is limited to "1". Therefore, the number of modulo bits is also uniquely limited. On the other hand, according to the modular exponentiation operation method and apparatus of the present invention, there is provided a means for arbitrarily shifting and inputting the modulus, and by using this, when storing the modulus, the most significant bit is always "1". Can be Therefore, it is possible to execute a modular exponentiation operation with any bit length as long as it is equal to or less than the bit length of the modulus register, and to perform a modular exponentiation operation using a redundant binary number without limiting the bit length in the modulus. Will be able to
[0007]
【Example】
By adding an input / output correction unit of the parameter of the present invention to a redundant binary arithmetic unit conventionally used for arithmetic operations requiring high speed processing with a large number of bits, if the bit length is less than the modulus register, Can perform modular exponentiation with no restriction on the bit length of.
[0008]
First, it is shown that a modular exponentiation operation with a modulo arbitrary bit length can be executed by combining multiplication and remainder arithmetic.
[0009]
羃乗remainder operation R = A B mod N, when data of羃指number B of k bits is input, with k ≧ i ≧ 1 becomes i,
B = b k × 2 k−1 + b k−1 × 2 k−2 +... + B i × 2 i−1 +... + B 2 × 2 1 + b 1 × 2 0
age,
Can be obtained by That is, the modular exponentiation operation can be obtained by repeating multiplication and remainder arithmetic.
[0010]
As described above, the bit length of the modulus N must be equal to the bit length of the redundant binary arithmetic unit in order to execute this arithmetic processing by the redundant binary calculation method. When shorter than the bit length of the binary operator, j is determined so that N · 2 j is equal to the bit length of the redundant binary operator;
Is executed, the desired operation of R = A B mod N can be executed.
[0011]
Performs calculation of A B mod N as羃乗remainder operation, describes an example of outputting the remainder R of the calculation result. This example can be divided into the following phases:
(1) Inputting three parameters necessary for the operation to the parameter register (2) Parameter conversion for inputting each parameter to the redundant binary operation unit (3) Modulo exponentiation operation in the redundant binary operation unit (4 ) Output of calculation result The following describes each phase.
[0012]
FIG. 1 shows an embodiment of the present invention, in which 1 is a parameter input / output correction unit, 2 is a parameter register unit, 3 is a parameter conversion unit, 4 is an improved redundant binary operation unit, and 5 is a state. It is a transition control unit.
[0013]
FIG. 2 shows the details of the parameter input /
[0014]
The counter unit 6 counts up input 8-bit data. The
[0015]
The input
[0016]
The
[0017]
The
[0018]
FIG. 3 shows details of the
[0019]
The redundant binary representation
[0020]
The improved redundant
[0021]
FIG. 4 is an overall operation flowchart of the present embodiment, and FIG. 5 is a detailed operation flowchart at the time of the modular exponentiation operation.
[0022]
(1) Input of Three Parameters Required for Operation to Parameter Register First, input of parameters is started before the operation (S1). Here, the state
[0023]
If the input is modulus N, the state
[0024]
The state
[0025]
The one-byte data stored in the input first-
[0026]
When the 2-byte data of the input rear-
[0027]
The output is input from the LSB side of the
[0028]
After the third octet, the data is input to the
[0029]
In the case of modulo N data input, the first octet input to the
[0030]
When data of modulus N is input, parameters are stored in the
[0031]
After the parameters of the modulus N are input, the parameters of the number A are input, and the process is almost the same as that of the method N. The only difference from the method N is the method of determining the bit shift amount in the input
[0032]
As for the input of the exponent exponent B, it is not necessary to shift and input like the modulus N or the number A, so that the parameter is directly stored in the exponent exponent B register 23 from the output of the counter unit 6 (S9).
The input of the three parameters is completed as described above.
[0033]
(2) Parameter Conversion for Inputting Parameters to the Redundant Binary Operation Unit The redundant binary operation is different from the binary expression used in general, and shows two bits of data of one ordinary bit. Therefore, it is necessary to convert a normal binary representation into a redundant binary representation. The parameters stored in the
[0034]
(3) Exponentiation remainder operation in redundant binary operation unit The
[0035]
When the operation is started (S121), first, the
[0036]
{Circle around (1)} The data of the redundant R register 33 in the redundant binary expression is input to the redundant binary multiplier
[0037]
Result of this operation (R i + 1 = {R i · (R i · 2 j )} mod (N · 2 j ): where j = value of byte shift
[0038]
▲ 2 ▼ watching first bit of data羃指number B register 23 "1" (b i = 1) unless (S124), this task skip.
[0039]
The data of the
[0040]
(3) The value of the first bit of the data of the
[0041]
(4) Output of Operation Result The value of the
[0042]
In response to an instruction from the state
[0043]
A total of 16 bits of data, in which the 8 bits of the
[0044]
The output of the parameters of the modulus N and the number A other than the operation result is exactly the same as that of the output from the
[0045]
【The invention's effect】
As described above, according to the present invention, the most significant bit of the method for the modular exponentiation operation, which is a disadvantage, is “1” while taking advantage of the multiple-length high-speed operation, which is an advantage of the redundant binary operation method. , That is, the limitation that the bit length is limited to a constant value can be solved.
[Brief description of the drawings]
FIG. 1 is a block diagram showing an embodiment of the present invention. FIG. 2 is a block diagram showing details of a parameter input / output correction unit and a parameter register unit. FIG. 3 is a detail of a parameter conversion unit and an improved redundant binary operation unit. FIG. 4 is an overall operation flowchart. FIG. 5 is a detailed operation flowchart at the time of modular exponentiation operation.
DESCRIPTION OF
Claims (6)
法Nのデータを上位からmビット毎に入力用前段データ記憶手段に取り込むとともに該法Nのデータが何mビット入力されたかをデータカウント手段で計測し、
入力用前段データ記憶手段に最初に取り込まれたデータの先頭から何ビット目に最初に“1”が現れたかを検出し、
該検出したビット数をビットシフト量として決定し、
入力用前段データ記憶手段内のデータを入力用後段データ記憶手段に順次転送し、
入力用前段データ記憶手段内のデータを下位mビットとし入力用後段データ記憶手段内のデータを上位mビットとして、その2mビットを前記ビットシフト量だけ上位にシフトし、
該シフトした後の2mビットのデータの上位mビットをmビットシフトデータ記憶手段に格納し、
法Nのデータ入力完了後、データカウント手段の値とmビットシフトデータ記憶手段の容量/mとの差分をシフト量としてシフト量記憶手段に記憶し、
mビットシフトデータ記憶手段のデータをシフト量記憶手段の値だけ上位にmビット単位にシフトして法記憶手段に記憶し、
数Aのデータを上位からmビット毎に入力用前段データ記憶手段に取り込むとともに該数Aのデータが何mビット入力されたかをデータカウント手段で計測し、
入力用前段データ記憶手段内のデータを入力用後段データ記憶手段に順次転送し、
入力用前段データ記憶手段内のデータを下位mビットとし入力用後段データ記憶手段内のデータを上位mビットとして、その2mビットを前記ビットシフト量だけ上位にシフトし、
該シフトした後の2mビットのデータの上位mビットをmビットシフトデータ記憶手段に格納し、
数Aのデータ入力完了後、mビットシフトデータ記憶手段のデータをシフト量記憶手段の値だけ上位にmビット単位にシフトして数記憶手段に記憶し、
羃指数Bのデータを羃指数記憶手段に直接取り込んで記憶するとともに該羃指数Bのデータが何ビット入力されたかをデータカウント手段で計測して記憶し、記憶された法N、数A及び羃指数Bのデータを使用して冗長2進演算手段に羃乗剰余演算を行わせ、
演算結果の剰余Rを剰余記憶手段に記憶し、
剰余記憶手段より剰余Rのデータを上位からmビット毎に出力用前段データ記憶手段に取り込み、
出力用前段データ記憶手段内のデータを出力用後段データ記憶手段に順次転送し、
出力用前段データ記憶手段内のデータを下位mビットとし出力用後段データ記憶手段内のデータを上位mビットとして、その2mビットを前記ビットシフト量だけ下位にシフトして出力する
ことを特徴とする羃乗剰余演算方法。A modulo N, a number A consisting of a natural number less than or equal to the modulus N and a power exponent B are input, and a modular exponentiation operation R = A B mod N using a redundant binary operation method in which the modulus N is limited to d bits. , And at least the remainder R of the operation result is output,
The data of the modulus N is taken into the input preceding data storage means for each m bits from the higher order, and the number of m bits of the data of the modulus N is measured by the data counting means,
Detecting at which bit from the beginning of the data first taken into the input pre-stage data storage means a "1" first appears;
The detected bit number is determined as a bit shift amount,
Sequentially transferring the data in the input pre-stage data storage means to the input post-stage data storage means,
The data in the input pre-stage data storage means is set to the lower m bits, the data in the input post-stage data storage means is set to the upper m bits, and the 2m bits are shifted upward by the bit shift amount.
Storing the upper m bits of the shifted 2m bit data in m bit shifted data storage means;
After completion of the data input of the modulus N, the difference between the value of the data count means and the capacity / m of the m-bit shift data storage means is stored in the shift amount storage means as a shift amount,
data in the m-bit shift data storage means is shifted upward by the value of the shift amount storage means in m-bit units and stored in the modulus storage means;
The data of the number A is taken into the input preceding data storage means for each m bits from the high order, and the number of m bits of the data of the number A is measured by the data counting means,
Sequentially transferring the data in the input pre-stage data storage means to the input post-stage data storage means,
The data in the input pre-stage data storage means is set to the lower m bits, the data in the input post-stage data storage means is set to the upper m bits, and the 2m bits are shifted upward by the bit shift amount.
Storing the upper m bits of the shifted 2m bit data in m bit shifted data storage means;
After the data input of the number A is completed, the data in the m-bit shift data storage means is shifted upward by the value of the shift amount storage means in m-bit units and stored in the number storage means,
The data of the exponent exponent B is directly taken into the exponent exponent storage means and stored, and how many bits of the data of the exponent exponent B are input is measured and stored by the data counting means, and the stored modulus N, number A and exponent are stored. Using the data of the exponent B, the redundant binary arithmetic means performs a modular exponentiation operation,
Storing the remainder R of the operation result in the remainder storage means,
The data of the remainder R is fetched from the remainder storage means into the output pre-stage data storage means for each m bits from the high order,
Sequentially transferring the data in the output pre-stage data storage means to the output post-stage data storage means,
The data in the output pre-stage data storage means is the lower m bits, the data in the output post-data storage means is the upper m bits, and the 2m bits are shifted down by the bit shift amount and output. Modulo exponentiation method.
出力用前段データ記憶手段内のデータを出力用後段データ記憶手段に順次転送し、
出力用前段データ記憶手段内のデータを下位mビットとし出力用後段データ記憶手段内のデータを上位mビットとして、その2mビットをデータ入力時に決定したビットシフト量だけ下位にシフトして出力する
ことを特徴とする請求項1記載の羃乗剰余演算方法。The data of the modulus N is fetched from the legal storage means into the output pre-stage data storage means for each m bits from the high order,
Sequentially transferring the data in the output pre-stage data storage means to the output post-stage data storage means,
The data in the output pre-stage data storage means is the lower m bits, the data in the output post-stage data storage means is the upper m bits, and the 2m bits are shifted down by the bit shift amount determined at the time of data input and output. 2. The method according to claim 1, further comprising:
出力用前段データ記憶手段内のデータを出力用後段データ記憶手段に順次転送し、
出力用前段データ記憶手段内のデータを下位mビットとし出力用後段データ記憶手段内のデータを上位mビットとして、その2mビットを法Nのデータ入力時に決定したビットシフト量だけ下位にシフトして出力する
ことを特徴とする請求項1記載の羃乗剰余演算方法。The data of the number A is fetched from the number storage means into the output pre-stage data storage means for each m bits from the higher order,
Sequentially transferring the data in the output pre-stage data storage means to the output post-stage data storage means,
The data in the output pre-stage data storage means is set to the lower m bits, the data in the output post-stage data storage means is set to the upper m bits, and the 2 m bits are shifted to the lower order by the bit shift amount determined at the time of inputting the modulus N data. 2. The method according to claim 1, further comprising outputting the result.
出力用前段データ記憶手段内のデータを出力用後段データ記憶手段に順次転送し、
出力用前段データ記憶手段内のデータを下位mビットとし出力用後段データ記憶手段内のデータを上位mビットとしてそのまま出力する
ことを特徴とする請求項1記載の羃乗剰余演算方法。The data of the exponent exponent B is taken from the exponent exponent storage means into the output pre-stage data storage means for each m bits from the high order,
Sequentially transferring the data in the output pre-stage data storage means to the output post-stage data storage means,
2. The modular exponentiation arithmetic method according to claim 1, wherein the data in the output pre-stage data storage means is set as the lower m bits, and the data in the output post-stage data storage means is output as it is as the upper m bits.
法Nもしくは数Aのデータを上位からmビット毎に取り込む入力用前段データ記憶手段と、
法Nもしくは数Aのデータが何mビット入力されたか及び羃指数Bのデータが何ビット入力されたかを計測するデータカウント手段と、
入力用前段データ記憶手段に最初に取り込まれた法Nのデータの先頭から何ビット目に最初に“1”が現れたかを検出する先頭“1”ビット検出手段と、
前記先頭“1”ビット検出手段で検出したビット数をビットシフト量として決定するビットシフト量決定手段と、
入力用前段データ記憶手段のデータを次に受け取る入力用後段データ記憶手段と、
入力用前段データ記憶手段内のデータを下位mビットとし入力用後段データ記憶手段内のデータを上位mビットとして、ビットシフト量決定手段で決定したシフト量だけ上位にシフトする2mビット上位シフト手段と、
法N、数A及び羃指数Bのデータを使用して冗長2進演算方法により羃乗剰余演算を行う冗長2進演算手段と、
2mビット上位シフト手段によりシフトした後の2mビットのデータ又は冗長2進演算手段より得られる剰余Rあるいはこれに加えて法Nもしくは数Aもしくは羃指数Bのデータの上位mビットを格納するmビットシフトデータ記憶手段と、
法Nのデータ入力完了後、データカウント手段の値とmビットシフトデータ記憶手段の容量/mとの差分をシフト量として記憶するシフト量記憶手段と、
mビットデータシフト記憶手段より演算結果の剰余Rあるいはこれに加えて法Nもしくは数Aもしくは羃指数Bのデータを上位からmビット毎に取り込む出力用前段データ記憶手段と、
出力用前段データ記憶手段のデータを次に受け取る出力用後段データ記憶手段と、
出力用前段データ記憶手段内のデータを下位mビットとし出力用後段データ記憶手段内のデータを上位mビットとして、演算結果の剰余R、法N及び数Aのみビットシフト量決定手段で決定したビットシフト量だけ下位にシフトする2mビット下位シフト手段とを備えた
ことを特徴とする羃乗剰余演算装置。A modulo N, a number A consisting of a natural number less than or equal to the modulus N and a power exponent B are input, and a modular exponentiation operation R = A B mod N using a redundant binary operation method in which the modulus N is limited to d bits. And a modular exponentiation operation device that outputs at least the remainder R of the operation result,
Input pre-stage data storage means for taking in modulo N or data of number A every m bits from the higher order;
Data counting means for measuring how many bits of data of modulo N or number A are input and how many bits of data of exponent B are input;
A leading "1" bit detecting means for detecting at which bit "1" first appears from the beginning of modulo N data first taken into the input preceding data storage means;
Bit shift amount determining means for determining the number of bits detected by the leading "1" bit detecting means as a bit shift amount;
An input post-stage data storage unit that receives data of the input pre-stage data storage unit next,
2m-bit upper shift means for shifting the data in the input preceding data storage means to lower m bits and the data in the input latter data storage means to upper m bits to shift the data upward by the shift amount determined by the bit shift amount determining means; ,
Redundant binary arithmetic means for performing modular exponentiation by a redundant binary arithmetic method using data of modulus N, number A and exponent B;
2 m-bit data after shifting by 2 m-bit high-order shift means or m bits for storing the remainder R obtained by redundant binary operation means or the high-order m bits of modulo N, number A, or exponent B data Shift data storage means,
A shift amount storing means for storing, as a shift amount, a difference between the value of the data counting means and the capacity / m of the m-bit shift data storing means after completion of the data input of the modulus N;
an output pre-stage data storage means for taking in the remainder R of the operation result from the m-bit data shift storage means or data of the modulus N or the number A or the exponent B in addition to the m bits from the upper bit for each m bits;
An output post-stage data storage unit that receives data of the output pre-stage data storage unit next;
The data in the output pre-stage data storage means are the lower m bits, and the data in the output post-data storage means are the upper m bits. A 2m-bit lower shift means for shifting lower by a shift amount;
数Aを冗長2進表現に変換する数A−冗長2進変換手段と、
剰余Rを冗長2進表現に変換する数A−冗長2進変換手段と、
演算結果の剰余Rを格納する演算結果格納手段と、
演算結果格納手段の内容を“1”に初期化する初期化手段と、
kビットの羃指数Bのデータが入力された時、k≧i≧1なるiを用いて
B=bk ×2k−1 +bk−1 ×2k−2 +……+bi ×2i−1 +……+b2 ×21 +b1 ×20
とし、i=kとして、演算結果の剰余R及び法Nを冗長2進表現にして法Nの格納ビット数と同一ビット数だけ上位ビットからR×2d−k =(R×R×2d−k )mod (N×2d−k )の演算を行い、また、bi =1であれば、R×2d−k =(A×R×2d−k )mod (N×2d−k )の演算を行い、iを1つずつ減じて0になるまで前記演算を繰り返し行うN×2d−k ビット冗長2進羃乗剰余手段と、
冗長2進数を通常の2進数に戻す全加算手段と、
演算結果格納手段の上位d−kを求める羃乗剰余演算結果として出力する演算結果出力手段とからなる冗長2進演算手段を備えた
ことを特徴とする請求項5記載の羃乗剰余演算装置。A modulo N-redundant binary conversion means for converting the modulo N into a redundant binary representation;
A number A-redundant binary conversion means for converting the number A into a redundant binary representation;
A number A-redundant binary conversion means for converting the remainder R into a redundant binary representation;
Operation result storage means for storing the remainder R of the operation result;
Initialization means for initializing the contents of the operation result storage means to "1";
When data of a power exponent B of k bits is input, B = b k × 2 k−1 + b k−1 × 2 k−2 +... + b i × 2 i using i satisfying k ≧ i ≧ 1 -1 +... + B 2 × 2 1 + b 1 × 2 0
When i = k, the remainder R and the modulus N of the operation result are expressed in redundant binary notation, and the same number of bits as the number of bits stored in the modulus N is used, starting from the higher-order bits and R × 2 d−k = (R × R × 2 d -K ) mod (N × 2 d−k ), and if b i = 1, R × 2 d−k = (A × R × 2 d−k ) mod (N × 2 d) N × 2 d−k- bit redundant binary power residue means for performing the operation of −k ) and repeating the above operation until i becomes 0 by decreasing i by one;
Full addition means for returning a redundant binary number to a normal binary number;
6. The modular exponentiation arithmetic unit according to claim 5, further comprising redundant binary arithmetic means comprising: an arithmetic result output means for outputting as a modular exponentiation operation result for obtaining the higher order dk of the arithmetic result storage means.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP28685394A JP3555091B2 (en) | 1994-11-21 | 1994-11-21 | Method and apparatus for modular exponentiation operation |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP28685394A JP3555091B2 (en) | 1994-11-21 | 1994-11-21 | Method and apparatus for modular exponentiation operation |
Publications (2)
Publication Number | Publication Date |
---|---|
JPH08147266A JPH08147266A (en) | 1996-06-07 |
JP3555091B2 true JP3555091B2 (en) | 2004-08-18 |
Family
ID=17709881
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP28685394A Expired - Lifetime JP3555091B2 (en) | 1994-11-21 | 1994-11-21 | Method and apparatus for modular exponentiation operation |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP3555091B2 (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6175850B1 (en) | 1997-02-03 | 2001-01-16 | Nippon Telegraph And Telephone Corporation | Scheme for carrying out modular calculations based on redundant binary calculation |
JP5175983B2 (en) * | 2009-09-24 | 2013-04-03 | 株式会社東芝 | Arithmetic unit |
-
1994
- 1994-11-21 JP JP28685394A patent/JP3555091B2/en not_active Expired - Lifetime
Also Published As
Publication number | Publication date |
---|---|
JPH08147266A (en) | 1996-06-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US4893268A (en) | Circuit and method for accumulating partial products of a single, double or mixed precision multiplication | |
JP3970337B2 (en) | Hardware-optimized Reed-Solomon decoder for large data blocks | |
JP2835153B2 (en) | High radix divider | |
ARAKI et al. | Fast inverters over finite field based on Euclid's algorithm | |
US5261001A (en) | Microcircuit for the implementation of RSA algorithm and ordinary and modular arithmetic, in particular exponentiation, with large operands | |
US6523054B1 (en) | Galois field arithmetic processor | |
CA2294554A1 (en) | Method and circuit for multiplication using booth encoding and iterative addition techniques | |
CA2329104C (en) | Method and apparatus for calculating a reciprocal | |
JP3555091B2 (en) | Method and apparatus for modular exponentiation operation | |
JP3551113B2 (en) | Divider | |
US8909689B2 (en) | Arithmetic device | |
JPH10500513A (en) | Digital division execution unit | |
JP3271120B2 (en) | Device for fast multiplication of binary numbers | |
JPH10283164A (en) | Division circuit | |
JPH09146924A (en) | Method and device for arithmetic, and microprocessor | |
JP3422001B2 (en) | Division / residue calculation method and apparatus | |
JPH10307707A (en) | Circuit and method for deciding multiple | |
EP1504338B1 (en) | "emod" a fast modulus calculation for computer systems | |
JP2578482B2 (en) | Floating point arithmetic unit | |
JP2645422B2 (en) | Floating point processor | |
CN118245017B (en) | Binary floating-point multiplication device in memory and operation method thereof | |
GB2372353A (en) | Method and apparatus for calculating a reciprocal | |
JP4428778B2 (en) | Arithmetic device, arithmetic method, and computing device | |
JP3104569B2 (en) | Division circuit | |
JP2993119B2 (en) | Floating point arithmetic unit |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
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: 20040427 |
|
RD01 | Notification of change of attorney |
Free format text: JAPANESE INTERMEDIATE CODE: A7426 Effective date: 20040430 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20040430 |
|
R150 | Certificate of patent or registration of utility model |
Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
S533 | Written request for registration of change of name |
Free format text: JAPANESE INTERMEDIATE CODE: R313533 |
|
R360 | Written notification for declining of transfer of rights |
Free format text: JAPANESE INTERMEDIATE CODE: R360 |
|
R370 | Written measure of declining of transfer procedure |
Free format text: JAPANESE INTERMEDIATE CODE: R370 |
|
S533 | Written request for registration of change of name |
Free format text: JAPANESE INTERMEDIATE CODE: R313533 |
|
R350 | Written notification of registration of transfer |
Free format text: JAPANESE INTERMEDIATE CODE: R350 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20090521 Year of fee payment: 5 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20090521 Year of fee payment: 5 |
|
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 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20100521 Year of fee payment: 6 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20100521 Year of fee payment: 6 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20110521 Year of fee payment: 7 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20110521 Year of fee payment: 7 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20120521 Year of fee payment: 8 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20120521 Year of fee payment: 8 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20130521 Year of fee payment: 9 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20140521 Year of fee payment: 10 |
|
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 |