JP2003029632A - Method, device and program for generating prime number - Google Patents

Method, device and program for generating prime number

Info

Publication number
JP2003029632A
JP2003029632A JP2001216473A JP2001216473A JP2003029632A JP 2003029632 A JP2003029632 A JP 2003029632A JP 2001216473 A JP2001216473 A JP 2001216473A JP 2001216473 A JP2001216473 A JP 2001216473A JP 2003029632 A JP2003029632 A JP 2003029632A
Authority
JP
Japan
Prior art keywords
prime number
candidate
prime
divisible
applying
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.)
Pending
Application number
JP2001216473A
Other languages
Japanese (ja)
Inventor
Yoshiki Samejima
吉喜 鮫島
Hideaki Saishiyo
秀明 才所
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hitachi Software Engineering Co Ltd
Original Assignee
Hitachi Software Engineering Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hitachi Software Engineering Co Ltd filed Critical Hitachi Software Engineering Co Ltd
Priority to JP2001216473A priority Critical patent/JP2003029632A/en
Publication of JP2003029632A publication Critical patent/JP2003029632A/en
Pending legal-status Critical Current

Links

Abstract

PROBLEM TO BE SOLVED: To provide a method, a device and a program for generating prime number, with which a prime number can be generated and outputted at high speed even by the arithmetic function of low throughput such as smart card. SOLUTION: This method is provided with a first step for generating natural numbers to become prime number candidates at random, a second step for judging whether each of generated prime number candidates can be just divided by a small prime number or not and a third step for repeating processing for deciding whether it is a prime number or not by applying the prime number deciding method of a low erroneous decision rate when the candidate is not just divided, outputting the prime number candidate as a prime number when it is decided as a prime number, providing a new prime number candidate by adding the product of the small prime numbers to the prime number candidate when it is not judged as a prime number, and deciding whether it is a prime number or not by applying the prime number deciding method of the low erroneous decision rate.

Description

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

【0001】[0001]

【発明の属する技術分野】本発明は、データの暗号化や
ディジタル署名に使われる公開鍵暗号のパラメータや鍵
になる大きな素数を生成するのに使用する素数生成方法
及び装置に係り、特に高速に大きな素数を生成する方法
および装置に関するものである。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a prime number generation method and apparatus used for generating a large prime number which becomes a parameter or key of public key cryptography used for data encryption and digital signature, and particularly at high speed. The present invention relates to a method and apparatus for generating a large prime number.

【0002】[0002]

【従来の技術】素数を生成する方法として、従来、図5
のフローチャートに示すような方法がある。図5におい
て、まず、ステップ501でランダムに自然数Pを生成
し、素数候補Pとし、次のステップ502で該素数候補P
が小さな素数p1、p2、p3、…、pNで割り切れないかどう
かを、p1=2から順にテストする。割り切れたならば、ス
テップ501に戻る。素数候補Pが小さな素数p1、p2、p
3、…、pNで割り切れない場合、ステップ503で、Mil
ler-Rabin法を適用して素数であるか否かテストする。
2. Description of the Related Art Conventionally, as a method for generating a prime number, FIG.
There is a method as shown in the flowchart of FIG. In FIG. 5, first, in step 501, a natural number P is randomly generated to be a prime number candidate P, and in the next step 502, the prime number candidate P is generated.
Test if is not divisible by small primes p 1 , p 2 , p 3 , ..., p N , starting from p 1 = 2. If it is divisible, the process returns to step 501. The prime number candidate P is a small prime number p 1 , p 2 , p
3 , ..., p N if not divisible by Mil
Apply the ler-Rabin method to test whether it is a prime number.

【0003】ここで、Miller-Rabin法はIEEE P1363 Ann
ex A に開示されているように、誤りを含む素数判定方
法であり、合成数と判断されれば正しく合成数である
が、素数と判断されても合成数である可能性がある。し
かし、誤って合成数を素数と判定する確率は非常に低
く、実用上問題ないといわれている。本ステップ503
で合成数と判定されればステップ101に戻るが、素数
と判断されれば素数候補Pを素数として出力、処理を終
了する。ここで、ステップ502で最初から10番目ま
での素数でテストすると、p1=2、p2=3、p3=5、…、p10=
29である。
Here, the Miller-Rabin method is based on IEEE P1363 Ann.
As disclosed in ex A, this is a method of determining a prime number that includes an error. If it is determined to be a composite number, it is a correct composite number, but even if it is determined to be a prime number, it may be a composite number. However, the probability that a composite number is mistakenly determined to be a prime number is extremely low, and it is said that there is no practical problem. This step 503
If it is determined to be a composite number, the process returns to step 101, but if it is determined to be a prime number, the prime number candidate P is output as a prime number, and the process ends. Here, in step 502, when tested with the first to tenth prime numbers, p 1 = 2, p 2 = 3, p 3 = 5, ..., p 10 =
29.

