0

I'm a non-mathematician but I've been reading up on number theory as part of furthering my understanding of cryptography, and I've been focusing particularly on modular arithmetic in $\mathbb{Z}_p$ for $p > 2$, where $p$ is prime.

I'm mostly understanding it, but I came across the following example:

$$2^{-1}\textrm{ in }\mathbb{Z}_p\textrm{ is }\frac{p+1}{2}$$

This appears to work, and I can't find any counterexamples, but I'm struggling to understand whether it's a special case for $x=2$ or part of a more general rule, or where this identity was even derived from.

Further confusing me is that $x^{-1}=x^{p-2}$ in $\mathbb{Z}_p$ for $x \neq 0$, which would imply that $2^{p-2}\equiv\frac{p+1}{2}$ in $\mathbb{Z}_p$ for all prime $p > 2$, and I can't see how this arises.

How does this work?

Vsotvep
  • 6,123
  • If $p\equiv 1\bmod 3$ then $3^{-1} = - \frac{p-1}{3}$. – reuns Jan 14 '20 at 01:04
  • 3
    Note: $2\times\dfrac{p+1}2=p+1\equiv1\pmod p$ – J. W. Tanner Jan 14 '20 at 01:04
  • 1
    Side note: $\mathbb{Z}/p\mathbb{Z}$ is better notation: don't want to confuse with the $p$-adics $\mathbb{Z}_p$! – DanLewis3264 Jan 14 '20 at 01:07
  • 2
    @J.W.Tanner Oh, of course! Because $x \cdot x^{-1} \equiv 1$, and $p+1$ (mod $p$) $\equiv 1$ too. Perfect. If you can write that as an answer I'll accept it. – Polynomial Jan 14 '20 at 01:08
  • @bounceback I'm referring to a particular book that consistently uses $Z_p$ and $Z_p^*$ as notation for groups and generators throughout, so it makes sense for me to use this particular notation, but I'll keep that in mind for the more general case. – Polynomial Jan 14 '20 at 01:11

1 Answers1

2

For all odd $n>2$ (in particular for all prime $n>2$),

$2\times\dfrac{n+1}2=n+1\equiv1\pmod n$,

so $2^{-1}\equiv\dfrac{n+1}2\pmod n$.

You are correct that, for prime $n>2$, $2^{n-2}\equiv2^{-1}$, so $2^{n-2}\equiv \dfrac{n+1}2\pmod n$.

This is essentially $2^{n-1}\equiv n+1\equiv 1\pmod n.$

J. W. Tanner
  • 60,406