Anonymous voting and multi-condition vote counting method based on block chain
Technical Field
The invention relates to a block chain-based anonymous voting and multi-condition vote counting method, and belongs to the technical field of internet.
Background
Most of the existing open source block chain technologies are subjected to mediation management, and although the master block chain technology solves the supervision problem, the problems of loss of public and private keys, loss of CA certificates, no guarantee of information and the like are caused.
The existing electronic voting system can realize anonymous voting, but is difficult to solve the problems of malicious vote brushing, voter voting information tampering, hacker tampering and the like.
The existing voting technology based on the block chain can solve the characteristics of mediation, tamper resistance, information encryption and the like, but is difficult to realize the problems of anonymous voting, dynamic registration and voting of voters, multi-conditional vote counting and the like.
In the existing network voting technology, functions of distribution, trustiness, disintermediation and multi-terminal voting cannot be achieved, so that the voting condition can be counted on line.
Disclosure of Invention
In view of the above, the present invention provides a block chain-based anonymous voting and multi-conditional vote counting method, which solves the problem of the anonymous voting system of the de-mediated, distributed and multi-trusted terminal; the terminal voting security is ensured by respectively storing a CA certificate in each block chain voting terminal and each node of the block chain network. The key and unique identity information of the voter is encrypted and then hash is carried out to generate the unique confidential identity information of the voter, so that the identity uniqueness and the information security of the voter are ensured, and the malicious behavior of ticket swiping is prevented. Because the confidential identity information of the voter is encrypted by the public key of the voter and then has a hash, only the voter can check the information, and the anonymous voting can be realized. The public information of the voter is encrypted and digitally signed, and then the encrypted and signed public information is stored in a database of each network node of the block chain, so that the requirement of multi-condition ticket counting through an intelligent contract is met. The invention can realize the functions of anonymous voting of distributed and multi-trusted terminals and multi-condition vote counting under the condition of ensuring the voting right and information security of voters.
The purpose of the invention is realized by the following technical scheme:
a block chain-based anonymous voting and multi-condition vote counting method utilizes a data encryption algorithm and anti-tampering characteristics of a block chain to ensure that the information privacy, the legitimate voting right and the final voting result of a voter are not tampered; the method specifically comprises the following steps:
s1: registering a voter;
s2: voting by voters;
s3: voting and inquiring by voters;
s4: and (5) counting voting results.
Further, the step S1 specifically includes:
s101: the voter submits a public key, a unique information combination capable of identifying the identity of the voter and public identity information;
s102: a voter generates a pair of public and private keys on a trustable voting terminal by using an elliptic curve algorithm, the voter reserves the private key, and each voting terminal and each block chain network node generate a CA certificate;
s103: filling information of voters who need to be disclosed in the voting;
s104: combining the identity information of the voters to generate a unique abstract, encrypting the unique abstract by using a public key, and then generating an identity hash value by using hash;
s105: carrying out digital signature on the identity hash value of the voter, public information of the voter and a public key and submitting the digital signature to a block chain network for consensus authentication;
s106: after receiving the registration consensus authentication, the block chain network computing node performs CA authentication by using a CA certificate of the node, confirms that the registration is from a trustable terminal, and performs registration decryption by using a submitted public key to acquire registration information of a voter;
s107: calling an intelligent contract registration interface, and storing the public key of the voter, the identity hash value and the identity public information in a database;
s108: and performing whole-network consensus on the registration transaction, performing chain link recording, and returning a registration result of the terminal user.
Further, the voter information to be disclosed comprises gender, age, regional conditions; the identity information of the voter includes a name and an id.
Further, the step S2 is: the voter carries out private key encryption and digital authentication on the voting result information and the identity organization hash value of the voter at a trusted terminal and then carries out voting; the method specifically comprises the following steps:
s201: a voter initiates voting on a trustable voting terminal, encrypts voting information of the voter by using a private key, digitally signs the encrypted voting information and an identity combined hash value, and submits the result to a block chain network for consensus authentication;
s202: after receiving the voting consensus authentication, the block chain network computing node firstly utilizes a CA certificate under the node to carry out digital signature authentication and confirms that the voting is from a trustable voting terminal;
s203: calling an intelligent contract interface to obtain a corresponding public key of the voter stored in a database under the node, wherein key is the identity hash value of the voter, and value is the public key;
s204: decrypting the voting information by using the public key of the voter to obtain a voting result, and storing the data in a node database through an intelligent contract recording interface;
s205: and performing whole-network consensus on the voting affairs, performing uplink recording, and returning the voting result of the terminal user.
Further, the step S3 is: the voter can inquire the voting result of the voter through the terminal and can also provide an interface to inquire all voting conditions; the method specifically comprises the following steps:
s301: a voter initiates a voting query on a trustable voting terminal, and the voter initiates the query after CA digital signature is carried out on the identity combination hash value and the query condition of the voter;
s302: each node of the block chain is verified according to the consensus, the computing node carries out digital signature authentication and then calls an intelligent contract query interface to carry out voting query, and a query result is encrypted by a public key of a voter;
s303: carrying out whole network consensus on the inquiry transaction, carrying out chain winding recording and returning an inquiry result of a terminal user;
s304: and decrypting the trusted terminal by using the private key of the voting inquirer to obtain an inquiry result.
Further, the step S4 is: real-time or final multi-condition voting condition statistics can be carried out through a trustable voting inquiry terminal; the method specifically comprises the following steps:
s401: when the voting condition is counted, submitting a piece of information containing the voting transaction number and the voting counting condition;
s402: the CA certificate is used for carrying out digital signature and submitting the digital signature to a block chain network, and after the whole network consensus authentication is carried out, the computing node calls an intelligent contract statistical query interface according to the query condition parameters;
s403: the intelligent contract extracts voting data from the database, and encapsulates the voting initial data according to the query conditions;
s404: and performing the whole network consensus on the inquiry transaction, performing uplink recording and returning a terminal user result.
Further, the ticket transaction number is used for positioning a certain voting event; the voting statistical conditions are id, age, gender and region conditions of a certain candidate.
The invention has the beneficial effects that:
a. a trustable distributed voting terminal is realized by utilizing the block chain, the CA certificate and each operation terminal;
b. the information of the voter is divided into secret information and public information, and the secret information is encrypted by a private key and then subjected to hash operation;
c. chaining registration, voting, inquiry, ticket counting and other operations to form a traceable historical certificate;
d. storing the confidential information and the public information in each node database of the block chain network, and counting tickets under multiple conditions according to the public information;
e. a voter query interface is arranged in the intelligent contract, and the voter can query the voting result by the secret information so as to ensure that the voting information is not tampered;
f. the operation information of the voter is encrypted by the private key, so that the information security of the voting related operation is ensured.
Additional advantages, objects, and features of the invention will be set forth in part in the description which follows and in part will become apparent to those having ordinary skill in the art upon examination of the following or may be learned from practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof.
Drawings
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be further described in detail with reference to the accompanying drawings, in which:
FIG. 1 is a flow chart of voter registration in the present invention;
FIG. 2 is a flow chart of voter voting according to the present invention;
FIG. 3 is a flow chart of voter voting query/result statistics in the present invention;
fig. 4 is a working principle diagram of the present invention.
Detailed Description
Hereinafter, preferred embodiments of the present invention will be described in detail with reference to the accompanying drawings. It should be understood that the preferred embodiments are illustrative of the invention only and are not limiting upon the scope of the invention.
And the data encryption algorithm and the anti-tampering characteristic of the block chain are utilized to ensure that the information privacy, the legal voting right and the final voting result of the voter are not tampered. The method generally comprises four steps:
as shown in fig. 1, a process is registered for a voter. The voter submits a public key, a unique information combination capable of identifying the identity of the voter and public identity information.
a. Firstly, a voter generates a pair of public and private keys on a trustable voting terminal by using an elliptic curve algorithm, the voter reserves the private key, and each voting terminal and each block chain network node generate a CA certificate;
b. then, filling in voter information (such as sex, age, area and other conditions) required to be disclosed in the current vote;
c. combining identity information (name, id and other identity authentication information) of the voter to generate a unique abstract, encrypting the unique abstract by using a public key, and generating an identity hash value by using hash;
d. then, carrying out digital signature on the identity hash value of the voter, the public information of the voter and the public key, and submitting the digital signature to a block chain network for consensus authentication;
e. after receiving the registration consensus authentication, the block chain network computing node performs CA authentication by using a CA certificate of the node (the registration is confirmed to be from a trustable terminal), and performs registration decryption by using the submitted public key to acquire voter registration information;
f. then, calling an intelligent contract registration interface, and storing the public key of the voter, the identity hash value and the identity public information in a database;
g. and finally, performing whole-network consensus on the registration transaction, performing uplink recording, and returning a registration result of the terminal user.
As shown in fig. 2, a voting process is performed for the voter. The voter carries out private key encryption and digital authentication on the voting result information and the identity organization hash value of the voter at the trusted terminal, and then carries out voting.
a. Firstly, a voter initiates voting on a trustable voting terminal, encrypts voting information of the voter by using a private key, digitally signs the encrypted voting information and an identity combined hash value, and submits the result to a block chain network for consensus authentication;
b. then, after receiving the voting consensus authentication, the block chain network computing node performs digital signature authentication (to confirm that the vote is from a trustable voting terminal) by using a CA certificate under the node;
c. then, calling an intelligent contract interface to obtain a corresponding public key of the voter (key is the identity hash value of the voter, and value is the public key) stored in a database under the node;
d. then, the public key of the voter is used for decrypting the voting information to obtain the voting result, and the data is stored in the node database through the intelligent contract recording interface;
e. and finally, performing total network consensus on the voting affairs, performing uplink recording and returning the voting result of the terminal user.
In fig. 3, the voter votes for a query. The voter can inquire the voting result of the voter through the terminal, and an interface can be provided for inquiring all the voting conditions.
a. Firstly, a voter initiates voting inquiry on a trustable voting terminal, and the voter initiates the inquiry after CA digital signature is carried out on the identity combination hash value and the inquiry condition of the voter;
b. then, each node of the block chain is verified according to the consensus, the computing node carries out digital signature authentication and then calls an intelligent contract query interface to carry out voting query, and the query result is encrypted by a public key of a voter;
c. then, carrying out the whole network common identification on the inquiry affair, carrying out chain winding recording and returning the inquiry result of the terminal user;
d. and finally, decrypting the query result by using a private key of the voting querier at the trusted terminal to obtain the query result.
In fig. 3, the voting result is counted. Real-time or final multi-condition voting condition statistics can be carried out through a trusted voting inquiry terminal.
a. Firstly, when the voting condition is counted, submitting information including the voting transaction number (positioning a certain voting activity), voting statistical conditions (such as the id of a certain candidate, the score, the sex, the region and other conditions) and the like;
b. then, a CA certificate is used for carrying out digital signature and submitting the digital signature to a blockchain network, and after the whole network consensus authentication is carried out, the computing node calls an intelligent contract statistical query interface according to the query condition parameters;
c. thirdly, the intelligent contract extracts voting data from the database, and the voting initial data are subjected to result encapsulation according to the query conditions;
d. and finally, performing total network consensus on the inquiry transaction, performing uplink recording and returning a terminal user result.
Fig. 4 is a working principle diagram of the present invention.
Finally, the above embodiments are only intended to illustrate the technical solutions of the present invention and not to limit the present invention, and although the present invention has been described in detail with reference to the preferred embodiments, it will be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions, and all of them should be covered by the claims of the present invention.