10. The largest prime $p$ such that $\frac{p+1}{2}$ and $\frac{p^{2}+1}{2}$ are both perfect squares is $\qquad$.
10.7.

Let $\frac{p+1}{2}=x^{2} ， \frac{p^{2}+1}{2}=y^{2}\left(x, y \in \mathbf{Z}_{+}\right)$.
Obviously, $p>y>x, p>2$.
From $p+1=2 x^{2}, p^{2}+1=2 y^{2}$, subtracting the two equations gives $p(p-1)=2(y-x)(y+x)$.
Since $p(p>2)$ is a prime number and $p>y-x$, then $p \mid(y+x)$.
Because $2 p>y+x$, so $p=y+x$.
Thus, $p-1=2(y-x) \Rightarrow p+1=4 x$
$$
\Rightarrow 4 x=2 x^{2} \Rightarrow x=2 \Rightarrow p=7, y=5 \text {. }
$$

Therefore, the only $p$ that satisfies the condition is $p=7$.