We write $\mathrm{Exp}_{T,S}^{\mathrm{sim}}(v_1, \ldots, v_n, z)$ to denote the distribution of $(s, \mathrm{cont}, \mathrm{result})$ in the simulation.
The simulator $S$. $S$ runs a copy of $\mathcal{A}$ and simulates everything that $\mathcal{A}$ sees, including the behavior of the honest voters. When $\mathcal{A}$ changes phase in the protocol so does $S$. If $\mathcal{A}$ lets a corrupt voter post something on the message board, $S$ verifies the proof. If the proof is valid, $S$ uses rewinding techniques to extract the witness. It then submits the entire thing to $\mathcal{T}$. In particular, this means that the vote is submitted in plaintext to $\mathcal{T}$. If $\mathcal{A}$ activates an honest party in the key registration phase, $S$ selects $h_i$ at random and simulates the proof of knowledge of $x_i$. It submits $h_i$ and the simulated proof to $\mathcal{T}$. If $\mathcal{A}$ activates an honest voter in the voting phase, and this is not the last remaining honest voter to vote, $S$ picks $(U,V)$ at random and simulates a proof of knowledge of the corresponding $x_i, r_i, v_i$. If the activated honest voter is the last honest voter to submit a vote, then $S$ queries $\mathcal{T}$ for the partial tally of the honest voters. Knowing the witnesses for the corrupt voters' submissions it can then compute the partial tally of voters that have voted so far. Let $S$ be the set of voters that have voted, including the voter to vote right now. Let $\mathcal{T}$ be the set of remaining eligible voters; all of them are corrupt. $S$ picks $U$ at random and computes $V = U \sum_{j \in \tau} x_j g^{r_j \sum_{i \in S} v_i}$. It then simulates the proof for having computed $(U,V)$ correctly and gives it to $\mathcal{T}$. At some point the simulated $\mathcal{A}$ halts with output $s$. $S$ outputs $s$ and halts.
Lemma 1. For any adversary $\mathcal{A}$ there exists a simulator $S$ such that the distributions $\mathrm{Exp}{V_1, \dots, V_n, \mathcal{A}}^{\mathrm{real}}(v_1, \dots, v_n, z)$ and $\mathrm{Exp}{T, S}^{\mathrm{sim}}(v_1, \dots, v_n, z)$ are indistinguishable for all $v_1, \dots, v_n, z$.
Proof. We use the simulator $S$ described above. To show indistinguishability we will go through a series of intermediate experiments $\mathrm{Exp}_1, \dots, \mathrm{Exp}3$. We then show that $\mathrm{Exp}{V_1, \dots, V_n, \mathcal{A}}^{\mathrm{real}}(v_1, \dots, v_n, z) \approx \mathrm{Exp}_1(v_1, \dots, v_n, z) \approx \mathrm{Exp}_2(v_1, \dots, v_n, z) \approx \mathrm{Exp}3(v_1, \dots, v_n, z) \approx \mathrm{Exp}{T,S}^{\mathrm{sim}}(v_1, \dots, v_n, z)$.
$\mathrm{Exp}1$ works like $\mathrm{Exp}{V_1, \dots, V_n, \mathcal{A}}^{\mathrm{real}}$ except whenever $\mathcal{A}$ submits a valid input on behalf of a corrupt voter. In these cases, we use rewinding techniques to extract the corresponding witnesses in expected polynomial time. This way for each key registration from a corrupt voter we know the corresponding exponent $x_i$, and for each vote we know the vote $v_i$ as well as the randomness $r_i$ and $x_i$. Having knowledge of the witnesses, we may now run the entire protocol using the trusted party $\mathcal{T}$ from the simulation experiment to control the message board. The outputs of the two experiments are the same, so indistinguishability is obvious.
$\mathrm{Exp}_2$ works like $\mathrm{Exp}_1$ except we simulate all proofs made by honest voters. Typically, these proofs are statistical zero-knowledge and then we get statistical indistinguishability between $\mathrm{Exp}_1$ and $\mathrm{Exp}_2$.
Let us consider $\mathrm{Exp}2$ a little further. Define $g_i = g^{r_i}$ and $h{ij} = h_j^{r_i}$, where $r_i$ is the randomness used by voter $i$. Consider the voting phase, denote at a given time $S$ to be the voters that have cast votes already and $\mathcal{T}$ to be the voters that