【0004】[0004]

【発明が解決しようとする課題】ところで、素数判定方
法には一般に剰余べき乗演算が含まれている。この演算
は処理が重く、特にスマートカードのような演算能力の
低い環境で使用すると素数が見つかるまでに時間がかか
る。よって、素数判定方法を適用する素数候補にはでき
る限り、素数であると思われる数であることが望まれ
る。通常は1ないし2桁の素数で割り切れないか否かを
テストした後に、Miller-Rabin法のような高精度な素数
判定方法を適用していたが、スマートカードではこの処
理も負担となってしまい、1ないし2桁の素数で割り切
れないか否かのテストもできる限り避けることが望まし
い。
By the way, the prime number determination method generally includes a modular exponentiation operation. This operation is heavy in processing, and it takes a long time to find a prime number especially when used in an environment with low operation capacity such as a smart card. Therefore, it is desirable that the number of prime candidates to which the prime number determination method is applied is a number that is considered to be a prime number as much as possible. Normally, after testing whether or not divisible by a prime number of 1 or 2 digits, a high-precision prime number determination method such as Miller-Rabin method was applied, but this process also becomes a burden on smart cards. It is also desirable to avoid testing whether divisible by a prime number of 1 or 2 as much as possible.

【0005】本発明は、スマートカード等の処理能力の
低い演算機能であっても高速に素数を生成して出力する
ことができる素数生成方法及び装置並びにプログラムを
提供することにある。
An object of the present invention is to provide a prime number generation method, device and program capable of generating and outputting a prime number at high speed even with an arithmetic function having low processing capability such as a smart card.

【0006】[0006]

【課題を解決するための手段】上記目的を達成するため
に、本発明に係る素数生成方法は、素数候補となる自然
数をランダムに生成する第1のステップと、生成した前
記素数候補が小さな素数で割り切れるか否かを判断する
第2のステップと、割り切れない場合に誤判定率の低い
素数判定方法を適用して素数か否かを判定し、素数と判
定されれば該素数候補を素数として出力し、素数でない
と判断されれば前記小さな素数の積を該素数候補に加え
て新たな素数候補とし、誤判定率の低い素数判定方法を
適用して素数か否かを判定する処理を繰返す第3のステ
ップとを備えることを特徴とする。また、前記第2のス
テップにおいて、素数候補が小さな素数から順番に割り
切るか否かテストし、割り切れた場合には、その素数よ
り小さな素数の積を加えて新たな素数候補とし、割り切
れた素数から割り切るか否かをテストするステップを備
えることを特徴とする。また、前記第3のステップにお
いて、素数候補をPとした時に、誤判定率の低い素数判
定方法を適用する前に、Pを法とした2以上の小さな自
然数のP−1乗が1となることを確認した上で誤判定率
の低い素数判定方法を適用するステップを備えることを
特徴とする。
In order to achieve the above object, a prime number generation method according to the present invention comprises a first step of randomly generating a natural number as a prime number candidate, and the generated prime number candidate having a small prime number. The second step of judging whether or not it is divisible by, and when it is not divisible, it is judged whether or not it is a prime number by applying a prime number judgment method with a low erroneous judgment rate, and when it is judged as a prime number, the prime number candidate is output as a prime number. If it is determined that the prime number is not a prime number, the product of the small prime numbers is added to the prime number candidate as a new prime number candidate, and a process of determining whether or not it is a prime number is repeated by applying a prime number determination method with a low false determination rate. And the steps of. Further, in the second step, it is tested whether or not the prime number candidates are divided in order from a small prime number. If the prime numbers are divisible, a product of prime numbers smaller than the prime number is added as a new prime number candidate, and the prime number is divided from the prime numbers. It is characterized by comprising a step of testing whether it is divisible. Further, in the third step, when the prime number candidate is P, the P-1 power of two or more small natural numbers modulo P becomes 1 before applying the prime number determination method with a low erroneous determination rate. And a step of applying a prime number determination method having a low erroneous determination rate.

