Skip to content

Commit bd98e47

Browse files
committed
Frobenius test is an addition now instead of an alternative. Documentation update
1 parent 17f10f8 commit bd98e47

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

doc/bn.tex

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,9 +2204,8 @@ \subsection{Required Number of Tests}
22042204
the diagonal from $(512,2^{-80})$ downwards and to the right to gain a lower probability of getting
22052205
a composite declared a pseudoprime for the same amount of work or less.
22062206

2207-
If this version of the library has the strong Lucas--Selfridge and/or the Frobenius--Underwood test
2208-
implemented only one or two rounds of the Miller--Rabin test with a random base is necessary for
2209-
numbers larger than or equal to $1024$ bits.
2207+
If this version of the library has the extra strong Lucas test implemented only one or two rounds
2208+
of the Miller--Rabin test with a random base is necessary for numbers larger than or equal to $1024$ bits.
22102209

22112210
This function is meant for RSA. The number of rounds for DSA is $\lceil -log_2(p)/2\rceil$ with $p$
22122211
the probability which is just the half of the absolute value of $p$ if given as a power of two.
@@ -2234,7 +2233,7 @@ \section{Frobenius (Underwood) Test}
22342233
\end{alltt}
22352234
Performs the variant of the Frobenius test as described by Paul Underwood. It can be included at
22362235
build--time if the preprocessor macro \texttt{LTM\_USE\_FROBENIUS\_TEST} is defined and will be
2237-
used instead of the extra strong Lucas test.
2236+
used after the extra strong Lucas test.
22382237

22392238
It returns \texttt{MP\_ITER} if the number of iterations is exhausted, assumes a composite as the
22402239
input and sets \texttt{result} accordingly. This will reduce the set of available pseudoprimes by a
@@ -2255,11 +2254,11 @@ \section{Primality Testing}
22552254
mp_err mp_prime_is_prime(const mp_int *a, int t, bool *result)
22562255
\end{alltt}
22572256
This will perform a trial division followed by two rounds of Miller--Rabin with bases 2 and 3 and a
2258-
Lucas--Selfridge test. The Frobenius--Underwood is available as a compile--time option with the
2257+
extra strong Lucas test. The Frobenius--Underwood time is available as a compile--time option with the
22592258
preprocessor macro \texttt{LTM\_USE\_FROBENIUS\_TEST}. See file \texttt{bn\_mp\_prime\_is\_prime.c}
22602259
for the necessary details. It shall be noted that both functions are much slower than the
22612260
Miller--Rabin test and if speed is an essential issue, the macro \texttt{LTM\_USE\_ONLY\_MR}
2262-
switches the Frobenius--Underwood test and the Lucas--Selfridge test off and their code will not
2261+
switches the Frobenius--Underwood test and the Lucas test off and their code will not
22632262
even be compiled into the library.
22642263

22652264
If $t$ is set to a positive value $t$ additional rounds of the Miller--Rabin test with random bases

mp_prime_is_prime.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,22 +92,26 @@ mp_err mp_prime_is_prime(const mp_int *a, int t, bool *result)
9292
}
9393

9494
/*
95-
* Both, the Frobenius-Underwood test and the the Lucas-Selfridge test are quite
95+
* Both, the Frobenius-Underwood test and the the extra strong Lucas test are quite
9696
* slow so if speed is an issue, define LTM_USE_ONLY_MR to use M-R tests with
9797
* bases 2, 3 and t random bases.
9898
*/
9999
#ifndef LTM_USE_ONLY_MR
100100
if (t >= 0) {
101-
#ifdef LTM_USE_FROBENIUS_TEST
102-
err = mp_prime_frobenius_underwood(a, &res);
103-
if ((err != MP_OKAY) && (err != MP_ITER)) {
101+
if ((err = mp_prime_extra_strong_lucas(a, &res)) != MP_OKAY) {
104102
goto LBL_B;
105103
}
106104
if (!res) {
107105
goto LBL_B;
108106
}
109-
#else
110-
if ((err = mp_prime_extra_strong_lucas(a, &res)) != MP_OKAY) {
107+
/*
108+
The Frobenius-Underwood pseudoprimes are sufficiently different from the
109+
Extra Strong Lucas pseudoprimes with the parameters used in this library
110+
to offer it as an additionally test (but it nearly doubles the runtime).
111+
*/
112+
#ifdef LTM_USE_FROBENIUS_TEST
113+
err = mp_prime_frobenius_underwood(a, &res);
114+
if ((err != MP_OKAY) && (err != MP_ITER)) {
111115
goto LBL_B;
112116
}
113117
if (!res) {

0 commit comments

Comments
 (0)