how prove this $\sum_{x=1}^{p-1}\left(\frac{1+x^4}{p}\right)\equiv 4\pmod 8$ Today, I read  a book saying it is easy to show this result:

Let $k$ be postive integer,and prime number $p=8k+1$, show that
$$\sum_{x=1}^{p-1}\left(\dfrac{1+x^4}{p}\right)\equiv 4\pmod 8$$
where $\left(\dfrac{\cdot}{p}\right)$ is  Legendre symbol mod $p$

I know that $\sum_{y\in\mathbb{F}_p} \left(\dfrac{y}{p} \right)=0$, but how  do show this?
This is from a competition question. It's easy to prove the following conclusion,At present, middle school only needs to know elementary number theory, but algebraic number theory and analytic number theory do not need to master, because I am a middle school teacher
 A: This turns out not to have too much to do with the Legendre symbol; all we will use about $(\frac zp)$ is that it equals $\pm1$ unless $z\equiv0\pmod p$ in which case it equals $0$.
We will also use the following facts, both of which follow from the fact that the multiplicative group $(\Bbb Z/p\Bbb Z)^\times$ is cyclic of order $p-1=8k$.

*

*If $Q$ is the range of the map $x\mapsto x^4\pmod p$ as $x$ ranges over $\{1,\dots,p-1\}$, then $Q$ has $\frac{p-1}4 = 2k$ elements each of which is hit $4$ times by that fourth-power map.

*$-1\pmod p$ is an element of $Q$. (Indeed, if $g$ is a primitive root modulo $p$ then $(g^k)^4 \equiv q^{(p-1)/2} \equiv -1\pmod p$.)

Using these observations, we can now rewrite the sum in question as
\begin{align*}
\sum_{x=1}^{p-1}\bigg(\frac{1+x^4}{p}\bigg) &= \sum_{q\in Q} 4\bigg(\frac{1+q}{p}\bigg) \\
&= 4\bigg(\frac{1+(-1)}{p}\bigg) + \sum_{q\in Q\setminus\{-1\}} 4\bigg(\frac{1+q}{p}\bigg) \\
&= 0 + \sum_{q\in Q\setminus\{-1\}} \pm4 \\
&\equiv 0 + \sum_{q\in Q\setminus\{-1\}} 4 = (2k-1)4 \equiv 4\pmod 8,
\end{align*}
since $-4\equiv4\pmod8$.
A: First of all, since $\mathbb F_p^\times\cong\mathbb Z/(p-1)\mathbb Z$ contains an element of order $8$, there is a $t\in\mathbb F_p$ such that $t^4=-1$.
Let $S$ be a set of representatives of $\mathbb F_p^\times/\sim$, where $a\sim b$ iff $ab$ or $ab^{-1}$ is a fourth root of unity. Note that whenever $a\sim b$, we have $\left(\frac{1+a^4}p\right)=\left(\frac{1+b^4}p\right)$. For each $s\in S$, let $[s]$ be the set of $x\in\mathbb F_p^\times$ with $x\sim s$. We have:
\begin{align*}
\sum_{x\in\mathbb F_p^\times}\left(\frac{1+x^4}p\right)&=\sum_{s\in S}\sum_{x\in[s]}\left(\frac{1+x^4}p\right)\pmod8.
\end{align*}
Whenever $[s]$ consists of $8$ elements, clearly the inner sum is $0$ modulo $8$. Thus we only need to consider the case when $[s]$ consists of $<8$ elements. This may only happen when $s=\omega s^{-1}$ where $\omega^4=1$. That is, $s^8=1$ and so $s=t^n$ for some $n$. Thus, we have:
\begin{align*}
\sum_{x\in\mathbb F_p^\times}\left(\frac{1+x^4}p\right)\equiv\sum_{n=0}^7\left(\frac{1+t^{4n}}p\right)=4\left(\frac{1+1}p\right)+4\left(\frac{1+(-1)}p\right)=4\pmod8.
\end{align*}
P.S. all arguments here can be directly applied to prove that when $p\equiv1\pmod{2n}$, we have:
$$\sum_{x\in\mathbb F_p^\times}\left(\frac{1+x^n}p\right)\equiv n\pmod{2n}.$$
