Estonian e-voting, vote verification system

I believe I do understand the basics of how the Estonian e-voting system works, but I'm stuck at their vote verification system. In order to get the vote verified, a client needs to encrypt all of the possible vote selections plus some random string with an election public key and then compare the given results with the voter's actual vote in order to find a match.

Here is where I got stuck. I've learned that RSA public encryption doesn't always put out the same result because of padding, so how is it possible that the client produces the same result as the one on the server?

I'm a complete beginner regarding cryptography and would therefore appreciate answers given in as basic a manner as possible. Since I'm a beginner, I'm not really interested in the details of how they implemented it, but in how I could somehow reproduce this in my very much simplified PHP project using OpenSSL.

Let's say there are 3 candidates: Mike Miller, John Smith and Nick Stone. The voter chooses John Smith.

$$public_key='--- election public key ----';$$vote='John Smith';
openssl_public_encrypt($$vote,$$encrypted_vote, $$public_key); Lets say$$encrypted_vote gets stored in a database.


Vote verification:

$$actual_encrypted_vote; //users actual vote retrieved from database$$candidates= array("Mike Miller", "John Smith", "Nick Stone");
$$public_key='--- election public key ----';$$selected_candidate="";
foreach($$candidates as$$candidate){
openssl_public_encrypt($$candidate,$$encrypted_vote, $$public_key); if($$encrypted_vote == $$actual_encrypted_vote)$$selected_candidate=$$candidate; } echo "You voted for: ".$$selected_candidate;


This obviously doesn't work, since RSA encryption, because of padding, always produces different results for the same key and data. So what should I do to get this to work?

Is it possible to set specific padding and use it for both encryptions, or is there another way?

• I don't know anything about the Estonia e-voting mechanism. But it can't work the way you describe: that allows anyone to find out how each voter voted. Many e-voting systems allow anyone to verify whether a voter voted, and allow the voter to verify that their choice was recorded correctly, but they do preserve voter secrecy. RSA encryption uses random padding precisely to avoid anyone finding out the encrypted message by guessing and matching. – Gilles 'SO- stop being evil' Aug 10 '17 at 12:07
• Please post a link to you source of information. Also see Security Analysis of the Estonian Internet Voting System for more information. – zaph Aug 10 '17 at 12:47