<s>[INST] Let $p$ be prime and $\left(\frac{-3}p\right)=1$. Prove that $p$ is of the form $p=a^2+3b^2$ 
Let $p$ be prime and $\left(\frac{-3}p\right)=1$, where $\left(\frac{-3}p\right)$ is Legendre symbol. Prove that $p$ is of the form $p=a^2+3b^2$.

My progress:
$\left(\frac{-3}p\right)=1 \Rightarrow$ $\left(\frac{-3}p\right)=\left(\frac{-1}p\right)\left(\frac{3}p\right)=(-1)^{\frac{p-1}2}(-1)^{\left\lfloor\frac{p+1}6\right\rfloor}=1 \Rightarrow$ $\frac{p-1}2+\left\lfloor\frac{p+1}6\right\rfloor=2k$  I'm stuck here. This is probably not the way to prove that.
Also tried this way:
$\left(\frac{-3}p\right)=1$, thus $-3\equiv x^2\pmod{p} \Rightarrow$ $p|x^2+3 \Rightarrow$ $x^2+3=p\cdot k$
stuck here too.
Any help would be appreciated.
 [/INST] Let $\omega\in\Bbb C$ satisfy $\omega^2+\omega+1$. Then $\Bbb Z[\omega]$ is a UFD, since $N(a+b\omega)=a^2-ab+b^2$ defines an Euclidean norm.
Since $\left(\frac{-3}{p}\right)=1$, there is an $s$ such that $p\mid s^2+3$. Working over $\Bbb Z[\omega]$ we have $$p\mid (s+1+2\omega)(s+1+2\omega^2)$$ If $p$ is prime we would have both $p\mid s+1$ and $p\mid 2$. This is impossible, so $p$ cannot be prime. Therefore we must have $p=\alpha\beta$, where $\alpha,\beta\in\Bbb Z[\omega]$. Taking norms, we get $$p^2=N(p)=N(\alpha)N(\beta)$$ Since neither $\alpha,\beta$ are units, we have $N(\alpha),N(\beta)\neq 1$. This forces $N(\alpha)=N(\beta)=p$. Let $\alpha=m+n\omega$, then $$p=N(\alpha)=m^2-mn+n^2$$ Without loss of generality we may assume that $n$ is even, as $p$ is an odd prime. We can then write:
$$4p=4m^2-4mn+n^2+3n^2\\4p=(2m-n)^2+3n^2\\p=\left(m-\frac{n}{2}\right)^2+3\left(\frac{n}{2}\right)^2$$ Choose $a=m-\frac{n}{2}$ and $b=\frac{n}{2}$ and we get $$p=a^2+3b^2$$
</s>