Beruflich Dokumente
Kultur Dokumente
, can be very
and
compute
Example:
Let
. Compute
Steps:
1)
2)
3)
30
4)
,n
Output: result
2, b < n
, result =
mod n
Pseudocode:
if (b = 0) then
result := 0
else if (e = 0) then
result := 1
else
while e > 0
if (e mod 2 = 1) then
result := (result * b) mod n
endif
e := e / 2
b := (b * b) mod n
endwhile
endif
return result
31
Computational algorithm:
Prototype: function SolveEquationModN(m, n, x) : xFinal
Input:
, x[i,1], x[i,2]
,x
, xFinal[j]
, xFinal[j] < n,
Pseudocode:
solutionIndex := 1
call BackTrackSolutionsModN(m, n, x, 1, solutionIndex, xFinal)
return xFinal
For cryptography purposes, the fastest and most efficient primality tests are the probabilistic ones
(with the Miller-Rabin test being the most effective), their downside residing in the fact that,
regardless of the number of test iterations applied on the candidate prime, the candidate number
45
cannot be proven to be prime with 100% confidence, although its compositeness (if any) can be
established with absolute certainty.
and
. The map
2) if p is prime,
3) if
4) if
, p prime,
,
46
is called
, then
prime and
. Then,
Let
. If
, then
is prime.
. Then,
passing the Fermat test for a given base . The probability of a composite number
Fermats tests for
is at most
different bases
passing
Fermats tests, the probability that the tested number is prime is at least
A defining weakness of Fermats test are the Carmichael numbers. A natural composite number
is called a Carmichael number, if it passes Fermats test for any base . It has been proven that,
for a large-enough , the number of Carmichael numbers less than
is greater than
, and, as a
consequence to this fact, that the set of Carmichael numbers is infinite [Men96].
Let
.
if
, for some
if
and
, then
, for every
47
, then
is a Carmichael number
Let
, such that
and
. Also,
. Therefore,
is a Carmichael number.
Let
1)
The number
conclude that
, therefore we can
N, n
3, k
Output: res
, corresponding to
if (result
1) then
return COMPOSITE
endif
endfor
return PRIME
. Uniquely write
be a prime number,
,
as
odd. Let
odd. Let
. Then, either:
or
, for some
[Men96]
. Uniquely express
be an odd number,
,
as
. If either:
or
, for some
then
is prime.
, if either
or
different bases
is
different Miller-Rabin tests, the probability that the tested number is prime is at least
.
49
1)
1.
2.
3.
4.
5.
2)
1.
2.
3.
4.
5.
6.
3)
1.
2.
3.
4.
5.
Let
1)
1.
50
2.
Seeing that our number
can claim that
, we
N, n
3, k
Output: res
, corresponding to
Write
, r odd
for i :=1 to k do
Randomly choose a, 1 < a < n - 1
result := ModularExponentiation(a, r, n)
if ( (result
1) and (result
n - 1) ) then
j :=1
while ( (j
s - 1) and (result
n - 1) ) do
1) then
return COMPOSITE
endif
j := j + 1
endwhile
if (result
n - 1) then
return COMPOSITE
endif
endif
endfor
return PRIME
51
The algorithms for both tests employ operations of the same computational
complexity.
Both tests can determine composite numbers with absolute certainty. Since the set
of strong liars (bases for which a given composite number
Rabin test) is a narrow subset of the set of Fermat liars (bases for which a given
composite number
Fig. 2.4 Relationship between the Fermat and the strong liars for any composite
number
52
[Men96]
requires only half of the bases Fermats test would need in order to achieve the
same confidence on the primality of .
53