📜 ⬆️ ⬇️

How to create an electronic voting system on the blockchain?

In the last article, we talked about the data exchange system built using blockchain technology. The 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 the blockchain for in the voting system?


Voting, as a decision-making process on major issues for 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 became involved in the decision-making process - hundreds of thousands and even millions. Then these simple methods of counting votes were replaced by more complex ones: polling stations began to be created, amphoras were replaced with ballot boxes, and balloons with ballot papers. Although this approach to voting made it possible to take into account the opinion of huge masses of the population, it has several drawbacks:



Some of the problems described are solved by electronic voting systems (used in countries such as India, Brazil, Estonia, the Netherlands, the USA, Germany), although their use also carries a number of drawbacks:
')
  1. Security issues (electronic systems can be hacked, often scandals are associated with this)
  2. Problems with the verification of election results (as opposed to paper ballots that can be counted)
  3. The possibility of incorrect operation of the system due to software errors

In this regard, electronic voting devices and electronic voting itself did not become a global practice. Moreover, many countries (the Netherlands, Great Britain, Germany), in which e-voting was initially widespread, ultimately limited their use due to the imperfection of the technology and returned to a more reliable analog method of voting.

Nevertheless, the development of technology and society is pushing humanity to search for cheaper and more reliable methods of voting. 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 successively written blocks, so the data hash of the previous block is included in the next. This ensures the immutability of data - changing any block will automatically invalidate all subsequent ones. The blockchain stores all information about all transactions in full simultaneously on all nodes, and it cannot be changed or deleted. The blockchain has found the widest application in the field of registration of 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”, can either be created automatically, according to a predetermined algorithm, during the operation of the system (“mined”) or produced by a system participant who has the right to do so.

The idea of ​​using the blockchain in voting systems suggests itself: the blockchain allows you to replace the old voting technology by passing someone your voice, expressed by a physical object (a ball of the desired color, paper bulletin, etc.), to transfer a digital token. At the same time, as in many other cases of the transition of the business process from the physical to the digital world, transaction costs are sharply reduced and the availability of the system increases. In addition, the use of the blockchain provides additional benefits:

  1. The validity of the results. The results of voting, organized with the use of blockchain technology, can not be faked. You can always check how many votes were issued at the beginning of a vote, how they were distributed to wallets and at what time the transactions were conducted.
  2. Transparency process. The blockchain gives you the opportunity to control the voting process, since any interested person can deploy a node with a full copy of all the data and independently analyze them at the blockchain level.
  3. Anonymity. Each participant 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, except for the case when the member himself declares that the wallet belongs to him.
  4. The speed of data processing. Voting within a city, region, country or corporation with offices in different countries can be associated with significant costs, organizational difficulties and temporary losses - both for voting and data processing. Decentralization will allow 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 for load distribution.

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

  1. Many of the existing projects are based on a developed platform like Ethereum or Bitcoin. Although lately the course of cryptocurrency is very volatile, the same Ether has grown impressively since the beginning of the year, which makes voting based on this platform rather expensive.
  2. Most of these systems use the proof of work algorithm, which makes the calculation of results for large-scale voting very slow (the problems described above are described in detail here :
  3. They are promoted solely as stand-alone voting platforms (i.e., you must go through an explicit process of registering with the platform for voting or participation in it).
  4. Most of them remained at the level of the idea or ceased to develop.

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 participants (each of which also has a wallet), transfer voting tokens. For each vote, a unique token is issued, so a token issued, for example, to vote about your favorite tea, cannot be voted to build a parking lot instead of a playground.

In the final version of the application, we want to implement various types of voting: majority voting (decision made by simple majority), alternative (several options are selected from the 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 for participation). The areas in which such a vote can be useful can be very different: the election of the head of the HOA, voting in any competition, voting for a decision within a joint stock company, etc.

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

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

  1. The user is registered in the system and generates a key wallet pair on the local machine. The system asks the user for a code word and encrypts the wallet data with it, and then saves the encrypted wallet to the same blockchain in order to save the user from having to install specialized wallet software. At the same time, the wallet in the open form is processed only on the client side, which guarantees that only its owner has access to the wallet. However, it is important to understand that when a code word is lost, the user will lose access to the wallet, in which case it will be impossible to help him.
  2. At the prototype stage, we decided to issue 10 IDV tokens to all registered users, intended to pay for the creation of a vote in the system. With their help, any registered member will be able to organize a vote and see how the whole process works. Therefore, immediately after the creation of the wallet, our processing server charges 10 IDVs to the user's wallet.
  3. The cost of creating a vote in the system is 1IDV. Thus, when a 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 voting options and emits a number of unique voting tokens. The results of the creation of a vote (whether it was created successfully, if not, why) were recorded in a special log, which is also stored in the blockchain.

When a user wants to vote, the following happens:

  1. He chooses the right vote for him 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 with a unique token of this vote.
  3. The user votes for one of the proposed options, after which the system checks whether the user can vote and, if so, the voting token is transferred from his wallet to the wallet of the selected voting option.

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

A little about selected technologies


Before we talk about the technological component of the project, we note the following: the main objective of the project is to provide convenient means for embedding reliable votes on the blockchain platform into any third-party application. That is why we pay special attention to developing a convenient API. Of course, we will provide our own clients 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 dignity - anonymity. When anyone can deploy any number of writing nodes, there is a risk that he will deploy 51% of the total number of nodes with modified information and other nodes will accept it for writing, since the longest chain of blocks will be behind it. This is called a 51 percent attack. In order to prevent such attacks, the majority of public algorithms use the Proof of Work confirmation algorithm - each node solves a complex mathematical problem, for which it receives a certain reward (“mine coin”). The solution of the problem requires time and significant computing power. This makes this kind of attack too expensive and impractical. The main feature of Multichain is that it is specially created for organizing 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, by default, Read only nodes. That is, they store all the data, but do not have the right to record new data. To obtain the right to write the node must obtain the appropriate rights from the Master node. Thus, we will ensure the recording of new data into the system only by authenticated nodes and reduce the risks of fraud. At the same time, the Read only nodes receive a complete copy of all blockchain data and can independently analyze the data on consistency polls.
  2. Resource intensity. As noted above, when applying the Proof of Work algorithm, significant computational requirements are required, and as the number of users grows, time 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 the identified sites. Thus, the new information enters the blockchain much faster and the “cost of recording” becomes minimal.
  3. Experience. We have experience in using this blockchain platform in past projects, and we know well how to solve the emerging difficulties.

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

The structure of the system 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 the UI web site 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.

The Common Area is the N nodes of the system on which Multichain is deployed in recording mode and a Web server with a shared API.

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

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

Processing server

Implemented in the same way as the Common REST API on APS.NET Core 1.1. In the prototype is responsible for:

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

Identity server

Server user authentication system. Implemented on ASP.NET Core 1.1 using the IdentityServer 4 component.

Functional:


User profiles are also stored in Multichain in encrypted form.

Prototype constraints


Our system is developed for voting and polls of various types. However, to demonstrate the capabilities of the prototype, we decided to limit ourselves to the simple majority voting scenario with an open list of participants, i.e. anyone can join this vote. Therefore, in this article we will not consider the scenarios of inviting people to participate in closed 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


View the prototype and try out the creation of a vote here . If you want to deploy a Read only site, contact us through the form on the website - we will send you instructions on how to do this.

Source: https://habr.com/ru/post/340342/


All Articles