applied cryptography - protocols, algorithms, and source code in c

These fields are called gfqn all arithmetic is done

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: rohibited. Read EarthWeb's privacy statement. To access the contents, click the chapter and section titles. Applied Cryptography, Second Edition: Protocols, Algorthms, and Source Code in C (cloth) Go! Keyword Brief Full Advanced Search Search Tips (Publisher: John Wiley & Sons, Inc.) Author(s): Bruce Schneier ISBN: 0471128457 Publication Date: 01/01/96 Search this book: Go! Previous Table of Contents Next ----------- Jacobi Symbol The Jacobi symbol, written J(a,n), is a generalization of the Legendre symbol to composite moduli; it is defined for any integer a and any odd integer n. The function shows up in primality testing. The Jacobi symbol is a function on the set of reduced residues of the divisors of n and can be calculated by several formulas [1412]. This is one method: Definition 1: J(a,n) is only defined if n is odd. Definition 2: J(0,n) = 0. Definition 3: If n is prime, then the Jacobi symbol J(a,n) = 0 if n divides a. Definition 4: If n is prime, then the Jacobi symbol J(a,n) = 1 if a is a quadratic residue modulo n. Definition 5: If n is prime, then the Jacobi symbol J(a,n) = - 1 if a is a quadratic nonresidue modulo n. Definition 6: If n is composite, then the Jacobi symbol J(a,n) = J(a,p1) *...* J(a,pm), where p1...pm is the prime factorization of n. The following algorithm computes the Jacobi symbol recursively: Rule 1: J(1,n) = 1 Rule 2: J(a*b,n) = J(a,n)*J(b,n) Rule 3: J(2,n) = 1 if (n2 - 1)/8 is even, and - 1 otherwise Rule 4: J(a,n) = J((a mod n),n) Rule 5: J(a,b1*b2) = J(a,b1)*J(a,b2) Rule 6: If the greatest common divisor of a and b = 1, and a and b are odd: Rule 6a: J(a,b) = J(b,a) if (a - 1)(b - 1)/4 is even Rule 6b: J(a,b) = - J(b,a) if (a-1)(b-1)/4 is odd Here is the algorithm in C: /* This algorithm computes the Jacobi symbol recursively */ int jacobi(int a, int b) { int g; assert(odd(b)); if (a >= b) a %= b; /* by Rule 4 */ if (a == 0) return 0; /* by Definition 2 */ if (a == 1) return 1; /* by Rule 1 */ if (a < 0) if (((b-1)/2 % 2 == 0) return jacobi(-a,b); else return -jacobi(-a,b); if (...
View Full Document

Ask a homework question - tutors are online