Solution (source code)

= Solution

Let $\pi$ be the <Frobenius isogeny> and let $a=p+1-N$ be its <Trace of Frobenius>. Its characteristic equation is $\pi^2-[a]\pi+[p]=0$, so the <trace of the square of an elliptic-curve endomorphism> is $a^2-2p$. The <elliptic-curve point count over a finite field> therefore gives
$$
\#E(\mathbb F_{p^2})=p^2+1-(a^2-2p)
=(p+1)^2-(p+1-N)^2.
$$
The <prime-square point-count formula> is consequently
$$
\boxed{\#E(\mathbb F_{p^2})=N\bigl(2p+2-N\bigr).}
$$
One can also obtain it directly from the <degree of an isogeny>: the maps $1-\pi$ and $1+\pi$ are <separable isogenies>, with degrees $p+1-a$ and $p+1+a$. Their composition is $1-\pi^2$, whose <kernel of an isogeny> is exactly $E(\mathbb F_{p^2})$. Multiplicativity of degree gives the same product.