How to create an electronic voting system on the blockchain?

    In a previous article, we talked about a data exchange system built using blockchain technology. Successful experience inspired us to create another product using this technology - the voting system. In this article we will talk about the details of the implementation of the system.

    What is blockchain in the voting system for?


    Voting, as a decision-making process on issues critical to society, has been known to mankind for thousands of years. There was a time when decisions were made by a narrow circle of authorized persons by throwing colored balls into a special amphora or by hand gesture. However, the population grew, society developed and more and more people began to take part in the decision-making process - hundreds of thousands and even millions. Then such simple methods of counting votes were replaced by more complicated ones: polling stations began to be created, amphoras were replaced by ballot boxes, and balls were replaced by ballots. Although this approach to voting made it possible to take into account the opinion of the huge masses of the population, it has several disadvantages:

    • Technical: the possibility of stuffing ballots; the use of fading ink in areas to fake results; Protocol falsification violation of the secrecy of the vote; intentional errors in the calculations; low speed of calculation of results.
    • Social: bribery ("carousels", etc.); administrative pressure on the voter.
    • Economic: high cost for the state budget. For example, the 2015 elections in Russia cost almost $ 100,000,000 .


    Some of the problems described are solved by electronic voting systems (used in countries such as India, Brazil, Estonia, the Netherlands, USA Germany), although their use also carries a number of disadvantages:

    1. Security problems (electronic systems can be hacked, often scandals are associated with this)
    2. Problems with verification of election results (as opposed to paper ballots that can be counted)
    3. The possibility of incorrect system operation due to software errors

    In this regard, electronic voting devices and electronic voting themselves have not become a worldwide practice. Moreover, many countries (the Netherlands, Great Britain, Germany), in which electronic voting was initially widespread, eventually limited their use due to imperfect technology and returned to a more reliable analog voting method.

    However, the development of technology and society is pushing humanity to look for cheaper and more reliable voting methods. The use of blockchain technology in voting can solve most of the problems of existing electoral systems.

    The blockchain technology is based on a transactional model: each user has a wallet with unique public and private keys, with which he confirms any data change. All transaction information is stored in sequentially written blocks, so the data hash of the previous block is included in the data of the next. This ensures the immutability of the data - changing any block will automatically invalidate all subsequent ones. The blockchain stores all the information about all transactions in full at the same time on all nodes, and it cannot be changed or deleted. The blockchain found the widest application precisely in the field of registering data on the movement of property rights to certain digital objects - all modern cryptocurrencies are built on this idea. Such objects, usually called “coins” or “tokens,”

    The idea of ​​using blockchain in voting systems suggests itself: blockchain allows replacing the ancient voting technology by transmitting to someone their voice expressed by a physical object (a ball of the desired color, a paper ballot, etc.), to transmit a digital token. At the same time, as in many other cases of the transition of a business process from the physical world to the digital one, transaction costs are sharply reduced and the availability of the system is increased. In addition, the use of blockchain provides additional advantages:

    1. The authenticity of the results. The results of voting organized using blockchain technologies cannot be faked. You can always check how many votes were issued at the beginning of voting, how they were distributed among wallets and at what time transactions were conducted.
    2. Process transparency. The blockchain makes it possible to control the voting process, since any interested person can deploy a node with a full copy of all the data and independently analyze it at the blockchain level.
    3. Anonymity. Each voter has the opportunity to create a pair of public and private keys on the local machine and no one except him will know that a particular wallet belongs to him. Thus, no one can know how this member voted, unless the participant himself announces that this wallet belongs to him.
    4. Data processing speed. Voting within a city, region, country, or corporation with offices in different countries can entail significant costs, organizational difficulties and time losses - both for voting and data processing. Decentralization will allow you to see the results of voting throughout the country as a whole, despite the fact that each region / city / district can operate its own system node to distribute the load.

    Before us, there were attempts to implement a voting system on the blockchain, but they did not get wide distribution. In our opinion, this has several reasons:

    1. Many of the existing projects are based on some developed platform like Ethereum or Bitcoin. Although the rate of cryptocurrencies has been very volatile lately, the same Ether has grown impressive compared to the beginning of the year, which makes voting based on this platform quite expensive.
    2. Most of these systems use the proof of work algorithm, which makes calculating the results of large-scale voting very slow (the problems described above are described in detail here :
    3. They are promoted exclusively as independent voting platforms (i.e., in order to vote or participate in it, you must go through the explicit registration process in the platform).
    4. Most of them remained at the idea level or stopped developing

    About the voting process


    Voting in our system is a transaction. Each of the options for which you can vote has its own wallet, to which the voters (each of which also has a wallet) transfer voting tokens. A unique token is issued for each vote, thus, a token issued, for example, to vote on your favorite tea, you cannot vote for the construction of a parking lot instead of a playground.

    In the final version of the application, we want to implement various types of voting: majority (the decision is made by a simple majority), alternative (several options are selected from those proposed) and rating (each option is assigned a certain “weight” depending on its preference). All of them can be open (anyone can connect) and closed (an invitation is required to participate). The areas in which such a vote can be useful can be very different: election of the head of the HOA, voting at any competition, voting for a decision within the framework of a joint-stock company, etc.

    At the prototype stage, we decided to confine ourselves to the majority scenario of voting according to an open scheme. This was done to demonstrate the capabilities of the platform, as well as to understand how this topic is interesting to the public and business.

    In the prototype, the process of creating a vote consists of several stages:

    1. The user logs in to the system and generates a key wallet pair on the local machine. The system asks the user for a code word and encrypts wallet data with it, after which it saves the encrypted wallet in the same blockchain in order to save the user from the need to install specialized wallet software. At the same time, the wallet in open form is processed only on the client side, which ensures that only its owner has access to the wallet. However, it is important to understand that if you lose the code word, the user will also lose access to the wallet, in which case it will be impossible to help him.
    2. At the prototype stage, we decided to give all registered users 10 IDV tokens designed to pay for the creation of voting in the system. With their help, any registered participant will be able to organize voting and see how the whole process works. Therefore, immediately after creating the wallet, our processing server credits 10 IDVs to the user's wallet.
    3. The cost of creating a vote in the system is 1IDV. Thus, when the user creates a vote, the system checks the balance and, if there is enough money, writes off 1 token, and prepares the vote: creates wallets for the voting options and issues a number of unique voting tokens. The results of the creation of the vote (whether it was created successfully, if not, then why) are recorded in a special log, which is also stored in the blockchain.

    When a user wants to vote, the following occurs:

    1. He selects the vote he needs from the general list and requests permission to participate in it.
    2. The system checks whether the user can take part in the vote and, if so, charges him a unique token of this vote.
    3. The user votes for one of the proposed options, after which the system will check whether the user can vote and, if so, the voting token is transferred from his wallet to the wallet of the selected voting option.

    Checking the voting results is possible in several ways. Firstly, in the profile of each participant there is an option “My Transactions”, where you can see all transactions, starting with creating a wallet. Secondly, in the voting list, you can go to the specific voting screen and in the voting details find the transaction from your wallet to the wallet of the selected option. Thirdly, there is always the opportunity to deploy a Read only node and check the accounting of results and the operation of the system at the blockchain level.

    A bit about selected technologies


    Before telling about the technological component of the project, we note the following: the main task of the project is to provide convenient means for embedding reliable votes on the blockchain platform in any third-party application. That is why we pay special attention to the development of a convenient API. Of course, we will provide our own customers for voting, but we are developing them primarily to demonstrate the capabilities of our voting platform. Below we consider the technological side of the project.
    As in previous projects, we took the Mulitchain blockchain as a basis. We proceeded from the following considerations:

    1. Security.One of the vulnerabilities of most blockchain systems lies in its own advantage - anonymity. When anyone can expand any number of writing nodes, there is a risk that he will expand 51% of the total number of nodes with changed information and the rest of the nodes will accept it for writing, since it will be followed by the longest chain of blocks. This is called a 51 percent attack. To prevent such attacks, most public algorithms use the Proof of Work confirmation algorithm - each node solves a complex mathematical problem, for which it receives a certain reward (“mine coins”). The solution of the problem requires time and considerable computing power. This makes this kind of attack too expensive and impractical. The main feature of Multichain is that it is specially created to organize a blockchain on the principle of a consortium, i.e. for a limited circle of people who know each other, i.e. not anonymous. In our implementation, all nodes connecting to the blockchain are Read only nodes by default. That is, they store all the data, but they do not have the right to write new data. To obtain a write permission, the node must obtain the corresponding rights from the Master node. Thus, we will ensure that new data is written to the system only by authenticated nodes and reduce the risks of fraud. At the same time, Read only nodes receive a full copy of all blockchain data and can independently analyze the voting data for consistency. To obtain a write permission, the node must obtain the corresponding rights from the Master node. Thus, we will ensure that new data is written to the system only by authenticated nodes and reduce the risks of fraud. At the same time, Read only nodes receive a full copy of all blockchain data and can independently analyze the voting data for consistency. To obtain a write permission, the node must obtain the corresponding rights from the Master node. Thus, we will ensure that new data is written to the system only by authenticated nodes and reduce the risks of fraud. At the same time, Read only nodes receive a full copy of all blockchain data and can independently analyze the voting data for consistency.
    2. Resource intensity. As noted above, when applying the Proof of Work algorithm, significant computational, and with an increase in the number of users, temporary resources are also required. To solve this problem, we abandon the Proof of Work algorithm in favor of the Proof of Authority, in this case we give the right to record information only to nodes that have identified themselves. Thus, new information falls into the blockchain much faster and the “recording price” becomes minimal.
    3. Experience. We have experience in using this blockchain platform in past projects, and we well know how to solve the arising difficulties.

    Let's look at the technical part in more detail. The voting block diagram is as follows:

    The system structure is divided into 3 segments:

    UI - end-user applications that connect to the public REST API (Common Area segment) or directly to the reading node of the warhead (not shown in the diagram). In the prototype, to demonstrate the functionality, we implemented a UI website as a SPA on Angular. Anyone can implement their UI on any available technology using our REST API or Read only Multichain node as a data source.

    Common Area - these are N nodes of the system on which Multichain in recording mode and a Web server with an API for shared access are deployed.

    REST API web site written in ASP.NET Core 1.1. Implemented work with voting metadata, a metadata archive, the voting process itself (selecting an option and casting a vote for it), as well as a user's wallet. A detailed description of the API can be found here .

    Private Area - a part of the system that is closed for general access (recording), which includes a processing server and a user authorization server.
    In the proprietary part, we took out a processing server and a user authorization server:

    Processing Server

    Implemented as well as the Common REST API on APS.NET Core 1.1. In the prototype is responsible for:
    • Calculation of IDV tokens during user registration (to pay for created polls)
    • Create Voting
    • Management of the voting status (opening and closing according to specified conditions)
    • Accrual of voting tokens to the user.

    All actions performed by the processing server are recorded in Multichain. Therefore, any node (including the reader) can see these actions.

    Identity Server

    Server identifying users of the system. Implemented on ASP.NET Core 1.1 using the IdentityServer 4 component .

    Functional:

    • User registration;
    • User Authentication
    • User authorization;

    User profiles are also stored in Multichain in encrypted form.

    Prototype Limitations


    Our system is designed to conduct polls and polls of various types. However, to demonstrate the capabilities of the prototype, we decided to confine ourselves to the scenario of a simple majority vote with an open list of participants, i.e. anyone can join such a vote. Therefore, in this article we will not consider scenarios of inviting people to participate in private voting, rating and alternative voting. Also in the prototype, we did not implement strict identification mechanisms. This was done deliberately, so that anyone could try them on their own.

    Prototype


    You can see the prototype and try out the creation of voting here . If you want to deploy Read only node - contact us through the form on the site - we will send you instructions on how to do this.

    Also popular now: