how to prove an equation involving sums of Kronecker symbol Let $p\equiv 8 \mod 9$ be a prime, I find the following equation:
$$2\sum_{\substack{0<x<p\\ 2|x}}\sum_{r|p^2-x^2}\left(\frac{-3}{r}\right)=p+1.$$
where $\left(\frac{-3}{r}\right)$ is the Kronecker symbol.
I checked it for many $p$ using computer. Does anyone have ideal how to prove it?

The identity can be rewritten as
$$\sum_{\substack{|x|<p\\ 2|x}}\sum_{r|p^2-x^2}\left(\frac{-3}{r}\right)=p+2,$$
because for $x=0$ the inner sum is $1-1+1=1$. Writing $x=2c$, the identity becomes
$$\sum_{|c|<p/2}\,\sum_{r|p^2-4c^2}\left(\frac{-3}{r}\right)=p+2.$$
The inner sum counts the number of integral representations $p^2-4c^2=a^2+ab+b^2$ divided by $6$, hence the identity is equivalent to the statement that the number of integral representations of $p^2$ by the quadratic form $a^2+ab+b^2+4c^2$ equals $6(p+2)$. We shall verify this by Siegel's mass formula, as it appears in Über die analytische Theorie der quadratischen Formen, Ann. of Math. 36 (1935), 527-606.
As the class of $a^2+ab+b^2+4c^2$ is alone in its genus, the number of representations of $p^2$ can be calculated as a product of local densities:
$$r(p^2)=\alpha_\infty\alpha_2\alpha_3\alpha_p\prod_{q\nmid 6p}\alpha_q.$$
By Hilfssatz 26 and (71) and the line below (59) in Siegel's paper,
$$\alpha_\infty=\frac{p}{\sqrt{3}}\cdot\frac{\pi^{3/2}}{\Gamma(3/2)}=\frac{2\pi }{\sqrt{3}}p.$$
By Hilfssatz 13 in Siegel's paper,
$$\alpha_2=\frac{3}{2}\qquad\text{and}\qquad\alpha_3=\frac{4}{3}.$$
By Hilfssatz 16 in Siegel's paper,
$$\alpha_p=\left(1-p^{-2}\right)\left(1+\frac{p^{-1}}{1+p^{-1}}\right)=(1-p^{-1})(1+2p^{-1}).$$
Finally, by Hilfssatz 12 in Siegel's paper,
$$\prod_{q\nmid 6p}\alpha_q=\prod_{q\nmid 6p}(1+\chi(q)q^{-1})=\frac{2}{1-p^{-1}}\prod_{q\neq 3}(1+\chi(q)q^{-1}),$$
where $\chi$ denotes the nontrivial quadratic character modulo $3$. Therefore,
$$r(p^2)=(p+2)\frac{8\pi}{\sqrt{3}}\prod_{q\neq 3}(1+\chi(q)q^{-1}).$$
We can identify the product over $q\neq 3$ as
$$\prod_{q\neq 3}(1+\chi(q)q^{-1})=\prod_{q\neq 3}\frac{1-q^{-2}}{1-\chi(q)q^{-1}}=\frac{9}{8}\cdot\frac{6}{\pi^2}L(1,\chi)=\frac{3\sqrt{3}}{4\pi},$$
hence in the end
$$r(p^2)=(p+2)\frac{8\pi}{\sqrt{3}}\cdot\frac{3\sqrt{3}}{4\pi}=6(p+2).$$
The proof is complete.
