Generation method and device for genesis block
By using preset algorithms and consensus mechanisms in the blockchain network, the target nodes are determined to create the Chuangshi block, which solves the problem of low security in the Chuangshi block and achieves the security improvement of the blockchain network.
Patent Information
- Application Number
- CN202210724963.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-24
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2042-06-24
AI Technical Summary
In the prior art, the security of the Genesis block is too low and is easily tampered with by attackers, resulting in malicious control of the blockchain network.
The first blockchain is set up through the first preset algorithm, and each first block is calculated using multiple network nodes, and the target node creates a genealogy block, builds a second blockchain, and uses a hash function algorithm and consensus mechanism to verify and compete mechanism to ensure the security of the blockchain.
It improves the security of the Creation Block, reduces the possibility of attackers tampering with the blockchain, ensures that the Creation Block is generated in the target node, and enhances the security of the blockchain network.
Smart Images

Figure CN115033644B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network technologies, and in particular, to a method and device for generating a genesis block. Background Art
[0002] A blockchain is a decentralized data storage form, which is a chain-like "list" composed of multiple blocks simultaneously saved by multiple nodes in a network, with a continuously growing and neatly sorted storage method. At the same time, the most significant feature of the blockchain is that when generating or modifying a block, it is often achieved through "voting" among all nodes having the blockchain. That is to say, when more than a certain number of nodes agree that a certain node adds or modifies a block in the blockchain, the blockchain will update the entire blockchain based on the modification or addition behavior of that node. Therefore, at the beginning of creating any blockchain, the number of blocks added to the blockchain is small, and the number of nodes in the blockchain network is also relatively small. At this time, attackers can easily take advantage of the small number of nodes and launch attacks through a certain number of hacker nodes, thereby resetting the blockchain. Especially for the first block in the blockchain, that is, the genesis block, when the genesis block is tampered with, based on the characteristics of the genesis block, a new blockchain that conforms to the attacker's intention will be regenerated. According to the characteristics of the blockchain network, this new blockchain will become the main chain. Therefore, how to prevent the genesis block from being tampered with by attackers at the beginning of the blockchain network creation and resulting in the malicious control of the blockchain network has become an urgent problem to be solved.
[0003] In the prior art, generally, the genesis block is saved in the blockchain software in a hard-coded form. However, in practical applications, since the genesis block hard code is placed in the blockchain software, attackers can directly control more than half of the nodes to run and tamper with the blockchain software of the genesis block or attack the server that publishes the blockchain software and upload the tampered blockchain software to achieve the purpose of modifying the genesis block, resulting in the problem of too low security of the genesis block. Summary of the Invention
[0004] Embodiments of this application provide a method and device for generating a genesis block, mainly aiming to solve the problem of too low security of the current genesis block.
[0005] To solve the above technical problems, the embodiments of this application provide the following technical solutions:
[0006] In a first aspect, this application provides a method for generating a genesis block, the method including:
[0007] Setting a first blockchain based on a first preset algorithm, where each first block in the first blockchain is a block to be authenticated, and the block to be authenticated is a block that contains output data and unknown input data;
[0008] Each of the first blocks in the first blockchain is calculated by multiple network nodes to obtain a second block, and the network node that generates the second block among the multiple network nodes is determined as the target node, where the second block is a block obtained after the target node determines the input data of the first block through a second preset algorithm;
[0009] Create the genesis block according to the target node, and the genesis block is used to construct a second blockchain.
[0010] Optionally, the first preset algorithm is a hash function algorithm;
[0011] The setting of the first blockchain based on the first preset algorithm includes:
[0012] Set the first blockchain and the verification data packet in a preset blockchain running device, and distribute the preset blockchain running device to each of the network nodes;
[0013] Among them, the preset blockchain running device is used for multiple network nodes to perform blockchain construction operations, the verification data packet includes the data content of the alternative first blockchain and the length information corresponding to the alternative first blockchain, and the length information is used to represent the number of the first blocks in the alternative first blockchain;
[0014] The calculation of each of the first blocks in the first blockchain by multiple network nodes to obtain a second block, and the determination of the network node that generates the second block among the multiple network nodes as the target node includes:
[0015] Obtain the length information from each of the network nodes, and determine the alternative first blockchain with the largest number of the first blocks as the first blockchain based on the length information;
[0016] Use a consensus mechanism to run the preset blockchain running device among multiple network nodes, so as to calculate the input data of each of the first blocks in the first blockchain by using a competition mechanism to obtain the second block, where the competition mechanism is that when multiple network nodes calculate the output data, there is only one operation time to correctly obtain the output data;
[0017] Determine the network node that generates the input data among the multiple network nodes as the target node.
[0018] Optionally, the second preset algorithm is an exhaustive algorithm. The preset blockchain running device is run among multiple network nodes by using the consensus mechanism, so as to calculate the input data of each first block in the first blockchain by using the competition mechanism to obtain the second block. The competition mechanism refers to the number of operations for correctly obtaining the output data only once when multiple network nodes calculate the output data, including:
[0019] Calculate the alternative input data through the preset blockchain running device and the exhaustive algorithm for the output data of the first block;
[0020] Distribute the alternative input data to the remaining network nodes, and determine whether the alternative input data passes the verification, where the remaining network nodes are the remaining nodes among the multiple network nodes except those that generate the alternative input data;
[0021] If it passes, determine the alternative input data as the input data, and update the first block according to the input data to obtain the second block.
[0022] Optionally, the distributing the alternative input data to the remaining network nodes and determining whether the alternative input data passes the verification includes:
[0023] Obtain the verification results from each of the remaining nodes;
[0024] Wherein, the verification results include a first verification result and a second verification result; the first verification result is used to indicate that the remaining nodes determine that the calculation result is consistent with the output data of the first block after calculating the calculation result based on the alternative input data and the hash function algorithm; the second verification result is used to indicate that the remaining nodes determine that the calculation result is inconsistent with the output data of the first block after calculating the calculation result based on the alternative input data and the hash function algorithm;
[0025] Judge whether the number of the first verification results among the multiple verification results exceeds a first preset threshold, and the first preset threshold is determined based on the proportion of the multiple network nodes;
[0026] The if it is determined that the alternative input data passes the verification, then determining the alternative input data as the input data, and updating the first block according to the input data to obtain the second block includes:
[0027] If it is determined that the number of the first verification results exceeds the first preset threshold, then determine the alternative input data as the input data, and update the first block according to the input data to obtain the second block.
[0028] Optionally, updating the first block according to the input data to obtain the second block includes:
[0029] Updating the first block based on the input data by the current network node to obtain the second block, adding the network node mark of the current network node to the second block, and distributing the second block and the network node mark to the remaining nodes so that the remaining nodes replace the first block based on the second block;
[0030] Or,
[0031] Each network node synchronously updates the first block according to the input data to obtain the second block, and adds the network node mark of the network node that obtains the input data to the second block.
[0032] Optionally, creating the genesis block according to the target node includes:
[0033] Determining a genesis node among multiple target nodes through a candidate algorithm, and constructing the genesis block based on the genesis node.
[0034] Optionally, after determining a genesis node among multiple target nodes through a candidate algorithm and constructing the genesis block based on the genesis node, the method further includes:
[0035] Adding the genesis node mark of the genesis node to the genesis block, and distributing the genesis block and the genesis node mark to multiple network nodes through the genesis node;
[0036] Determining whether the genesis block passes verification through the feedback information of the target node;
[0037] If it is determined based on the feedback information that the genesis block passes the verification of the target node, adding the genesis block to multiple network nodes so as to construct the second blockchain based on the genesis block.
[0038] Optionally, determining whether the genesis block passes verification through the feedback information of the target node includes:
[0039] Obtain feedback information from each of the target nodes, where the feedback information includes first feedback information and second feedback information; the first feedback information is used to represent that after determining the network node mark corresponding to the genesis node from the first blockchain through the target node, it is determined that the network node mark is consistent with the genesis node mark; the second feedback information is used to represent that after determining the network node mark corresponding to the genesis node from the first blockchain through the target node, it is determined that the network node mark is inconsistent with the genesis node mark;
[0040] Judge whether the quantity of the first feedback information in the feedback information exceeds a second preset threshold;
[0041] If it is determined that the genesis block passes the verification of the target node based on the feedback information, then add the genesis block among multiple network nodes so as to construct the second blockchain based on the genesis block, including:
[0042] If it is determined that the quantity of the first feedback information exceeds the second preset threshold, add the genesis block among multiple network nodes so as to construct the second blockchain based on the genesis block.
[0043] Optionally, the network node mark is obtained by calculating the first data corresponding to the network node that generates the input data through the hash function algorithm; where the first data is the public key of the network node, or the public key and the content data of the first blockchain;
[0044] The genesis node mark is obtained by calculating the second data of the genesis node through the hash function algorithm; where the second data is the public key of the genesis node, or the public key and the content data of the first blockchain.
[0045] In a second aspect, the present application further provides a genesis block generation device, including:
[0046] A setting unit, configured to set a first blockchain based on a first preset algorithm, each first block in the first blockchain being a block to be authenticated, the block to be authenticated being a block that includes output data and unknown input data, and the output data being obtained based on the first preset algorithm;
[0047] A first determination unit, configured to calculate, through multiple network nodes, each of the first blocks in the first blockchain to obtain a second block, and determine the network node that generates the second block among the multiple network nodes as a target node, where the second block is a block obtained after the target node determines the input data of the first block through a second preset algorithm;
[0048] A creation unit for creating the genesis block according to the target node, where the genesis block is used to construct a second blockchain.
[0049] Optionally, the first preset algorithm is a hash function algorithm;
[0050] The setting unit is specifically configured to set the first blockchain and the verification data packet in a preset blockchain running device, and distribute the preset blockchain running device to each of the network nodes;
[0051] Wherein, the preset blockchain running device is used for multiple network nodes to perform blockchain construction operations, the verification data packet includes the data content of the alternative first blockchain and the length information corresponding to the alternative first blockchain, and the length information is used to represent the number of the first blocks in the alternative first blockchain;
[0052] The first determination unit includes:
[0053] A first determination subunit for obtaining the length information from each of the network nodes, and determining the alternative first blockchain with the largest number of the first blocks as the first blockchain based on the length information;
[0054] An operation subunit for running the preset blockchain running device among multiple network nodes by using a consensus mechanism, so as to calculate the input data of each of the first blocks in the first blockchain by using a competition mechanism to obtain the second block, where the competition mechanism is the number of operations for correctly obtaining the output data only once when multiple network nodes calculate the output data;
[0055] A second determination subunit for determining the network node that generates the input data among multiple network nodes as the target node.
[0056] Optionally, the second preset algorithm is an exhaustive algorithm;
[0057] The operation subunit includes:
[0058] A calculation module for calculating the output data of the first block through the preset blockchain running device and the exhaustive algorithm to obtain alternative input data;
[0059] A first determination module for distributing the alternative input data to the remaining network nodes and determining whether the alternative input data passes the verification, where the remaining network nodes are the remaining nodes among multiple network nodes except the nodes that generate the alternative input data;
[0060] A second determination module, configured to, if the alternative input data is distributed to the remaining network nodes and it is determined that the alternative input data passes the verification, determine the alternative input data as the input data, and update the first block according to the input data to obtain the second block.
[0061] Optionally, the first determination module includes:
[0062] An acquisition sub-module, configured to acquire verification results from each of the remaining nodes;
[0063] Wherein, the verification results include a first verification result and a second verification result; the first verification result is used to characterize that the remaining nodes determine that the calculation result is consistent with the output data of the first block after calculating the calculation result based on the alternative input data and the hash function algorithm; the second verification result is used to characterize that the remaining nodes determine that the calculation result is inconsistent with the output data of the first block after calculating the calculation result based on the alternative input data and the hash function algorithm;
[0064] A judgment sub-module, configured to judge whether the number of the first verification results among the multiple verification results exceeds a first preset threshold, and the first preset threshold is determined based on the proportion of the multiple network nodes;
[0065] The second determination module is specifically configured to, if it is determined that the number of the first verification results exceeds the first preset threshold, determine the alternative input data as the input data, and update the first block according to the input data to obtain the second block.
[0066] Optionally, the second determination module includes:
[0067] A first update sub-module, configured to update the first block based on the input data by the current network node to obtain the second block, and add a network node mark of the current network node to the second block, and distribute the second block and the network node mark to the remaining nodes, so that the remaining nodes replace the first block based on the second block;
[0068] A second update sub-module, configured to each network node synchronously update the first block according to the input data to obtain the second block, and add a network node mark of the network node that obtains the input data to the second block.
[0069] Optionally, the creation unit is specifically configured to determine a genesis node from multiple target nodes through a candidate algorithm, and construct the genesis block based on the genesis node.
[0070] Optionally, the apparatus further includes:
[0071] The first adding unit is configured to add the creation node mark of the creation node to the creation block, and distribute the creation block and the creation node mark to a plurality of the network nodes through the creation node;
[0072] The second determining unit is configured to determine whether the creation block passes the verification through the feedback information of the target node;
[0073] The second adding unit is configured to add the creation block to a plurality of the network nodes if it is determined based on the feedback information that the creation block passes the verification of the target node, so as to construct the second blockchain based on the creation block.
[0074] Optionally, the second determining unit includes:
[0075] An obtaining subunit is configured to obtain feedback information from each of the target nodes, where the feedback information includes first feedback information and second feedback information; the first feedback information is used to represent that after determining the network node mark corresponding to the creation node from the first blockchain through the target node, it is determined that the network node mark is consistent with the creation node mark; the second feedback information is used to represent that after determining the network node mark corresponding to the creation node from the first blockchain through the target node, it is determined that the network node mark is inconsistent with the creation node mark;
[0076] A judging subunit is configured to judge whether the quantity of the first feedback information in the feedback information exceeds a second preset threshold;
[0077] The second adding unit is specifically configured to add the creation block to a plurality of the network nodes if it is determined that the quantity of the first feedback information exceeds the second preset threshold, so as to construct the second blockchain based on the creation block.
[0078] Optionally, the network node mark is obtained by calculating the first data corresponding to the network node that generates the input data through the hash function algorithm; where the first data is the public key of the network node, or the public key and the content data of the first blockchain;
[0079] The creation node mark is obtained by calculating the second data of the creation node through the hash function algorithm; where the second data is the public key of the creation node, or the public key and the content data of the first blockchain.
[0080] In a third aspect, an embodiment of the present application provides a storage medium, which includes a stored program. When the program runs, it controls the device where the storage medium is located to execute the genesis block generation method according to any one of the first aspects.
[0081] In a fourth aspect, an embodiment of the present application provides a genesis block generation device, which includes a storage medium and one or more processors. The storage medium is coupled to the processor, and the processor is configured to execute program instructions stored in the storage medium. When the program instructions run, they execute the genesis block generation method according to any one of the first aspects.
[0082] By means of the above technical solutions, the technical solutions provided by the present application have at least the following advantages:
[0083] The present application provides a method and a device for generating a genesis block. The present application can set a first blockchain based on a first preset algorithm. Each first block in the first blockchain is a block to be authenticated, and the block to be authenticated is a block that contains output data and unknown input data. By calculating each of the first blocks in the first blockchain through multiple network nodes, a second block is obtained, and the network node that generates the second block among the multiple network nodes is determined as the target node. The second block is a block obtained after the target node determines the input data of the first block through a second preset algorithm. The genesis block is created according to the target node, and the genesis block is used to construct a second blockchain. Compared with the prior art, in the present application, by setting the first blockchain through the first preset algorithm, the process of calculating the second block by multiple network nodes through each block in the first blockchain actually confirms which of the multiple network nodes conform to the first preset algorithm, thereby increasing the difficulty for an attacker to tamper with the blockchain. The genesis block is implemented based on the target node, ensuring that even if a certain number of network nodes are tampered with, it cannot be guaranteed that the tampered network nodes by the attacker will become the target node to participate in the creation of the genesis block. It can be seen that the present application actually enables multiple network nodes to compete to become the target node, thereby ensuring that in the subsequent process of creating the genesis block, the possibility that the tampered network nodes by the attacker become the target node is greatly reduced, thus improving the security of the genesis block. That is to say, the genesis block in the present application is created and generated in the target node, rather than directly placing the genesis block in the blockchain software, solving the problem in the prior art that an attacker can directly control more than a certain number of nodes to run and tamper with the blockchain software of the genesis block or attack the server that publishes the blockchain software to modify the genesis block, thereby improving the security of the genesis block.
[0084] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features and advantages of this application more obvious and understandable, the following specifically illustrates the specific implementation manners of this application. BRIEF DESCRIPTION OF THE DRAWINGS
[0085] By reading the following detailed description with reference to the accompanying drawings, the above and other purposes, features and advantages of the exemplary embodiments of this application will become understandable. In the drawings, several embodiments of this application are shown in an exemplary rather than restrictive manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0086] Figure 1 The flowchart of a method for generating a genesis block provided by an embodiment of this application is shown;
[0087] Figure 2 The flowchart of another method for generating a genesis block provided by an embodiment of this application is shown;
[0088] Figure 3 The block diagram of a device for generating a genesis block provided by an embodiment of this application is shown;
[0089] Figure 4 The block diagram of another device for generating a genesis block provided by an embodiment of this application is shown. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0090] The exemplary embodiments of this application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of this application are shown in the drawings, it should be understood that this application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that this application can be more thoroughly understood and the scope of this application can be fully conveyed to those skilled in the art.
[0091] It should be noted that unless otherwise specified, the technical terms or scientific terms used in this application should have the ordinary meanings understood by those skilled in the art to which this application belongs.
[0092] An embodiment of this application provides a method for generating a genesis block, specifically as Figure 1 shown, the method includes:
[0093] 101. Set a first blockchain based on a first preset algorithm.
[0094] Each first block in the first blockchain is a block to be authenticated. The block to be authenticated is a block that contains output data and unknown input data, and the output data is obtained based on the first preset algorithm.
[0095] Among them, the first preset algorithm refers to generating an output of a specific length from the received input. It can be seen that there is a certain computational relationship between the unknown input and the output data, which can prevent attackers or hackers from arbitrarily tampering with the data of the blocks in the first blockchain without knowing the algorithm, thereby improving the security of the first blockchain. Each first block in the first blockchain is called a block to be authenticated. The block to be authenticated means that all the genesis blocks in the first blockchain are marked as 0, and the unknown input and the node public key are initially empty.
[0096] Generally speaking, a large number of nodes running blockchain software are involved in the process of building a blockchain. These nodes can be referred to as the network nodes described in this embodiment. According to the characteristics of the blockchain building process, through voting verification among multiple nodes, when more than a certain number of nodes pass the verification, the blocks in the blockchain can be rewritten based on the verification results of these nodes. That is to say, when an attacker launches an attack, when the number of nodes it controls exceeds a certain proportion, based on the above principle, it is very easy to modify the blocks in the blockchain through voting verification, so as to achieve the effect of tampering with the data in the blockchain. However, at the beginning of the creation of the blockchain network, the number of nodes added to the blockchain network is still relatively small, and it is very easy for an attacker to launch a certain number of attacks.
[0097] Therefore, the process of setting the blockchain through the first preset algorithm in this application can provide an algorithm basis for the subsequent selection of target nodes by each network node, thereby increasing the difficulty for an attacker to become a target node.
[0098] 102. Calculate each first block in the first blockchain through multiple network nodes to obtain a second block, and determine the network node that generates the second block among the multiple network nodes as the target node.
[0099] Among them, the second block is the block obtained after the target node determines the input data of the first block through the second preset algorithm.
[0100] Based on the characteristic of the blockchain that it is a chain-like structure composed of multiple blocks in a certain order, therefore, in the process of building a blockchain, actually multiple computers need to participate. In the network composed of these computers, each computer is equivalent to a node in this network. Therefore, the network nodes described in this embodiment can be understood as these computers that want to participate in building the first blockchain.
[0101] After setting the first blockchain in the above step 101, since the first blocks in the first blockchain are all blocks of unknown input data, that is, unauthenticated blocks, in this step, calculation operations can be performed simultaneously on multiple network nodes to calculate the actual values of the unknown inputs of each first block. Specifically, in this step, each first block in the first blockchain can be calculated by the second preset algorithm. The second preset algorithm refers to substituting each input data to be verified in sequence when the output data is known until the result obtained by a certain input data to be verified through the first preset algorithm is consistent with the output data, and then this input data to be verified is confirmed as the input data.
[0102] If a certain network node in the first blockchain calculates the result corresponding to the output data in the first block through the second preset algorithm, the unknown input of the first block is updated to this calculation result to obtain the second block, and this network node is determined as the target node. That is to say, in the process of determining the target node, in fact, it is a process in which multiple network nodes calculate the results corresponding to the output data of each first block through the second preset algorithm. Since the network nodes determine the input data corresponding to the output data in a "competitive" manner with each other, different first blocks are updated to the second block after the output data is calculated by different network nodes.
[0103] Based on this, the target node in this step is determined by multiple network nodes in a competitive manner, which can greatly reduce the possibility of an attacker or hacker becoming the target node. Especially when they do not know the first preset algorithm, it is difficult to know the logical relationship between the output data and the input data, thus avoiding the situation where a large number of network nodes controlled by attackers or hackers become the target node.
[0104] Since the second block is the block obtained after the target node determines the input data of the first block through the second preset algorithm, when the first preset algorithm is unknown, it is impossible to know the relationship between the input data and the output data in the block, and then it is impossible to use the second preset algorithm to calculate the corresponding input data based on the output data, and thus it is impossible to realize the update from the first block to the second block, and thus it is impossible to become the target node, so as to exclude the nodes of hackers or attackers.
[0105] 103. Create the genesis block according to the target node.
[0106] The genesis block is used to construct the second blockchain.
[0107] Based on the description in the foregoing step 102, since it is difficult for an attacker to participate in the generation process of the second block when the attacker does not know exactly what the first preset algorithm is, this ensures that it is difficult for network nodes controlled by the attacker or hacker to become target nodes. At the same time, the genesis block is precisely created by the target node during the construction process of the second block. In this way, the possibility that network nodes controlled by the attacker or hacker penetrate into the cluster of target nodes to tamper with the genesis node is avoided, greatly improving the security during the establishment process of the genesis block, thereby laying a foundation for the security of the second blockchain constructed based on the genesis block.
[0108] This application provides a method for generating a genesis block. This application can set a first blockchain based on a first preset algorithm. Each first block in the first blockchain is a block to be authenticated. The block to be authenticated is a block that contains output data and unknown input data. By calculating each of the first blocks in the first blockchain through multiple network nodes, a second block is obtained, and the network node that generates the second block among the multiple network nodes is determined as the target node. Among them, the second block is a block obtained after the target node determines the input data of the first block through a second preset algorithm. The genesis block is created according to the target node, and the genesis block is used to construct a second blockchain. Compared with the prior art, in this application, by setting the first blockchain through the first preset algorithm, the process of calculating the second block by multiple network nodes through each block in the first blockchain is actually to confirm which of the multiple network nodes conform to the first preset algorithm, further increasing the difficulty for an attacker to tamper with the blockchain. The genesis block is implemented based on the target node, ensuring that even if a certain number of the network nodes are tampered with, it cannot be guaranteed that the network nodes tampered with by the attacker will become the target nodes to participate in the creation of the genesis block. It can be seen that this application actually enables multiple network nodes to compete to become the target node, thereby ensuring that in the subsequent process of creating the genesis block, the possibility that the network nodes tampered with by the attacker become the target nodes is greatly reduced, thereby improving the security of the genesis block. That is to say, the genesis block in this application is created and generated in the target node, rather than directly placing the genesis block in the blockchain software, solving the problem in the prior art that an attacker can directly control more than a certain number of nodes to run the blockchain software with a tampered genesis block or attack the server that publishes the blockchain software to achieve the purpose of modifying the genesis block, and then improving the security of the genesis block.
[0109] For a more detailed description below, another method for generating a genesis block is provided in an embodiment of this application, specifically as Figure 2 shown. This method includes:
[0110] 201. Set up the first blockchain based on the first preset algorithm.
[0111] Each first block in the first blockchain is a block to be authenticated. The block to be authenticated is a block that contains output data and unknown input data, and the output data is obtained based on the first preset algorithm. In this embodiment, the unknown input data can be understood as the input of the block being empty or a specific placeholder. That is to say, the current first block has only one output data, but the input data is actually unknown and is replaced by an empty value or a placeholder.
[0112] The first preset algorithm is a hash function algorithm. The hash function algorithm is an algorithm that calculates the unknown input data in the block to be authenticated packet to generate output data of a specific length.
[0113] Since the hash function algorithm is one-way, this means that from a mathematical and computer perspective, it is impossible to reverse-derive the unknown input data based on the output result of the hash function algorithm. That is to say, when a output result of a hash function algorithm is given, it is very difficult for an attacker to determine the unknown input of the hash function algorithm based on the output result. The hash function algorithm can be SHA2–256, Keccak-256, etc. Such algorithms are conventional hash function algorithms and will not be elaborated here.
[0114] This step can be specifically carried out in the following manner when executed:
[0115] Set up the first blockchain and the verification data packet in the preset blockchain running device, and distribute the preset blockchain running device to each of the network nodes.
[0116] Among them, the preset blockchain running device is used for multiple network nodes to perform blockchain construction operations. The verification data packet contains the data content of the alternative first blockchain and the length information corresponding to the alternative first blockchain. The length information is used to represent the number of the first blocks in the alternative first blockchain.
[0117] The preset blockchain running device can be understood as blockchain running software. During the process of blockchain construction, each network node in the network can perform operations of adding or modifying the blockchain through this blockchain running software. In addition, the verification data packet refers to the data packet for participating network nodes to confirm the blockchain construction situation during the blockchain construction process. Among the various parameters included in the verification data packet, the length information used to represent the number of blocks in the blockchain is particularly important. Each network node uses this length information to confirm which network node stores a complete blockchain.
[0118] When constructing the first blockchain, according to common sense, the first blockchain replicas in each network node, that is, the alternative first blockchains, should be the same. However, in some cases, such as data loss or tampering, the number of the first blocks in the alternative first blockchains in the three network nodes may not be the same. Therefore, during the construction process, each network node also needs to set the number of the first blocks of the alternative first blockchain it stores in the preset blockchain running device, that is, the length information. This ensures that it can be determined which network node stores a complete alternative first blockchain during the subsequent construction process.
[0119] For example, assume that there are currently eight network nodes participating in the construction process of the first blockchain, namely network node A, network node B, network node C, network node D, network node E, network node F, network node G, and network node H. At this time, each network node needs to set the length information in the verification data packet based on the number of the first blocks in the alternative blockchain it stores, which are respectively: network node A - the length information is 5, network node B - the length information is 4, network node C - the length information is 3, network node D - the length information is 5, network node E - the length information is 4, network node F - the length information is 5, network node G - the length information is 6, and network node H - the length information is 7.
[0120] 202. Calculate each first block in the first blockchain through multiple network nodes to obtain a second block, and determine the network node that generates the second block among the multiple network nodes as the target node.
[0121] Among them, the second block is the block obtained by the target node after determining the input data of the first block through a second preset algorithm;
[0122] When this step is executed, it can specifically be:
[0123] Step A. Obtain the length information from each of the network nodes, and determine the alternative first blockchain with the largest number of the first blocks as the first blockchain based on the length information;
[0124] Step B. Run the preset blockchain running device among the multiple network nodes by using a consensus mechanism, so as to calculate the input data of each of the first blocks in the first blockchain by using a competition mechanism to obtain the second block. The competition mechanism is that when the multiple network nodes calculate the output data, there is only one operation time to correctly obtain the output data;
[0125] Step C. Determine the network node that generates the input data among the multiple network nodes as the target node.
[0126] Based on the foregoing steps, since the length information of the alternative first blockchains stored in different network nodes may be different, in order to avoid data loss during subsequent construction, the premise of selecting the target node in this step is first to determine which network node's alternative first blockchain is actually the most complete blockchain. That is to say, it is necessary to determine which network node among these network nodes stores the "longest" alternative first blockchain, and this "longest" blockchain is the most complete. Therefore, after obtaining the length information feedback by each network node, based on this length information, the alternative first blockchain with the largest number of first blocks, that is, the "longest" alternative first blockchain, can be used as the real first blockchain.
[0127] Continuing with the foregoing example, for instance, when the length information of network node A is 5, network node B is 4, network node C is 3, network node D is 5, network node E is 4, network node F is 5, network node G is 6, and network node H is 7, then according to the length information, it can be known that the alternative first blockchain stored by network node H has the largest number of first blocks, that is, the longest alternative first blockchain. At this time, the alternative first blockchain stored by this network node H can be determined as the first blockchain.
[0128] After determining the first blockchain, since each first block in the first blockchain is a block of unknown input data, that is, an unauthenticated block. Then, in the process of selecting the target node, the unknown input in each first block can be calculated in turn by relying on the competition among these network nodes. That is to say, through this method, the screening of network nodes can be realized. Since this process is based on a competition mechanism, it means that each network node has only one chance to calculate correctly. When a certain network node successfully calculates the output data and is recognized by other network nodes, then in the subsequent calculation process of the remaining first blocks of this network node, there is no chance to calculate the parameters again, and at the same time, this network node is determined as the target node. In this way, by selecting the target node through the competition among multiple network nodes, even if there are network nodes controlled by hackers or attackers among these network nodes, the hackers or attackers cannot ensure that these network nodes will definitely be able to calculate the unknown input corresponding to the output data in the first block first during the competition process, and thus cannot make the network nodes they control become the target nodes for creating the genesis block subsequently.
[0129] Furthermore, the specific execution of the foregoing step B can be as follows:
[0130] Step B1, calculate the output data of the first block through the preset blockchain running device and the exhaustive algorithm to obtain alternative input data;
[0131] If the output result of a hash function algorithm is given and the unknown input result needs to be found, an exhaustive algorithm can be used. The exhaustive algorithm means that the approximate range of the answer is determined according to the required partial conditions, and all possible situations within this range are verified one by one until all situations are verified, so as to obtain the alternative input data. For example, when there is an output data of α, at this time, through 1, 2... to N, and respectively using the hash function algorithm to calculate, it is found that the data s also gets the result α after passing through the hash function algorithm, then s is determined as the input data of the output data α. This way of obtaining the input data by continuously listing the data input for verification is the exhaustive method.
[0132] Step B2: Distribute the alternative input data to the remaining network nodes, and determine whether the alternative input data passes the verification, where the remaining network nodes are the remaining nodes among the multiple network nodes except those that generate the alternative input data;
[0133] Step B3: If it is determined that the alternative input data passes the verification, then determine the alternative input data as the input data, and update the first block according to the input data to obtain the second block.
[0134] For example, in combination with the example in the foregoing steps, when a total of eight nodes from network node A to network node H participate in the process of calculating the unknown input of the output data α of a certain first block in the first blockchain, when network node B calculates the result s first based on the competition mechanism, that is, the alternative input data s, at this time, this network node B will distribute the alternative input data s to network node A, and then network node A calculates through the hash function algorithm and the alternative input data s to see if α can be obtained. When it is determined that α can indeed be obtained, the verification result is fed back to confirm that the alternative input data s can pass the verification. At this time, the unknown input in this first block is replaced with the input data s, and at this time, the first block is updated to the second block.
[0135] After a certain network node calculates the alternative input data first, the remaining network nodes will perform verification, but the verification results are not consistent. In this case, the process of confirming whether the alternative input data can pass the verification may require further analysis of the verification results among multiple network nodes.
[0136] Based on this, when the foregoing step B2 is executed, it can specifically be:
[0137] First, obtain the verification results from each of the remaining nodes;
[0138] Among them, the verification result includes a first verification result and a second verification result; the first verification result is used to represent that after the remaining nodes calculate the calculation result based on the alternative input data and the hash function algorithm, it is determined that the calculation result is consistent with the output data of the first block; the second verification result is used to represent that after the remaining nodes calculate the calculation result based on the alternative input data and the hash function algorithm, it is determined that the calculation result is inconsistent with the output data of the first block.
[0139] Secondly, it is judged whether the number of the first verification results among the multiple verification results exceeds a first preset threshold, and the first preset threshold is determined based on the proportion of the multiple network nodes.
[0140] For the convenience of description, continue with the foregoing example. For example, when network node B first calculates the alternative input data s, the alternative input data s can be distributed to each of the remaining network nodes, that is, network nodes A and network nodes B to network node H. At this time, each network node will calculate whether the alternative input data s can obtain the output data α based on the hash function algorithm, that is, whether the result obtained by the hash function algorithm based on the input data s is consistent with the output data α. If they are consistent, a first verification result is generated; otherwise, a second verification result is generated. Then, the first verification result or the second verification result generated by each network node is obtained respectively, and then the number of the first verification results is counted, that is, the verification number that can determine that the alternative input data s obtains α after being calculated by the hash function algorithm, and is compared with the preset first preset threshold.
[0141] It should be noted that the specific quantity of the first preset threshold can be selected according to actual needs in practical applications and is not limited here. For example, generally, it can be selected as the quantity of 50% of the total number of network nodes, that is, the situation where more than half of the network nodes recognize the current alternative input data.
[0142] Based on this, since the verification method in the foregoing steps is implemented based on the comparison between the first verification result and the second verification result, the specific execution rule of the foregoing step B3 is as follows:
[0143] If it is determined that the number of the first verification results exceeds the first preset threshold, the alternative input data is determined as the input data, and the first block is updated according to the input data to obtain the second block.
[0144] In this way, by comparing the quantity of the first verification result with the first preset threshold to determine whether the alternative input data can be determined as the input data, it is possible to achieve the effect that multiple network nodes "vote" based on the verification results to determine whether the preferentially calculated alternative input data can be used, avoiding the problem that the selection of the target node may be maliciously interfered due to calculation errors of individual network nodes.
[0145] Furthermore, when specifically performing step B3, it can be as follows:
[0146] On the one hand, the current network node can update the first block based on the input data to obtain the second block, and add the network node mark of the current network node to the second block, and distribute the second block and the network node mark to the remaining nodes, so that the remaining nodes can replace the first block based on the second block. In this way, the network node that currently generates the second block can publish the second block to the remaining network nodes, and the remaining network nodes directly replace the original first block with the received second block, thus realizing the update in the way of block replacement, without the need for each network node to operate inside the first block.
[0147] On the other hand, each network node can also synchronously update the first block according to the input data to obtain the second block, and add the network node mark of the network node that obtains the input data to the second block. In this way, during the update process, each network node can synchronously update the original empty or placeholder positions based on the input data, so as to achieve the effect that all network nodes in the network update the second block simultaneously.
[0148] Since the target node determined in this step is for the subsequent establishment of the genesis block node, then for the security of the subsequent genesis block establishment process, during the process of replacing the input data in the first block with the unknown input to obtain the second block, it is not only necessary to determine which network node currently generates the second block, but also necessary to add the mark of this network node, that is, the network node mark, to the block for subsequent verification of the target node.
[0149] To ensure security, the network node label can also be data obtained after encryption. Among them, the network node label is the result of calculating the first data corresponding to the network node that generates the input data through the hash function algorithm. This first data can be the public key of the network node, or the public key and the content data of the first blockchain. This can prevent the label identified as the target node from being obtained by hackers. At the same time, since the node public keys of each network node are different, they are not only easy to be saved by each network node but also have security. In addition, the content data of the first blockchain is added to the first data, which further increases the complexity of the data input into the hash function algorithm, thus better reducing the risk of being cracked by hackers.
[0150] 203. Create a genesis block according to the target node.
[0151] Among them, the genesis block is used to construct the second blockchain.
[0152] Specifically, in the process of creating the genesis block, the genesis node can be determined from multiple target nodes through a candidate algorithm, and the genesis block can be constructed based on the genesis node.
[0153] The genesis node refers to a target node elected through a candidate algorithm; the candidate algorithm can be the Raft algorithm or the Paxos algorithm. Such algorithms are conventional candidate algorithms and will not be elaborated here. For example, among all the target nodes, through the election algorithm, a target node can be selected as the genesis node, and the genesis block is constructed starting from this genesis node.
[0154] Since the target node is determined by multiple network nodes in a competitive manner, the possibility that the network node tampered by the attacker becomes the target node is greatly reduced. Then, on this basis, using the candidate algorithm to confirm the genesis node to construct the genesis block can effectively improve the security of the genesis block.
[0155] 204. Add the genesis node label of the genesis node to the genesis block, and distribute the genesis block and the genesis node label to multiple network nodes through the genesis node.
[0156] Among them, the genesis node label is the result of calculating the second data of the genesis node through the hash function algorithm; among them, the second data is the public key of the genesis node, or the public key and the content data of the first blockchain.
[0157] Even if the genesis block is generated, it is not certain whether the genesis block is the previously selected target node. For example, if a network node disguises itself as a genesis node and first sends a block to be the genesis block, then this block needs to be verified at this time. The verification process can be based on comparing the label of the current genesis block with the label of the target node in the previous first blockchain generation process to determine whether the two are consistent. When they are consistent, it indicates that this block is indeed the target node "selected" from the network nodes according to the previous steps.
[0158] It should be noted that in this embodiment, the generation method of the genesis node label needs to be exactly the same as the generation method of the network node label when performing the previous steps. For example, when the generation process of the network node label is based on the hash function algorithm SHA2–256 combined with the public key of the network node, then the generation process of the genesis node label in this step also needs to be based on the hash function algorithm SHA2–256 combined with the public key of the genesis node. Similarly, when the generation process of the network node label is based on inputting the public key of the network node and the content data of the first blockchain into the hash function algorithm MD-5 algorithm, the generation process of the genesis node label is also based on inputting the public key of the genesis node and the content data of the first blockchain into the hash function algorithm MD-5 algorithm.
[0159] 205. Determine whether the genesis block passes the verification based on the feedback information of the target node.
[0160] Based on the description of the previous steps, to ensure the security of the genesis block, the genesis block also needs to be verified. Therefore, the specific verification process in this step can be as follows:
[0161] First, obtain the feedback information from each of the target nodes.
[0162] Then, determine whether the number of the first feedback information in the feedback information exceeds a second preset threshold.
[0163] Among them, the feedback information includes first feedback information and second feedback information; the first feedback information is used to represent that after determining the network node label corresponding to the genesis node from the first blockchain through the target node, it is determined that the network node label is consistent with the genesis node label; the second feedback information is used to represent that after determining the network node label corresponding to the genesis node from the first blockchain through the target node, it is determined that the network node label is inconsistent with the genesis node label.
[0164] In this embodiment, the verification process is similar to the way of verifying alternative input data in the foregoing steps. After the genesis block is created, the genesis node sends the genesis block to each target node. Since the genesis node is theoretically selected from among the target nodes, the genesis node should theoretically also participate in the first blockchain construction process. That is to say, at this time, the first blockchain is entirely composed of second blocks, and each second block has a mark added by the target node that generated the second block, namely the network node mark. Then, at this time, each target node can determine whether the genesis node mark added to the current genesis block is consistent with the network node mark, that is, to confirm whether the network node that generated this genesis block is a target node based on the mark. When it is determined that the network node mark is consistent with the genesis node mark, it means that the network node that generated this genesis block is the target node determined during the previous construction of the first blockchain. Then this node is okay, thus proving that this genesis block is okay. At the same time, since there are multiple target nodes, when this step is specifically executed, it is actually necessary to obtain the verified feedback information of each target node, and at the same time count the number of first feedback information indicating that the network node mark is consistent with the genesis node mark, and determine whether it exceeds a preset second preset threshold.
[0165] For example, when it is detected that the genesis block appears, after target node 1 receives the genesis block and simultaneously receives the genesis block mark, denoted as mark A here, then target node 1 checks in the first blockchain whether there is a consistent mark, that is, to determine whether the network node mark in the first blockchain is consistent with this mark A. When it is found that mark A also exists in the first blockchain, it means that the network node that generated this genesis block is the target node that participated in the construction of the first blockchain before. At this time, target node 1 can send the first feedback information, otherwise it sends the second feedback information. Then count the number of first feedback information among all target nodes like target node 1. Suppose there are a total of 60 target nodes, and the second preset threshold is set according to a total of greater than or equal to 50%, that is, the second preset threshold is 30. Then determine whether the number of first feedback information is greater than 30.
[0166] It should be noted that the setting method of the second preset threshold can be set by the user according to needs and will not be specifically limited here.
[0167] 206. If it is determined based on the feedback information that the genesis block passes the verification of the target node, then add the genesis block among multiple network nodes so as to construct the second blockchain based on the genesis block.
[0168] Based on the foregoing steps, it can be seen that in the specific judgment process, the process of determining whether the genesis block passes the verification is actually based on the verification by multiple target nodes and then realized by comparing the first feedback information with a preset second threshold. Therefore, when this step is executed, it specifically includes:
[0169] If it is determined that the number of the first feedback information exceeds the second preset threshold, add the genesis block among the multiple network nodes, so as to construct the second blockchain based on the genesis block.
[0170] Combined with the foregoing example, for example, when it is determined that 31 target nodes have fed back the first feedback information, that is to say, these 31 target nodes have determined through judgment that the genesis node mark of the current genesis block is consistent with the network node mark in the previous first blockchain. At this time, the second preset threshold is 30. Then, since the number of the first feedback information exceeds the second preset threshold, it can be determined that the current genesis block was indeed created by the target nodes that generated the second block when constructing the first blockchain before. That is to say, this genesis node is secure. Therefore, the subsequent construction of the second blockchain can be carried out based on this genesis block.
[0171] To achieve the above object, according to another aspect of the present application, an embodiment of the present application further provides a storage medium. The storage medium includes a stored program, wherein when the program runs, it controls the device where the storage medium is located to execute the above-mentioned genesis block generation method.
[0172] To achieve the above object, according to another aspect of the present application, an embodiment of the present application further provides a genesis block generation device. The device includes a storage medium; and one or more processors. The storage medium is coupled to the processors, and the processors are configured to execute program instructions stored in the storage medium; when the program instructions run, they execute the above-mentioned genesis block generation method.
[0173] Further, as an implementation of the above Figure 1 and Figure 2 shown method, another embodiment of the present application further provides a genesis block generation device. The embodiment of this genesis block generation device corresponds to the foregoing method embodiment. For the convenience of reading, the details in the foregoing method embodiment will not be repeated one by one in this embodiment of the genesis block generation device. However, it should be clear that the device in this embodiment can correspondingly implement all the contents in the foregoing method embodiment. The main purpose of the genesis block generation device is to solve the problem of too low security in the current genesis block generation process. Specifically as Figure 3 shown, this genesis block generation device includes:
[0174] A setting unit 31, which can be used to set a first blockchain based on a first preset algorithm. Each first block in the first blockchain is a block to be authenticated, and the block to be authenticated is a block that contains output data and unknown input data, and the output data is obtained based on the first preset algorithm;
[0175] A first determination unit 32, which can be used to calculate each first block in the first blockchain through multiple network nodes to obtain a second block, and determine the network node that generates the second block among the multiple network nodes as the target node. Wherein, the second block is a block obtained after the target node determines the input data of the first block through a second preset algorithm;
[0176] A creation unit 33, which can be used to create the genesis block according to the target node, and the genesis block can be used to construct a second blockchain.
[0177] Further, as Figure 4 shown, the first preset algorithm is a hash function algorithm;
[0178] The setting unit 31 can specifically be used to set the first blockchain and verification data packets in a preset blockchain running device, and distribute the preset blockchain running device to each network node;
[0179] Wherein, the preset blockchain running device can be used for multiple network nodes to perform blockchain construction operations. The verification data packet includes the data content of the alternative first blockchain and the length information corresponding to the alternative first blockchain, and the length information can be used to represent the number of first blocks in the alternative first blockchain;
[0180] The first determination unit 32 includes:
[0181] A first determination subunit 321, which can be used to obtain the length information from each network node, and determine the alternative first blockchain with the largest number of first blocks as the first blockchain based on the length information;
[0182] An operation subunit 322, which can be used to run the preset blockchain running device among multiple network nodes by using a consensus mechanism, so as to calculate the input data of each first block in the first blockchain by using a competition mechanism to obtain the second block. The competition mechanism is that when multiple network nodes calculate the output data, there is only one operation time to correctly obtain the output data;
[0183] A second determination subunit 323, which can be used to determine the network node that generates the input data among the multiple network nodes as the target node.
[0184] Further, as Figure 4 shown, the second preset algorithm is an exhaustive algorithm;
[0185] The operation subunit 322 includes:
[0186] A calculation module 3221, which can be used to calculate the output data of the first block through the preset blockchain operation device and the exhaustive algorithm to obtain alternative input data;
[0187] A first determination module 3222, which can be used to distribute the alternative input data to the remaining network nodes and determine whether the alternative input data passes the verification, where the remaining network nodes are the remaining nodes among the multiple network nodes except those that generate the alternative input data;
[0188] A second determination module 3223, which can be used to, if the alternative input data is distributed to the remaining network nodes and it is determined that the alternative input data passes the verification, determine the alternative input data as the input data and update the first block according to the input data to obtain the second block.
[0189] Further, as Figure 4 shown, the first determination module 3222 includes:
[0190] An acquisition sub-module 32221, which can be used to obtain verification results from each of the remaining nodes;
[0191] Among them, the verification results include a first verification result and a second verification result; the first verification result can be used to indicate that the remaining nodes determine that the calculation result is consistent with the output data of the first block after calculating the calculation result based on the alternative input data and the hash function algorithm; the second verification result can be used to indicate that the remaining nodes determine that the calculation result is inconsistent with the output data of the first block after calculating the calculation result based on the alternative input data and the hash function algorithm;
[0192] A judgment sub-module 32222, which can be used to judge whether the number of the first verification results among the multiple verification results exceeds a first preset threshold, and the first preset threshold is determined based on the ratio of the multiple network nodes;
[0193] The second determination module 3223 can specifically be used to, if it is determined that the number of the first verification results exceeds the first preset threshold, determine the alternative input data as the input data and update the first block according to the input data to obtain the second block.
[0194] Further, as Figure 4As shown, the second determination module 3223 includes:
[0195] A first update sub-module 32231, which can be used to update the first block based on the input data by the current network node to obtain the second block, add the network node mark of the current network node to the second block, and distribute the second block and the network node mark to the remaining nodes, so that the remaining nodes replace the first block based on the second block;
[0196] A second update sub-module 32232, which can be used for each network node to synchronously update the first block according to the input data to obtain the second block, and add the network node mark of the network node that obtains the input data to the second block.
[0197] Furthermore, as Figure 4 shown, the creation unit 33 can specifically be used to determine a genesis node among multiple target nodes through a candidate algorithm, and construct the genesis block based on the genesis node.
[0198] Furthermore, as Figure 4 shown, the device further includes:
[0199] A first addition unit 34, which can be used to add the genesis node mark of the genesis node to the genesis block, and distribute the genesis block and the genesis node mark to multiple network nodes through the genesis node;
[0200] A second determination unit 35, which can be used to determine whether the genesis block passes verification through the feedback information of the target node;
[0201] A second addition unit 36, which can be used to add the genesis block to multiple network nodes if it is determined based on the feedback information that the genesis block passes the verification of the target node, so as to construct the second blockchain based on the genesis block.
[0202] Furthermore, as Figure 4 shown, the second determination unit 35 includes:
[0203] An obtaining subunit 351 can be used to obtain feedback information from each of the target nodes, where the feedback information includes first feedback information and second feedback information; the first feedback information can be used to represent that after determining the network node label corresponding to the genesis node from the first blockchain through the target node, it is determined that the network node label is consistent with the genesis node label; the second feedback information can be used to represent that after determining the network node label corresponding to the genesis node from the first blockchain through the target node, it is determined that the network node label is inconsistent with the genesis node label.
[0204] A judging subunit 352 can be used to judge whether the quantity of the first feedback information in the feedback information exceeds a second preset threshold.
[0205] The second adding unit 36 can specifically be used to add the genesis block to multiple network nodes if it is determined that the quantity of the first feedback information exceeds the second preset threshold, so as to construct the second blockchain based on the genesis block.
[0206] Further, as Figure 4 shown, the network node label is obtained by calculating the first data corresponding to the network node that generates the input data through the hash function algorithm; where the first data is the public key of the network node, or the public key and the content data of the first blockchain.
[0207] The genesis node label is obtained by calculating the second data of the genesis node through the hash function algorithm; where the second data is the public key of the genesis node, or the public key and the content data of the first blockchain.
[0208] The present application provides a method and apparatus for generating a genesis block. The present application can set a first blockchain based on a first preset algorithm. Each first block in the first blockchain is a block to be authenticated, and the block to be authenticated is a block that contains output data and unknown input data. By calculating each of the first blocks in the first blockchain through multiple network nodes, a second block is obtained, and the network node that generates the second block among the multiple network nodes is determined as the target node. Among them, the second block is a block obtained after the target node determines the input data of the first block through a second preset algorithm. The genesis block is created according to the target node, and the genesis block is used to construct a second blockchain. Compared with the prior art, in the present application, by setting the first blockchain through the first preset algorithm, the process of calculating the second block by multiple network nodes through each block in the first blockchain actually confirms which of the multiple network nodes conform to the first preset algorithm, further increasing the difficulty for an attacker to tamper with the blockchain. The genesis block is implemented based on the target node, ensuring that even if a certain number of the network nodes are tampered with, it cannot be guaranteed that the tampered network nodes by the attacker will become the target node to participate in the creation of the genesis block. It can be seen that the present application actually enables multiple network nodes to become the target node through competition, thereby ensuring that in the subsequent process of creating the genesis block, the possibility of the tampered network nodes by the attacker becoming the target node is greatly reduced, thus improving the security of the genesis block. That is to say, the genesis block in the present application is created and generated based on the second block, rather than directly placing the genesis block in the blockchain software, solving the problem in the prior art that an attacker can directly control more than a certain number of nodes to run the blockchain software with a tampered genesis block or attack the server that publishes the blockchain software to achieve the purpose of modifying the genesis block, and then improving the security of the genesis block.
[0209] An embodiment of the present application provides a storage medium. The storage medium includes a stored program. Among them, when the program runs, it controls the device where the storage medium is located to execute the above-mentioned method for generating a genesis block.
[0210] The storage medium may include non-permanent memory in a computer-readable medium, forms such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash memory (flash RAM). The memory includes at least one storage chip.
[0211] The embodiments of the present application further provide a genesis block generation device, which includes a storage medium; and one or more processors. The storage medium is coupled to the processors, and the processors are configured to execute program instructions stored in the storage medium; when the program instructions run, they execute the above-mentioned genesis block generation method.
[0212] The embodiments of the present application provide a device, which includes a processor, a memory, and a program stored on the memory and executable on the processor. When the processor executes the program, the following steps are implemented: setting a first blockchain based on a first preset algorithm, where each first block in the first blockchain is a block to be authenticated, and the block to be authenticated is a block that contains output data and unknown input data; calculating each of the first blocks in the first blockchain through multiple network nodes to obtain a second block, and determining the network node that generates the second block among the multiple network nodes as the target node, where the second block is a block obtained after the target node determines the input data of the first block through a second preset algorithm; creating a genesis block according to the target node, and the genesis block is used to construct a second blockchain.
[0213] Further, the first preset algorithm is a hash function algorithm;
[0214] The setting of the first blockchain based on the first preset algorithm includes:
[0215] Setting the first blockchain and a verification data packet in a preset blockchain running device, and distributing the preset blockchain running device to each of the network nodes;
[0216] Wherein, the preset blockchain running device is used for multiple network nodes to perform blockchain construction operations, the verification data packet includes the data content of the alternative first blockchain and the length information corresponding to the alternative first blockchain, and the length information is used to represent the number of the first blocks in the alternative first blockchain;
[0217] The calculating each of the first blocks in the first blockchain through multiple network nodes to obtain a second block, and determining the network node that generates the second block among the multiple network nodes as the target node includes:
[0218] Obtaining the length information from each of the network nodes, and determining the alternative first blockchain with the largest number of the first blocks as the first blockchain based on the length information;
[0219] Run the preset blockchain operating device among multiple network nodes by using a consensus mechanism, so as to calculate the input data of each first block in the first blockchain by using a competition mechanism to obtain the second block, where the competition mechanism is the number of operations for correctly obtaining the output data only once when multiple network nodes calculate the output data;
[0220] Determine the network node that generates the input data among multiple network nodes as the target node.
[0221] Further, the second preset algorithm is an exhaustive algorithm. The step of running the preset blockchain operating device among multiple network nodes by using a consensus mechanism, so as to calculate the input data of each first block in the first blockchain by using a competition mechanism to obtain the second block, where the competition mechanism is the number of operations for correctly obtaining the output data only once when multiple network nodes calculate the output data, includes:
[0222] Calculate alternative input data for the output data of the first block through the preset blockchain operating device and the exhaustive algorithm;
[0223] Distribute the alternative input data to the remaining network nodes, and determine whether the alternative input data passes the verification, where the remaining network nodes are the remaining nodes among multiple network nodes except those that generate the alternative input data;
[0224] If it passes, determine the alternative input data as the input data, and update the first block according to the input data to obtain the second block.
[0225] Further, the step of distributing the alternative input data to the remaining network nodes and determining whether the alternative input data passes the verification includes:
[0226] Obtain verification results from each of the remaining nodes;
[0227] Wherein, the verification results include a first verification result and a second verification result; the first verification result is used to represent that the remaining nodes determine that the calculation result is consistent with the output data of the first block after calculating the calculation result based on the alternative input data and the hash function algorithm; the second verification result is used to represent that the remaining nodes determine that the calculation result is inconsistent with the output data of the first block after calculating the calculation result based on the alternative input data and the hash function algorithm;
[0228] Judge whether the number of the first verification results among the multiple verification results exceeds a first preset threshold, and the first preset threshold is determined based on the proportion of multiple network nodes;
[0229] If it is determined that the alternative input data passes the verification, then determine the alternative input data as the input data, and update the first block according to the input data to obtain the second block, including:
[0230] If it is determined that the number of the first verification results exceeds a first preset threshold, then determine the alternative input data as the input data, and update the first block according to the input data to obtain the second block.
[0231] Further, the updating the first block according to the input data to obtain the second block includes:
[0232] The current network node updates the first block based on the input data to obtain the second block, adds the network node mark of the current network node to the second block, and distributes the second block and the network node mark to the remaining nodes, so that the remaining nodes replace the first block based on the second block;
[0233] Or,
[0234] Each network node synchronously updates the first block according to the input data to obtain the second block, and adds the network node mark of the network node that obtains the input data to the second block.
[0235] Further, the creating the genesis block according to the target node includes:
[0236] Determine a genesis node from multiple target nodes through a candidate algorithm, and construct the genesis block based on the genesis node.
[0237] Further, after determining a genesis node from multiple target nodes through the candidate algorithm and constructing the genesis block based on the genesis node, the method further includes:
[0238] Add the genesis node mark of the genesis node to the genesis block, and distribute the genesis block and the genesis node mark to multiple network nodes through the genesis node;
[0239] Determine whether the genesis block passes the verification through the feedback information of the target node;
[0240] If it is determined based on the feedback information that the genesis block passes the verification of the target node, then add the genesis block to multiple network nodes, so as to construct the second blockchain based on the genesis block.
[0241] Further, the determining whether the genesis block passes the verification through the feedback information of the target node includes:
[0242] Obtain feedback information from each of the target nodes, where the feedback information includes first feedback information and second feedback information; the first feedback information is used to represent that after determining the network node mark corresponding to the genesis node from the first blockchain through the target node, it is determined that the network node mark is consistent with the genesis node mark; the second feedback information is used to represent that after determining the network node mark corresponding to the genesis node from the first blockchain through the target node, it is determined that the network node mark is inconsistent with the genesis node mark.
[0243] Judge whether the quantity of the first feedback information in the feedback information exceeds a second preset threshold.
[0244] If it is determined that the genesis block passes the verification of the target node based on the feedback information, adding the genesis block to multiple network nodes so as to construct the second blockchain based on the genesis block includes:
[0245] If it is determined that the quantity of the first feedback information exceeds the second preset threshold, add the genesis block to multiple network nodes so as to construct the second blockchain based on the genesis block.
[0246] Furthermore, the network node mark is obtained by calculating the first data corresponding to the network node that generates the input data through the hash function algorithm; wherein, the first data is the public key of the network node, or the public key and the content data of the first blockchain.
[0247] The genesis node mark is obtained by calculating the second data of the genesis node through the hash function algorithm; wherein, the second data is the public key of the genesis node, or the public key and the content data of the first blockchain.
[0248] The present application also provides a computer program product, which when executed on a data processing device, is adapted to execute program code initialized with the following method steps: setting a first blockchain based on a first preset algorithm, each first block in the first blockchain being a block to be authenticated, the block to be authenticated being a block containing output data and unknown input data; calculating each of the first blocks in the first blockchain through multiple network nodes to obtain a second block, and determining the network node that generates the second block among the multiple network nodes as the target node, wherein the second block is a block obtained after the target node determines the input data of the first block through a second preset algorithm; creating a genesis block according to the target node, the genesis block being used to construct a second blockchain.
[0249] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) that contain computer-usable program code.
[0250] The present application is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, as well as the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0251] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including instruction means, and the instruction means implement the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0252] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process. Thus, the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0253] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and a memory.
[0254] The memory may include non-permanent memory in a computer-readable medium, in the form of random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
[0255] A computer-readable medium includes permanent and non-permanent, removable and non-removable media that can implement information storage by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transitory medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer-readable medium does not include transitory computer-readable media, such as modulated data signals and carrier waves.
[0256] It should also be noted that the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, commodity or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, commodity or device comprising the element.
[0257] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0258] The above are only the embodiments of the present application and are not used to limit the present application. For those skilled in the art, the present application can have various changes and modifications. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.
Claims
1. A method for generating a genesis block, characterized in that, The method includes: Setting a first blockchain based on a first preset algorithm, where each first block in the first blockchain is a block to be authenticated, the block to be authenticated is a block containing output data and unknown input data, and the output data is obtained based on the first preset algorithm; Calculating each of the first blocks in the first blockchain by multiple network nodes to obtain a second block, and determining the network node that generates the second block among the multiple network nodes as the target node. Among them, the second block is a block obtained after the target node determines the input data of the first block through a second preset algorithm. The preset blockchain running device is run among the multiple network nodes by using a consensus mechanism, so as to calculate the input data of each of the first blocks in the first blockchain by using a competition mechanism to obtain the second block. The competition mechanism is that when calculating the output data by the multiple network nodes, there is only one operation time to correctly obtain the output data; Creating a genesis block according to the target node, and the genesis block is used to construct a second blockchain.
2. The method according to claim 1, wherein The first preset algorithm is a hash function algorithm. The setting of the first blockchain based on the first preset algorithm includes: Setting the first blockchain and a verification data packet in the preset blockchain running device, and distributing the preset blockchain running device to each of the network nodes; Among them, the preset blockchain running device is used for the multiple network nodes to perform blockchain construction operations. The verification data packet includes the data content of an alternative first blockchain and the length information corresponding to the alternative first blockchain, and the length information is used to represent the number of the first blocks in the alternative first blockchain; The calculating each of the first blocks in the first blockchain by multiple network nodes to obtain a second block, and determining the network node that generates the second block among the multiple network nodes as the target node includes: Obtaining the length information from each of the network nodes, and determining the alternative first blockchain with the largest number of the first blocks as the first blockchain based on the length information; Determining the network node that generates the input data among the multiple network nodes as the target node.
3. The method according to claim 2, wherein The second preset algorithm is an exhaustive algorithm. The running of the preset blockchain running device among the multiple network nodes by using a consensus mechanism so as to calculate the input data of each of the first blocks in the first blockchain by using a competition mechanism to obtain the second block includes: Calculating the output data of the first block through the preset blockchain running device and the exhaustive algorithm to obtain alternative input data; Distributing the alternative input data to the remaining network nodes, and determining whether the alternative input data passes the verification, where the remaining network nodes are the remaining nodes among the multiple network nodes except the nodes that generate the alternative input data; If it passes, determining the alternative input data as the input data, and updating the first block according to the input data to obtain the second block.
4. The method according to claim 3, characterized in that, Distributing the alternative input data to the remaining network nodes and determining whether the alternative input data passes verification includes: Obtaining verification results from each of the remaining nodes; Wherein, the verification results include a first verification result and a second verification result; the first verification result is used to characterize that the remaining nodes determine that the calculation result is consistent with the output data of the first block after calculating the calculation result based on the alternative input data and the hash function algorithm; the second verification result is used to characterize that the remaining nodes determine that the calculation result is inconsistent with the output data of the first block after calculating the calculation result based on the alternative input data and the hash function algorithm; Judging whether the number of the first verification results among the multiple verification results exceeds a first preset threshold, and the first preset threshold is determined based on the ratio of the multiple network nodes; If it is determined that the alternative input data passes verification, determining the alternative input data as the input data, and updating the first block according to the input data to obtain the second block includes: If it is determined that the number of the first verification results exceeds the first preset threshold, determining the alternative input data as the input data, and updating the first block according to the input data to obtain the second block.
5. The method according to claim 3, characterized in that The updating the first block according to the input data to obtain the second block includes: Updating the first block to obtain the second block by the current network node based on the input data, adding the network node mark of the current network node to the second block, and distributing the second block and the network node mark to the remaining nodes so that the remaining nodes replace the first block based on the second block; Or, Each network node synchronously updates the first block according to the input data to obtain the second block, and adds the network node mark of the network node that obtains the input data to the second block.
6. The method according to any one of claims 2-5, characterized in that, The creating the genesis block according to the target node includes: Determining a genesis node among the multiple target nodes through a candidate algorithm, and constructing the genesis block based on the genesis node.
7. The method according to claim 6, characterized in that After determining the genesis node among the multiple target nodes through the candidate algorithm and constructing the genesis block based on the genesis node, the method further includes: Adding the genesis node mark of the genesis node to the genesis block, and distributing the genesis block and the genesis node mark to the multiple network nodes through the genesis node; Determining whether the genesis block passes verification through the feedback information of the target node; If it is determined based on the feedback information that the genesis block passes the verification of the target node, adding the genesis block to the multiple network nodes so as to construct the second blockchain based on the genesis block.
8. The method according to claim 7, wherein The determining whether the genesis block passes verification through the feedback information of the target node includes: Obtain feedback information from each of the target nodes, where the feedback information includes first feedback information and second feedback information; the first feedback information is used to represent that after determining the network node label corresponding to the genesis node from the first blockchain through the target node, it is determined that the network node label is consistent with the genesis node label; the second feedback information is used to represent that after determining the network node label corresponding to the genesis node from the first blockchain through the target node, it is determined that the network node label is inconsistent with the genesis node label. Judge whether the quantity of the first feedback information in the feedback information exceeds a second preset threshold. If it is determined based on the feedback information that the genesis block passes the verification of the target node, then adding the genesis block among multiple network nodes, so as to construct the second blockchain based on the genesis block, includes: If it is determined that the quantity of the first feedback information exceeds the second preset threshold, add the genesis block among multiple network nodes, so as to construct the second blockchain based on the genesis block.
9. The method according to claim 8, characterized in that The network node label is obtained by calculating the first data corresponding to the network node that generates the input data through the hash function algorithm; where the first data is the public key of the network node, or the public key and the content data of the first blockchain. The genesis node label is obtained by calculating the second data of the genesis node through the hash function algorithm; where the second data is the public key of the genesis node, or the public key and the content data of the first blockchain.
10. A genesis block generation device, characterized in that, The device includes: A setting unit, configured to set a first blockchain based on a first preset algorithm, each first block in the first blockchain being a block to be authenticated, the block to be authenticated being a block containing output data and unknown input data, and the output data being obtained based on the first preset algorithm. A first determination unit, configured to calculate each first block in the first blockchain through multiple network nodes to obtain a second block, and determine the network node that generates the second block among the multiple network nodes as the target node, where the second block is a block obtained after the target node determines the input data of the first block through a second preset algorithm, and a preset blockchain running device is run among the multiple network nodes by using a consensus mechanism, so as to calculate the input data of each first block in the first blockchain by using a competition mechanism to obtain the second block, and the competition mechanism is the number of operation times when only one correct output data is obtained when the multiple network nodes calculate the output data. A creation unit, configured to create the genesis block according to the target node, where the genesis block is used to construct the second blockchain.
11. The device according to claim 10, wherein The first preset algorithm is a hash function algorithm, and the setting unit is specifically configured to set the first blockchain and a verification data packet in the preset blockchain running device, and distribute the preset blockchain running device to each network node. Among them, the preset blockchain operating device is used for multiple network nodes to perform blockchain construction operations. The verification data packet includes the data content of the alternative first blockchain and the length information corresponding to the alternative first blockchain. The length information is used to represent the number of the first blocks in the alternative first blockchain; The first determination unit includes: The first determination subunit is configured to obtain the length information from each of the network nodes, and determine the alternative first blockchain with the largest number of the first blocks as the first blockchain based on the length information; The second determination subunit is configured to determine the network node that generates the input data among the multiple network nodes as the target node.
12. The device according to claim 11, characterized in that, The second preset algorithm is an exhaustive algorithm. The operation subunit includes: The calculation module is configured to calculate the alternative input data through the preset blockchain operating device and the exhaustive algorithm for the output data of the first block; The first determination module is configured to distribute the alternative input data to the remaining network nodes and determine whether the alternative input data passes the verification, where the remaining network nodes are the remaining nodes among the multiple network nodes except those that generate the alternative input data; The second determination module is configured to, if the alternative input data is distributed to the remaining network nodes and it is determined that the alternative input data passes the verification, determine the alternative input data as the input data, and update the first block according to the input data to obtain the second block.
13. The device according to claim 12, characterized in that, The first determination module includes: The acquisition submodule is configured to obtain the verification results from each of the remaining nodes; Among them, the verification results include a first verification result and a second verification result; the first verification result is used to represent that the remaining nodes determine that the calculation result is consistent with the output data of the first block after calculating the calculation result based on the alternative input data and the hash function algorithm; the second verification result is used to represent that the remaining nodes determine that the calculation result is inconsistent with the output data of the first block after calculating the calculation result based on the alternative input data and the hash function algorithm; The judgment submodule is configured to judge whether the number of the first verification results among the multiple verification results exceeds a first preset threshold, and the first preset threshold is determined based on the ratio of the multiple network nodes; The second determination module is specifically configured to, if it is determined that the number of the first verification results exceeds the first preset threshold, determine the alternative input data as the input data, and update the first block according to the input data to obtain the second block.
14. The device according to claim 12, characterized in that, The second determination module includes: The first update submodule is configured to update the first block to obtain the second block by the current network node based on the input data, add the network node mark of the current network node to the second block, and distribute the second block and the network node mark to the remaining nodes so that the remaining nodes replace the first block based on the second block; A second update sub-module, configured to enable each of the network nodes to synchronously update the first block according to the input data to obtain the second block, and add a network node label of the network node that obtains the input data to the second block.
15. The device according to any one of claims 11-14, characterized in that The creating unit is specifically configured to determine a genesis node from multiple target nodes through a candidate algorithm, and construct the genesis block based on the genesis node.
16. The device according to claim 15, characterized in that, The apparatus further includes: A first adding unit, configured to add a genesis node label of the genesis node to the genesis block, and distribute the genesis block and the genesis node label to multiple network nodes through the genesis node; A second determining unit, configured to determine whether the genesis block passes verification through feedback information of the target nodes; A second adding unit, configured to, if it is determined based on the feedback information that the genesis block passes verification by the target nodes, add the genesis block to multiple network nodes, so as to construct the second blockchain based on the genesis block.
17. The device according to claim 16, wherein, The second determining unit includes: An obtaining subunit, configured to obtain feedback information from each of the target nodes, where the feedback information includes first feedback information and second feedback information; the first feedback information is used to represent that after determining the network node label corresponding to the genesis node from the first blockchain through the target node, it is determined that the network node label is consistent with the genesis node label; the second feedback information is used to represent that after determining the network node label corresponding to the genesis node from the first blockchain through the target node, it is determined that the network node label is inconsistent with the genesis node label; A judging subunit, configured to judge whether the number of the first feedback information in the feedback information exceeds a second preset threshold; The second adding unit is specifically configured to, if it is determined that the number of the first feedback information exceeds the second preset threshold, add the genesis block to multiple network nodes, so as to construct the second blockchain based on the genesis block.
18. The device according to claim 17, characterized in that, The network node label is obtained by calculating, through the hash function algorithm, first data corresponding to the network node that generates the input data; where the first data is the public key of the network node, or the public key and the content data of the first blockchain; The genesis node label is obtained by calculating, through the hash function algorithm, second data of the genesis node; where the second data is the public key of the genesis node, or the public key and the content data of the first blockchain.
19. A storage medium, characterized in that, The storage medium includes a stored program, where when the program runs, it controls the device where the storage medium is located to execute the genesis block generation method according to any one of claims 1 to 9.
20. A genesis block generation device, characterized in that, The apparatus includes a storage medium; and one or more processors, the storage medium is coupled to the processors, and the processors are configured to execute program instructions stored in the storage medium; when the program instructions run, they execute the genesis block generation method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Blockchain consensus method and node
CN111177263A
Method and device for preventing bifurcation of block chain
CN111445247A