A lot of really clever people have thought about this problem, including Prof. Rivest (the "R" in RSA) https://people.csail.mit.edu/rivest/Rivest-ElectronicVoting....
It also leaves me wondering, is there really no good way to secure voting machines?