【0007】本発明に係る素数生成装置は、素数候補と
なる自然数をランダムに生成する第1の手段と、生成し
た前記素数候補が小さな素数で割り切れるか否かを判断
する第2の手段と、割り切れない場合に誤判定率の低い
素数判定方法を適用して素数か否かを判定し、素数と判
定されれば該素数候補を素数として出力し、素数でない
と判断されれば前記小さな素数の積を該素数候補に加え
て新たな素数候補とし、誤判定率の低い素数判定方法を
適用して素数か否かを判定する処理を繰返す第3の手段
とを備えることを特徴とする。また、前記第2の手段
が、素数候補が小さな素数から順番に割り切るか否かテ
ストし、割り切れた場合には、その素数より小さな素数
の積を加えて新たな素数候補とし、割り切れた素数から
割り切るか否かをテストする手段を備えることを特徴と
する。また、前記第3の手段が、素数候補をPとした時
に、誤判定率の低い素数判定方法を適用する前に、Pを
法とした2以上の小さな自然数のP−1乗が1となるこ
とを確認した上で誤判定率の低い素数判定方法を適用す
る手段を備えることを特徴とする。
The prime number generation apparatus according to the present invention comprises first means for randomly generating natural numbers as prime number candidates, and second means for determining whether or not the generated prime number candidate is divisible by a small prime number. If it is not divisible, it is determined whether or not it is a prime number by applying a prime number determination method with a low erroneous determination rate, and if it is determined to be a prime number, the prime number candidate is output as a prime number. Is added to the prime number candidate as a new prime number candidate, and a third means for repeating the process of determining whether or not it is a prime number by applying a prime number determination method having a low erroneous determination rate is provided. Further, the second means tests whether or not the prime number candidate is divisible in order from a small prime number, and when it is divisible, a product of prime numbers smaller than the prime number is added as a new prime number candidate, and the prime number is divided from the divisible prime number. It is characterized by comprising means for testing whether or not it is divisible. Also, when the third means is P as a prime number candidate, the P-1 power of two or more small natural numbers modulo P becomes 1 before applying the prime number determination method with a low erroneous determination rate. And a means for applying a prime number determination method having a low erroneous determination rate.

【0008】本発明に係る素数生成用のプログラムは、
素数候補となる自然数をランダムに生成する第1の処理
と、生成した前記素数候補が小さな素数で割り切れるか
否かを判断する第2の処理と、割り切れない場合に誤判
定率の低い素数判定方法を適用して素数か否かを判定
し、素数と判定されれば該素数候補を素数として出力
し、素数でないと判断されれば前記小さな素数の積を該
素数候補に加えて新たな素数候補とし、誤判定率の低い
素数判定方法を適用して素数か否かを判定する処理を繰
返す第3の処理とを備えることを特徴とする。また、前
記第2の処理が、素数候補が小さな素数から順番に割り
切るか否かテストし、割り切れた場合には、その素数よ
り小さな素数の積を加えて新たな素数候補とし、割り切
れた素数から割り切るか否かをテストする処理を備える
ことを特徴とする。また、前記第3の処理が、素数候補
をPとした時に、誤判定率の低い素数判定方法を適用す
る前に、Pを法とした2以上の小さな自然数のP−1乗
が1となることを確認した上で誤判定率の低い素数判定
方法を適用する処理を備えることを特徴とする。
A program for generating a prime number according to the present invention is
A first process for randomly generating a natural number as a prime number candidate, a second process for determining whether or not the generated prime number candidate is divisible by a small prime number, and a prime number determination method with a low false determination rate when the prime number candidate is not divisible. It is applied to determine whether it is a prime number, and if it is determined to be a prime number, the candidate prime number is output as a prime number, and if it is determined not to be a prime number, the product of the small prime numbers is added to the prime number candidate to make a new prime number candidate. And a third process for repeating a process for determining whether or not the number is a prime number by applying a prime number determination method having a low erroneous determination rate. Further, the second processing tests whether or not the prime number candidate is divisible in order from a small prime number, and when it is divisible, a product of prime numbers smaller than the prime number is added to obtain a new prime number candidate, and the prime number is divided from the divisible prime number. It is characterized by having a process of testing whether or not it is divisible. Further, in the third processing, when the prime number candidate is P, the P-1 power of two or more small natural numbers modulo P becomes 1 before applying the prime number determination method with a low erroneous determination rate. And a process for applying a prime number determination method with a low erroneous determination rate.

【0009】すなわち、本発明では、最初に自然数をラ
ンダムに生成し、小さな素数で割り切れないことを確か
め、高精度な素数判定方法を適用する。素数でないと判
断された場合は、再度先の処理を繰返すのではなく、先
に素数でないと判断された自然数に小さな素数の積を加
えて、高精度な素数判定方法を適用する。こうすること
により、小さな素数で割り切れるか否かのテストを省く
ことができる。
That is, in the present invention, a natural number is first randomly generated, it is confirmed that it cannot be divided by a small prime number, and a high-precision prime number determination method is applied. When it is determined that the prime number is not a prime number, the previous process is not repeated, and the product of a small prime number is added to the natural number that was previously determined to be a non-prime number, and the high-precision prime number determination method is applied. By doing so, it is possible to omit the test of whether or not divisible by a small prime number.

