Number of solutions to $a^2-b^2+c^2 = k\pmod{p}$ Let $k\neq 0$ be a fixed integer. How many triplets $(a,b,c)$ are there satisfying $$a^{2}-b^{2}+c^{2}\equiv k\pmod{p}$$ I know that if $c=0$, then there are $p-1$. Not sure for the general case
 A: Let $N_k$ be the number of solutions.
Define the Gauss sum $\tau=\sum_{a=0}^{p-1}\zeta^{a^2}$ where $\zeta=\exp(2\pi i/p)$.
Then
$$\tau^2\overline{\tau}=\sum_{a,b,c=0}^{p-1}\zeta^{a^2-b^2+c^2}
=\sum_{k=0}^{p-1} N_k\zeta^k.$$
 So
$$p\tau=p\sum_{k=0}^{p-1}\left(\frac kp\right)\zeta^k=\sum_{k=0}^{p-1} N_k\zeta^k=\sum_{k=1}^{p-1}(N_k-N_0)\zeta^k.$$
Here  $\left(\frac kp\right)$ is the Legendre symbol. Since $\zeta,\ldots,\zeta^{p-1}$ are linearly independent over $\Bbb Q$, then
it follows that $N_k-N_0=p\left(\frac kp\right)$. So
$$N_k=N_0+p\left(\frac kp\right).$$
Adding over all $k$ gives
$$p^3=pN_0$$
so
$$N_k=p^2+p\left(\frac kp\right).$$
A: What is the problem if $c\neq 0$?
Fix $c$, then $c^2$ leaves some remainder when divided by $p$, now if you move $c^2$ to the left-hand side of the equation, and let $k-c^2$(mod p)=$k$', so we have to find the number of solutions
$a^2+b^2=k'$ (mod p)
As you said if $k'\neq 0$ then it has $p-1$ solutions, so if $k$ is not a square modulo $p$(i.e $k'$ is not zero for any value of $c$) then the number of solutions of the original equation is $(p-1) \times p$.
Note that $a^2+b^2=0$ (mod p)  has $p+(p-1)=2p-1$ solutions.
Now say $k'=0$ for some $c\neq 0$ (i.e. $k$ is a quadratic residue modulo $p$ and $k\neq 0$), then for exactly $2$ values of $c$, $k'=0$ and the equation will have $2p-1$ solutions for those $2$ values and for the rest $p-2$ values of $c$ we will have $p-1$ pairs of $(a,b)$ for each value of $c$, hence the total number of solutions of the original congruence in this case is $(p-2)\times (p-1)+2(2p-1)=p^2+p$, when $k\neq 0$ is a quadradic residue modulo $p$.
If $k=0$, then for $c=0$ the congruence has exactly $2p-1$ solutions and for all other $p-1$ values of $c$ the congruence has $p-1$ solutions for each $c$.
Hence, in this case, the total number of solution is $(p-1)^2+2p-1=p^2$
