Cryptography/Mathematical Background

From testwiki
Jump to navigation Jump to search

Template:Subpages See Talk page for other suggestions.

Introduction

Modern public-key (asymmetric) cryptography is based upon a branch of mathematics known as number theory, which is concerned solely with the solution of equations that yield only integer results. These type of equations are known as diophantine equations, named after the Greek mathematician Diophantos of Alexandria (ca. 200 CE) from his book Arithmetica that addresses problems requiring such integral solutions.

One of the oldest diophantine problems is known as the Pythagorean problem, which gives the length of one side of a right triangle when supplied with the lengths of the other two side, according to the equation

a2+b2=c2 

where c  is the length of the hypotenuse. While two sides may be known to be integral values, the resultant third side may well be irrational. The solution to the Pythagorean problem is not beyond the scope, but is beyond the purpose of this chapter. Therefore, example integral solutions (known as Pythagorean triplets) will simply be presented here. It is left as an exercise for the reader to find additional solutions, either by brute-force or derivation.

Template:Center

a  b  c 
3 4 5
5 12 13
7 24 25
8 15 17

Prime Numbers

Description

Asymmetric key algorithms rely heavily on the use of prime numbers, usually exceedingly long primes, for their operation. By definition, prime numbers are divisible only by themselves and 1. In other words, letting the symbol | denote divisibility (i.e. - a|b means "b divides into a"), a prime number strictly adheres to the following mathematical definition

p  | b  Where b=1  or p  only

The Fundamental Theorem of Arithmetic states that all integers can be decomposed into a unique prime factorization. Any integer greater than 1 is considered either prime or composite. A composite number is composed of more than one prime factor

c  | b  where ultimately b=p0e0p1e1pnen 

in which pn  is a unique prime number and en  is the exponent.

Numerical Examples

543,312 = 24  32  50  73  111
553,696 = 25  30  50  70  113  131

As can be seen, according to this systematic decomposition, each factorization is unique.

In order to deterministically verify whether an integer a  is prime or composite, only the primes pc  need be examined. This type of systematic, thorough examination is known as a brute-force approach. Primes and composites are noteworthy in the study of cryptography since, in general, a public key is a composite number which is the product of two or more primes. One (or more) of these primes may constitute the private key.

There are several types and categories of prime numbers, three of which are of importance to cryptography and will be discussed here briefly.

Fermat Primes

Fermat numbers take the following form

Fn=22n+1 

If Fn is prime, then it is called a Fermat prime.

Numerical Examples

F0=220+1=3 
F1=221+1=5 
F2=222+1=17 
F3=223+1=257 
F4=224+1=65,537 
F5=225+1=4,294,967,297 

The only Fermat numbers known to be prime are F0F4 . Moreover, the primality of all Fermat numbers was disproven by Euler, who showed that F5=6416,700,417.

Mersenne Primes

Mersenne primes - another type of formulaic prime generation - follow the form

Mp=2p1 

where p  is a prime number. The [1] Wolfram Alpha engine reports Mersenne Primes, an example input request being "4th Mersenne Prime".

Numerical Examples

The first four Mersenne primes are as follows

M2=221=3 
M3=231=7 
M5=251=31 
M7=271=127 

Numbers of the form Mp = 2p without the primality requirement are called Mersenne numbers. Not all Mersenne numbers are prime, e.g. M11 = 211−1 = 2047 = 23 · 89.

Coprimes (Relatively Prime Numbers)

Two numbers are said to be coprime if the largest integer that divides evenly into both of them is 1. Mathematically, this is written

gcd(a,b)=1 

where gcd  is the greatest common divisor. Two rules can be derived from the above definition

If ab  | c  and gcd(b,c)=1 , then a  | c 
If ab=c2  with gcd(a,b)=1 , then both a  and b  are squares, i.e. - a=a02 , b=b02 

The Prime Number Theorem

The Prime Number Theorem estimates the probability that any integer, chosen randomly will be prime. The estimate is given below, with π(x)  defined as the number of primes x 

π(x)xlnx 

