p
x where ax = b mod p
p is prime, then there always exists some
a for which there is always a discrete logarithm for
any b!=0
a "generate" the group mod p
a is called a primitive root
This is the inverse problem to exponentiation. And here we see an example of a problem thats "easy" one way (raising a number to a power), but "hard" the other (finding what power a number is raised to giving the desired answer). Problems with this type of asymmetry are very rare, but are of critical usefulness in modern cryptography.
(a,b) of a and b
is the largest number that divides evenly into both a and b
Another common problem is to determine the "greatest common divisor", that is the largest number that divides into both a & b. Actually, a lot of the time we want to show that its 1, that is the two number a & b are relatively prime, with no factors in common.
a and n, given a<n
a and b have divisor
d then so does a-b, a-2b, ...
GCD (a,n) is given by:
let g0=n
g1=a
gi+1 = gi-1 mod gi
when gi=0 then (a,n) = gi-1
Euclid's Algorithm is derived from the observation that if a & b have a
common factor d (ie. a=m.d & b=n.d) then
d is also a factor in any difference between them, vis:
a-p.b = (m.d)-p.(n.d) = d.(m-p.n). Euclid's Algorithm
keeps computing successive differences until it vanishes, at which
point that divisor has been reached.
g0=98 g1=56 g2 = 98 mod 56 = 42 g3 = 56 mod 42 = 14 g4 = 42 mod 14 = 0 hence (56,98)=14
a-1 is inverse of a mod n if
a.a-1 = 1 mod n,
where a,x in {0,n-1}
3.7 = 1 mod 10
GCD(a,n)=1 then the inverse always exists
gi = ui.n + vi.a
GCD(a,n)=1 will find
1 = ui.n + vi.a giving us the inverse
Finding the multiplicative inverse is a common problem. Needed to
do "division". An extension to Euclid's Algorithm can help us find it,
by tracking gi = ui.n + vi.a.
When have 1 = ui.n + vi.a, we have the
inverse of a mod n as vi.
a mod n (where (a,n)=1)
Inverse(a,n) is given by:
g0=n u0=1 v0=0
g1=a u1=0 v1=1
loop computing
y = gi-1 div gi
gi+1 = gi-1 - y.gi = gi-1 mod gi
ui+1 = ui-1 - y.ui
vi+1 = vi-1 - y.vi
until gi=0
at end Inverse(a,n) = vi-1
i y g u v 0 - 460 1 0 1 - 3 0 1 2 153 1 1 -153 3 3 0 -3 460 hence Inverse(3,460) = -153 = 307 mod 460
i y g u v Difference Equation tracked 0 - 323 1 0 323 = 1.323 + 0.299 1 - 299 0 1 299 = 0.323 + 1.299 2 1 24 1 -1 24 = 1.323 + -1.299 3 12 11 -12 13 11 = -12.323 + 13.299 4 2 2 25 -27 2 = 25.323 + -27.299 5 5 1 -137 148 1 = -137.323 + 148.299 *** answer *** ie 148.299 = 137.323 + 1 = 1 mod 323 gives 148 as inverse of 299 mod 323
0..n-1
The reduced set of residues is important, because these are the values which are relatively prime to the modulus. The other values share some common factor with the modulus, which means that multiplying them by some values gives a multiple of the modulus, ie they are factors of zero, which is pretty nasty when multiplying. eg. 5.4 = 20 = 0 mod 10, so 5 & 4 are factors of zero. Knowing how many "non-zero" multipliers there are is important, when working out exponentiations for example.
p (p prime) ø(p) = p-1 pr (p prime) ø(p) = pr-1(p-1) p.q (p,q prime) ø(p.q) = (p-1)(q-1)
To work out ø(n), start with n-1 non-zero residues, then remove all factors of n, and all multiples of those factors. If n is prime, there are no factors, so ø(n)=n-1. If n=p.q, then remove all multiples of p les than n (ie q-1 of them), and all multiples of p (ie p-1 of) to get ø(n=p.q)=p.q-(q-1).p-(p-1).q-1=(p-1).(q-1). Can extend the same idea to get the general formula based on the prime factorisation of n. Hence need to know all factors to compute ø(n).
ap-1 mod p = 1
aø(n) mod n = 1
These are a couple of important theorems concerning powers of an reduced residue. Its used both as one way to find inverses (see below), and also as the key theorem used in the RSA crypto system.
a-1 mod n
a-1 is found with
a.a-1 = 1 mod n
ø(n) is known, then from Euler's Theorem have
a-1 = aø(n)-1 mod n
Now have 3 ways to find inverses: search for it if n is (really) small.
Use Euler's Theorem by writing it as a.b=1 mod n where
b=aø(n)-1. Or use the Extended Euclid's
Alg in the general case.
an-1 = 1 mod n where GCD(a,n)=1
(a) (-) (mod n) = a (n-1)/2 (mod n) (n) where (a) (-) is the Jacobi function of a,n (n)
M mod N
M1 mod p and
M2 mod q and combine results to get answer
M = [((M2 +q - M1)u mod q] p + M1 where p.u mod q = 1
2x = 3 mod 5 4x = 3 mod 7 4x = 2 mod 13 5x = 3 mod 7 6x = 10 mod 11 7x = 3 mod 13 8x = 3 mod 11 9x = 6 mod 11
GCD(65,91) GCD(102,238) GCD(110,154) GCD(171,285) GCD(185,259)
57 61 65 79 83 85
2 mod 11 2 mod 15 5 mod 7 5 mod 17 12 mod 35 13 mod 45 17 mod 199 19 mod 193 21 mod 197 22 mod 199