Method, device and electronic device for generating and verifying voting results
By receiving voting transaction requests on the blockchain, obtaining the true voting results, and generating target voting results based on secret values and voting summary, the problems in the existing technology of anonymous voting methods are solved, and the audit nodes are unreliable, inefficient voting, and inability to supervise malicious voting nodes are achieved, and efficient and reliable anonymous voting and voting results are achieved.
Patent Information
- Application Number
- CN202110333936.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-29
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2041-03-29
AI Technical Summary
The existing anonymous voting methods on blockchains have problems such as unreliability of audit nodes leading to information leakage, inefficient voting, and inability to supervise malicious voting nodes.
By receiving voting transaction requests, obtain the true voting results, and based on the secret value and voting summary, random questions with the preset number of questions are randomly selected from the voting questions, determine the random voting results, and generate the target voting results. This method does not rely on audit nodes, avoids cryptographic calculations, and realizes the anonymity and verification of voting results.
It realizes efficient and reliable anonymous voting, avoids the problems of information leakage and low voting efficiency, and has the ability to supervise and verify voting results to ensure the accuracy of voting results.
Smart Images

Figure CN112989419B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain technology. Specifically, the present application relates to a method, device and electronic device for generating and verifying voting results. Background Art
[0002] Voting surveys play an important role in human life. In some application scenarios, anonymous voting is required.
[0003] Blockchain has the advantages of decentralization, transparency, and data immutability, and is gaining more and more attention. Currently, anonymous voting on blockchain is mostly done in the following ways:
[0004] The first is to set up an audit node to record voting information while removing the voter’s identity information.
[0005] The second method is to use blind signatures, ring signatures, homomorphic cryptography and other technologies to issue voting rights, and use ring signature technology to hide the identity of voters.
[0006] The first anonymous voting method mentioned above requires the establishment of audit nodes and relies on the neutrality of the audit nodes, otherwise the voting information will be directly leaked, which is not in line with the spirit of blockchain decentralization.
[0007] Although the second anonymous voting method mentioned above can achieve the purpose through cryptographic technology, it requires cryptographic calculations, which makes the voting efficiency low, and is particularly unfavorable for large-scale voting situations.
[0008] In addition, the existing anonymous voting method cannot monitor the voting results and detect malicious voting nodes.
[0009] Therefore, the existing anonymous voting methods on the blockchain all have certain defects, and there is an urgent need to provide an efficient and reliable anonymous voting solution. Summary of the invention
[0010] The purpose of this application is to solve at least one of the above technical defects. The technical solution adopted by this application is as follows:
[0011] In a first aspect, an embodiment of the present application provides a method for generating voting results, the method comprising:
[0012] Receive a voting transaction request, where the voting transaction request carries at least one voting topic and corresponding voting options;
[0013] Get the real voting results of users on each voting topic;
[0014] Based on the secret value, the voting summary and the number of the voting topic, a preset number of random topics are randomly selected from the voting topics, and a random voting result is determined for each random topic, wherein the secret value is generated based on the private key of the voting node and the voting summary and based on a preset signature algorithm;
[0015] A target voting result is generated based on the real voting result and the random voting result, wherein each option in the random voting result has the same probability of being selected.
[0016] Optionally, the above method further includes:
[0017] Generates a proof for verifying a secret value.
[0018] Optionally, the above method further includes:
[0019] When receiving the voting result verification request sent by the trusted node, the secret value and evidence are returned to the trusted node.
[0020] Optionally, based on the secret value, the voting summary and the number of the voting topic, a preset number of random topics are randomly selected from the voting topics, including:
[0021] A hash operation is performed based on the secret value, the voting summary and the number of the voting question to obtain the operation result;
[0022] Based on the parity of the calculation result, a preset number of random questions are randomly selected from the voting questions.
[0023] Optionally, the above method further includes:
[0024] Send the target voting results to the voting statistics node.
[0025] In a second aspect, an embodiment of the present application provides a method for verifying voting results, the method comprising:
[0026] Send a voting result verification request to the voting node, which carries relevant information about the voting transaction;
[0027] Receive the secret value and evidence corresponding to the voting transaction returned by the voting node;
[0028] The secret value is verified based on the evidence.
[0029] Optionally, if the secret value is verified based on the evidence, the method further includes:
[0030] Get the real voting results from the voting nodes;
[0031] Generate a first target voting result based on the secret value and the real voting result;
[0032] The first target voting result is compared with the second target voting result generated by the voting node.
[0033] In a third aspect, an embodiment of the present application provides a device for generating voting results, the device comprising:
[0034] A transaction request receiving module, used to receive a voting transaction request, wherein the voting transaction request carries at least one voting topic and corresponding voting options;
[0035] The real voting result acquisition module is used to obtain the real voting results of users on each voting topic;
[0036] A random voting result determination module is used to randomly select a preset number of random questions from the voting questions based on a secret value, a voting summary and the question number of the voting question, and determine a random voting result for each random question, wherein the secret value is generated based on the private key of the voting node and the voting summary and based on a preset signature algorithm;
[0037] The target voting result generating module is used to generate the target voting result based on the real voting result and the random voting result, wherein each option in the random voting result has the same probability of being selected.
[0038] Optionally, the above device further includes:
[0039] The evidence generation module is used to generate evidence for verifying secret values.
[0040] Optionally, the above device further includes:
[0041] The data return module is used to return the secret value and evidence to the trusted node when receiving the voting result verification request sent by the trusted node.
[0042] Optionally, the random voting result determination module is specifically used to randomly select a preset number of random questions from the voting questions based on the secret value, the voting summary and the question number of the voting question:
[0043] A hash operation is performed based on the secret value, the voting summary and the number of the voting question to obtain the operation result;
[0044] Based on the parity of the calculation result, a preset number of random questions are randomly selected from the voting questions.
[0045] Optionally, the above device further includes:
[0046] The voting result return module is used to send the target voting results to the voting statistics node.
[0047] In a fourth aspect, an embodiment of the present application provides a voting result verification device, the device comprising:
[0048] A verification request receiving module is used to send a voting result verification request to the voting node, and the voting result verification request carries relevant information of the voting transaction;
[0049] The data receiving module is used to receive the secret value and evidence corresponding to the voting transaction returned by the voting node;
[0050] A verification module is used to verify the secret value based on the evidence.
[0051] Optionally, if the secret value is verified based on the evidence, the above device further includes a voting result comparison module, and the voting result comparison module is used to:
[0052] Get the real voting results from the voting nodes;
[0053] Generate a first target voting result based on the secret value and the real voting result;
[0054] The first target voting result is compared with the second target voting result generated by the voting node.
[0055] In a fifth aspect, an embodiment of the present application provides an electronic device, the electronic device comprising: a processor and a memory;
[0056] A memory, used for storing operation instructions;
[0057] The processor is used to execute the method shown in any implementation of the first aspect or any implementation of the second aspect of the present application by calling an operation instruction.
[0058] In the third aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method shown in any implementation of the first aspect or any implementation of the second aspect of the present application.
[0059] The beneficial effects of the technical solution provided by the embodiment of the present application are:
[0060] The solution provided by the implementation of this application receives a voting transaction request and obtains the user's real voting results for each voting topic. Based on the secret value, the voting summary and the topic number of the voting topic, a preset number of random topics are randomly selected from the voting topics, and a random voting result is determined for each random topic, and a target voting result is generated based on the real voting result and the random voting result. The target voting result generated in this solution can be used for voting statistics, thereby realizing anonymous voting, and the voting results can be verified by the secret value to ensure the accuracy of the voting results, thereby overcoming the defects existing in the existing anonymous voting method. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in describing the embodiments of the present application are briefly introduced below.
[0062] Figure 1 A flowchart of a method for generating voting results provided in an embodiment of the present application;
[0063] Figure 2 A flowchart of a specific implementation method of a method for generating voting results provided in an embodiment of the present application;
[0064] Figure 3 A schematic diagram of a process for counting voting results provided in an embodiment of the present application;
[0065] Figure 4 A flowchart of a voting result verification method provided in an embodiment of the present application;
[0066] Figure 5 A schematic diagram of the structure of a voting result generating device provided in an embodiment of the present application;
[0067] Figure 6 A schematic diagram of the structure of a voting result verification device provided in an embodiment of the present application;
[0068] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0069] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be interpreted as limiting the present invention.
[0070] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be an intermediate element. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.
[0071] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0072] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0073] Figure 1 A flowchart of a method for generating voting results provided in an embodiment of the present application is shown. Figure 1 As shown, the method may mainly include:
[0074] Step S110: receiving a voting transaction request, wherein the voting transaction request carries at least one voting topic and corresponding voting options;
[0075] Step S120: Obtain the actual voting results of the user on each voting topic;
[0076] Step S130: Based on the secret value, the voting summary and the number of the voting topic, a preset number of random topics are randomly selected from the voting topics, and a random voting result is determined for each random topic, wherein the secret value is generated based on the private key of the voting node and the voting summary and based on a preset signature algorithm;
[0077] Step S140: Generate a target voting result based on the real voting result and the random voting result, wherein each option in the random voting result has the same probability of being selected.
[0078] In the embodiment of the present application, the user can send a voting transaction request to the blockchain node through the client. The information carried in the voting transaction request may include: voting content (questionnaire), users who can vote, voting validity period (start time and end time), voting digest, and signature. Among them, digest = hash (voting content, users who can vote, voting validity period).
[0079] When a blockchain node receives a voting transaction request sent by a user, it can verify the voting transaction request. Specifically, it can verify whether the signature is legal. If not, the transaction can be considered invalid. If legal, it can continue to verify the legality of the transaction content. If legal, it responds to the client; if not, it prompts that the transaction is invalid and returns a prompt message to the client.
[0080] When a blockchain node verifies a voting transaction request sent by a user, it can send the voting transaction request to the consensus node set, which will process it, package the transaction, and generate a new block. After consensus, the new block is broadcast to the entire network and sent to all nodes in the network. When a node in the blockchain receives a consensus block containing the voting request, it will feedback to the client that the voting content has been uploaded to the chain.
[0081] The method provided in the embodiment of the present application can be applied to voting nodes, and the voting nodes can respond when parsing the voting transaction request. Specifically, before voting, it can be verified whether the voting is within the voting validity period. If not, the voting node does not vote; if it is, it verifies whether the user who initiated the voting transaction request is a user who can vote. If not, the voting node does not vote; if so, the voting node votes.
[0082] In an embodiment of the present application, the voting node can obtain the user's actual voting results for each voting topic, and then generate random voting results for a preset number of topics, and generate a target voting result based on the actual voting results and the random voting results.
[0083] Since the target voting results are generated based on the random voting results and the real voting results, when the votes are counted through the target voting results, the real voting results can be hidden, thereby realizing anonymous voting.
[0084] In the embodiment of the present application, each option in the random voting result has the same probability of being selected. For example, when there are four voting options, the probability of each voting option being selected is 25%. Therefore, when the voting results are counted, the real voting results can be derived based on the preset number of questions corresponding to the random voting results, which provides a basis for determining the real voting results from the target voting results.
[0085] Specifically, based on the secret value, the voting summary and the number of the voting topic, a preset number of random topics can be randomly selected from the voting topics, and a random voting result can be determined for each random topic.
[0086] In the embodiment of the present application, when a user registers, the user's secret value can be generated based on the private key of the voting node and the voting summary and based on a preset signature algorithm. The signature algorithm requires that the secret value signed by the same signer (with a fixed private key) for the same string is fixed.
[0087] The user's secret value can be stored by the user himself without being put on the chain. In actual use, the secret value can also be temporarily generated each time you participate in voting.
[0088] As an example, the voting summary and the node's private key can be input into the preset signature algorithm to output the secret value as follows:
[0089] a) h = Alpha (Note: Alpha is the result of the hash operation of the voting summary), initialize h x =h;
[0090] b) h x As the horizontal coordinate, according to the elliptic curve algorithm, solve the vertical coordinate h y ;
[0091] c) Determine whether the elliptic curve algorithm can be used to pass h x Solve for h y ;
[0092] If yes, indicate h x On the elliptic curve, the output h = (h x ,h y );
[0093] If no, indicate h x If it is not on the elliptic curve, continue to execute h x ++, until h is passed according to the elliptic curve algorithm x It is possible to calculate h y .
[0094] d) Through the private key x and coordinate h = (h x ,h y ), then we can calculate γ=h x , the calculation is performed on the elliptic curve.
[0095] e) Perform a hash operation on γ to obtain secret = Hash (γ), where secret is the generated random secret value.
[0096] In the embodiment of the present application, since voting is conducted through voting nodes on the blockchain, it is possible to avoid setting up audit nodes, thereby avoiding the leakage of voting information due to unreliable audit nodes.
[0097] In the embodiment of the present application, the voting node does not need to hide the identity of the voter through cryptographic technology, thus avoiding cryptographic calculations and ensuring voting efficiency.
[0098] In the embodiment of the present application, since the random voting result is determined based on the secret value, and the secret value is obtained based on a preset signature algorithm and can be verified, the voting result can be supervised by verifying the secret value, so as to discover malicious voting nodes. If the verification of the secret value fails, it can be confirmed that the voting result may be unreliable, thereby discovering malicious voting nodes.
[0099] The method provided by the implementation of this application receives a voting transaction request and obtains the user's real voting results for each voting topic. Based on the secret value, the voting summary and the topic number of the voting topic, a preset number of random topics are randomly selected from the voting topics, and a random voting result is determined for each random topic, and a target voting result is generated based on the real voting result and the random voting result. The target voting result generated in this solution can be used for voting statistics, thereby realizing anonymous voting, and the voting results can be verified by the secret value to ensure the accuracy of the voting results, thereby overcoming the defects existing in the existing anonymous voting method.
[0100] In an optional manner of the embodiment of the present application, the above method further includes:
[0101] Generates a proof for verifying a secret value.
[0102] In an embodiment of the present application, while generating a secret value, evidence for verifying the secret value can also be generated to provide a basis for verifying the accuracy of the voting results based on the secret value verification results.
[0103] As an example, the evidence generation process is as follows:
[0104] a) Calculate γ = h x For the specific process, please refer to the above example of generating a secret value;
[0105] b) Randomly select k∈Z q ; q is the order of the base point of the elliptic curve, and Z is the parameter of the elliptic curve; q Represents the number after modulo q;
[0106] Verify whether k is equal to 0 or 1. If it is, reselect k; if it is not, proceed to the next step.
[0107] c) Calculate c = Hash (g, h, g x ,h x ,g k ,h k );
[0108] g is the base point on the elliptic curve and is the parameter of the elliptic curve;
[0109] h is the point calculated in the previous example of generating a secret value.
[0110] g x is the public key of the random source node.
[0111] h x Based on h and x, we can find h x .
[0112] g k Based on k and g, we can find g k .
[0113] h k Based on h and k, h can be calculated k .
[0114] Finally, through hash operation, we get c = Hash (g, h, g x ,h x ,g k ,h k ).
[0115] d) Calculate s = k-cx mod q; q is the order of the elliptic curve base point;
[0116] e) Verify whether s is equal to 0 or 1. If so, reselect k. Otherwise, proceed to the next step.
[0117] f) Output result: evidence π = (γ, c, s).
[0118] In an optional manner of the embodiment of the present application, the above method further includes:
[0119] When receiving the voting result verification request sent by the trusted node, the secret value and evidence are returned to the trusted node.
[0120] In an embodiment of the present application, the voting results can be verified by a trusted node in the blockchain. When the trusted node sends a voting result verification request to the voting node, the voting node returns the secret value and evidence to the trusted node.
[0121] In an optional manner of the embodiment of the present application, based on the secret value, the voting summary and the number of the voting topic, a preset number of random topics are randomly selected from the voting topics, including:
[0122] A hash operation is performed based on the secret value, the voting summary and the number of the voting question to obtain the operation result;
[0123] Based on the parity of the calculation result, a preset number of random questions are randomly selected from the voting questions.
[0124] In the embodiment of the present application, the specific method of selecting a random topic can be to perform a hash operation based on the user's secret value, the voting summary, and the topic number of the voting topic, and randomly select a preset number of random topics from the voting topics based on the parity of the operation result. For example, when the operation result corresponding to the topic number is an even number, the topic corresponding to the topic number can be determined as a random topic, and the voting result is randomly selected from the voting options. When the operation result corresponding to the topic number is an odd number, the topic corresponding to the topic number can be determined as not a random topic, and the actual voting result corresponding to the topic number can be used as the final voting result.
[0125] In actual use, there are many ways to specify the random topic. For example, the calculation result can be divided by 3, and the voting topic corresponding to the calculation result that is not divisible by 3 is determined as the random topic.
[0126] As an example, Figure 2 A flowchart of a specific implementation of a method for generating voting results provided in an embodiment of the present application is shown in FIG.
[0127] like Figure 2 As shown in , the voting node receives the new block, parses the voting transaction, and responds to the vote;
[0128] Voting transaction information includes: voting content (questionnaire), users who can vote, voting validity period (start time and end time), voting digest, and signature.
[0129] Verify whether the voting is within the validity period. If yes, proceed to the next step of verification; otherwise, the node does not vote;
[0130] Verify whether the user is eligible to vote. If so, proceed to the next step. Otherwise, the node does not vote.
[0131] Assume that there are m questions in the entire voting questionnaire, initialize the variable i, i=0, i+1 is the first question;
[0132] If i<m, execute the next step;
[0133] i=i+1;
[0134] Using the voting digest, secret value, and question number i, calculate the voting random value xi = hash(digest, secret, i) for question i.
[0135] Determine whether the random number xi is an even number;
[0136] If xi is an even number, then choose random voting; call the Random function to generate a random number k, then calculate k%n+1 (that is, perform a modulo operation on k and n, and add 1 to the result), and vote for the option corresponding to the result. For example: a question has 4 options (A, B, C, D), then n=4; call the Random function to generate a random number k=8, k%n+1=8%4+1=1, then choose option A as the random voting result.
[0137] If xi is an odd number, vote according to your true thoughts.
[0138] Calculate the next item in a loop until all question numbers in the questionnaire are traversed;
[0139] When i ≥ m, the loop ends, the entire questionnaire completes voting, and the voting results are sent to the node that initiated the vote.
[0140] In an optional manner of the embodiment of the present application, the above method further includes:
[0141] Send the target voting results to the voting statistics node.
[0142] In the embodiment of the present application, a voting statistics node may be set to collect voting results. In actual use, the voting initiating node may serve as the voting statistics node.
[0143] In the embodiment of the present application, the voting statistics node can count the target voting results of each voting node, and perform statistics to obtain the target voting result statistics. Since the number of preset questions corresponding to the random voting results can be pre-specified, and each option in the random voting results has the same probability of being selected, the random voting result statistics can be expected, and the random voting result statistics can be subtracted from the target voting result statistics to determine the real voting result statistics, thereby realizing the statistics of the real voting results.
[0144] In an embodiment of the present application, the voting statistics node can count the user's target voting results before the voting end time.
[0145] After counting the target voting results of the user, it can be verified whether the user has completed the voting within the valid time range. If the voting is not completed within the valid time range, the voting is deemed invalid and the voting statistics are terminated. If the voting is completed within the valid time range, it can be verified whether the user is in the valid voting user set. If the user is not in the valid voting user set, the voting statistics are terminated. If the user is in the valid voting user set, it is verified whether the voting information counted is a repeated vote. If it is a repeated vote, the vote will not be counted repeatedly (only counted once), otherwise, the vote will be counted.
[0146] When counting votes, the voting summary can be used as an index value to count the options for each question number in the questionnaire, and the voting results for each option are accumulated.
[0147] For example, the voting summary is digest1, and the voting statistics for each option in each question number are shown in Table 1.
[0148] Table 1
[0149]
[0150] By counting the target voting results in Table 1, we can get:
[0151] Question number 1: {A: 2, B: 1}, 2 votes for A and 1 vote for B.
[0152] Question number 2: {A: 1, B: 1, C: 1}, 1 vote for A, 1 vote for B, and 1 vote for C.
[0153] Question number 3: {A: 1, B: 0, C: 0, D: 2}, 1 vote for A, 0 votes for B, 0 votes for C, and 2 votes for D.
[0154] The column of vote count for each option in Table 1 may not be directly presented in the statistical results, but may be stored separately using the voting summary as an index.
[0155] The method provided by the implementation of this application receives the target voting results for each voting topic from multiple voting nodes, and counts the target voting results of each voting node to obtain the target voting result statistics, thereby determining the real voting result statistics for each voting topic based on the total number of topics corresponding to the target voting results and the preset number of topics corresponding to the random voting results in the target voting results, and based on the target voting result statistics. Based on this solution, it is possible to count the real voting results, realize anonymous voting, overcome the defects in the existing anonymous voting methods, and have the advantages of being more efficient and reliable.
[0156] In an embodiment of the present application, when the target voting results of each voting node are counted to obtain the target voting result statistical value, the target voting results of each voting node can be counted to obtain the initial voting result statistical value of each voting topic; if the initial voting result statistical value meets the preset conditions, the initial voting result statistical value is determined as the target voting result statistical value.
[0157] At present, the existing anonymous voting cannot identify the situation where participants vote at random (vote irresponsibly), which will affect the accuracy of the voting results.
[0158] In an embodiment of the present application, a preset condition can be set for the initial voting result statistics of each voting topic. When the initial voting result statistics do not meet the preset condition, it can be considered that the voting result of the voting topic may be inaccurate, and the voting result of the voting topic can be discarded.
[0159] In actual use, the preset condition can be set as a reference threshold, and it is considered that when the statistical value of the initial voting result is greater than the reference threshold, the corresponding voting result is credible.
[0160] As an example, the reference threshold may be determined as follows:
[0161] (1) Set the reference threshold of each option in each question in the questionnaire to p'. In this example, the number of preset questions is 1 / 2 of the total number of questions. At this time, the theoretical threshold p = 1 / 2*1 / n can be used as a reference, and p' is set according to the number of people participating in the vote. Where n is the total number of options for the question; Table 2 shows the voting results statistics:
[0162] Table 2
[0163] Options Random voting Real voting A 1 / n <![CDATA[p1]]> B 1 / n <![CDATA[p2]]> C 1 / n <![CDATA[p3]]> D 1 / n <![CDATA[p4]]> …… …… …… The nth option 1 / n <![CDATA[p n ]]>
[0164] According to the actual number of people counted and the error, the actual threshold can be slightly smaller. For example: this question has 4 options (A, B, C, D), the probability of randomly voting for each option is 1 / 4, and the probabilities of real voting are p1, p2, p3, and p4 respectively. Therefore, the theoretical threshold is p = 1 / 2*1 / 4 = 0.125. Assuming that there are 10,000 valid nodes participating in the voting, considering the error, the reference threshold p' of this question can be set to 0.11, that is, the voting ratio of each option needs to be greater than or equal to 0.11.
[0165] In an optional manner of the embodiment of the present application, the above method further includes:
[0166] If the statistical value of the initial voting result does not meet the preset conditions, a voting request is generated based on the voting topic corresponding to the initial voting result that does not meet the preset conditions, and the voting request is sent to the blockchain.
[0167] In an embodiment of the present application, a voting topic whose initial voting result statistics do not meet the preset conditions can be determined as an invalid topic, the topic number of the invalid topic can be recorded, and the invalid topics can be screened out, a voting request can be generated for the invalid topic, and the voting request can be sent to the blockchain to re-count the voting results.
[0168] In the embodiment of the present application, the statistical value of the actual voting result can be calculated based on the conditional probability.
[0169] Table 3
[0170] Options Random voting Real voting A 1 / n <![CDATA[p1]]> B 1 / n <![CDATA[p2]]> C 1 / n <![CDATA[p3]]> D 1 / n <![CDATA[p4]]> …… …… …… The nth option 1 / n <![CDATA[p n ]]>
[0171] As shown in Table 3, p1 p2 ... p n is the statistical value of the actual voting results of each voting option, and n is the total number of voting options. From Table 3, the probability of the nth option (i.e. the statistical value of the target voting result) is: n '=0.5*1 / n+0.5*p n According to this formula, we can solve p n, Right now:
[0172]
[0173] As an example, Figure 3 A schematic diagram of the process of counting voting results provided in an embodiment of the present application is shown in FIG. Figure 3 As shown in:
[0174] a) Input the statistical result table (i.e. the target voting results to be counted);
[0175] b) There are m questions in the questionnaire, and the variable i is initialized, i=0, i+1 is the first question;
[0176] c) When i<m, execute the next step;
[0177] d) i = i + 1;
[0178] e) There are n options for question i;
[0179] f) Determine whether the statistical result of each option in the i-th question is greater than or equal to the reference threshold;
[0180] If it is satisfied, the voting result of this question is a valid vote, and the question number and the statistical result of this question are output;
[0181] If it is not satisfied, the vote is considered invalid. The invalid question number is filtered out and a new questionnaire is generated. A new voting request is initiated to the blockchain network to re-count the voting results and complete the voting result statistics for the entire questionnaire.
[0182] Calculate the next item in a loop until all the options for all the question numbers in the questionnaire have been traversed;
[0183] g) When i ≥ m, the loop ends and the entire questionnaire voting result check is completed.
[0184] Figure 4 A flowchart of a voting result verification method provided in an embodiment of the present application is shown. Figure 4 As shown, the method may mainly include:
[0185] Step S210: Send a voting result verification request to the voting node, where the voting result verification request carries relevant information of the voting transaction;
[0186] Step S220: receiving the secret value and evidence corresponding to the voting transaction returned by the voting node;
[0187] Step S230: Verify the secret value based on the evidence.
[0188] In an embodiment of the present application, in an embodiment of the present application, the voting results can be verified by a trusted node in the blockchain. When the trusted node sends a voting result verification request to the voting node, the voting node returns the secret value and evidence to the trusted node.
[0189] After receiving the secret value and evidence, the trusted node can verify the secret value through the evidence, so as to supervise the voting results through the verification of the secret value, and effectively discover malicious voting nodes. If the verification of the secret value fails, it can be confirmed that the voting result may be unreliable, thus discovering malicious voting nodes.
[0190] As an example, the specific process of verifying a secret value based on evidence is as follows:
[0191] a) Enter the public key g parsed from the certificate x , evidence π, secret value secret and transaction information;
[0192] b) Analyze γ, c and s from evidence π and calculate u = (g x ) c ·g s ;
[0193] c) Perform a hash operation on the transaction content that needs to be verified to obtain Alpha (voting digest);
[0194] d) Calculate h (coordinate) using Alpha; this method is the same as the previous example of generating a secret value.
[0195] e) Calculate v = (γ) c ·h s ;
[0196] f) Verify c and Hash(g,h,g x ,γ,u,v) are equal;
[0197] c is analyzed from the evidence π;
[0198] g is the base point on the elliptic curve.
[0199] h is the point on the elliptic curve calculated in the previous example of generating a secret value.
[0200] g x is the public key of the random source node.
[0201] γ is analyzed from the evidence π.
[0202] u is calculated through b) in this process.
[0203] v is calculated through e) in this process.
[0204] Finally, for (g,h,g x ,γ,u,v) is hashed to get Hash(g,h,g x ,γ,u,v), compare with c, if they are equal, proceed to the next step; otherwise, the verification fails;
[0205] g) Verify whether the input secret value secret and Hash(γ) are equal;
[0206] The input secret value secret is compared with Hash(γ), where γ is parsed from the evidence π and Hash(γ) is obtained by hashing γ; if the two are equal, the verification passes, otherwise, the verification fails.
[0207] h) All the above verifications are passed, indicating that the evidence π and secret value secret corresponding to the transaction are legal.
[0208] Due to the unique signature feature, the same signer can only obtain a provably unique secret for the same digest, thus ensuring that the random voting process cannot be forged.
[0209] The method provided by the implementation of this application includes sending a voting result verification request to a voting node, the voting result verification request carries relevant information of the voting transaction; receiving the secret value and evidence corresponding to the voting transaction returned by the voting node; and verifying the secret value based on the evidence. In this scheme, the secret value is verified by evidence, so that the verification result of the secret value can monitor the voting result, so as to discover malicious voting nodes and overcome the defects in the existing anonymous voting method.
[0210] In an optional manner of the embodiment of the present application, if the secret value is verified based on the evidence, the method further includes:
[0211] Get the real voting results from the voting nodes;
[0212] Generate a first target voting result based on the secret value and the real voting result;
[0213] The first target voting result is compared with the second target voting result generated by the voting node.
[0214] In an embodiment of the present application, the trusted node obtains the real voting result from the voting node, and then generates a first target voting result based on the official voting result and the secret value, and compares the first target voting result with the second target voting result generated by the voting node. If the two are consistent, it can be considered that the voting node votes normally; otherwise, the voting node may be abnormal.
[0215] In an embodiment of the present application, the way in which the trusted node generates the target voting result based on the real voting result and the secret value is the same as the way in which the voting node generates the target voting result.
[0216] Based on Figure 1 The same principle as shown in the method, Figure 5 A schematic diagram of the structure of a voting result generating device provided in an embodiment of the present application is shown. Figure 5 As shown, the voting result generating device 30 may include:
[0217] The transaction request receiving module 310 is used to receive a voting transaction request, wherein the voting transaction request carries at least one voting topic and corresponding voting options;
[0218] The real voting result acquisition module 320 is used to acquire the real voting results of the user on each voting topic;
[0219] A random voting result determination module 330 is used to randomly select a preset number of random questions from the voting questions based on a secret value, a voting summary and a question number of the voting question, and determine a random voting result for each random question, wherein the secret value is generated based on a private key of the voting node and the voting summary and based on a preset signature algorithm;
[0220] The target voting result generating module 340 is used to generate the target voting result based on the real voting result and the random voting result, wherein each option in the random voting result has the same probability of being selected.
[0221] The device provided by the implementation of the present application receives a voting transaction request and obtains the real voting results of the user on each voting topic. Based on the secret value, the voting summary and the topic number of the voting topic, a preset number of random topics are randomly selected from the voting topics, and a random voting result is determined for each random topic, and a target voting result is generated based on the real voting result and the random voting result. The target voting result generated in this solution can be used for voting statistics, thereby realizing anonymous voting, and the voting results can be verified by the secret value to ensure the accuracy of the voting results, thereby overcoming the defects existing in the existing anonymous voting method.
[0222] Optionally, the above device further includes:
[0223] The evidence generation module is used to generate evidence for verifying the secret value.
[0224] Optionally, the above device further includes:
[0225] The data return module is used to return the secret value and evidence to the trusted node when receiving the voting result verification request sent by the trusted node.
[0226] Optionally, the random voting result determination module is specifically used to randomly select a preset number of random questions from the voting questions based on the secret value, the voting summary and the question number of the voting question:
[0227] A hash operation is performed based on the secret value, the voting summary and the number of the voting question to obtain the operation result;
[0228] Based on the parity of the calculation result, a preset number of random questions are randomly selected from the voting questions.
[0229] Optionally, the above device further includes:
[0230] The voting result return module is used to send the target voting results to the voting statistics node.
[0231] It can be understood that the above modules of the voting result generation device in this embodiment have the function of realizing Figure 1 The functions of the corresponding steps of the method for generating voting results in the embodiment shown in . The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions. The above modules can be software and / or hardware, and the above modules can be implemented separately or integrated with multiple modules. For the functional description of each module of the above voting result generation device, please refer to Figure 1 The corresponding description of the method for generating the voting results in the embodiment shown in is not repeated here.
[0232] Based on Figure 4 The same principle as shown in the method, Figure 6 A schematic diagram of the structure of a voting result verification device provided in an embodiment of the present application is shown. Figure 6 As shown, the voting result verification device 40 may include:
[0233] The verification request receiving module 410 is used to send a voting result verification request to the voting node, where the voting result verification request carries relevant information of the voting transaction;
[0234] The data receiving module 420 is used to receive the secret value and evidence corresponding to the voting transaction returned by the voting node;
[0235] The verification module 430 is used to verify the secret value based on the evidence.
[0236] The device provided by the implementation of this application sends a voting result verification request to a voting node, and the voting result verification request carries relevant information of the voting transaction; receives the secret value and evidence corresponding to the voting transaction returned by the voting node; and verifies the secret value based on the evidence. In this scheme, the secret value is verified by evidence, so that the verification result of the secret value can monitor the voting result, so as to discover malicious voting nodes and overcome the defects in the existing anonymous voting method.
[0237] Optionally, if the secret value is verified based on the evidence, the above device further includes a voting result comparison module, and the voting result comparison module is used to:
[0238] Get the real voting results from the voting nodes;
[0239] Generate a first target voting result based on the secret value and the real voting result;
[0240] The first target voting result is compared with the second target voting result generated by the voting node.
[0241] It can be understood that the above modules of the voting result verification device in this embodiment have the function of realizing Figure 4 The functions of the corresponding steps of the voting result verification method in the embodiment shown in . The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions. The above modules can be software and / or hardware, and the above modules can be implemented separately or integrated with multiple modules. For the functional description of each module of the voting result verification device, please refer to Figure 4 The corresponding description of the method for verifying the voting results in the embodiment shown in will not be repeated here.
[0242] An embodiment of the present application provides an electronic device, including a processor and a memory;
[0243] A memory, used for storing operation instructions;
[0244] The processor is used to execute the method provided in any embodiment of the present application by calling an operation instruction.
[0245] As an example, Figure 7 A schematic diagram of the structure of an electronic device applicable to the embodiment of the present application is shown. Figure 7 As shown, the electronic device 2000 includes: a processor 2001 and a memory 2003. The processor 2001 and the memory 2003 are connected, such as through a bus 2002. Optionally, the electronic device 2000 may also include a transceiver 2004. It should be noted that in actual applications, the transceiver 2004 is not limited to one, and the structure of the electronic device 2000 does not constitute a limitation on the embodiments of the present application.
[0246] The processor 2001 is applied in the embodiment of the present application to implement the method shown in the above method embodiment. The transceiver 2004 may include a receiver and a transmitter. The transceiver 2004 is applied in the embodiment of the present application to implement the function of the electronic device of the embodiment of the present application communicating with other devices when executed.
[0247] Processor 2001 may be a CPU (Central Processing Unit), a general purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. Processor 2001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0248] The bus 2002 may include a path to transmit information between the above components. The bus 2002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 2002 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0249] The memory 2003 can be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to these.
[0250] Optionally, the memory 2003 is used to store application code for executing the solution of the present application, and the execution is controlled by the processor 2001. The processor 2001 is used to execute the application code stored in the memory 2003 to implement the method provided in any embodiment of the present application.
[0251] The electronic device provided in the embodiment of the present application is applicable to any embodiment of the above method and will not be described in detail here.
[0252] The embodiment of the present application provides an electronic device, which, compared with the prior art, receives a voting transaction request and obtains the user's real voting results for each voting topic, randomly selects a preset number of random topics from the voting topics based on a secret value, a voting summary, and the topic number of the voting topic, and determines a random voting result for each random topic, and generates a target voting result based on the real voting result and the random voting result. The target voting result generated in this solution can be used for counting votes, thereby realizing anonymous voting, and can realize the verification of the voting results with a secret value, ensure the accuracy of the voting results, and overcome the defects existing in the existing anonymous voting method.
[0253] An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the method shown in the above method embodiment is implemented.
[0254] The computer-readable storage medium provided in the embodiments of the present application is applicable to any embodiment of the above method and will not be described in detail here.
[0255] The embodiment of the present application provides a computer-readable storage medium. Compared with the prior art, by receiving a voting transaction request and obtaining the real voting results of the user on each voting topic, based on the secret value, the voting summary and the topic number of the voting topic, a random topic with a preset number of topics is randomly selected from the voting topics, and a random voting result is determined for each random topic respectively, and a target voting result is generated based on the real voting result and the random voting result. The target voting result generated in this solution can be used for voting statistics, thereby realizing anonymous voting, and the voting result can be verified by the secret value to ensure the accuracy of the voting result, thereby overcoming the defects existing in the existing anonymous voting method.
[0256] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0257] The above are only some embodiments of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for generating voting results, characterized in that: include: Receive a voting transaction request, wherein the voting transaction request carries at least one voting topic and corresponding voting options; Obtaining the actual voting results of the user on each of the voting topics; Based on the secret value, the voting summary and the number of the voting topic, a preset number of random topics are randomly selected from the voting topics, and a random voting result is determined for each of the random topics, wherein the secret value is generated based on the private key of the voting node and the voting summary and based on a preset signature algorithm, and the secret value signed by the preset signature algorithm for the same signer for the same string is fixed, and the private key corresponding to the same signer is fixed; A target voting result is generated based on the real voting result and the random voting result, wherein each option in the random voting result has the same probability of being selected.
2. The method according to claim 1, characterized in that Also includes: A proof is generated for verifying the secret value.
3. The method according to claim 2, characterized in that Also includes: When receiving a voting result verification request sent by a trusted node, the secret value and the evidence are returned to the trusted node.
4. The method according to any one of claims 1 to 3, characterized in that The method of randomly selecting a preset number of random questions from the voting questions based on the secret value, the voting summary and the question number of the voting question includes: A hash operation is performed based on the secret value, the voting summary and the number of the voting question to obtain the operation result; Based on the parity of the calculation result, a preset number of random questions are randomly selected from the voting questions.
5. The method according to any one of claims 1 to 3, characterized in that: Also includes: The target voting result is sent to the voting statistics node.
6. A device for generating voting results, characterized in that: include: A transaction request receiving module, configured to receive a voting transaction request, wherein the voting transaction request carries at least one voting topic and corresponding voting options; A real voting result acquisition module is used to acquire the real voting results of the user on each voting topic; A random voting result determination module, for randomly selecting a preset number of random questions from the voting questions based on a secret value, a voting summary and a question number of the voting question, and determining a random voting result for each of the random questions, wherein the secret value is generated based on a private key of a voting node and a voting summary and based on a preset signature algorithm, and the secret value signed by the preset signature algorithm for the same signer for the same string is fixed, and the private key corresponding to the same signer is fixed; The target voting result generating module is used to generate the target voting result based on the real voting result and the random voting result, wherein each option in the random voting result has the same probability of being selected.
7. An electronic device, characterized in that: including a processor and a memory; The memory is used to store operation instructions; The processor is used to execute the method according to any one of claims 1 to 5 by calling the operation instruction.
8. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Electronic voting system
CN110400410A