π(x)  is asymptotic to xlnx , that is to say limxπ(x)xlnx=1 . What this means is that generally, a randomly chosen number is prime with the approximate probability 1lnx .

The Euclidean Algorithm

Introduction

The Euclidean Algorithm is used to discover the greatest common divisor of two integers. In cryptography, it is most often used to determine if two integers are coprime, i.e. - gcd(a,b)=1 .

In order to find gcd(a,b)  where a>b  efficiently when working with very large numbers, as with cryptosystems, a method exists to do so. The Euclidean algorithm operates as follows - First, divide a  by b , writing the quotient q1 , and the remainder r1 . Note this can be written in equation form as a=q1b+r1 . Next perform the same operation using b  in a 's place: b=q2r1+r2 . Continue with this pattern until the final remainder is zero. Numerical examples and a formal algorithm follow which should make this inherent pattern clear.

Mathematical Description

a=q1b+r1 
b=q2r1+r2 
r1=q3r2+r3 
r2=q4r3+r4 
 
 
 
rn2=qnrn1+rn 

When rn=0 , stop with gcd(a,b)=rn1 .

Numerical Examples

Example 1 - To find gcd(17,043,12,660)

17,043 = 1  12,660 + 4383
12,660 = 2  4,383 + 3894
 4,383 = 1  3,894 + 489
 3,894 = 7  489 + 471
   489 = 1  471 + 18
   471 = 26  18 + 3
    18 = 6  3 + 0

gcd (17,043,12,660) = 3

Example 2 - To find gcd(2,008,1,963)

2,008 = 1  1,963 + 45
1,963 = 43  45 + 28
   45 = 1  28 + 17
   28 = 1  17 + 11
   17 = 1  11 + 6
   11 = 1  6 + 5
    6 = 1  5 + 1
    5 = 5  1 + 0

gcd (2,008,1963) = 1 Note: the two number are coprime.

Algorithmic Representation

Euclidean Algorithm(a,b)
Input:     Two integers a and b such that a > b
Output:    An integer r = gcd(a,b)
  1.   Set a0 = a, r1 = r
  2.   r = a0 mod r1
  3.   While(r1 mod r  0) do:
  4.      a0 = r1
  5.      r1 = r
  6.      r = a0 mod r1
  7.   Output r and halt

The Extended Euclidean Algorithm

In order to solve the type of equations represented by Bézout's identity, as shown below

au+bv=gcd(a,b) 

where a , b , u , and v  are integers, it is often useful to use the extended Euclidean algorithm. Equations of the form above occur in public key encryption algorithms such as RSA (Rivest-Shamir-Adleman) in the form ed+w(p1)(q1)=1  where gcd(e,(p1)(q1))=1 . There are two methods in which to implement the extended Euclidean algorithm; the iterative method and the recursive method.

As an example, we shall solve an RSA key generation problem with e = 216 + 1, p = 3,217, q = 1,279. Thus, 62,537d + 51,456w = 1.

Methods

The Iterative Method

This method computes expressions of the form ri=axi+byi for the remainder in each step i of the Euclidean algorithm. Each modulus can be written in terms of the previous two remainders and their whole quotient as follows:

ri=ri2ri2ri1ri1

By substitution, this gives:

ri=(axi2+byi2)ri2ri1(axi1+byi1)
ri=a(xi2ri2ri1xi1)+b(yi2ri2ri1yi1)

The first two values are the initial arguments to the algorithm:

r1=a=a(1)+b(0) 
r2=b=a(0)+b(1) 

The expression for the last non-zero remainder gives the desired results since this method computes every remainder in terms of a and b, as desired.

