Block generation method, apparatus, device, medium, and product
By generating election tags and calculating the number of votes, the problem of uneven block production probability among nodes in the proof-of-stake consensus is solved, thus realizing the decentralization of the blockchain network.
Patent Information
- Application Number
- CN202410411636.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-07
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2044-04-07
AI Technical Summary
The existing proof-of-stake consensus mechanism leads to an uneven probability of nodes producing blocks, which can easily result in system centralization.
By obtaining random beacons and using node private keys to sign and generate election tags, and combining the node addresses to calculate the number of candidate votes, it is ensured that all participating nodes have an equal probability of producing blocks.
This achieves a balance in the block production probability of all participating nodes, avoids system centralization, and improves the decentralization of the blockchain network.
Smart Images

Figure CN118631427B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of blockchains, and particularly relates to a block generation method and device, equipment, medium and product. BACKGROUND
[0002] In the prior art, a proof of stake (PoS) consensus determines the block generation probability according to the number of votes held by a node, and a node with more votes has a higher block generation probability. However, the proof of stake consensus leads to different block generation probabilities of different nodes, so that several nodes with more votes monopolize the network, and the system is easily centralized. SUMMARY
[0003] Embodiments of the application provide a block generation method, device, equipment, medium and product, which can accurately allocate the gain power of gain amplifiers at all levels and avoid the saturation of a gain amplifier.
[0004] In a first aspect, embodiments of the application provide a block generation method, and a blockchain includes a plurality of candidate nodes, and a candidate node is any one of the plurality of candidate nodes. The method comprises:
[0005] obtaining a random beacon for generating a first block, the random beacon of the first block including first random number data and a block height of the first block;
[0006] signing the random beacon of the first block by using a node private key to generate an election label of the candidate node, the election label being used for the candidate node to participate in consensus election;
[0007] generating a candidate vote number of the candidate node in the consensus election according to the election label of the candidate node and a node address, the candidate vote number being used for a consensus system to select a block generation node from the plurality of candidate nodes, so that the block generation node generates the first block.
[0008] In an optional embodiment of the first aspect, the random beacon for generating the first block is obtained, and the method comprises:
[0009] obtaining a random beacon of a second block, a domain label and an entropy value, the random beacon of the second block including second random number data and a block height of the second block;
[0010] sequentially concatenating the second random number data, the domain label, the block height of the second block and the entropy value to obtain concatenation data;
[0011] generating the first random number data based on the concatenation data;
[0012] determining the block height of the first block based on the block height of the second block.
[0013] In an optional embodiment of the first aspect, the first random number data is generated based on the spliced data, including:
[0014] The first random number data is generated by processing the spliced data using the first preset function.
[0015] In an optional embodiment of the first aspect, the election label of the candidate node is generated by signing the random beacon of the first block using the node private key, including:
[0016] The second preset function is called to sign the random beacon of the first block using the node private key to generate the election label of the candidate node.
[0017] In an optional embodiment of the first aspect, the number of votes of the candidate node in the current consensus election is generated according to the election label of the candidate node and the node address, including:
[0018] The node address of the candidate node and the election label of the candidate node are hashed to obtain a calculation result.
[0019] The calculation result is taken modulo a preset value to generate the number of votes of the candidate node in the current consensus election.
[0020] In a second aspect, the embodiments of the present application provide a block generation method, applied to a consensus system, including:
[0021] Obtaining the number of votes of each candidate node in the plurality of candidate nodes;
[0022] Determining the node with the largest number of votes in the plurality of candidate nodes as a block generation node based on the number of votes of each candidate node in the plurality of candidate nodes;
[0023] Obtaining the node information of the block generation node, the block label of the second block, and the transaction information within a preset time, the node information of the block generation node including the node private key of the block generation node, the election label of the block generation node, the node address of the block generation node, the number of votes of the block generation node, and the random beacon of the block generation node;
[0024] Generating the block label of the first block based on the node private key of the block generation node, the block label of the second block, and the election label of the block generation node;
[0025] Storing the node information of the block generation node and the transaction information within the preset time into the first block to generate the first block.
[0026] In a third aspect, the embodiments of the present application provide a block generation device, applied to a candidate node, the block chain including a plurality of candidate nodes, the candidate node being any one of the plurality of candidate nodes; the device includes:
[0027] an obtaining module configured to obtain a random beacon for generating a first block, the random beacon of the first block comprising first random number data and a block height of the first block;
[0028] a generating module configured to sign the random beacon of the first block by using a node private key, and to generate an election label of a candidate node, the election label being used for the candidate node to participate in a consensus election;
[0029] The generating module is further configured to generate a candidate vote number of the candidate node in the consensus election according to the election label of the candidate node and a node address, and the candidate vote number is used for the consensus system to select a block node from the plurality of candidate nodes, so that the block node generates the first block.
[0030] In a fourth aspect, an embodiment of the present application provides a block generation apparatus applied to a consensus system, and the apparatus comprises:
[0031] an obtaining module configured to obtain a candidate vote number of each candidate node in the plurality of candidate nodes;
[0032] a determining module configured to determine a node with the largest candidate vote number in the plurality of candidate nodes as a block node based on the candidate vote number of each candidate node in the plurality of candidate nodes;
[0033] The obtaining module is further configured to obtain node information of the block node, a block label of a second block, and transaction information within a preset time, and the node information of the block node comprises a node private key of the block node, an election label of the block node, a node address of the block node, a candidate vote number of the block node, and a random beacon of the block node.
[0034] a generating module configured to generate a block label of the first block based on the node private key of the block node, the block label of the second block, and the election label of the block node;
[0035] The generating module is further configured to store the node information of the block node and the transaction information within the preset time into the first block, so as to generate the first block.
[0036] In a third aspect, an electronic device is provided, which comprises a memory configured to store computer program instructions, and a processor configured to read and run the computer program instructions stored in the memory, so as to execute the block generation method provided in any optional embodiment of the first aspect.
[0037] In a fourth aspect, a computer storage medium is provided, and the computer storage medium stores computer program instructions, and the computer program instructions are executed by a processor to implement the block generation method provided in any optional embodiment of the first aspect.
[0038] In a fifth aspect, a computer program product is provided, the computer program product comprising a computer program which, when executed by a processor, implements the block generation method provided in any of the optional embodiments of the first aspect.
[0039] In the embodiments of the present application, the candidate node can obtain the random beacon used for generating the first block, and sign the random beacon of the first block using a node private key to generate an election label of the candidate node, the election label being used for the candidate node to participate in the consensus election. Based on this, the number of votes of the candidate node in the consensus election can be generated according to the election label and the node address of the candidate node. In this way, the block generation probability of all candidate nodes participating in the election can be equalized, and system centralization can be avoided. BRIEF DESCRIPTION OF DRAWINGS
[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required to be used in the embodiments of the present application will be briefly introduced as follows. Those skilled in the art can obtain other drawings according to these drawings without creative labor.
[0041] Figure 1 is a flowchart of a block generation method provided by the embodiments of the present application;
[0042] Figure 2 is a flowchart of another block generation method provided by the embodiments of the present application;
[0043] Figure 3 is a structural diagram of a block generation device provided by the embodiments of the present application;
[0044] Figure 4 is a structural diagram of a block generation device provided by the embodiments of the present application;
[0045] Figure 5 is a structural diagram of an electronic device provided by the embodiments of the present application. DETAILED DESCRIPTION
[0046] The features and exemplary embodiments of each aspect of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application more clear and apparent, the present application will be further described in detail below with reference to the drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, but not to limit the present application. The present application can be implemented without some of these specific details by those skilled in the art. The following description of the embodiments is only intended to provide a better understanding of the present application by showing examples of the present application.
[0047] It should be noted that, in this article, the relationship terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between the entities or operations. Moreover, the terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or equipment including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or equipment. Without more limitations, the elements defined by the statement "include" do not exclude the presence of other identical elements in the process, method, article or equipment including the elements.
[0048] The term "and / or" in this article is only a description of the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B, which can represent the three cases of A alone, A and B together, and B alone.
[0049] In order to solve the problem that the existing proof of stake consensus will lead to system centralization, the embodiments of the present application provide a block generation method, device, equipment, medium and product. The candidate node can obtain a random beacon for generating a first block, and sign the random beacon of the first block using a node private key to generate an election label of the candidate node. The election label is used for the candidate node to participate in the consensus election. Based on this, the number of votes of the candidate node in this consensus election can be generated according to the election label of the candidate node and the node address. In this way, the block generation probability of all candidate nodes participating in the election can be equal, and system centralization can be avoided.
[0050] The block generation method provided by the embodiments of the present application will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0051] Figure 1 is a flowchart of a block generation method provided by the embodiments of the present application.
[0052] As Figure 1 shown, the execution subject of the method can be a candidate node. It should be noted that the blockchain can include a plurality of candidate nodes, and the above-mentioned candidate node can be any one of the plurality of candidate nodes included in the blockchain. Based on this, the method can specifically include the following steps.
[0053] S110, obtaining a random beacon for generating a first block.
[0054] In some embodiments, the random beacon of the first block mentioned above can include first random number data and a block height of the first block.
[0055] S120, signing the random beacon of the first block by using the node private key to generate an election label of the candidate node.
[0056] The node private key can be a node private key of the candidate node and is stored in the candidate node. In addition, the election label is used for the candidate node to participate in the consensus election.
[0057] Specifically, after obtaining the random beacon used for generating the first block, the candidate node can sign the random beacon by using the node private key of the candidate node to generate the election label of the candidate node.
[0058] S130, generating a candidate vote number of the candidate node in the consensus election according to the election label of the candidate node and the node address.
[0059] The node address can be a node address of the candidate node.
[0060] In some embodiments, the candidate vote number is used for the consensus system to select a block node from the plurality of candidate nodes, so that the block node can generate the first block.
[0061] Specifically, after obtaining the election label of the candidate node in the consensus election, the candidate node can generate the candidate vote number of the candidate node in the consensus election based on the obtained election label of the candidate node and the node address of the candidate node.
[0062] In the embodiments of the present application, the candidate node can obtain the random beacon used for generating the first block, and sign the random beacon of the first block by using the node private key to generate the election label of the candidate node, which is used for the candidate node to participate in the consensus election. Based on this, the candidate vote number of the candidate node in the consensus election can be generated according to the election label of the candidate node and the node address. In this way, the block generation probability of all candidate nodes participating in the election can be equal, and the system centralization can be avoided.
[0063] In one embodiment, the S110 involved can include the following steps:
[0064] obtaining a random beacon, a domain label and an entropy value of the second block;
[0065] sequentially concatenating the second random number data, the domain label, the block height of the second block and the entropy value to obtain the concatenation data;
[0066] generating the first random number data based on the concatenation data;
[0067] determining the block height of the first block based on the block height of the second block.
[0068] In some embodiments, the random beacon of the second block can include the second random number data and the block height of the second block.
[0069] The domain tag can be used to represent the purpose of the random beacon, and the entropy value can represent the degree of dispersion of the second random number data.
[0070] Specifically, the candidate node can obtain the random beacon of the second block, the domain tag, and the entropy value. Since the random beacon of the second block can include the second random number data and the block height of the second block, the candidate node can sequentially concatenate the second random number data, the domain tag, the block height of the second block, and the entropy value to obtain the concatenated data, and then generate the first random number data based on the concatenated data. At the same time, after obtaining the block height of the second block, the candidate node can determine the block height of the first block based on the obtained block height of the second block.
[0071] In one example, after the candidate node obtains the random beacon of the second block, the domain tag, and the entropy value, the candidate node can process the random beacon of the second block, the domain tag, and the entropy value obtained by the candidate node to obtain the first random number data of the first block using a random beacon generation function. Specifically, the random beacon function can be as shown in the following formula (1):
[0072] Create_RandomBeacon(Domain_str, R1, chain_entropy) (1)
[0073] Wherein, Domain_str is the domain tag, which is a string type, representing the purpose of the random beacon, and can be set to "GongShi". R1 is the random beacon of the second block, which is a 256-bit string. chain_entropy is the entropy value, representing the degree of dispersion of the random number.
[0074] Based on this, the specific process of calculating the first random number data by the random beacon generation function based on the obtained random beacon of the second block, the domain tag, and the entropy value can be as follows:
[0075] 1) Read the second block, and obtain the random beacon R1, the domain tag, and the entropy value from the second block. R1 contains the block height nHeight-1 of the second block and the second random data DrandData1,
[0076] 2) Copy the second random data DrandData1 to the memory buffer.
[0077] 3) Append the "Gongshi" domain tag string in the buffer.
[0078] 4) Append nHeight-1 in the buffer.
[0079] 5) Append an entropy value in the buffer, which can be determined according to actual conditions. For example, the entropy value can be set to 62586.
[0080] 6) Process the content of the buffer to obtain 256-bit first random data DrandData.
[0081] In one example, the above-mentioned second block height based on the second block can be determined in the process of determining the block height of the first block. The sum of the block height of the second block and a preset value can be the block height of the first block, wherein the preset value can be a value set in advance based on actual experience or conditions. For example, the preset value can be set to 1, which is not limited here.
[0082] In this embodiment, the random beacon, domain label and entropy value of the second block can be obtained, and the second random number data, domain label, block height of the second block and entropy value can be spliced in sequence to obtain spliced data. Based on the spliced data, the first random number data is generated, and the block height of the first block is determined based on the block height of the second block. In this way, the random beacon of the candidate node can be accurately obtained.
[0083] In one embodiment, the above-mentioned step of generating the first random number data based on the spliced data can specifically include the following steps:
[0084] The spliced data is processed by using a first preset function to generate the first random number data.
[0085] The first preset function can be a function for generating random numbers based on actual experience or conditions. For example, the first preset function can include a blake2b.sum256 function.
[0086] Specifically, after obtaining the spliced data, the candidate node can process the spliced data by using the first preset function to generate the first random number data.
[0087] In this embodiment, the spliced data can be processed by using the first preset function to generate the first random number data, so that the number of votes of the candidate node can be generated based on the random number data in the subsequent process, ensuring that the block probability of all candidate nodes participating in the election is equal, and avoiding system centralization.
[0088] In one embodiment, the above-mentioned S120 can specifically include the following steps:
[0089] The second preset function is called to sign the random beacon by using the node private key to generate the election label of the candidate node.
[0090] The second preset function can be set in advance based on actual experience or a situation, for example, the second preset function can be a VRF function, which is not limited here.
[0091] Specifically, the candidate node can call the second preset function to sign the random beacon by using the node private key to generate the election label of the candidate node.
[0092] It should be noted that the VNF function can be used to verify which node signs the election label (ElectionTicketRandomness) of the node. For example, a user A uses a private key Pirvate_KeyA to sign a message M of an arbitrary data content by using a VRF function to generate a VRF output data VRF_O. A third party verifies the VRF_O by using the public key Publick_KeyA of the user A, M and VRF_O to verify that the VRF_O is signed by the private key of the user A. In the block label generation process, the third party verifies whether the block is generated by the block declaration node by using the VRF function. VRF_Node=VRF (worker private key of the node, random beacon R) to generate the election label (ElectionTicketRandomness) of the node.
[0093] In this embodiment, the second preset function can be called to sign the random beacon by using the node private key to generate the election label of the candidate node. In this way, the accuracy of the election label of the candidate node can be improved, and tampering can be avoided.
[0094] In one embodiment, the S130 described above can specifically include the following steps:
[0095] The node address of the candidate node and the election label of the candidate node are hashed to obtain a calculation result;
[0096] The calculation result is taken modulo a preset value to generate the number of votes of the candidate node in the current consensus election.
[0097] Specifically, the candidate node can hash the node address of the candidate node and the election label of the candidate node to obtain a calculation result, and then take the calculation result modulo a preset value to generate the number of votes of the candidate node in the current consensus election.
[0098] The preset value can be a numerical value set in advance based on actual experience or a situation, for example, the preset value can be set to 100, which is not limited here.
[0099] In one example, the step of obtaining the calculation result by hashing the node address of the candidate node and the election label of the candidate node can satisfy the following formula (2):
[0100] Calculation result = sha256(node address & election label) (2)
[0101] In this embodiment, the calculation result is obtained by hashing the node address of the candidate node and the election label of the candidate node, and the number of votes of the candidate node in the current consensus election is generated by taking the modulus of the preset value of the calculation result. In this way, the block probability of all candidate nodes participating in the election can be ensured to be equal, and system centralization can be avoided.
[0102] As shown in FIG. 1, the execution subject of the method can be a consensus system. Based on this, the method can include the following steps: Figure 2
[0103] S210, obtaining the number of votes of each candidate node in the plurality of candidate nodes.
[0104] In some embodiments, the number of votes of each candidate node is used for the candidate node to participate in the consensus election.
[0105] S220, determining the node with the most number of votes in the plurality of candidate nodes as the block node based on the number of votes of each candidate node in the plurality of candidate nodes.
[0106] Specifically, after obtaining the number of votes of each candidate node in the plurality of candidate nodes, the consensus system can determine the node with the most number of votes in the plurality of candidate nodes as the block node based on the number of votes of each candidate node in the plurality of candidate nodes.
[0107] S230, obtaining the node information of the block node, the block label of the second block, and the transaction information within the preset time.
[0108] Specifically, after determining the block node, the consensus system can obtain the node information of the block node, the block label of the second block, and the transaction information within the preset time, so as to subsequently generate the first block.
[0109] In some embodiments, the node information of the block node includes the node private key of the block node, the election label of the block node, the node address of the block node, the number of votes of the block node, and the random beacon of the block node. The random beacon of the block node can include random number data corresponding to the block node and the block height of the block node.
[0110] In addition, the preset time can be set in advance based on actual experience or situation, and will not be limited here. The transaction information in the preset time can be the transaction information in the preset time before the first block starts to be generated.
[0111] It should be noted that each node sets the block attribute of the block chain system to T seconds (a block is generated every T seconds), sets the calculation time of the block chain system to S seconds (a block is generated by the block node in S seconds), and sets the transaction time to M seconds (the transaction is completed within M seconds). After each node configures the static configuration parameters, link other nodes, enter the block chain network, participate in the block consensus calculation, and win, a block can be generated. That is, the period for generating a block is T seconds, and the transaction information in the preset time can be the transaction information generated between M seconds and (T-S) seconds.
[0112] S240, generating a block label of the first block based on the node private key of the block node, the block label of the second block, and the election label of the block node.
[0113] Specifically, after obtaining the node information of the block node and the block label of the second block, the consensus system can generate the block label of the first block based on the node private key of the block node, the block label of the second block, and the election label of the block node. Wherein, the block label can be a unique label of the first block, and the block label is generated in the current period. The block label can be used to link other blocks of the first block.
[0114] In one embodiment, S240 can specifically include the following steps:
[0115] The second preset function is called to sign the block label of the second block and the election label of the block node using the node private key of the block node to obtain the block label of the first block.
[0116] Wherein, the second preset function can be a function set in advance based on actual experience or situation, and will not be limited here.
[0117] Specifically, after obtaining the node information of the block node and the block label of the second block, the consensus system can call the second preset function, sign the block label of the second block and the election label of the block node using the node private key of the block node to obtain the block label of the first block.
[0118] S250, storing the node information of the block node and the transaction information in the preset time into the first block to generate the first block.
[0119] Specifically, after generating the block tag of the first block, the node information of the block node and the transaction information within the preset time can be stored in the first block to generate the first block.
[0120] It should be noted that after the first block is generated, the first block needs to be pushed into the block pool corresponding to the block node, and the Gossipsub protocol is used for network synchronization, so that the block set in the block pool of each node in the block chain is basically the same.
[0121] Based on this, it should also be noted that the block header and the message are propagated by using the Gossipsub protocol, which is a sub-protocol of the Gossip (Gossip) protocol. Gossipsub protocol is a classic case of pubsub publish / subscribe protocol. After a node subscribes to a title, it will receive messages related to the title. When the node receives the message subscribed by the node, the node will run a processing process: 1, pass the message to the application. 2, pass this message to other nodes that subscribe to the same title that this node knows. GossipSub protocol has a security mechanism, making the protocol elastic and preventing attacks. The GossipSub protocol specification provides all design principles, implementation methods, protocol details, and parameter settings. The specific form of the subscription title in the GossipSub protocol of the equal-probability block generation consensus system based on the domain value label entropy random beacon and the static configuration of block attributes is fil / blocks / WinCount001 and fil / msgs / WinCount001. The block pool of each node synchronizes the blocks in the block pool by subscribing to fil / blocks / WinCount001. The message pool of each node synchronizes the messages in the message pool by subscribing to fil / msgs / WinCount001. Each node sorts the block height by subscribing to the block tag. After 1 hour, each node writes the globally confirmed block into the shared ledger, completes global block confirmation, forms consensus, and extends the height of the block chain by 1 hour.
[0122] In the embodiment of the present application, the number of votes of each candidate node in the plurality of candidate nodes can be obtained, and the node with the largest number of votes in the plurality of candidate nodes is determined as the block node based on the number of votes of each candidate node in the plurality of candidate nodes, and then the node information of the block node, the block label of the second block and the transaction information within the preset time can be obtained, the node information of the block node includes the node private key of the block node, the election label of the block node, the node address of the block node, the number of votes of the block node and the random beacon of the block node, in this way, the block label of the first block can be generated based on the node private key of the block node, the block label of the second block and the election label of the block node, and the node information of the block node and the transaction information within the preset time are stored in the first block to generate the first block. In this way, the block probability of all candidate nodes participating in the election can be equal, and the system centralization is avoided
[0123] Based on the same inventive concept, the present application also provides a block generation device. The block generation device is applied to a candidate node, and the blockchain can include a plurality of candidate nodes. The candidate node can be any one of the plurality of candidate nodes included in the blockchain. Specifically, the block generation device includes Figure 3 The block generation device provided by the embodiment of the present application is described in detail.
[0124] Figure 3 FIG. 1 is a structural schematic diagram of a block generation device provided by an embodiment of the present application.
[0125] As shown in Figure 3 , the block generation device 300 can include an acquisition module 310 and a generation module 320.
[0126] The acquisition module 310 is configured to acquire a random beacon used for generating a first block, the random beacon of the first block including first random number data and a block height of the first block.
[0127] The generation module 320 is configured to sign the random beacon of the first block using a node private key, generate an election label of the candidate node, and the election label is used for the candidate node to participate in consensus election.
[0128] The generation module 320 is further configured to generate a number of votes of the candidate node in the consensus election according to the election label of the candidate node and the node address, and the number of votes is used for the consensus system to select a block node from the plurality of candidate nodes, so that the block node generates the first block.
[0129] In one embodiment, the block generation device mentioned above can further include a splicing module and a determination module.
[0130] The acquisition module is specifically configured to acquire a random beacon, a domain label, and an entropy value of a second block, the random beacon of the second block comprising a second random number data and a block height of the second block.
[0131] The splicing module is configured to sequentially splice the second random number data, the domain label, the block height of the second block, and the entropy value to obtain spliced data.
[0132] The generation module is further configured to generate the first random number data based on the spliced data.
[0133] The determination module is configured to determine the block height of the first block based on the block height of the second block.
[0134] In one embodiment, the generation module mentioned above is further configured to process the spliced data by using a first preset function to generate the first random number data.
[0135] In one embodiment, the block generation apparatus mentioned above can further comprise a calling module.
[0136] The calling module is configured to call a second preset function, and sign the random beacon of the first block by using a node private key to generate an election label of the candidate node.
[0137] In one embodiment, the block generation apparatus mentioned above can further comprise a calculation module.
[0138] The calculation module is configured to perform a hash calculation on the node address of the candidate node and the election label of the candidate node to obtain a calculation result.
[0139] The generation module is specifically configured to perform a modulus operation on the calculation result by using a preset value to generate a number of votes of the candidate node in the current consensus election.
[0140] In the embodiments of the present application, the candidate node can acquire the random beacon used to generate the first block, and sign the random beacon of the first block by using the node private key to generate the election label of the candidate node, which is used for the candidate node to participate in the consensus election. Based on this, the number of votes of the candidate node in the current consensus election can be generated according to the election label of the candidate node and the node address. In this way, the block generation probability of all candidate nodes participating in the election can be equalized, and the system centralization can be avoided.
[0141] The various modules in the block generation apparatus provided in the embodiments of the present application can be implemented Figure 1 The method steps of the embodiments shown above can achieve corresponding technical effects, and for brevity, will not be described here.
[0142] Furthermore, based on the same inventive concept, this application also provides a block generation apparatus. This block generation apparatus is applied to a public election system. (Specifically combined with...) Figure 4 The block generation apparatus provided in the embodiments of this application will be described in detail.
[0143] Figure 4 This is a schematic diagram of the structure of a block generation device provided in an embodiment of this application.
[0144] like Figure 4 As shown, the block generation device 300 may include: an acquisition module 410, a determination module 420, and a generation module 430.
[0145] The acquisition module 410 is used to acquire the number of votes for each candidate node among multiple candidate nodes;
[0146] The determination module 420 is used to determine the node with the most votes among multiple candidate nodes as the block producing node based on the number of votes for each candidate node among multiple candidate nodes;
[0147] The acquisition module 410 is also used to acquire the node information of the block-producing node, the block label of the second block, and transaction information within a preset time. The node information of the block-producing node includes the node private key of the block-producing node, the election label of the block-producing node, the node address of the block-producing node, the number of votes cast by the block-producing node, and the random beacon of the block-producing node.
[0148] The generation module 430 is used to generate the block label of the first block based on the node private key of the block-producing node, the block label of the second block, and the election label of the block-producing node.
[0149] The generation module 430 is also used to generate the first block by storing the node information of the block-producing node and the transaction information within a preset time period into the first block.
[0150] In this embodiment, the number of votes for each of the multiple candidate nodes can be obtained. Based on the number of votes for each candidate node, the node with the most votes is determined as the block-producing node. Then, the node information of the block-producing node, the block tag of the second block, and transaction information within a preset time period can be obtained. The node information of the block-producing node includes its private key, election tag, node address, number of votes, and random beacon. Thus, based on the private key, the block tag of the second block, and the election tag, the block tag of the first block can be generated. The first block is generated by storing the node information and transaction information within the preset time period in the first block. This ensures that all participating candidate nodes have an equal probability of producing blocks, avoiding system centralization.
[0151] The various modules in the block generation apparatus provided by the embodiments of the present application can implement the method steps of the embodiments as shown in the Figure 2 The method steps of the embodiments as shown in the drawings can achieve corresponding technical effects, and are not described herein for brevity.
[0152] Figure 5 A hardware structure schematic diagram of an electronic device provided by the embodiments of the present application is shown.
[0153] The electronic device can include a processor 501 and a memory 502 storing computer program instructions.
[0154] Specifically, the processor 501 can include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or can be configured as one or more integrated circuits implementing the embodiments of the present application.
[0155] The memory 502 can include a mass storage for data or instructions. By way of example and not limitation, the memory 502 can include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. Where appropriate, the memory 502 can include removable or non-removable (or fixed) media. Where appropriate, the memory 502 can be internal or external to the integrated gateway disaster recovery device. In certain embodiments, the memory 502 is non-volatile solid-state memory.
[0156] The memory can include read-only memory (ROM), random-access memory (RAM), magnetic disk storage media devices, optical storage media devices, flash memory devices, electrical, optical, or other physical / tangible memory storage devices. Thus, in general, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software that, when executed (by one or more processors), is operable to perform operations described with reference to the methods according to an aspect of the present disclosure.
[0157] The processor 501 reads and executes the computer program instructions stored in the memory 502 to implement any one of the block generation methods in the above embodiments.
[0158] In one example, the electronic device can further include a communication interface 503 and a bus 510. Wherein, as shown in Figure 5As shown, the processor 501, the memory 502, and the communication interface 503 are connected by the bus 510 and accomplish the communication between each other.
[0159] The communication interface 503 is mainly used to realize the communication between the modules, devices, units and / or equipment in the embodiments of the application.
[0160] The bus 510 includes hardware, software or both to couple the components of the online data traffic billing device to each other. By way of example, and not limitation, the bus can include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand (IB) interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or another suitable bus or a combination of two or more of these. Where suitable, the bus 510 can include one or more buses. Although specific buses are described and illustrated in the embodiments of the application, the application contemplates any suitable bus or interconnect.
[0161] In addition, in combination with the block generation method in the above-mentioned embodiments, the embodiments of the application can provide a computer storage medium for implementation. The computer storage medium has computer program instructions stored thereon; the computer program instructions are executed by a processor to implement the block generation method provided by the embodiments of the application.
[0162] The embodiments of the application also provide a computer program product, instructions in the computer program product are executed by a processor of an electronic device to enable the electronic device to execute the block generation method provided by the embodiments of the application.
[0163] It needs to be clear that the application is not limited to the specific configurations and processes described above and shown in the drawings. For the sake of brevity, detailed descriptions of well-known methods are omitted here. In the above-mentioned embodiments, several specific steps are described and shown as examples. However, the method process of the application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between steps, after understanding the spirit of the application.
[0164] The functional blocks shown in the structural block diagrams above can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application specific integrated circuits (ASICs), appropriate firmware, plug-ins, functional cards, and the like. When implemented in software, the elements of the present application are program or code segments that are used to perform the required tasks. The program or code segments can be stored in a machine-readable medium, or transmitted through a data signal carried in a carrier wave over a transmission medium or communication link. A "machine-readable medium" includes any medium that can store or transport information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROMs, flash memory, erasable ROMs (EROMs), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, and the like. The code segments can be downloaded via computer networks such as the Internet, intranets, and the like.
[0165] It is also important to note that the examples in the present application are described based on a series of steps or units for performing some methods or systems. However, the present application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the examples, or in an order different from the examples, or several steps can be performed simultaneously.
[0166] The above generally describes aspects of the present application with reference to a flowchart and / or a block diagram of methods, apparatus (systems) and computer program products according to embodiments of the present application. It should be understood that each block of the flowchart and / or block diagram, and combinations of blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / acts specified in the flowchart and / or block diagram block or blocks. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special-purpose application processor, or a field programmable logic array (FPLA). It should also be understood that each block of the flowchart and / or block diagram, and combinations of blocks in the flowchart and / or block diagram, can also be implemented by dedicated hardware, or a combination of hardware and computer instructions. The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable data processing apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable data processing apparatus provide steps for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks.
[0167] The above is only a specific implementation of the present application, and those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described system, module and unit can refer to the corresponding process in the foregoing method embodiments, which will not be described here. It should be understood that the protection scope of the present application is not limited thereto, and any skilled person in the art can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be covered within the protection scope of the present application.
Claims
1. A block generation method comprising: The application is applied to a candidate node, a blockchain includes a plurality of candidate nodes, and the candidate node is any one of the plurality of candidate nodes; the method includes: Obtaining a random beacon for generating a first block, the random beacon of the first block including first random number data and a block height of the first block; Signing the random beacon of the first block by using a node private key to generate an election label of the candidate node, the election label being used for the candidate node to participate in consensus election; According to the election label and the node address of the candidate node, generating a candidate vote number of the candidate node in this consensus election, the candidate vote number being used for the consensus system to screen a block node from the plurality of candidate nodes, so that the block node generates a first block; The candidate vote number of the candidate node in the consensus election is generated according to the election label and the node address of the candidate node, including: By hashing the node address of the candidate node and the election label of the candidate node, a calculation result is obtained; By taking a preset value of the calculation result, the candidate vote number of the candidate node in the consensus election is generated.
2. The method of claim 1, wherein, The random beacon for generating the first block is obtained, including: Obtaining a random beacon of a second block, a domain label and an entropy value, the random beacon of the second block including second random number data and a block height of the second block; Concatenating the second random number data, the domain label, the block height of the second block and the entropy value in sequence to obtain concatenation data; Based on the concatenation data, the first random number data is generated; Based on the block height of the second block, the block height of the first block is determined.
3. The method of claim 2, wherein, The first random number data is generated based on the concatenation data, including: The first random number data is generated by processing the concatenation data by using a first preset function.
4. The method of claim 1, wherein, The random beacon of the first block is signed by using the node private key to generate the election label of the candidate node, including: A second preset function is called, and the random beacon of the first block is signed by using the node private key to generate the election label of the candidate node.
5. A block generation method characterized by comprising: The application is applied to a consensus system, and the method includes: Obtaining a candidate vote number of each candidate node in a plurality of candidate nodes; the candidate vote number is generated by a candidate node according to an election label and a node address of the candidate node; the election label is generated by signing a random beacon by using a node private key of the candidate node; the random beacon includes first random number data and a block height of a first block; Based on the candidate vote number of each candidate node in the plurality of candidate nodes, determining that a node with the largest candidate vote number in the plurality of candidate nodes is a block node; Obtaining node information of the block node, a block label of a second block and transaction information within a preset time, the node information of the block node including a node private key of the block node, an election label of the block node, a node address of the block node, a candidate vote number of the block node and a random beacon of the block node; generate a block label of the first block based on a node private key of the block-producing node, the block label of the second block, and the election label of the block-producing node; generate the first block by storing node information of the block-producing node and transaction information within a preset time into the first block.
6. A block generating apparatus characterized by comprising: The application is applied to a candidate node, and a block chain includes a plurality of candidate nodes, and the candidate node is any one of the plurality of candidate nodes. The device includes: The obtaining module is configured to obtain a random beacon used to generate a first block, the random beacon of the first block including first random number data and a block height of the first block. The generating module is configured to sign the random beacon of the first block by using a node private key to generate an election label of the candidate node, the election label being used for the candidate node to participate in consensus election. The generating module is further configured to generate a candidate vote number of the candidate node in the current consensus election according to the election label of the candidate node and a node address, the candidate vote number being used for the consensus system to screen a block-producing node from the plurality of candidate nodes, so that the block-producing node generates the first block. The computing module is configured to perform hash calculation on the node address of the candidate node and the election label of the candidate node to obtain a calculation result. The generating module is specifically configured to perform modulo calculation on the calculation result by using a preset value to generate the candidate vote number of the candidate node in the current consensus election.
7. A block generating apparatus characterized by comprising: The application is applied to a consensus system, and the device includes: The obtaining module is configured to obtain a candidate vote number of each candidate node in a plurality of candidate nodes, the candidate vote number being generated by a candidate node according to an election label of the candidate node and a node address, the election label being generated by the candidate node by signing a random beacon by using a node private key, and the random beacon including first random number data and a block height of a first block. The determining module is configured to determine a node with the largest candidate vote number in the plurality of candidate nodes as a block-producing node based on the candidate vote number of each candidate node in the plurality of candidate nodes. The obtaining module is further configured to obtain node information of the block-producing node, a block label of a second block, and transaction information within a preset time, the node information of the block-producing node including a node private key of the block-producing node, an election label of the block-producing node, a node address of the block-producing node, a candidate vote number of the block-producing node, and a random beacon of the block-producing node. The generating module is configured to generate a block label of the first block based on a node private key of the block-producing node, the block label of the second block, and the election label of the block-producing node. The generating module is further configured to generate the first block by storing the node information of the block-producing node and the transaction information within the preset time into the first block.
8. An electronic device, comprising: The device includes a processor and a memory storing computer program instructions. The processor reads and executes the computer program instructions to implement the block generation method in any one of claims 1-5.
9. A computer storage medium, characterized in that The computer storage medium stores computer program instructions, and the computer program instructions are executed by the processor to implement the block generation method in any one of claims 1-5.
10. A computer program product, characterised in that, The computer program product comprises a computer program which, when executed by a processor, implements the block generation method of any one of claims 1-5.
Citation Information
Patent Citations
Non-mortgage secret election method based on linkable ring signature and sliding window
CN115314351A
Data processing method and device based on block chain and readable storage medium
CN116542668A