Example 6 Let $p$ be an odd prime satisfying $p \equiv 1(\bmod 4)$. Calculate the value of $\sum_{k=1}^{p-1}\left\{\frac{k^{2}}{p}\right\}$ where $(\{x\}=x-[x],[x]$ denotes the greatest integer not exceeding the real number $x$). ${ }^{[5]}$
(5th Hong Kong Mathematical Olympiad (2002))
Since $p \equiv 1(\bmod 4)$, by Theorem 3 we have
$$
\left(\frac{-1}{p}\right)=(-1)^{\frac{2-1}{2}} \equiv 1(\bmod p) \text {, }
$$

Therefore, -1 is a quadratic residue modulo $p$.
By $\left(\frac{-b}{p}\right)=\left(\frac{b}{p}\right)\left(\frac{-1}{p}\right)$, we know that $b$ is a quadratic residue if and only if $p-b$ is also a quadratic residue. According to the lemma, all quadratic residues are $\left\{1^{2}, 2^{2}, \cdots,\left(\frac{p-1}{2}\right)^{2}\right\}$, hence in the sense of modulo $p$, this set is equivalent to
$\left\{a_{1}, p-a_{1}, \cdots, a_{\frac{p-1}{4}}, p-a_{\frac{p-1}{4}}\right\}$.
When $1 \leqslant a_{i} 、 p-a_{i}<p$,
$$
\left\{\frac{a_{i}}{p}\right\}+\left\{\frac{p-a_{i}}{p}\right\}=1 \text {. }
$$

Thus, the value of the required sum is $\frac{p-1}{4}$.
By Euler's criterion, we know that when $p \equiv 1(\bmod 4)$, -1 is a quadratic residue modulo $p$; when $p \equiv 3(\bmod 4)$, -1 is a quadratic non-residue modulo $p$. Using this property, we can derive the following two corollaries.

Corollary 3 If integers $(a, b)=1$, then all prime factors of $a^{2}+b^{2}$ are of the form $4k+1$.
Proof Let $p$ be a prime factor. Then $a^{2}+b^{2} \equiv 0(\bmod p)$.
By $(a, b)=1$, we know $(a, p)=1$.
Let $c$ be the modular inverse of $a$ modulo $p$. Then
$a c=1(\bmod p)$.
Thus, $(a c)^{2}+(b c)^{2} \equiv 1+(b c)^{2} \equiv 0(\bmod p)$.
It follows that -1 is a quadratic residue modulo $p$.
Therefore, $p$ is a prime of the form $4k+1$.
Corollary 4 There are infinitely many primes of the form $4k+1$.
Proof Assume there are only finitely many primes $p_{1}, p_{2}, \cdots, p_{k}$. Let $p=\left(2 p_{1} p_{2} \cdots p_{k}\right)^{2}+1$, and take any prime factor $q$ of $p$.
Clearly, $q$ is an odd number and is coprime with $p_{1}, p_{2}, \cdots, p_{k}$.
But $p=\left(2 p_{1} p_{2} \cdots p_{k}\right)^{2}+1 \equiv 0(\bmod q)$, so -1 is a quadratic residue modulo $q$.
It follows that $q$ is also a prime of the form $4k+1$.
Therefore, the assumption is false; the original proposition holds.