Elections 2018

Pakistan General Elections 2018 over Blockchain

Written by Zeeshan ul Hassan ·  5 min read >

The history of elections and the charges of corruption, voters’ fraud, ghost votes, interferences by deep state, or violence go hand in hand. There is (almost) no country in the world without the fear or accusations of such incidents in elections. Whether it is Russia’s meddling in the US elections or the alleged role of Cambridge Analytica to sway voters in one way or other, 92 people getting killed in Kenya’s election or 31 in Honduras, 80 candidates in Mexico or 11 in Assam, India, 74 in Pakistan’s last elections and 174 in this election so far. Election fraud and rigging would find its roots in all the happenings.

Can blockchain solve all or some of these issues – counterfeit votes, rigging, changes in the record after the polls, physical voters’ suppression at polling booths, fifty-shades of electoral fraud and the violence during the elections? How about cost saving for this multi-billion dollar global industry?

The blockchain is being used worldwide from health care to refugees registration, from supply chain management to a sexual harassment complaint registry, from property records to humanitarian assistance, and from transferring remittances to auctioning art and antiques. It can also be used to change the way elections are being conducted throughout the world. It can increase voters’ participation, enhance security, efficiency, and transparency of ballots, reduce election violence, eliminate electoral fraud and corruption, and improve reliability, safety, affordability, and access to the system.

We can start with Pia Mancini’s Ted Talk on upgrading democracy. She has brilliantly articulated that,

“We are 21st-century citizens, dealing with 19th-century institutions, that are formed on the basis of 15th-century information technology”and what we can and should do to upgrade the system. DemocracyOS is what came out of her work and worth reading.

Let me give you a brief and most comprehensive definition of the blockchain:

“Blockchain is a peer-to-peer decentralized distributed ledger that permanently & chronologically records and guarantees an immutable, unalterable trustworthy transaction (of money or any valuable asset) in a trust-less environment through consensus protocol secured by cryptography with economically incentivized participation.”

Running #PakistanElections2018 on Blockchain is as easy as this. Election Commission of Pakistan (ECP) would issue a unit of specialized tokens to all eligible voters after due verification and enrollment. All candidates will have their own wallet. Verified voters will be able to transfer the tokens back to their chosen candidates’ addresses with transparency, security, and reliability of a public-ledger while keeping their identities anonymous. The voting token cannot be used before the voting date and time and will automatically “burn” by a smart contract when the time ends. At the end of the day, person with maximum number of tokens would win.

The concerned parties can easily observe and verify the results on public ledger without the need for lengthy legal procedures that cause instability with claims of wrongdoing. The verification process will rely on the underlying blockchain technology without central control to make it as transparent and unbiased as it can get. Anyone can verify the results and identify inconsistencies. This eliminates the possibility of electoral fraud, manipulation of results, and miscalculation & misrepresentation of tallies.

To keep the voters anonymous, the token issuing authority (say ECP or NADRA) would verify the voters through their CNIC/NICOP/Passports and issue them a private unique ID. Voters can then use that ID to vote on a public blockchain, so while anyone can confirm the real voter by his/her unique ID, no one can find out who the voter is. The issuing authority can also use a cryptography base masking algorithm, zero-knowledge proof, ring transaction, or a fancy encryption technique to generate the IDs which they cannot decode by themselves either (trying to reverse engineer and map the actual voters with submitted votes). There are few challenges though, to verify the citizen has the right to vote in a particular jurisdiction in the first place, and his eligibility to vote needs a central authority to confirm, and then the mechanism to make sure that the person who just got confirmed will be the same person at the time of voting is another nightmare.

These technical challenges can be overcome with right technical and intellectual capital, innovation and cryptography methods available today. Given the advantages of blockchain technology, we should pilot it in bi-elections and come up with a national plan to switch to blockchain based voting in the near future.

Think about the advantages such a system has to offer. It will increase transparency, when you vote now, you have no idea what happened to your vote, was it counted at all, was it counted right, there is no way to go back and confirm that. With blockchain, anyone can check their vote and how it got counted after the polls on a public ledger. It will eliminate rigging altogether as it would be impossible to cheat the cryptographic-governance of the blockchain ledger. It will be fast, as all counting and tally can happen in real-time. It will save billions of Rupees, as there will be no need for polling stations, security staff, presiding officers, no need to transport millions of people to polling stations, no traffic jams, no Biryaniand no terrorism threats for the masses. Moreover, it can increase voters’ turn-out by allowing almost everyone to vote from the comfort of their homes, offices or even outside the country. People inside Adiala jail can vote too.

