{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

This is because to be a square mod n the residue must

Info icon This 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: (-" << b << ") * " << v << " = " << gcd << endl; if (gcd == 1) cout << "the inverse of " << v << " mod " << u << " is: " << u - b << endl; return 0; } I’m not going to prove that it works or give the theory behind it. Details can be found in [863], or in any of the number theory texts previously listed. The algorithm is iterative and can be slow for large numbers. Knuth showed that the average number of divisions performed by the algorithm is: .843*log2(n) + 1.47 Solving for Coefficients Euclid’s algorithm can be used to solve this class of problems: Given an array of m variables x1, x2,...xm, find an array of m coefficients, u1, u2...um, such that u1*x1 + ...+ um*xm = 1 Fermat’s Little Theorem If m is a prime, and a is not a multiple of m, then Fermat’s little theorem says am -1 a 1 (mod m) (Pierre de Fermat, pronounced “Fair-ma, ” was a French mathematician who lived from 1601 to 1665. This theorem has nothing to do with his last theorem.) The Euler Totient Function There is another method for calculating the inverse modulo n, but it’s not always possible to use it. The reduced set of residues mod n is the subset of the complete set of residues that is relatively prime to n. For example, the reduced set of residues mod 12 is {1, 5, 7, 11}. If n is prime, then the reduced set of residues mod n is the set of all numbers from 1 to n- 1. The number 0 is never part of the reduced set of residues for any n not equal to 1. The Euler totient function, also called the Euler phi function and written as Æ(n), is the number of elements in the reduced set of residues modulo n. In other words, Æ(n) is the number of positive integers less than n that are relatively prime to n (for any n greater than 1). (Leonhard Euler, pronounced “Oiler, ” was a Swiss mathematician who lived from 1707 to 1783.) If n is prime, then Æ(n) = n- 1. If n = pq, where p and q are prime, then Æ(n)...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern