 The ability to solve the Chinese remainder problem leads to a method of solving the discrete logarithm problem that's known as the Pollack-Hellman algorithm. And the basis of it is the following. So remember that from the Euler Fermat theorem that if two numbers are relatively prime, if my base is relatively prime to my modulus, then the base raised to d is going to be congruent to 1 for some divisor of phi of n. And what that tells me, if I imagine raising this to whatever the other cofactor is going to be, that tells me that when I take a and raise it to the power of phi of n, I get something that's going to be always congruent to 1 log n. And what this allows us to do is this allows us to solve the discrete logarithm problem by solving a Chinese remainder problem. So that follows in this way. Let phi of n be the product of two numbers, p and q, they don't have to be primes. And I'm going to do the following. So I'm going to let my unknown solution to the discrete logarithm problem be written as a0 plus a1 times p, where p is one of these divisors of phi of n. And if you want to think about it this way, what I'm actually looking at is I'm looking at the unknown value being congruent to a0 mod p. And then I can do the following. If I raise both sides of this congruence to power q, then over on the right-hand side I get b to the q, over on the left-hand side I get a to the qx. And by my substitution x being a0 plus a1p, I can be righted this way and I can apply my standard rules of exponents. So if I'm raising something to a sum, it's the same as the product of the two. And if I'm raising a number to a product of exponents, I can rewrite it by raising something to one exponent raised again to the other factor. So I can rewrite my expression this way. And here's the useful thing. Remember, a to the power of p of n is going to be congruent to one. Well, here's p of n. And then this is something I don't really care what because this relationship is going to hold true as long as a and n are relatively prime. And if a is relatively prime to n, so is a to any power that we care to name. So this second factor here is going to be congruent to one. So I can drop that out. And I've left with a to the q raised to the power a0. Now what makes this useful is that if I know q, then b to the q is an own quantity. a to the q is an own quantity. And the only thing I don't actually know is this a0. And a0 is going to be some number that's going to be between 0 and p. Which means I can try out different values and by trial and error, I can find what a0 is. Now we could have solved this problem here using trial and error as well. The difference here is that our possibilities for x are anywhere between 0 and n minus 1. Here, the possibilities for a0 are only going to go from 0 up to p. And that's a much smaller set of things we have to try out. And then once I know what a0 is, what that gives me is a congruence. x is going to be congruent to a0 mod whatever p happens to be. And similarly, I can find a congruence involving the other factor. And the Chinese remainder theorem allows me to solve for x at that point. For example, let's say I want to find 3 to the power x congruent to 22 mod 31. Now, again, with the discrete logarithm problem, it's not necessary that the modulus be prime. But if it is, we have some convenient ways of finding phi of n. Phi of n is just going to be 1 less than the prime number. And so phi of 31, 31 is prime. So phi of 31 is 30, which is the product 5 times 6. So what can I do? Well, I can start off by letting x be a0 plus some multiple of 5. And that gives me 3 to the x. If I raise it to the 6, that's 22 to the 6. And again, I can use my standard rules of exponents to simplify the expression a little bit. And here I have something raised to the 30th, raised to the phi of 31. And so this term here, this factor, is going to be congruent to 1, so I can drop it out. And now I have 3 to the 6. Wait, I know what that is. That's 16 raised to something congruent to 8 mod 31. And so I try out different values of a0 and see what works. And again, by trial and error, I find that if a0 is 2, 16 to the second is congruent to 8. So I know that a0 is 2, and x is congruent to 2 mod 5. I'll take it into that. Now, what else do I have? Well, again, 30 is 5 times 6. Well, that works so well. Let's try it the other way. So I'll assume x is something plus a multiple of 6. And again, through very much the same process, I have 3 to the x to the 5th, the missing factor, useful idea for later on. And then 22 to the 5th, I can find out what these are. Simplify, simplify, simplify, simplify, simplify. And so, again, I now know that 26 to the b0. I don't know what that is, but again, by trial and error, I can figure out that this exponent has to be 5. And so I know that x is going to be congruent to 5 mod 6. And now I have a Chinese remainder theorem problem. So I'll solve it. 6 is congruent to 1 mod 5. That means 12 is congruent to 2 mod 5. Next, I'll look for a multiple of 5 that's congruent to 1 mod 6. 25, for example. And then that tells me 125 is congruent to 5 mod 6. And if I add 125 to the first congruent, nothing changes. If I add 12 to the second, nothing changes. So that tells me 137 solves both. And I'll reduce, reduce, reduce, reduce. And I have my smallest positive solution, x equals 17. Now it's worth noting that this was not the only way we could have found the solution. We could have broken phi of 31 into smaller factors, 2 by 3 by 5. And so in this case, I'll let x be a0 plus a multiple of 2. And so my missing factor, since I have a multiple of 2, I need a 15 to get me up to 30. So I'll raise everything to the 15th power. And I'll simplify, simplify, simplify, simplify, simplify. And I have 30 to the a0, congruent to 30. And well, I don't really need trial and error. It should be kind of obvious that a0 is 1. And so x is congruent to 1 mod 2. Using the next factor, 3, I'll let x be something plus a multiple of 3. And if I raise everything to the 10th power, I'll get a 30 here. That's my phi of 31. So I'll raise everything to the 10th power. I'll use my standard rules of exponents again. And split off this second add end. And let's see. This is something to the 30th, which is phi of n. So this factor here is going to be congruent to 1. I can drop it. And the other factors, 22 to the 10th, I can figure out what that is. And now I have this congruence to solve. And again, by trial and error, the nice thing here is that I know that b0 has to be either 0 or 1, which it's obviously not, or 2. And I do try out x congruent to 2 mod 3. So now I know something about x. And finally, I'll go to that third factor, 5. And this is essentially the same factor that we used the last time. So we're going to get exactly the same congruence. And again, exactly the same congruence relationship. And now x, again, is the solution to a system of three simultaneous congruences. And we'll solve the Chinese remainder theorem problem. And our solution is 17 once again.