Example
Step Quotient Remainder Substitute Combine terms
1 4,110,048 = a 4,110,048 = 1a + 0b
2 65,537 = b 65,537 = 0a + 1b
3 62 46,754 = 4,110,048 - 65,537 62 46,754 = (1a + 0b) - (0a + 1b) 62 46,754 = 1a - 62b
4 1 18,783 = 65,537 - 46,754 1 18,783 = (0a + 1b) - (1a - 62b) 1 18,783 = -1a + 63b
5 2 9,188 = 46,754 - 18,783 2 9,188 = (1a - 62b) - (-1a + 62b) 2 9,188 = 3a - 188b
6 2 407 = 18,783 - 9,188 2 407 = (-1a + 63b) - (3a - 188b) 2 407 = -7a + 439b
7 22 234 = 9,188 - 407 22 234 = (3a - 188b) - (-7a + 439b) 22 234 = 157a - 9,846b
8 1 173 = 407 - 234 1 173 = (-7a + 439b) - (157a - 9,846b) 1 173 = -164a + 10,285b
9 1 61 = 234 - 173 1 61 = (157a - 9,846b) - (-164a + 10,285b) 1 61 = 321a + 20,131b
10 2 51 = 173 - 61 2 51 = (-164a + 10,285b) - (321a +20,131b) 2 51 = -806a + 50,547b
11 1 10 = 61 - 51 1 61 = (321a +20,131b) - (-806a + 50,547b) 1 10 = 1,127a - 70,678b
12 5 1 = 51 -10 5 1 = (-806a + 50,547b) - (1,127a - 70,678b) 5 1 = -6,441a + 403,937b
13 10 0 End of algorithm

Putting the equation in its original form ed+w(p1)(q1)=1  yields (65,537)(403,937)+(6,441)(3,2171)(1,2791)=1 , it is shown that d=403,937  and w=6,441 . During the process of key generation for RSA encryption, the value for w is discarded, and d is retained as the value of the private key In this case

d = 0x629e1 = 01100010100111100001

The Recursive Method

This is a direct method for solving Diophantine equations of the form au+bv=gcd(a,b) . Using this method, the dividend and the divisor are reduced over a series of steps. At the last step, a trivial value is substituted into the equation, and is then worked backward until the solution is obtained.

Example

Using the previous RSA vales of (p1)(p1)=4,110,048  and e=216+1=65,537 

Euclidean Expansion Collect Terms Substitute Retrograde Substitution Solve For dx
4,110,048 w0 + 65,537d0 = 1
(62 65,537 + 46,754) w0 + 65,537d0 = 1
65,537 (62w0 + d0) + 46,754w0 = 1 w1 = 62w0 + d0 4,595 = (62)(-6441) + d0 d0 = 403,937
65,537 w1 + 46,754d1 = 1 d1 = w0 w1 = -6,441
(1 46,754 + 18,783) w1 + 46,754d1 = 1
46,754 (w1 + d1) + 18,783w1 = 1 w2 = w1 + d1 -1,846 = 4,595 + d1 d1 = -6,441
46,754 w2 + 18,783d2 = 1 d2 = w1
(2 18,783 + 9,188) w2 + 18,783d2 = 1
18,783 (2w2 + d2) + 9,188w2 = 1 w3 = 2w2 + d2 903 = (2)(-1,846) + d2 d2 = 4,595
18,783 w3 + 9,188d3 = 1 d3 = w2
(2 9,188 + 407) w3 + 9,188d3 = 1
9,188 (2w3 + d3) + 407w3 = 1 w4 = 2w3 + d3 -40 = (2)(903) + d3 d3 = -1846
9,188 w4 + 407d4 = 1 d4 = w3
(22 407 + 234) w4 + 407d4 = 1
407 (22w4 + d4) + 234w4 = 1 w5 = 22w4 +d4 23 = (22)(-40) + d4 d4 = 903
407 w5 + 234d5 = 1 d5 = w4
(1 234 + 173) w5 + 234d5 = 1
234 (w5 + d5) + 173w5 = 1 w6 = w5 +d5 -17 = 23 + d5 d5 = -40
234 w6 + 173d6 = 1 d6 = w5
(1 173 + 61) w6 + 173d6 = 1
173 (w6 + d6) + 61w6 = 1 w7 = w6 +d6 6 = -17 + d6 d6 = 23
173 w7 + 61d7 = 1 d7 = w6
(2 61 + 51) w7 + 61d7 = 1
61 (2w7 + d7) + 51w7 = 1 w8 = 2w7 +d7 -5 = (2)(6) + d7 d7 = -17
61 w8 + 51d8 = 1 d8 = w7
(1 51 + 10) w8 + 51d8 = 1
51 (w8 + d8) + 10w8 = 1 w9 = w8 +d8 1 = -5 + d8 d8 = 6
51 w9 + 10d9 = 1 d9 = w8
(5 10 + 1) w9 + 10d9 = 1
10 (5w9 + d9) + 1w9 = 1 w10 = 5w9 +d9 0 = (5)(1) + d9 d9 = -5
10 w10 + 1d10 = 1 d10 = w9
(1 10 + 0) w10 + 1d10 = 1
1 (10w10 + d10) + 0w10 = 1 w11 = 10w10 +d10 1 = (10)(0) + d10 d10 = 1
1 w11 + 0d11 = 1 d11 = w10 w11 = 1, d11 = 0