【0010】[0010]

【発明の実施の形態】図1は、本発明の素数生成方法を
実現する装置の実施の形態を示すブロック構成図であ
り、パーソナルコンピュータ101とICカード102
から成り、ICカード102には本発明による素数生成
方法を実現する素数生成処理プログラム103が予め格
納されている。また、署名プログラム104、鍵生成プ
ログラム105、復号プログラム106が予め格納され
ると共に、秘密鍵保持領域107が設けられている。な
お、署名プログラム104、鍵生成プログラム105、
復号プログラム106、秘密鍵保持領域107について
は、例えばスマートカードとして使用する場合の機能で
あり、本発明とは直接に関係しないためにその説明は省
略する。
FIG. 1 is a block diagram showing an embodiment of an apparatus for realizing a prime number generation method of the present invention, which is a personal computer 101 and an IC card 102.
The IC card 102 stores in advance a prime number generation processing program 103 for realizing the prime number generation method according to the present invention. In addition, the signature program 104, the key generation program 105, and the decryption program 106 are stored in advance, and a private key holding area 107 is provided. The signature program 104, the key generation program 105,
The decryption program 106 and the private key holding area 107 are functions when used as a smart card, for example, and are not directly related to the present invention, and therefore their explanations are omitted.

【0011】図2は、素数生成処理プログラム103に
よる素数生成処理の手順を示すフローチャートである。
まず、ステップ201において、ランダムに自然数Pを
生成し、素数候補Pとする。次にステップ202におい
て、素数候補Pが小さな素数で割り切れるか否かを、p1
=2から順にテストする。割り切れたならば、ステップ2
01に戻る。しかし、割り切れない場合は、ステップ2
03において、Miller-Rabin法を適用して素数である
か、否かテストする。このステップ203で素数と判断
されれば素数候補Pを素数として出力し、処理を終了す
る。
FIG. 2 is a flow chart showing the procedure of prime number generation processing by the prime number generation processing program 103.
First, in step 201, a natural number P is randomly generated and used as a prime number candidate P. Next, in step 202, it is determined whether the prime number candidate P is divisible by a small prime number, p 1
= 2 to test in order. If it is divisible, step 2
Return to 01. However, if it is not divisible, step 2
In 03, the Miller-Rabin method is applied to test whether it is a prime number. If it is determined to be a prime number in this step 203, the prime number candidate P is output as a prime number, and the process ends.

【0012】しかし、合成数ならば(素数でないなら
ば)次のステップ204へ進み、このステップ204で
素数候補Pにp1×p2×p3×…×pNを加えて新たな素数候
補Pとし、ステップ203に戻る。ここで、前ステップ
202での素数候補Pはp1、p2、p3、…、pNでは割り切
れず、p1×p2×p3×…×pNはp1、p2、p3、…、pNでは割
り切れる。よって、和である新しい素数候補Pはp1
p2、p3、…、pNでは割り切れない。よって、ステップ2
02の処理、すなわち小さな素数p1、p2、p3、…、pN
割り切れるか否かのテストを省くことができる。
However, if it is a composite number (if it is not a prime number), the process proceeds to the next step 204, and in this step 204, p 1 × p 2 × p 3 × ... × p N is added to the prime number candidate P to obtain a new prime number candidate. Then, the process returns to step 203. Here, the prime number candidate P in the previous step 202 is not divisible by p 1 , p 2 , p 3 , ..., P N , and p 1 × p 2 × p 3 × ... × p N is p 1 , p 2 , p 3 , ..., divisible by p N. Therefore, the new prime candidate P that is the sum is p 1 ,
It is not divisible by p 2 , p 3 , ..., p N. Therefore, step 2
It is possible to omit the processing of 02, that is, the test of whether or not divisible by the small prime numbers p 1 , p 2 , p 3 , ..., P N.

【0013】なお、ステップ203で用いる素数判定方
法はMiller-Rabin法に限定されるわけではなく、合成数
を素数と判定する確率が低い判定法なら用いることがで
きる。例えば、Fermatの小定理と組合わせても良い。す
なわち、次の計算式が成立すれば素数と判断し、さらに
Miller-Rabin法を適用しても良い。 2p-1=1 (mod p) この手順を付加したのが図3のフローチャートである。
The prime number determination method used in step 203 is not limited to the Miller-Rabin method, and any determination method that has a low probability of determining a composite number as a prime number can be used. For example, it may be combined with Fermat's little theorem. That is, if the following formula is established, it is judged as a prime number, and
The Miller-Rabin method may be applied. 2 p-1 = 1 (mod p) This procedure is added to the flowchart of FIG.

