This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ong y, unsigned long n) { unsigned long s,t,u; int i; s = 1; t = x; u = y; while(u) { if(u&amp1) s = (s* t)%n; u>>=1; t = (t* t)%n; } return(s); } Another, recursive, algorithm is: unsigned long fast_exp(unsigned long x, unsigned long y, unsigned long N) { unsigned long tmp; if(y==1) return(x % N); if ((y&amp1)==0) { tmp = fast_exp(x,y/2,N); return ((tmp* tmp)%N); } else { tmp = fast_exp(x,(y1)/2,N); tmp = (tmp* tmp)%N; tmp = (tmp* x)%N; return (tmp); } } This technique reduces the operation to, on the average, 1.5*k operations, if k is the length of the number x in bits. Finding the calculation with the fewest operations is a hard problem (it has been proven that the sequence must contain at least k 1 operations), but it is not too hard to get the number of operations down to 1.1*k or better, as k grows. An efficient way to do modular reductions many times using the same n is Montgomery’s method [1111]. Another method is called Barrett’s algorithm [87]. The software performance of these two algorithms and the algorithm previously discussed is in [210]: The algorithm I’ve discussed is the best choice for singular modular reductions; Barrett’s algorithm is the best choice for small arguments; and Montgomery’s method is the best choice for general modular exponentiations. (Montgomery’s method can also take advantage of small exponents, using something called mixed arithmetic.) The inverse of exponentiation modulo n is calculating a discrete logarithm . I’ll discuss this shortly. Prime Numbers
A prime number is an integer greater than 1 whose only factors are 1 and itself: No other number evenly divides it. Two is a prime number. So are 73, 2521, 2365347734339, and 2756839  1. There are an infinite number of primes. Cryptography, especially publickey cryptography, uses large primes (512 bits and even larger) often. Evangelos Kranakis wrote an excellent book on number theory, prime numbers, and their applications to cryptography [896]. Paulo Ribenboim wrote two excellent references on prime numbers in general [1307, 1308]. Greatest Common Divisor
Two numbers are relatively prime when they share no factors in common other than 1. In other words, if the greatest common divisor of a and n is equal to 1. This is written: gcd(a,n) = 1 The numbers 15 and 28 are relatively prime, 15 and 27 are not, and 13 and 500 are. A prime number is relatively prime to all...
View
Full
Document
This note was uploaded on 10/18/2010 for the course MATH CS 301 taught by Professor Aliulger during the Fall '10 term at Koç University.
 Fall '10
 ALIULGER
 Cryptography

Click to edit the document details