Euler's Totient Function

Significant in cryptography, the totient function (sometimes known as the phi function) is defined as the number of nonnegative integers a  less than n  that are coprime to n . Mathematically, this is represented as

ϕ(n)=|{0an|gcd(a,n)=1}|

Which immediately suggests that for any prime p 

ϕ(p)=p1 

The totient function for any exponentiated prime is calculated as follows

ϕ(pα) 
=pαpα1 
=pα(11p) 

The Euler totient function is also multiplicative

ϕ(ab)=ϕ(a)ϕ(b) 

where gcd(a,b)=1 

Finite Fields and Generators

A field is simply a set 𝔽 which contains numerical elements that are subject to the familiar addition and multiplication operations. Several different types of fields exist; for example, , the field of real numbers, and , the field of rational numbers, or , the field of complex numbers. A generic field is usually denoted 𝔽.

Finite Fields

Cryptography utilizes primarily finite fields, nearly exclusively composed of integers. The most notable exception to this are the Gaussian numbers of the form a+bi  which are complex numbers with integer real and imaginary parts. Finite fields are defined as follows

(/n)=n  The set of integers modulo n 
(/p)=p  The set of integers modulo a prime p 

Since cryptography is concerned with the solution of diophantine equations, the finite fields utilized are primarily integer based, and are denoted by the symbol for the field of integers, .

A finite field 𝔽n  contains exactly n  elements, of which there are n1  nonzero elements. An extension of n  is the multiplicative group of n , written (/n)*=n* , and consisting of the following elements

an*  such that gcd(a,n)=1 

in other words, n*  contains the elements coprime to n 

Finite fields form an abelian group with respect to multiplication, defined by the following properties

 The product of two nonzero elements is nonzero (ab=c|c0) 
 The associative law holds ((ab)c=a(bc)) 
 The commutative law holds (ab=ba) 
 There is an identity element (Ia=a) 
 Any nonzero element has an inverse (aa1=1) 

A subscript following the symbol for the field represents the set of integers modulo n , and these integers run from 0  to n1  as represented by the example below

12={0,1,2,3,4,5,6,7,8,9,10,11} 

The multiplicative order of n is represented n* and consists of all elements an such that gcd(a,n)=1 . An example for 12 is given below

12*={1,5,7,11} 

If p  is prime, the set p* consists of all integers a  such that 1ap . For example

Composite n Prime p
9={0,1,2,3,4,5,6,7,8} 11={0,1,2,3,4,5,6,7,8,9,10}
9*={1,2,4,5,7,8} 11*={1,2,3,4,5,6,7,8,9,10}

Generators

Every finite field has a generator. A generator g  is capable of generating all of the elements in the set n by exponentiating the generator gmodn . Assuming g  is a generator of n*, then n* contains the elements gimodn  for the range 0iϕ(n)1. If n* has a generator, then n is said to be cyclic.

The total number of generators is given by

ϕ(ϕ(n))

Examples

For n=p=13  (Prime)

13={0,1,2,3,4,5,6,7,8,9,10,11,12}
13*={1,2,3,4,5,6,7,8,9,10,11,12}