【0014】図3において、ステップ301,302は
図2と同様の処理である。ステップ303において、Fe
rmatの定理を応用し、前記計算式「数1」が成立したな
らば、ステップ304に進み、不成立ならばステップ3
05に進む。ここで基数は2である必要はなく、P未満
の自然数であればよい。しかし、小さな数の方が高速に
処理できる。すなわち、素数候補をPとした時に、誤判
定率の低い素数判定方法を適用する前に、Pを法とした
2以上の小さな自然数のP−1乗が1となることを確認
した上で誤判定率の低い素数判定方法を適用する。そし
て、ステップ304においては、Miller-Rabin法を適用
して素数であるか否かをテストする。このステップ30
4で素数と判断されれば素数候補Pを素数として出力、
処理を終了する。しかし、合成数なら次のステップ30
5へ進み、現在の素数候補Pにp1×p2×p3×…×pNを加
えて新たな素数候補Pとし、ステップ303に戻る。
In FIG. 3, steps 301 and 302 are the same processes as in FIG. In step 303, Fe
Applying the rmat theorem, if the above-mentioned calculation formula “Equation 1” is established, the process proceeds to step 304, and if not, step 3
Go to 05. Here, the radix does not have to be 2, and may be a natural number less than P. However, smaller numbers can be processed faster. That is, when the prime number candidate is P, before applying a prime number determination method with a low false positive rate, it is confirmed that the P-1 power of two or more small natural numbers modulo P is 1, and then the false positive rate is determined. Apply a low prime number determination method of. Then, in step 304, the Miller-Rabin method is applied to test whether it is a prime number. This step 30
If it is judged as a prime number in 4, output the prime number candidate P as a prime number,
The process ends. However, if it is a composite number, the next step 30
5, the new prime number candidate P is obtained by adding p 1 × p 2 × p 3 × ... × p N to the current prime number candidate P, and the process returns to step 303.

【0015】図4はステップ202や302の処理をさ
らに高速化する手順を示すフローチャートである。ま
ず、ステップ401において、変数Iを1、変数Dを1と
する。次に、ステップ402において変数IがNより大か
否か判定する。Nは素数の数であり、予め設定してあ
る。大なら終了する。N以下なら、次のステップに進
む。次にステップ403において、素数候補PがpIで割
り切れるかテストする。割り切れないならば、ステップ
404に進む。割り切れるならば、ステップ405に進
む。ステップ404においては、変数Iを1増やし、Dを
pI倍し、ステップ402に戻る。ステップ405におい
ては、素数候補PにDを加えてステップ404に進む。こ
こで、ステップ403の素数候補Pはp1、p2、…、pI-1
では割り切れない。しして、D=p1×p2×…×pI-1である
ので、新たにDを加えたPはp1、p2、…、pI-1では割り切
れない。結果として、本処理全体を終えたとき、Pは
p1、p2、…、pNでは割り切れないことがわかる。
FIG. 4 is a flowchart showing a procedure for further speeding up the processing of steps 202 and 302. First, in step 401, the variable I is set to 1 and the variable D is set to 1. Next, in step 402, it is determined whether the variable I is larger than N. N is a prime number and is set in advance. If large, end. If N or less, proceed to the next step. Next, in step 403, it is tested whether the prime number candidate P is divisible by p I. If not divisible, go to step 404. If it is divisible, the process proceeds to step 405. In step 404, the variable I is increased by 1 and D is increased
Multiply by p I and return to step 402. In step 405, D is added to the prime number candidate P and the process proceeds to step 404. Here, the prime candidate P in step 403 is p 1 , p 2 , ..., P I-1
I can't divide it. Then, since D = p 1 × p 2 × ... × p I-1 , P newly added with D cannot be divided by p 1 , p 2 , ..., p I-1 . As a result, when the whole process is finished, P is
It can be seen that it is not divisible by p 1 , p 2 , ..., p N.

