An intersection calculation over a finite field Question: 
I made a calculation that must be wrong, but am having trouble spotting the error. Which steps below are invalid? Thank you in advance for your attention!
Setup:
Let $p$ and $\ell \neq p$ be prime numbers. Let $X_0$ be a geometrically connected, proper, smooth variety over $k=\mathbb{F}_p$. Let $X$ be the base change of $X_0$ to $\overline{k}$.
Let $[Z]\in H^{2i}(X,\mathbb{Q}_{\ell}(i))$ be the cycle class of a subvariety $Z \subset X$ of codimension $i$. Write $H^i(-)$ (and suppress Tate twists) for $\ell$-adic cohomology.
Let $\phi_0:X_0 \rightarrow X_0$ be the geometric frobenius endomorphism; let $\phi:X \rightarrow X$ be the base change of $\phi_0$ to $\overline{k}$. which is a morphism of $\overline{k}$-schemes that is finite of degree $p$. 
From now on, suppose for concreteness that $X_0$ is a curve.
Let $F=\text{id} \times \phi:X \times X \rightarrow X \times X$. Then $F$ is finite of degree $p$. For $k \geq 1$, let $\Gamma \subset X \times X$ be the graph of the morphism $F$. Let $\Delta$ be the diagonal subvariety inside $X \times X$. We have isomorphisms
$$F^*, F_*:H^2(X \times X) \rightarrow H^2(X \times X)$$
which satisfy $F_* \circ F^* =p\text{Id}$. 
Some equalities inside $H^2(X \times X)$:


*

*$F_*([\Delta])=[\Gamma]$, because $F$ restricts to an isomorphism $\Delta \xrightarrow{\sim} \Gamma$.

*$F^*([\Gamma])=p[\Delta]$. This can be checked after applying $F_*$; use equality 1 and the formula $F_* \circ F^* =p\text{Id}$.


An intersection calculation:
Let $\cdot$ denote the intersection pairing on $H^2(X \times X)$ (with values in $\mathbb{Q}_{\ell}$). 
We have that $[\Gamma] \cdot [\Gamma]=\sum_i (-1)^i\text{Tr}((\phi \circ \phi)^*|H^i(X,\mathbb{Q}_l))$ (see reference in comments), and by a similar formula, $[\Delta] \cdot [\Delta]=\chi(X)$ (euler characteristic). Using the formulas above and the projection formula, we calculate that
$\chi(X)=F_*([\Delta] \cdot [\Delta]) = F_*(\frac{1}{p}[\Delta] \cdot F^*([\Gamma]) = \frac{1}{p}F_*([\Delta]) \cdot [\Gamma] = \frac{1}{p} [\Gamma] \cdot [\Gamma]$, 
So $\sum_i (-1)^i\text{Tr}((\phi \circ \phi)^*|H^i(X,\mathbb{Q}_l))=[\Gamma] \cdot [\Gamma]=p\chi(X)$
which is not true: the left side is the cardinality of $X_0(\mathbb{F}_{p^2})$ and certainly does not only depend on $\chi(X)$. 
 A: The calculation of $[\Gamma] \cdot [\Gamma] = p \chi(X)$ is correct, the mistake is in the formula
$$[\Gamma] \cdot [\Gamma]=\sum_i (-1)^i\text{Tr}((\phi \circ \phi)^*|H^i(X,\mathbb{Q}_l)).$$
You derive that by choosing $f = \phi$ and $C = \Gamma$ in Example 4.6 of the reference in the comments. Confusingly, they view the graph of a function $f\colon X_2 \to X_1$ as a subscheme of $X_1 \times X_2$, with the order of the factors switched compared to the usual definition of the graph. Let us denote that by $\tilde \Gamma_f$. Then Example 4.6 reads
$$[\Gamma]\cdot [\tilde\Gamma_\phi] = \mathrm{Tr}(\phi^* \circ H^*([\Gamma])).$$
Here, $H^i([\Gamma])$ is the endomorphism $(p_1)_* \circ (p_2)^*$ of $H^i(X, \mathbb{Q}_\ell)$ with $p_1$ and $p_2$ the two projections
$$X \overset{p_2}{\leftarrow} \Gamma \overset{p_1}{\to} X.$$ 
In 4.5(c) they show that $H^i([\tilde \Gamma_f]) = f^*$. Your mistake comes from identifying $\Gamma$ with $\tilde \Gamma_\phi$ and thereby $H^i([\Gamma])$ with $\phi^*$. However, $\tilde \Gamma_\phi$ is $\Gamma = \Gamma_\phi$ with the factors switched!