Total number of generators ϕ(ϕ(13))=ϕ(12)=4 generators

Let g=2 , then g={2,4,8,3,6,12,11,9,5,10,7,1} , g=2  is a generator

Since 2  is a generator, check if gcd(i,p1)=1 
22=4 , and i=2 , gcd(2,12)=21 , therefore, 4  is not a generator
23=8 , and i=3 , gcd(3,12)=31 , therefore, 4  is not a generator

Let g=6 , then g={6,10,8,9,2,12,7,3,5,4,11,1} , g=6  is a generator
Let g=7 , then g={7,10,5,9,11,12,6,3,8,4,2,1} , g=7  is a generator
Let g=11 , then g={11,4,5,3,7,12,2,9,8,10,6,1} , g=11  is a generator

There are a total of 4  generators, (2,6,7,11) as predicted by the formula ϕ(ϕ(n)).
For n=10  (Composite)

9={0,1,2,3,4,5,6,7,8,9} 
9*={1,3,7,9} 

Total number of generators ϕ(ϕ(10))=ϕ(4)=2  generators

Let g=3 , then g={3,9,7,1,3,9,7,1,3} , g=3  is a generator
Let g=7 , then g={7,9,3,1,7,9,3,1,7} , g=7  is a generator

There are a total of 2  generators (3,7,)  as predicted by the formula ϕ(ϕ(n)).

Congruences

Description

Number theory contains an algebraic system of its own called the theory of congruences. The mathematical notion of congruences was introduced by Karl Friedrich Gauss in Disquisitiones (1801).

Definition

If a  and b  are two integers, and their difference is evenly divisible by m , this can be written with the notation

(ab)|m 

This is expressed by the notation for a congruence

abmodm

where the divisor m  is called the modulus of congruence. abmodm can equivalently be written as

ab=mk 

where k  is an integer.

Note in the examples that for all cases in which a0modm, it is shown that a|m . with this in mind, note that

a0mod2 Represents that a  is an even number.

a1mod2 Represents that a  is an odd number.

Examples

abmodm ab=mk 
145mod3 145=33 
137mod4 (13)7=4(5) 
900mod18 900=185 

Properties of Congruences

All congruences (with fixed m ) have the following properties in common

aamodm
abmodm if and only if bamodm
If abmodm and bcmodm then acmodm
Given aamodm there exists a unique b  such that 0bm1 

These properties represent an equivalence class, meaning that any integer is congruent modulo m  to one specific integer in the finite field m.

Congruences as Remainders

If the modulus of an integer m>2 , then for every integer a 

a=mk+r(rm)

which can be understood to mean r  is the remainder of a  divided by m , or as a congruence

armodm

Two numbers that are incongruent modulo m  must have different remainders. Therefore, it can be seen that any congruence abmodm holds if and only if a  and b  are integers which have the same remainder when divided by m .

Example

103mod7 is equivalent to
10=(71)+3  implies
3  is the remainder of 10  divided by 7 

The Algebra of Congruences

Suppose for this section we have two congruences, abmodm and cdmodm. These congruences can be added or subtracted in the following manner

a+cb+dmodm
acbdmodm

If these two congruences are multiplied together, the following congruence is obtained

acbdmodm

or the special case where c=d 

acbcmodm

Note: The above does not mean that there exists a division operation for congruences. The only possibility for simplifying the above is if and only if c  and m  are coprime. Mathematically, this is represented as

acbcmodm implies that abmodm if and only if gcd(c,m)=1

The set of equivalence classes defined above form a commutative ring, meaning the residue classes can be added, subtracted and multiplied, and that the operations are associative, commutative and have additive inverses.

Reducing Modulo m

Often, it is necessary to perform an operation on a congruence abmodm where b>m , when what is desired is a new integer d  such that 0dm1  with the resultant d  being the least nonnegative residue modulo m of the congruence. Reducing a congruence modulo m  is based on the properties of congruences and is often required during exponentiation of a congruence.

Algorithm