【0016】以上のように、上記説明した実施形態にお
いては、小さな素数p1、p2、…、pNでは割り切れるかの
テストを1回だけ行えば良い。従って、512ビットの素
数を生成しようとすると、素数定理により平均177個
のランダムな奇数のうち1つが素数であるので、本発明
では、この部分の速度が177倍になり、高速に素数を
生成することができる。また、Miller-Rabinのような高
精度な素数判定方法を適用する前に、処理が単純で高速
なFermatの定理を応用して素数判定を行うことにより、
さらに高速に処理することができる。これは、パーソナ
ルコンピュータに比べてスマートカードのように演算子
が限られている処理能力の低い計算機環境では特に有用
なものとなる。
As described above, in the above-described embodiment, it suffices to perform only one test whether divisible by small prime numbers p 1 , p 2 , ..., P N. Therefore, when attempting to generate a 512-bit prime number, one of the 177 random odd numbers on average is a prime number according to the prime number theorem, so in the present invention, the speed of this part is increased by 177 times, and a prime number is generated at high speed. can do. In addition, before applying a high-precision prime number determination method such as Miller-Rabin, by applying the Fermat's theorem that is simple and fast in processing, the prime number determination is performed.
It can be processed even faster. This is particularly useful in a computing environment with low processing power such as a smart card in which operators are limited as compared with a personal computer.

【0017】なお、図2〜図4のフローチャートで示し
た処理は、素数生成用のプログラムとして提供すること
ができる。
The processes shown in the flowcharts of FIGS. 2 to 4 can be provided as a program for generating a prime number.

【0018】[0018]

【発明の効果】以上の説明から明らかなように、本発明
によれば、スマートカード等の処理能力の低い演算機能
であっても高速に素数を生成して出力することができる
という効果がある。
As is apparent from the above description, according to the present invention, it is possible to generate and output a prime number at high speed even with an arithmetic function having a low processing capacity such as a smart card. .

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

【図1】本発明の方法を実現する装置の実施の形態を示
すブロック構成図である。
FIG. 1 is a block diagram showing an embodiment of an apparatus that realizes the method of the present invention.

【図2】本発明の素数生成処理プログラムの処理手順の
第1の例を示すフローチャートである。
FIG. 2 is a flowchart showing a first example of a processing procedure of a prime number generation processing program of the present invention.

【図3】本発明の素数生成処理プログラムの処理手順の
第2の例を示すフローチャートである。
FIG. 3 is a flowchart showing a second example of the processing procedure of the prime number generation processing program of the present invention.

【図4】図2のステップ202、図3のステップ302
の処理をさらに高速化する例を示すフローチャートであ
る。
FIG. 4 is a step 202 in FIG. 2 and a step 302 in FIG.
5 is a flowchart showing an example of further speeding up the process of FIG.

【図5】従来における素数生成方法の例を示すフローチ
ャートである。
FIG. 5 is a flowchart showing an example of a conventional prime number generation method.

【符号の説明】[Explanation of symbols]

101…パーソナルコンピュータ、102…ICカー
ド、103…素数生成処理プログラム。
101 ... Personal computer, 102 ... IC card, 103 ... Prime number generation processing program.

───────────────────────────────────────────────────── フロントページの続き (72)発明者 才所 秀明 神奈川県横浜市中区尾上町6丁目81番地 日立ソフトウエアエンジニアリング株式会 社内 Fターム(参考) 5B035 AA13 BB09 CA11 5B056 AA04 BB00 CC00 HH00 5J104 AA23 AA24    ─────────────────────────────────────────────────── ─── Continued front page    (72) Inventor Hideaki Saisho             6-81 Onoe-cho, Naka-ku, Yokohama-shi, Kanagawa             Hitachi Software Engineering Stock Association             In-house F-term (reference) 5B035 AA13 BB09 CA11                 5B056 AA04 BB00 CC00 HH00                 5J104 AA23 AA24

Claims (9)

