TITLE: Explicit formula for Fermat's 4k+1 theorem
QUESTION [18 upvotes]: Let $p$ be a prime number of the form $4k+1$. Fermat's theorem asserts that $p$ is a sum of two squares, $p=x^2+y^2$.
There are different proofs of this statement (descent, Gaussian integers,...). And recently I've learned there is the following explicit formula (due to Gauss):
$x=\frac12\binom{2k}k\pmod p$,
$y=(2k)!x\pmod p$
($|x|,|y|<p/2$). But how to prove it?
Remark. In another thread Matt E also mentions a formula 
$$
x=\frac12\sum\limits_{t\in\mathbb F_p}\left(\frac{t^3-t}{p}\right).
$$
Since $\left(\dfrac{t^3-t}p\right)=\left(\dfrac{t-t^{-1}}p\right)=(t-t^{-1})^{2k}\mod p$ (and $\sum t^i=0$ when $0<i<p-1$), this is, actually, the same formula (up to a sign).

REPLY [2 votes]: (Below is a kind of a low-tech version of David Speyer's answer — [essentially] proving Weil for a cubic instead of using it. On the other hand, it's a kind of a more conceptual version of the computation with Jacobsthal sums.)

I. Preliminaries
For any two (nontrivial multiplicative) characters mod $p$ define Jacobi sum
$$
J(\chi,\lambda):=\sum_{a+b=1}\chi(a)\lambda(b).
$$
Recall that (if $\chi\lambda$ is a non-trivial character)
$$
J(\chi,\lambda)=\frac{g(\chi)g(\lambda)}{g(\chi\lambda)},
$$
where
$$
g(\chi)=\sum\chi(t)\zeta^t
$$
is the usual Gauss sum (cf. beta-function and gamma-function, btw).
Corollary. Since $|g(\chi)|=\sqrt p$, the absolute value of a Jacobi sum is $\sqrt p$ (given that $\chi$, $\lambda$ and $\chi\lambda$ are non-trivial).
II. Proof
Take $\chi$ to be a non-trivial character of order $4$ mod $p=4k+1$; $\chi^2=:\rho$ is then the quadratic character. Since $\chi$ and $\rho$ take values in $\{\pm1,\pm i\}$, the sum $J(\chi,\rho)$ is a Gaussian integer, and by Corollary it has norm $p$.
This already gives a proof of Fermat's $4k+1$ theorem. And explicitly (using that $J$ is real only if $a$ is a quadratic residue)
$$
\operatorname{Re}J(\chi,\rho)=\frac12\sum_t\left(\frac tp\right)\left(\frac{1-t^2}p\right)=\frac12\sum_t\left(\frac{t-t^3}p\right).
$$
Which is, of course, just an example of counting of points on an elliptic curve ($y^2=x^3-x$ or $y^2=1-x^4$) — well, counting points on hypersurfaces is the point of Jacobi sums, after all.

Reference: Ireland, Rosen. A Classical Introduction to Modern Number Theory (ch. 8).