Source code of the Estonian online voting system

(github.com)

95 points | by theanonymousone 17 hours ago

7 comments

  • cryptonector 1 hour ago
    Fully software, even a combo of software and hardware, cannot by itself make elections secure. Think of the Reflections On Trusting Trust problem, the need to verify firmware, etc. You can't ensure that machines _will_ work correctly, but you _can_ verify that they _did_. To do verify the machines' functioning after the fact you have to do it very soon after closing of the polls, and you have to devise a manual, statistical random sampling method where you manually check randomly sampled, marked paper ballots, against the digital cast vote record, then do a digital risk limiting audit to check that the CVR totals up to the machines' reported results. The sooner after closing of the polls you do this, the better the likelihood that any cheating will be caught. I.e., an immediate manual, partial audit of enough randomly-selected polling locations.

    That still leaves tons of other technical problems to address, like security of mail-ballots / absentee ballots, the security of ballot boxes used for early voting (because you probably cannot run the above manual partial audit due to then having nightly results available to the public; or maybe you accept that), voter registration, etc.

    • himata4113 1 hour ago
      You solve all of these with cryptography.

      Your ID card contains a private key, you use that key to sign a transaction. It doesn't matter that machine you are running on is compromised as these details can be verified at a later date.

      Example A: You vote for candidate A, but software changes to candidate B and software displays that you voted for candidate A. At any later time you can check with an independent device and look at the transaction finding out that it was altered with and retract your vote / change it.

      Example B: How do you know your vote was counted? Publish a hash and the signature of every vote, recompute the final tally and compare with all the votes. If your vote is not in the final tally the hash will be different and you can visibly see your vote in the dataset as every transaction is published. To preserve privacy each round has a number, private key + number -> new key so each fingerprint will be unique between votes.

      • cryptonector 1 hour ago
        > You solve all of these with cryptography.

        I've spent a lot of time thinking about this problem, and my conclusion is that cryptography alone is not the solution, for reasons like:

        1. The public needs to believe it, and hypertechnical solutions are a hard sell.

        2. Any blockchain approach needs to preserve the secrecy of the ballot, otherwise you get all the problems you can expect of non-secret votes (coercion, vote buying, shaming network effects).

        3. You still need to have the cryptographic rubber meet the physical road _somewehere_ -- it has to, otherwise the need for vote secrecy means that the results can be entirely fictitious and pre-programmed and there is no way to check!

        I.e., you can have a paperless blockchain solution IFF you abandon vote secrecy. That is a very tough to swallow pill.

        On the other hand, if you accept paper ballots and manual partial audits as part of the solution, then blockchain can have a role to play. For example, the machines could display a blockchain head every 50 ballots cast, and voters take a copy of the blockchain head visible to them, then after the election the public can verify the integrity of the blockchain, and the fact that you only get running tallies every 50 ballots means you get vote secrecy.

        A system that uses paper ballots and partial manual audits can be explained to the public, and the public can develop confidence in it. Blockchains can then add a good deal of confidence: the blockchain tells you that the tallies were not modified after the fact, and the partial manual audit tells you to an acceptable level of statistical confidence that the digital cast vote record contains the actual paper ballots _as marked and cast_ by voters.

        • sigmoid10 52 minutes ago
          >I.e., you can have a paperless blockchain solution IFF you abandon vote secrecy. That is a very tough to swallow pill.

          This is false. I know this is a common thought here on HN because some formerly popular youtuber did a video about this that was regularly reposted here, but he was wrong in theory back then and it is wrong in practice today. Secrecy and anonymity and verifiability are no longer mutually exclusive as anyone who is well versed in modern cryptography will be able to tell you.

          • cryptonector 51 minutes ago
            I'd appreciate some references. That's not because I'm trying to put you down with a request for references, but clearly you have seen them, and I'd like to see them.

            Also, you still have to convince the public.

        • mariofdistrust 39 minutes ago
          the issue isn't that people won't believe it or that blockchain can't preserve secrecy of ballots (it can). it is, in part, that crypto eventually has to meet the real world, but mainly that crypto is hard and governments might not be up to the task. for example, last year the IACR (which had been doing online voting via crypto for more than a decade, and still is) had to void their elections because one of the trustees lost their private key and the results were impossible to decrypt. while it was ultimately fine because the IACR isn't really a high-stakes operation, how would you feel if your government just said "sorry folks, there's been some technical issues and elections will have to be redone"? would you believe them or suspect they're up to no good? what if this happens in a very contended and heated election?
        • varispeed 21 minutes ago
          > The public needs to believe it, and hypertechnical solutions are a hard sell.

          Public doesn't need to know the details. Production of paper, printers is quite complex and so production of the pen. Yet people are not concerned about that when voting and we don't publish schematics of a printer that printed the ballots.

      • matheusmoreira 22 minutes ago
        > software displays that you voted for candidate

        This enables coercion of voters. It must be impossible to attribute any vote to any specific person.

        • himata4113 4 minutes ago
          this is out of context, nobody would see who they have voted for in practice
      • emil-lp 30 minutes ago
        A major problem is that if you are able to verify who you vote for, you can either sell your vote or be coerced (by, say, your abusive husband) to vote a specific way.
        • rustyhancock 14 minutes ago
          We have the solution it's just not practicable. Cryptocurrencies and hardware wallets have solved this problem. But they operate at the scale of people in their bedrooms not hundreds of millions of people voting over one day all over a country.

          Passports would need to become like hardware wallets with screens such as Trezor. Who's firmware and design are open source.

          The screen means I can see what I'm signing and later be shown what I signed.

          Now, I don't want people to know who I vote for. So we make it e-passport gate so that no one can enter with me.

          Now I want to be able to verify my vote at a later date but not let others know it was me. Well this too is solved by multiple cryptocurrencies like monero and z-cash.

          I can go to my local town hall enter a room alone using a e-passport style gate and check my vote at the machine. My device can verify my vote.

          Someone with the vote can only see that 1 of N voters did it. Where N is so large they can't identify me.

          No duplicate vote is possible.

          Literally no one would agree to this however.

          • cryptonector 8 minutes ago
            Cryptocurrencies mostly are pseudonymous, and, really, not even that. Certainly bitcoin is at best pseudonymous.
        • spiddy 24 minutes ago
          retraction of vote with a new vote solves this.

          Since I'm able to retract my vote, I cannot sell it. And since I can retract my vote, I cannot be coerced in any way.

          • cryptonector 6 minutes ago
            Elections results have to be final at some point, and after that point no further retraction/changes can be made, therefore you can be coerced.
        • resist_futility 17 minutes ago
          You could have verification be done in person and not online with no way to share it.
          • cryptonector 6 minutes ago
            You'd have to go to your elections authority's location, and very few could do it w/o overwhelming the vote verification rate capacity, and very few would.
      • patrickmay 49 minutes ago
        Relevant xkcd: https://xkcd.com/2030https://xkcd.com/2030

        There is no problem that electronic voting solves that paper ballots and scanners do not, and the latter are not only more secure but are seen to be more secure. Trust is essential in a voting system and only paper ballots provide the necessary level of trust.

        • sam1714 30 minutes ago
          There are problems that electronic voting does solve: in some countries, moving paper ballots are problematic and subject to tampering. This shows up in mail-in voting, where there's always a risk of loss and delay. Overseas voters are an issue, e.g. deployed military.

          There is a specific problem with mail-in voting and disabled voters, for example elderly people who can't go to the polls and can't get an electronic ballot marker. 25 US states deliver ballots electronically and 15 allow electronic voting for this specific case [1].

          [1] https://www.ncsl.org/elections-and-campaigns/electronic-ball...

      • mmooss 1 hour ago
        Who makes your ID card, generates the private key, and stores it there? Do you trust them? Did they retain a copy of the key? Did they implement security effectively (a very difficult task, considering the resources of attackers)? What about securing the manufacturing process?

        In the end, you always must trust humans.

        • vincnetas 50 minutes ago
          So if someone else knows my private key and voted for me not the same way i intended to vote, this will be visible in final results. And then you can start asking questions. If they have my private key and voted the way i intended, then its no problem :)
          • drdexebtjl 31 minutes ago
            Why would others trust you to be telling the truth and not just lying to attempt to cause mistrust in the election?

            Naive solutions have naive problems.

            • thfuran 12 minutes ago
              I’m not sure what you’re trying to say. That the “solution” to that is just to ignore both votes in the case of multiple votes per id?
        • cryptonector 1 hour ago
          Indeed. The rubber hose always beats cryptography. Always.
      • thaumasiotes 57 minutes ago
        > Example A: You vote for candidate A, but software changes to candidate B and software displays that you voted for candidate A. At any later time you can check with an independent device and look at the transaction finding out that it was altered with and retract your vote / change it.

        This seems to make a pretty dramatic change to the election protocol, no?

        Consider example A': You vote for candidate A, but later realize that you hate candidate A. You repudiate your recorded vote for candidate A.

        What should happen?

        • devin 45 minutes ago
          How much later? Cryptographic systems certainly have methods for allowing revoting up to a deadline, but endlessly mutable voting is insane. It's also not really any different from today. I can say I didn't vote for candidate A 12 months after the upcoming election and it means... well... nothing.
        • sam1714 44 minutes ago
          You can do A' in some US states... you can vote by mail/early vote, and then later request they spoil that ballot and do it again, or by voting on election day the mail-in is invalidated.
          • grg0 16 minutes ago
            The US voting system is probably not a good starting point for modeling such systems :)
    • bel8 23 minutes ago
      But Brazilian gov says their electronic election system is unhackable... Yeah.

      Only a selected few orgs and groups are allowed to audit and in a very controlled environment because they also rely on security through obscurity. The source code is not available to the citizens.

      If by any chance I'm wrong and someone can point me a source code repo, please enlighten me.

      https://international.tse.jus.br/en/electronic-ballot-box/pr...

      • matheusmoreira 19 minutes ago
        One would think they'd have the balls to put up a billion dollar bounty.
        • bel8 18 minutes ago
          That would require at least access to the ballots, which citizens don't have.

          Not even a remote access to a demo ballot machine.

          • matheusmoreira 6 minutes ago
            Yeah. The audits are a joke. In the end it amounts to nothing but an idiotic judge-god-king proudly declaring that the machines are UNQUESTIONABLE.

            Our congress has determined that a paper trail must be implemented but the judges aren't having it.

            https://news.ycombinator.com/item?id=36543423

            Source code is a red herring too. If there's no reproducible builds that cryptographically establish source-executable correspondence, showing us the source code would prove nothing and only serve to embarrass us. Supply chain attacks could compromise it without any source code vulnerability. What they need to do is publish the signed executables that ran on election day as well as every executable used to construct those artifacts. Our AIs will make short work of the binaries.

            In any case, the prevailing theory is that the mesários are partidarian and simply impersonate people who didn't show up to vote in order to boost their candidate's numbers. Very low tech, can be fixed with surveillance: have people from all parties everywhere observing everything. It boggles my mind that this isn't being done already.

    • atoav 47 minutes ago
      While these all are problems, the REAL problem is that the goal of elections isn't to get scientifically or mathematically verifiably correct results. The goal is to produce agreeable consent.

      That means it doesn't matter one bit how correct you are if the regular Joe does believe you tricked. Adding computers into the mix always makes this worse. And again, this is not something you can fix with clever solutions and cryptography (that admittedly fascinates me nonetheless), the problem is that people can't see electricity generally and I something at the scale of a computer, even if you could it would be utterly meaningless.

      This is why the paper ballot system is so glorious in its stupid inefficiency, because it spreads the trust in a way any adult who has mastered object permanence can verify for themselves. Invite the conflicting parties to monitor and have them begrudgingly admit their defeat in the face of the simple, inefficient but agreeable process.

      This is why I as a cryptography fan, programmer and hardware guy think electronic voting is not up to the task for high stakes elections.

    • caaqil 1 hour ago
      > Think of the On Trusting Trust problem, the need to verify firmware, etc.

      I mean that's too abstract and philosophical of a problem when talking about voting machines/software: there are much more prevalent and concrete risks including but not limited to APT-grade breach/espionage if your country is important enough, and the various other issues (some in your comment itself).

      • cryptonector 1 hour ago
        Yes, of course. See my reply to sibling comment about why a software solution is insufficient, even a soft/hardware solution is insufficient. Cryptography does not save the day. A modicum of physically auditable paper trail is required.
  • devin 54 minutes ago
    There are a lot of folks who, whenever this topic comes up, seem to have no knowledge of the systems which already exist and have actually been used in real elections already. For instance, ElectionGuard has been used in several real elections in the US since 2020[1].

    [1]: https://electionguard.vote/

    • dietr1ch 45 minutes ago
      Used in the real world doesn't mean it's secure.

      There's issues that are pretty fundamental with the black-box approach that the electronic ballot becomes. Paper and transparent ballots can be scrutinized pretty easily, but once you have a black box that might also be connected to the internet there's nothing you can really trust.

      • devin 31 minutes ago
        [dead]
  • samat 1 hour ago
    Interesting that there are no updates for almost a year. Cool stable software, I guess?
    • jeff_vader 1 hour ago
      Explanation is in the README:

      > The intention behind this repository is to make source code of the Estonian online voting system available for public review.

      > The repository is not used for active development, but will be kept up to date, so the code that can be found here is the code that is used for election.

    • piiritaja 1 hour ago
      from README

      The repository is not used for active development, but will be kept up to date, so the code that can be found here is the code that is used for election. As the voting system used for legally binding elections must strictly follow the legislation, the actual development of Estonian I-voting system and I-vote verification application is supervised by State Electoral Office of Estonia. Please refer to www.valimised.ee for further information.

      • cryptonector 49 minutes ago
        But updates are promised, so GP's question is valid: where are they, and since they're not there, why? Is this the final product's source code and it has not been modified since?
        • Karliss 7 minutes ago
          Parliament elections in Estonia happen once every 4 years so don't expect frequent updates. Next one should be in 2027 so there are still ~5 months for them to publish next update. There was also a municipal election in 2025 and European parliament in 2024 which matches last 3 updates in git history. No elections in 2026 so no updates this year.
        • AntiqueFig 33 minutes ago
          If I understood correctly they make updates elsewhere, then update this repository only when elections happen, thus making the repository in the exact state it was used for that election.
  • phtrivier 1 hour ago
    I know the answer is "you don't", but suppose I vote vote electronically for candidate A. In the end, the candidate loses with 764 votes. How do I convince myself that my vote was counted in the 764 votes, and that it was not a randomly chosen number (with a RNG skewed around "plausible" scores) ?
    • franga2000 1 hour ago
      To take it one step further: how does the election authority convince everyone that their vote was counted?

      Us "computer folks" convincing ourselves is the easy part. Maybe after enough studying of the system, I'd be absolutely sure that my vote was counted, but what would the other 90 % of the population think? This not a "people are stupid" argument, a brain surgeon or nuclear physicist or philosopher isn't going to put in the effort to understand fully homomorphic cryptography, hardware-based security, etc. Why should they?

      The alternative works perfectly fine and it's so easy to explain. It's obvious to anyone, no matter their level or field of education, how their vote makes it from their hand into the tally, what prevents it from being misused and what they can do to further reduce that already tiny probability.

      You can see, feel and experience the technical measures keeping your vote safe. The people keeping their eyes on the ballot box alp day may literally be your neighbours, as are the people counting. You can reason about their motivations, you can theorise in your head about what lengths you'd have to go to in order to change even a few votes and how unlikely you would be to succeed.

      The biggest danger to elections, ultimately, isn't the risk of cheating. It's the risk of losing the people's trust.

      (I'm in the local election commission (that's layer 2 out of 4 in our particular election management hierarcy), we just had a big referendum, everyone keeps asking me about online elections so this rant was fresh on my mind)

    • Groxx 1 hour ago
      In this system: I have no idea.

      In any system, I suspect it is possible. There are strategies that allow doing private set intersections (or similar): https://en.wikipedia.org/wiki/Private_set_intersection (i.e. a set with one member is "you", and you can check to see if you're in that 764, without knowing who the others are)

      I'm not sure what strategies would also allow you to not reveal to the vote collectors where your vote went, but there might be something.

      • cryptonector 58 minutes ago
        From that wiki:

        > Private set intersection is a secure multiparty computation cryptographic technique[1] that allows two parties holding sets to compare encrypted versions of these sets in order to compute the intersection. In this scenario, neither party reveals anything to the counterparty except for the elements in the intersection.

        Revealing even elements in the intersection, if that means revealing individual votes, breaks ballot secrecy.

        • phtrivier 26 minutes ago
          Exactly, it means someone you could prove to someone else how you voted, which is the sine qua non condition for creating a vote economy. That's actually the main reason behind trying to keep the vote secret, much more than threats of intimidation for opposing parties voters, etc...
    • segmondy 1 hour ago
      I think this is an easy enough problem to solve, the issue is that someone else can how force you to reveal who you voted for. Spouse, rouge employers, mafia, corrupt politicians. You can now "sell" your vote.

      I think such a system could still work, but just like the voter has to go to the booth alone to vote, they must go the booth alone to verify.

    • aramend 52 minutes ago
      There is a separate verification tool I've used that lets me confirm who I voted for, and that the server has registered my vote. Also, like in elections in other places, every election has observers take part. OSCE regularly send their lot, their report on the last parliamentary election can be read here https://odihr.osce.org/odihr/elections/estonia/551179.
      • phtrivier 24 minutes ago
        So there is a tool that remembers who you voted for. That's great to convince your bully that you actually did what they told you.

        However, how do you know you're one of the X votes displayed in the final tally ?

    • vincnetas 1 hour ago
      Most likely similarly how you know in regular "paper" elections
      • phtrivier 14 minutes ago
        I've been an overseer at election booths several times. I kept a good look at the transparent ballot box, along with complete strangers. In the end, once, I may even have inadvertently recognized my envelope and bulletin during the opening and counting - because we where very very few people to choose that candidate in my polling station :D And I was lucky enough to follow the president of the polling station to the town hall where armies of public servant where doing the addition, and I checked the CSV on next Monday, etc, etc...
      • mmooss 1 hour ago
        In theory, it's much easier to fake a number stored electronically in a computer than a large number of paper ballots.
        • cryptonector 56 minutes ago
          In practice too. Elections are worth up to trillions of dollars. That means that agencies like state-level actors, and private actors with the necessary resources, will be tempted to mount supply chain and other attacks, and likely will succeed.

          Faking paper ballots is totally doable, but you can take various precautions to make that very difficult. For example, you can deliver ballots to polling locations in sequentially-numbered packs and shuffle them at the voter sign-in desk: by shuffling the packs before delivery, by having the elections judges record which packs they got and which numbers went unused, by making them sign ballots prior to placing them on the sign-in table, and so on, you can make it very difficult for elections administration staff to later replace those paper ballots. But you're going to need timely, partial or full hand-count audits in order to make it necessary to replace paper ballots in order to replace results.

          Election security is pretty expensive, but compared to the _value_ of elections, it's nothing.

    • juhanima 1 hour ago
      You convince yourself the way you do with any elections: you trust the people/system that counts the votes. If you think about it for a second, the requirements of a secret ballot (meaning it's not possible to know who voted who) and the fully verifiability you are asking for are mutually exclusive. You can have either one but not both at the same time.

      That being said I think the Estonian voting system does a decent job of being trustworthy. Publishing the source code is a big step to the better as well. As far as I knew the system was written in Java but seems like they have upgraded it in Go. Good job! Probably the best in the world.

      • dataflow 44 minutes ago
        > If you think about it for a second, the requirements of a secret ballot (meaning it's not possible to know who voted who) and the fully verifiability you are asking for are mutually exclusive.

        I might be missing something obvious but I'm not quite seeing the logical inconsistency between their two goals. Note they're only asking to verify their own vote, not to verify every other person's vote. For that, isn't it enough for authorities to announce a product of large primes, letting each person verify that their own prime was in the set? At each stage, the machines only report the product of primes up the chain, not the individual ones.

        It seems to me the difficulty is with the fact that we have so many places to hide malicious things with modern technology (tiny electronics, firmware, etc.), not a logical incompatibility between the goals. If you had some sort of abacus that did all this mechanically without reprogrammability... or a large computer whose logic was fully verifiable... then everyone could inspect the machine and verify that it behaves correctly prior to elections, and e.g. a camera/observers/etc. can ensure no tampering occurred with the machine until the tallies were conducted.

      • cryptonector 1 hour ago
        All the source code in the world means nothing when it comes to elections. It's the object code, down to firmwares, BMCs/MEs, even microcode that matters. It's hard to establish trust in those things.
        • juhanima 54 minutes ago
          I wouldn't say it means nothing, but you are right in that it is not a silver bullet. It is one piece of a chain of custody to build the trust. Having source code is better than not having it. Having verifiable builds is better than not having them. Having trustworthy hardware is better than not having it. You get the gist?
          • cryptonector 43 minutes ago
            I'd rather have a paper-based system, with machines to do the hard labor of counting, and timely partial manual audits. Then I don't have to inspect any source code.

            BTW, the source code we're talking about could easily be enormous, especially if you want the machines' firmware to be open too. Reviewing that source code would be a huge task. And you still have the problem of being unable to validate that the actual object code run in production corresponds to the source code you reviewed. And the public won't believe any of it anyway.

            • juhanima 33 minutes ago
              Preferring a paper-based system is your prerogative, that goes without saying. For what it's worth, I'm also partial to the manual system for its robustness.

              However, the Estonian governement has made a different choice and I salute that they are at least trying to do everything by the book and in the right way. Publishing the source code is a part of that. Estonia is a high-trust society (which is an incredible achievement in itself, considering they were a province of the Soviet Union only forty years ago) and they have the most functional e-identity system in the World. Voting is just a part of it. It does make many things easier and also helps economy if you can trust - and verify - your fellow man.

      • phtrivier 19 minutes ago
        Nope. Vote tallying is public with random overseers, in transparent boxes watched by a room of people from diverse opinions, with random inspections - precisely because we DO NOT trust the system or the people who count the vote.

        Which has always been my biggest beef about digital vote. I'm all trusting the people writing voting software to do their best, actually. Being a Software engineer myself, I'm more concerned about bugs and hacks than deliberate tampering by the government. Especially in an age where AI agents can access pretty much anything ever connected to an electric plug...

    • maccard 1 hour ago
      How do you convince yourself of this in a regular election?
      • InsideOutSanta 1 hour ago
        In a paper election, you have a chain of people who supervise each other. Depending on where you live, you can volunteer to be part of that and see it for yourself.

        In code, you have no insight into what actually happens.

        • himata4113 1 hour ago
          Let's say you encounter a mob society that is convinced that there is a very high risk of election fraud and will apply unnecessary scrutiny to votes, a little rip in the paper or ink not matching standards.

          trivia: did you know that a tear in any of the pages of your passport renders it invalid?

        • piiritaja 1 hour ago
          Believe it or not there is a chain of people who supervise each other for this e-voting system as well. Anyone can volunteer to be part of it as well.
          • InsideOutSanta 15 minutes ago
            How can I volunteer to see the bits in a voting machine's RAM?
          • cryptonector 45 minutes ago
            Logic tests only show that the machines worked correctly as of the logic test. It's easy enough to design them to behave correctly in all cases except actual elections.
  • pelagicAustral 53 minutes ago
    The answer is paper backed by an ID, but i guess is too late for that.