【特許請求の範囲】[Claims] 【請求項1】 素数を生成する方法であって、 素数候補となる自然数をランダムに生成する第1のステ
ップと、 生成した前記素数候補が小さな素数で割り切れるか否か
を判断する第2のステップと、 割り切れない場合に誤判定率の低い素数判定方法を適用
して素数か否かを判定し、素数と判定されれば該素数候
補を素数として出力し、素数でないと判断されれば前記
小さな素数の積を該素数候補に加えて新たな素数候補と
し、誤判定率の低い素数判定方法を適用して素数か否か
を判定する処理を繰返す第3のステップとを備えること
を特徴とする素数生成方法。
1. A method of generating a prime number, comprising a first step of randomly generating a natural number as a prime number candidate, and a second step of determining whether or not the generated prime number candidate is divisible by a small prime number. If it is not divisible, it is judged whether it is a prime number by applying a prime number judgment method with a low error rate, and if it is judged as a prime number, the prime number candidate is output as a prime number. And a third step of repeating a process of determining whether or not it is a prime number by applying a prime number determination method having a low erroneous determination rate to a new prime number candidate in addition to the prime number candidate, and generating a prime number. Method.
【請求項2】 前記第2のステップにおいて、素数候補
が小さな素数から順番に割り切るか否かテストし、割り
切れた場合には、その素数より小さな素数の積を加えて
新たな素数候補とし、割り切れた素数から割り切るか否
かをテストするステップを備えることを特徴とする請求
項1に記載の素数生成方法。
2. In the second step, it is tested whether or not the prime number candidate is divisible in order from a small prime number, and when it is divisible, a product of prime numbers smaller than the prime number is added to obtain a new prime number candidate, and the divisor is divided. The prime number generation method according to claim 1, further comprising a step of testing whether or not the prime number is divisible.
【請求項3】 前記第3のステップにおいて、素数候補
をPとした時に、誤判定率の低い素数判定方法を適用す
る前に、Pを法とした2以上の小さな自然数のP−1乗
が1となることを確認した上で誤判定率の低い素数判定
方法を適用するステップを備えることを特徴とする請求
項1または2に記載の素数生成方法。
3. In the third step, when a prime number candidate is P, a P-1 modulus of two or more small natural numbers modulo P is set to 1 before applying a prime number determination method having a low erroneous determination rate. The prime number generation method according to claim 1 or 2, further comprising a step of applying a prime number determination method having a low erroneous determination rate after confirming that
【請求項4】 素数を生成する装置であって、 素数候補となる自然数をランダムに生成する第1の手段
と、 生成した前記素数候補が小さな素数で割り切れるか否か
を判断する第2の手段と、 割り切れない場合に誤判定率の低い素数判定方法を適用
して素数か否かを判定し、素数と判定されれば該素数候
補を素数として出力し、素数でないと判断されれば前記
小さな素数の積を該素数候補に加えて新たな素数候補と
し、誤判定率の低い素数判定方法を適用して素数か否か
を判定する処理を繰返す第3の手段とを備えることを特
徴とする素数生成装置。
4. An apparatus for generating a prime number, comprising: first means for randomly generating a natural number as a prime number candidate; and second means for determining whether or not the generated prime number candidate is divisible by a small prime number. If it is not divisible, it is judged whether it is a prime number by applying a prime number judgment method with a low error rate, and if it is judged as a prime number, the prime number candidate is output as a prime number. And a third means for repeating the process of determining whether or not it is a prime number by applying a product of the above to the prime number candidate as a new prime number candidate and applying a prime number determination method with a low erroneous determination rate. apparatus.
【請求項5】 前記第2の手段が、素数候補が小さな素
数から順番に割り切るか否かテストし、割り切れた場合
には、その素数より小さな素数の積を加えて新たな素数
候補とし、割り切れた素数から割り切るか否かをテスト
する手段を備えることを特徴とする請求項4に記載の素
数生成装置。
5. The second means tests whether or not the prime number candidate is divisible in order from a small prime number, and when it is divisible, adds a product of prime numbers smaller than the prime number to obtain a new prime number candidate and divides it. 5. The prime number generation device according to claim 4, further comprising means for testing whether or not the prime number is divisible.
【請求項6】 前記第3の手段が、素数候補をPとした
時に、誤判定率の低い素数判定方法を適用する前に、P
を法とした2以上の小さな自然数のP−1乗が1となる
ことを確認した上で誤判定率の低い素数判定方法を適用
する手段を備えることを特徴とする請求項4または5に
記載の素数生成装置。
6. The third means sets P as a prime number candidate before applying a prime number determination method having a low erroneous determination rate when P is a prime number candidate.
6. A means for applying a prime number determination method having a low erroneous determination rate after confirming that the P-1 power of two or more small natural numbers modulo 1 is 1 is provided. Prime number generator.
【請求項7】 素数を生成するためのプログラムであっ
て、 素数候補となる自然数をランダムに生成する第1の処理
と、 生成した前記素数候補が小さな素数で割り切れるか否か
を判断する第2の処理と、 割り切れない場合に誤判定率の低い素数判定方法を適用
して素数か否かを判定し、素数と判定されれば該素数候
補を素数として出力し、素数でないと判断されれば前記
小さな素数の積を該素数候補に加えて新たな素数候補と
し、誤判定率の低い素数判定方法を適用して素数か否か
を判定する処理を繰返す第3の処理とを備えることを特
徴とする素数生成用のプログラム。
7. A program for generating a prime number, the first process of randomly generating a natural number as a prime number candidate, and the second process of determining whether or not the generated prime number candidate is divisible by a small prime number. If it is not divisible, it is judged whether it is a prime number by applying a prime number judgment method with a low false positive rate when it is not divisible, and if it is judged as a prime number, the prime candidate is output as a prime number, and if it is judged that it is not a prime number, A third process of repeating a process of determining whether or not a prime number by applying a product of small prime numbers to the prime number candidate as a new prime number candidate and applying a prime number determination method having a low erroneous determination rate. A program for generating prime numbers.
【請求項8】 前記第2の処理が、素数候補が小さな素
数から順番に割り切るか否かテストし、割り切れた場合
には、その素数より小さな素数の積を加えて新たな素数
候補とし、割り切れた素数から割り切るか否かをテスト
する処理を備えることを特徴とする請求項7に記載の素
数生成用のプログラム。
8. The second processing tests whether or not a prime number candidate is divisible in order from a small prime number, and when divisible, adds a product of prime numbers smaller than the prime number to obtain a new prime number candidate and divides it. 8. The program for generating a prime number according to claim 7, further comprising a process of testing whether or not it is divisible by a prime number.
【請求項9】 前記第3の処理が、素数候補をPとした
時に、誤判定率の低い素数判定方法を適用する前に、P
を法とした2以上の小さな自然数のP−1乗が1となる
ことを確認した上で誤判定率の低い素数判定方法を適用
する処理を備えることを特徴とする請求項7または8に
記載の素数生成用のプログラム。
9. In the third processing, when P is a prime number candidate, P is applied before applying a prime number determination method with a low erroneous determination rate.
9. The method according to claim 7 or 8, further comprising a process of applying a prime number determination method having a low false determination rate after confirming that the P-1 power of two or more small natural numbers modulo 2 is 1. A program for generating prime numbers.
JP2001216473A 2001-07-17 2001-07-17 Method, device and program for generating prime number Pending JP2003029632A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2001216473A JP2003029632A (en) 2001-07-17 2001-07-17 Method, device and program for generating prime number

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2001216473A JP2003029632A (en) 2001-07-17 2001-07-17 Method, device and program for generating prime number