Input: Integers b  and m  from abmodm with b>m 
Output: Integer d  such that 0dm1 

1. Let q=bm
2.     c=qm 
3.     d=bc 
4. Output d 

Example

Given 28949mod5

9=495
45=95 
4=4945 289494mod5

Note that 4  is the least nonnegative residue modulo 5 

Exponentiation

Assume you begin with abmodm. Upon multiplying this congruence by itself the result is a2b2modm. Generalizing this result and assuming n  is a positive integer

anbnmodm

Example

94mod13
8116mod13
72964mod13

This simplifies to

8116mod13 implies 163mod13
72964mod13 implies 2569mod13

Repeated Squaring Method

Sometimes it is useful to know the least nonnegative residue modulo m  of a number which has been exponentiated as a2modm. In order to find this number, we may use the repeated squaring method which works as follows:

1. Begin with amodm
2. Square a  and b  so that a2b2modm
3. Reduce b  modulo m  to obtain ab1modm
4. Continue with steps 2 and 3 until a2nbnmodm is obtained.
   Note that n  is the integer where 2n+1  would be just larger than the exponent desired
5. Add the successive exponents until you arrive at the desired exponent
6. Multiply all bi 's associated with the a 's of the selected powers
7. Reduce the resulting bmodm for the desired result

Example

To find 6149mod11:

66mod11
62=363mod11
649mod11
68814mod11
616165mod11
632253mod11
6649mod11
6128814mod11

Adding exponents:

128+16+4+1 

Multiplying least nonnegative residues associated with these exponents:

4596=1080 
1080mod11=2

Therefore: 

61492mod11

Inverse of a Congruence

Description

While finding the correct symmetric or asymmetric keys is required to encrypt a plaintext message, calculating the inverse of these keys is essential to successfully decrypt the resultant ciphertext. This can be seen in cryptosystems Ranging from a simple affine transformation

CaP+bmodN

Where

Pa1C+b1modN

To RSA public key encryption, where one of the deciphering (private) keys is

dA=eA1modϕ(nA)

Definition

For the elements am where gcd(a,m)=1, there exists bm such that ab1modm. Thus, b  is said to be the inverse of a , denoted anmodm where n  is the nth  power of the integer b  for which ab1modm.

Example
Find 6331mod2801

This is equivalent to saying 633b1mod2801

First use the Euclidean algorithm to verify gcd(633,2801)=1 .
Next use the Extended Euclidean algorithm to discover the value of b .
In this case, the value is 177 .

Therefore, 6331mod2801=177

It is easily verified that (633)(177)1mod2801

Fermat's Little Theorem

Definition

Where p  is defined as prime, any integer will satisfy the following relation:

apamodp

Example

When a=2  and p=19 

2223mod19
2452916mod19
282569mod19
216815mod19
16+2+1=19  implies that 5232=2302mod19

Conditions and Corollaries

An additional condition states that if a  is not divisible by p , the following equation holds

ap11modp

Fermat's Little Theorem also has a corollary, which states that if a  is not divisible by p  and nmmod(p1) then

anammodp

Euler's Generalization

If gcd(a,m)=1 , then aϕ(m)1modm

Chinese Remainder Theorem

If one wants to solve a system of congruences with different moduli, it is possible to do so as follows:

xa1modm1
xa2modm2
xakmodmk

A simultaneous solution x  exists if and only if gcd(mi,mj)=1 with (ij) , and any two solutions are congruent to one another modulo M=m1m2mk .

The steps for finding the simultaneous solution using the Chinese Remainder theorem are as follows:

1. Compute M 
2. Compute Mi=M/mi  for each of the different i 's
3. Find the inverse N  of Mimodmi for each i  using the Extended Euclidean algorithm
4. Multiply out aiMiNi  for each i 
5. Sum all aiMiNi 
6. Compute i=1kaiMiNimodM to obtain the least nonnegative residue

Example

Given:

x1mod11
x2mod7
x3mod5
x4mod9

M=3465 

M11=315 
M7=495 
M5=693 
M9=385 

