# Fermat's Little Theorem: $r \equiv s \pmod {p-1} \implies a^r \equiv a^s \pmod p$

An implication of Fermat's Little Theorem is the following:

If $$p$$ is prime, and $$a$$ is not a multiple of $$p$$, then $$r \equiv s \pmod {p-1} \implies a^r \equiv a^s \pmod p.$$

I need this implication to prove the verification of the Elgamal signature, but I honestly do not see how to derive from Fermat's Little Theorem to this implication and I could not find any proof of this.

Any help would be much appreciated!

• You can use the following properties to show that: (1) if $a_1 \equiv b_1 \pmod{p}$ and $a_2 \equiv b_2 \pmod{p}$ then $a_1\, a_2 \equiv b_1\, b_2 \pmod{p}$, and (2) if $k\,a \equiv k\,b \pmod{p}$ and $k$ is coprime with $p$, then $a \equiv b \pmod{p}$. Mar 9 at 14:46

Assume without loss of generality that $r\geq s$, so $r=s+k(p-1)$ for some $k\geq 0$. Then $a^r=a^sa^{k(p-1)}$. Can you see how to get from here to what you want?

• Yes, because $a^{k(p-1)}= a^{(p-1)^k} = 1^k = 1$. Thank you!
– Joey
Jun 10 '18 at 10:22

There is a more universal Theorem to get it.
The Theorem lies in 《elementary number thoery 6th》 Theorem 9.2.
It can be used to prove the verification of the Elgamal signature and DSA.
DSA is a much more popular variant of the Elgamal signature.

Theorem 9.2 If $$a$$ and $$n$$ are relative prime integers with $$n>0$$,then $$a^i \equiv a^j \pmod n$$,where i and j are nonnegative integers, if and only if $$i \equiv j \pmod {ord_n^a}$$

Specially, when $$p$$ is a prime integer, $${ord_p^a}=\varphi(p)=p-1$$ , so we get the result:
Corollary If $$a$$ and $$p$$ are relative prime integers, and $$p$$ is a prime integer,then $$a^i \equiv a^j \pmod p$$,where i and j are nonnegative integers, if and only if $$i \equiv j \pmod {p-1}$$

hence:

$$i \equiv j \pmod {p-1} \Leftrightarrow a^i \equiv a^j \pmod p.$$

That is the answer.

• Who is the author of the book you reference? Oct 1 '19 at 22:05
• Kenneth H. Rosen
– 孙海城
Oct 2 '19 at 0:22