Publications (1)

Publication Number Publication Date
JP2003029632A true JP2003029632A (en) 2003-01-31

Family

ID=19050943

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2001216473A Pending JP2003029632A (en) 2001-07-17 2001-07-17 Method, device and program for generating prime number

Country Status (1)

Country Link
JP (1) JP2003029632A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005531031A (en) * 2002-06-21 2005-10-13 アトメル・コーポレイション Checking estimated primes for cryptographic applications

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005531031A (en) * 2002-06-21 2005-10-13 アトメル・コーポレイション Checking estimated primes for cryptographic applications
JP4756117B2 (en) * 2002-06-21 2011-08-24 インサイド コンタクトレス ソシエテ アノニム Checking estimated primes for cryptographic applications

Similar Documents

Publication Publication Date Title
JP5328186B2 (en) Data processing system and data processing method
RU2376651C2 (en) Using isogenies to design cryptosystems
US8280041B2 (en) Chinese remainder theorem-based computation method for cryptosystems
US7908641B2 (en) Modular exponentiation with randomized exponent
US8280039B2 (en) Signature generating device, signature generating method and signature generating program
CN107004084B (en) Multiplicative mask for cryptographic operations
US9680647B2 (en) Method of using a token in cryptography
CN110493201B (en) Data processing method, device and system
CN109145616B (en) SM2 encryption, signature and key exchange implementation method and system based on efficient modular multiplication
US20030152218A1 (en) Cryptography method on elliptic curves
Parrilla et al. Elliptic curve cryptography hardware accelerator for high-performance secure servers
Joye et al. Fast generation of prime numbers on portable devices: An update
Ding et al. Study on secret sharing for SM2 digital signature and its application
US20020041683A1 (en) Method for selecting optimal number of prime factors of a modulus for use in a cryptographic system
US20190372757A1 (en) Generating a pseudorandom number based on a portion of shares used in a cryptographic operation
Wu et al. On the improvement of wiener attack on rsa with small private exponent
CN112737778A (en) Digital signature generation and verification method and device, electronic equipment and storage medium
Venkatesh et al. Reconfigurable architecture to speed-up modular exponentiation
Aulbach et al. Practical key-recovery attack on MQ-Sign
JP2003029632A (en) Method, device and program for generating prime number
JP3796867B2 (en) Prime number determination method and apparatus
EP4024755A1 (en) Secured performance of an elliptic curve cryptographic process
JP3750295B2 (en) Prime number generation method and apparatus
JP2004253950A (en) Electronic signature high-speed forming method and apparatus by pre-calculation
JP2008299335A (en) Method for calculating compressed rsa moduli