I have $p=1 \mod 3$. I am trying to show that $x^2-x+1=(x-a)^2 \mod p$ for some $a$. So far I have that $x^2-x+1=x^2-2ax+a^2 \mod p$. Which mean that $2a=1 \mod p$ and $a^2=1 \mod p$
The first identity tells us that $a=\frac{p+1}{2}$ Using this in the second identity we have $(\frac{p+1}{2})^2=1\mod p$. So we get $\frac{p^2+2p+1}{4}=1\mod p$. But now we run into trouble because this implies $1=4\mod p$ or in particular $p=3$. Have I done something wrong here, or am I mistaken that its possible to have $p=1\mod 3$.
for added context, $x^2-x+1$ is the minimal polynomial of $\frac{1+\sqrt{-3}}{2}$.
You need an element $a$ of order $3$ then $$x^2 -x+1=(x+a)(x+a^{-1})\in \Bbb{F}_p[x]$$
$x^{p-1}-1$ (of degree $p-1$) has $p-1$ distinct roots in $\Bbb{F}_p$ thus $$x^{p-1}-1=\prod_{n=1}^{p-1}(x-n)\in \Bbb{F}_p[x]$$ Take any root $b$ of $x^{p-1}-1$ which is not a root of $x^{(p-1)/3}-1$, the order of $b$ divides $p-1$ but not $(p-1)/3$ thus it is $3m$ so that $a=b^m$ works.