Using the Extended Euclidean algorithm:

315N1mod11N=3
315N1mod7N=3
315N1mod5N=2
315N1mod9N=4

i=14={1315(3)=94524953=297036392=415843854=6160

=12343

x=12343mod3465=1948

Quadratic Residues

If p  is prime and >2 , examining the nonzero elements of p={1,2,,p1}, it is sometimes important to know which of these are squares. If for some ap*, there exists a square such that b2=a . Then all squares for p* can be calculated by b2modp where b=1,2,,(p1)/2 . an* is a quadratic residue modulo n  if there exists an xn* such that ax2modn. If no such x  exists, then a  is a quadratic non-residue modulo n . a is a quadratic residue modulo a prime p  if and only if ap12modp=1.

Example

For the finite field 19, to find the squares 19={1,2,,9},, proceed as follows:

12=122=432=942=1652=662=272=1182=792=5

The values above are quadratic residues. The remaining (in this example) 9 values are known as quadratic nonresidues. the complete listing is given below.

p=19 
Quadratic residues: 1,2,4,5,6,7,9,11,16 
Quadratic nonresidues: 3,8,10,12,13,14,15,17,18 

Legendre Symbol

The Legendre symbol denotes whether or not a  is a quadratic residue modulo the prime p  and is only defined for primes p  and integers a . The Legendre of a  with respect to p  is represented by the symbol L(ap). Note that this does not mean a  divided by p . L(ap) has one of three values: 0,1,1 .

L(ap){0,if p divides a evenly1,if a is a quadratic residue modulo p1,if a is a quadratic nonresidue modulo p

Jacobi Symbol

The Jacobi symbol applies to all odd numbers n>3  where n=p1e1p2e2pmem , then:

J(an)=L(ap1)e1L(ap2)e2L(apm)em

If n  is prime, then the Jacobi symbol equals the Legendre symbol (which is the basis for the Solovay-Strassen primality test).

Primality Testing

Description

In cryptography, using an algorithm to quickly and efficiently test whether a given number is prime is extremely important to the success of the cryptosystem. Several methods of primality testing exist (Fermat or Solovay-Strassen methods, for example), but the algorithm to be used for discussion in this section will be the Miller-Rabin (or Rabin-Miller) primality test. In its current form, the Miller-Rabin test is an unconditional probabilistic (Monte Carlo) algorithm. It will be shown how to convert Miller-Rabin into a deterministic (Las Vegas) algorithm.

Pseudoprimes

Remember that if p  is prime and gcd(b,m)=1, Fermat's Little Theorem states:

ap11modp

However, there are cases where p  can meet the above conditions and be nonprime. These classes of numbers are known as pseudoprimes.

m  is a pseudoprime to the base a , with gcd(a,m)=1 if and only if the least positive power of a  that is congruent to 1modp evenly divides p1 .

If Fermat's Little Theorem holds for any p  that is an odd composite integer, then p  is referred to as a pseudoprime. This forms the basis of primality testing. By testing different a 's, we can probabilistically become more certain of the primality of the number in question.

The following three conditions apply to odd composite integers:

I. If the least positive power of a  which is congruent to 1modn and divides n1  which is the order of a  in n*, then n  is a pseudoprime.
II. If n  is a pseudoprime to base a1  and a2 , then n  is also a pseudoprime to a1a2modn and a1a21modn.
III. If n  fails ap11modp, for any single base ap*, then n  fails ap11modp for at least half the bases ap*.

An odd composite integer for which ap11modp holds for every ap* is known as a Carmichael Number.

Miller-Rabin Primality Test

Description

Examples

Factoring

The Rho Method

Description

Algorithm

Example

Fermat Factorization

Example

Random Number Generators

RNGs vs. PRNGs

ANSI X9.17 PRNG

Blum-Blum-Shub PRNG

RSA PRNG

Entropy Extractors

Whitening Functions

Large Integer Multiplication

Karatsuba Multiplication

Example

Furers Multiplication

Elliptic Curves

Description

Definition

Properties

Summary

Template:BookCat