All technical details and blockchain complexities can be automated and hidden under a user-friendly GUI where the user has to select the image of the party symbol or picture of his/her favorite candidate and press a button to transfer the token from his wallet to the chosen candidate’s address. It will also increase voters’ participation through mobile who don’t have to travel far for polling stations and face thuggish maneuvers to influence their choice.

Any claims raised by the opposition on validity, counting or transparency of votes can instantly be checked and confirmed by any party on public blockchain ledger in no time. ECP can publish the whole register next day in the newspapers so everyone can check if his or her vote is counted right through their unique IDs. It will save the legal costs, delays in forming the government and reduce the frustration and anxiety of indecision that usually generates after-shocks of violent national unrest.

There are several examples of blockchain based voting systems worldwide, like VoteWatcher, VoteUnits, Democracy Earth, MIT TR35 winner Jorge Garcia’s VotoSocial, Follow My Vote, Agora – the company behind Sierra Leone claimed and then debunked blockchain voting and even real-time blockchain based voting for national issues where voter has the flexibility to cast a vote or withdraw the support for a candidate or proposal even after the elections, a concept called Liquid Democracy through United Vote. There is also a patent of how to count and secure votes on the blockchain.

Free and Fair offers an open-source voting technology, Voatzhas recently made a debutto provide voting facility to on-duty veterans outside the country and Votemis the first mobile-based global voting solution. However, there are always cyber threats and drawbacks of such systems, like India’s Adhaar information found to be available online to purchase, and Pakistan’s NADRA data being sold publicly on Facebook.

One can learn how to develop such systems online. There is a course by Zastrin to build a voting application on Ethereum for free and here is a live demo of voting dApp. Here is an example smart contract in Solidity for a voting application.

Following is the basic voting smart contract (a modified version of Remixexample) to start with. See you all soon on the blockchain.

pragma solidity ^0.4.0;

contract PakistanElections {

    struct Voter {

        uint weight;

        bool voted;

        uint8 vote;

        address delegate;


    struct Candidate {

        uint voteCount;



    address ecp;

    mapping(address => Voter) voters;

    Candidate[] candidates;


    /// Create a new PakistanElections with $(_numCandidates ) different candidate.

    function PakistanElections(uint8 _numCandidates) public {

        ecp = msg.sender;

        voters[ecp].weight = 1;

        candidates.length = _numCandidates;



    /// Give $(toVoter) the right to vote on this PakistanElections.

    /// May only be called by $(ecp).

    function giveRightToVote(address toVoter) public {

        if (msg.sender != ecp || voters[toVoter].voted) return;

        voters[toVoter].weight = 1;



    /// Delegate your vote to the voter $(to).

    function delegate(address to) public {

        Voter storage sender = voters[msg.sender]; // assigns reference

        if (sender.voted) return;

        while (voters[to].delegate != address(0) && voters[to].delegate != msg.sender)

            to = voters[to].delegate;

        if (to == msg.sender) return;

        sender.voted = true;

        sender.delegate = to;

        Voter storage delegateTo = voters[to];

        if (delegateTo.voted)

            candidates[delegateTo.vote].voteCount += sender.weight;


            delegateTo.weight += sender.weight;



    /// Give a single vote to candidate $(toCandidate).

    function vote(uint8 toCandidate) public {

        Voter storage sender = voters[msg.sender];

        if (sender.voted || toCandidate >= candidates.length) return;

        sender.voted = true;

        sender.vote = toCandidate;

        candidates[toCandidate].voteCount += sender.weight;



    function winningCandidate() public constant returns (uint8 _winningCandidate) {

        uint256 winningVoteCount = 0;

        for (uint8 prop = 0; prop < candidates.length; candi++)

            if (candidates[candi].voteCount > winningVoteCount) {

                winningVoteCount = candidates[candi].voteCount;



Written by Zeeshan ul Hassan
Dr. Usmani is a Fulbright Scholar and Eisenhower Fellow. He holds a PhD and MS in Computer Science from the Florida Institute of Technology. Profile