Determine $2^{\frac{p-1}{4}}\equiv 1\pmod p$ or $2^{\frac{p-1}{4}}\equiv -1\pmod p$ when $p\equiv 1 \pmod 8$

Let $p=8k+1\equiv 1\pmod 8$ be a prime, thus $2$ is a quadratic residue module $p$. Euler's criterion show that $$2^{\frac{p-1}{2}}\equiv 1 \pmod p.$$

So we must have $$2^{\frac{p-1}{4}}\equiv \delta(p) \pmod p$$ where $\delta(p)=\pm1$.

Now my question is how to determine $\delta(p)$.

I calculated many examples. Statistics show that the value of $\delta(p)$ should be related with the parity of $k$ and $h(-p)$, the latter being the class number of $\mathbb{Q}(\sqrt{-p})$. I know little algebraic number theory and hope some experts could help me solve this problem. I am waiting for help, thank you very much!

EDIT

Now I have formulated my conjecture about $\delta(p)$, which states as follows.

Conjecture:

$$\delta (p)=(-1)^{\frac{h(-p)}{4}+k}$$

Any ideas to prove or counterexample to disprove this?

• Have you looked at quartic reciprocity? en.wikipedia.org/wiki/Quartic_reciprocity#Gauss – user19475 Aug 8 '18 at 10:50
• Thank you very much for your link. Dirichlet proved an identity for $\delta (p)$. But $h(-p)$ doesn't appear. Now, I have found the exact relation between $\delta (p)$ and $k$, $h(-p)$. See my conjecture above in the edit. Can you prove that? – 王李远 Aug 8 '18 at 11:19
• This is formula 1.5 in Williams Currie Canadian Journal of Math 1982 – Henri Cohen Aug 8 '18 at 16:59
• author = "Kenneth S. Williams and James D. Currie", title = "Class numbers and biquadratic reciprocity", journal = j-CAN-J-MATH, volume = "34", number = "??", pages = "969--988", – Will Jagy Aug 8 '18 at 17:17
• Barrucand and Cohn (MR0249396, Note on primes of type $x^2+32y^2$, class number, and residuacity. J. Reine Angew. Math. 238, 1969, 67--70) have proved that for primes $p \equiv 1 \textrm{ mod } 8$, the condition $h(-4p) \equiv 0 \textrm{ mod } 8$ is equivalent to $-4$ being a $8$-th power mod $p$. This implies your observation. (I learned this in Merel's article webusers.imj-prg.fr/uploads//loic.merel//files/u.pdf) – François Brunault Aug 8 '18 at 17:40

Barrucand and Cohn (MR0249396, Note on primes of type $x^2+32y^2$, class number, and residuacity. J. Reine Angew. Math. 238, 1969, 67--70) have proved that for primes $p \equiv 1 \textrm{ mod } 8$, the condition $h(−4p) \equiv 0 \textrm{ mod } 8$ is equivalent to $−4$ being a $8$-th power mod $p$. This implies your observation because $(-4)^{\frac{p-1}{8}} = (-1)^k 2^{\frac{p-1}{4}}$. I learned this in Merel's article L'accouplement de Weil entre le sous-groupe cuspidal et le sous-groupe de Shimura de $J_0(p)$, J. Reine Angew. Math. 477 (1996), 71--115, where you can find other characterizations e.g. $p$ is of the form $x^2+32y^2$, cf. Théorème 3.
In the case $p \equiv 5 \textrm{ mod } 8$, the formula 1.5 in Williams and Currie's article mentioned by Henri Cohen, together with $(\frac{p-1}{2})!^2 \equiv -1 \textrm{ mod } p$ for $p \equiv 1 \textrm{ mod } 4$ (Wilson's theorem) implies your second observation.