Unformatted text preview: a % 2 == 0) /* a is even */ if (((b*b  1)/8) % 2 == 0) return +jacobi(a/2, b) else return jacobi(a/2, b) /* by Rule 3 and Rule 2 */ g = gcd(a,b); assert(odd(a)); /* this is guaranteed by the (a % 2 == 0) test */ if (g == a) /* a exactly divides b */ return 0; /* by Rules 5 and 4, and Definition 2 */ else if (g != 1) return jacobi(g,b) * jacobi(a/g, b); /* by Rule 2 */ else if (((a1)*(b1)/4) % 2 == 0) return +jacobi(b,a); /* by Rule 6a */ else return jacobi(b,a); /* by Rule 6b */ } If n is known to be prime beforehand, simply compute a((n1)/2) mod n instead of running the previous algorithm; in this case J(a,n) is equivalent to the Legendre symbol. The Jacobi symbol cannot be used to determine whether a is a quadratic residue mod n (unless n is prime, of course). Note that, if J(a,n) = 1 and n is composite, it is not necessarily true that a is a quadratic residue modulo n. For example: J(7, 143) = J(7, 11)*J(7, 13) = ( 1)( 1) = 1 However, there is no integer x such that x2 a 7 (mod 143). Blum Integers
If p and q are two primes, and both are congruent to 3 modulo 4, then n = pq is sometimes called a Blum integer. If n is a Blum integer, each quadratic residue has exactly four square roots, one of which is also a square; this is the principal square root. For example, the principal square root of 139 mod 437 is 24. The other three square roots are 185, 252, and 413. Generators
If p is a prime, and g is less than p, then g is a generator mod p if for each b from 1 to p  1, there exists some a where ga a b (mod p). Another way of saying this is that g is primitive with respect to p. For example, if p = 11, 2 is a generator mod 11: 210 = 1024 a 1 (mod 11) 21 = 2 a 2 (mod 11) 28 = 256 a 3 (mod 11) 22 = 4 a 4 (mod 11) 24 = 16 a 5 (mod 11) 29 = 512 a 6 (mod 11) 27 = 128 a 7 (mod 11) 23 = 8 a 8 (mod 11) 26 = 64 a 9 (mod 11) 25 = 32 a 10 (mod 11) Every number from 1 to 10 can be expressed as 2a (mod p). For p = 11, the generators are 2, 6, 7, and 8. The other numbers are not generators...
View
Full Document
 Fall '10
 ALIULGER
 Cryptography, Bruce Schneier, Applied Cryptography, EarthWeb, Search Search Tips

Click to edit the document details