CN107566124B - Hash operation-based consensus establishing method, block chain system and storage medium - Google Patents
Hash operation-based consensus establishing method, block chain system and storage medium Download PDFInfo
- Publication number
- CN107566124B CN107566124B CN201710737728.6A CN201710737728A CN107566124B CN 107566124 B CN107566124 B CN 107566124B CN 201710737728 A CN201710737728 A CN 201710737728A CN 107566124 B CN107566124 B CN 107566124B
- Authority
- CN
- China
- Prior art keywords
- hash value
- node
- block
- candidate
- blockchain
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Landscapes
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Computer And Data Communications (AREA)
Abstract
本发明公开了一种基于抽签机制的共识建立方法、区块链系统和存储介质,所述方法包括:确定区块链中末位区块的记账节点,基于末位区块的记账节点,获取数据包,所述数据包至少包含准备与末位区块连接的待接入区块的交易数据;基于获取的所述数据包和本节点自存的节点数据,进行哈希运算得到第一候选哈希值;获取其他节点广播的第二候选哈希值,根据第一预设规则在第一候选哈希值和第二候选哈希值中选择目标哈希值,该目标哈希值的节点为待接入区块的记账节点。本发明可保证区块链中各节点完全平等地竞争记账权,可鼓励更多人参与到区块链中,有利于区块链的应用和推广。
The invention discloses a consensus building method based on a lottery mechanism, a blockchain system and a storage medium. The method includes: determining an accounting node of the last block in the blockchain, and an accounting node based on the last block , obtain a data packet, the data packet contains at least the transaction data of the block to be accessed that is prepared to be connected with the last block; a candidate hash value; obtain a second candidate hash value broadcast by other nodes, and select a target hash value from the first candidate hash value and the second candidate hash value according to the first preset rule, the target hash value The node is the accounting node of the block to be accessed. The invention can ensure that each node in the blockchain competes for the bookkeeping right completely and equally, and can encourage more people to participate in the blockchain, which is beneficial to the application and promotion of the blockchain.
Description
技术领域technical field
本发明涉及区块链技术领域,尤其涉及一种基于哈希运算的共识建立方法、区块链系统及存储介质。The present invention relates to the technical field of blockchain, in particular to a consensus establishment method based on hash operation, a blockchain system and a storage medium.
背景技术Background technique
区块链是由节点参与的分布式数据库系统,也可以将其理解为账簿系统,是由区块链网络中的所有节点各自独立竞争完成的。共识机制是区块链技术的核心,它使得区块链这样一个去中心化的账簿系统变成可能,共识机制与去中心化两个核心因素是区块链内生能力得以扩展的关键。The blockchain is a distributed database system participated by nodes, which can also be understood as a ledger system, which is completed by all nodes in the blockchain network through independent competition. Consensus mechanism is the core of blockchain technology, which makes a decentralized ledger system like blockchain possible. The two core factors of consensus mechanism and decentralization are the key to the expansion of blockchain's endogenous capabilities.
在中心化的结构体系中,系统的共识由中心决定,各参与方只需要服从这个中心即可,因此共识的建立是极为高效的,而在去中心化的结构体系中,由于系统的各个参与方地位平等,当出现分歧的时候如何达成共识就成了问题。In a centralized structural system, the consensus of the system is determined by the center, and each participant only needs to obey the center, so the establishment of consensus is extremely efficient, while in a decentralized structural system, due to the various participation of the system The status of each party is equal, and how to reach a consensus when there is a disagreement becomes a problem.
目前通常采用的区块链共识机制包括工作量证明、权益证明等方式。其中,权益证明的核心实现如下:记账节点在产生新的区块时,将自己的地址附在区块中,以证明其占有的权益比例,记账节点同时也需要用该地址对应的私钥对部分区块信息签名,以证明其确实拥有该地址的资产。这一共识机制倾向于在系统中占有权益大的节点,易导致腐败,不利于吸纳更多群体使用区块链。At present, the commonly used blockchain consensus mechanisms include workload proof, equity proof and so on. Among them, the core implementation of the proof of stake is as follows: when the accounting node generates a new block, it attaches its own address to the block to prove the proportion of equity it occupies, and the accounting node also needs to use the private address corresponding to the address. The key signs part of the block information to prove that it actually owns the assets of the address. This consensus mechanism tends to hold nodes with large stakes in the system, which can easily lead to corruption and is not conducive to attracting more groups to use the blockchain.
发明内容SUMMARY OF THE INVENTION
本发明的主要目的在于提供一种基于哈希运算的共识建立方法,旨在解决权益证明共识机制倾向于在系统中占有权益大的节点,易导致腐败,不利于吸纳更多群体使用区块链的技术问题。The main purpose of the present invention is to provide a consensus building method based on hash operation, which aims to solve the problem that the proof-of-stake consensus mechanism tends to hold large stakes in the system, which is easy to lead to corruption and is not conducive to attracting more groups to use the blockchain. technical issues.
为实现上述目的,本发明提供一种基于哈希运算的共识建立方法,所述方法包括:In order to achieve the above object, the present invention provides a consensus establishment method based on hash operation, the method includes:
确定区块链中末位区块的记账节点,基于末位区块的记账节点,获取数据包,所述数据包至少包含准备与末位区块连接的待接入区块的交易数据;Determine the accounting node of the last block in the blockchain, and obtain a data packet based on the accounting node of the last block, and the data packet at least contains the transaction data of the block to be accessed that is to be connected to the last block. ;
基于获取的所述数据包和本节点自存的节点数据,进行哈希运算得到第一候选哈希值;Based on the acquired data packet and the node data stored by the node, a hash operation is performed to obtain a first candidate hash value;
获取其他节点广播的第二候选哈希值,根据第一预设规则在所述第一候选哈希值和第二候选哈希值中选择目标哈希值,该目标哈希值的节点为所述待接入区块的记账节点。Obtain the second candidate hash value broadcast by other nodes, select a target hash value from the first candidate hash value and the second candidate hash value according to the first preset rule, and the node of the target hash value is the Describe the accounting node of the block to be accessed.
在其中一个实施例中,所述根据预设规则在第一候选哈希值和第二候选哈希值中选择目标哈希值的步骤包括:In one of the embodiments, the step of selecting the target hash value from the first candidate hash value and the second candidate hash value according to a preset rule includes:
在所述第一候选哈希值和第二候选哈希值中确定最小的候选哈希值,该最小候选哈希值为目标哈希值。The smallest candidate hash value is determined among the first candidate hash value and the second candidate hash value, and the smallest candidate hash value is the target hash value.
在其中一个实施例中,所述基于获取的所述数据包和本节点自存的节点数据,进行哈希运算得到第一候选哈希值的步骤包括:In one of the embodiments, the step of performing a hash operation to obtain the first candidate hash value based on the acquired data packet and the node data stored by the node itself includes:
获取所述数据包中待接入区块的交易数据,基于该交易数据和末位区块的特征值进行哈希运算,得到第一哈希值;Obtain the transaction data of the block to be accessed in the data packet, and perform a hash operation based on the transaction data and the characteristic value of the last block to obtain a first hash value;
基于自存的私钥对所述第一哈希值进行签名,将签名后的所述第一哈希值进行哈希运算,得到第一候选哈希值。The first hash value is signed based on the self-stored private key, and the signed first hash value is subjected to a hash operation to obtain a first candidate hash value.
在其中一个实施例中,所述获取数据包的步骤之后包括:In one of the embodiments, the step of acquiring the data packet includes:
根据区块链中的历史交易数据,验证所述数据包中待接入区块的交易数据是否全部有效;According to the historical transaction data in the blockchain, verify whether the transaction data of the block to be accessed in the data packet is all valid;
若该数据包中所述待接入区块的交易数据全部有效,则执行基于获取的所述数据包和本节点自存的节点数据,进行哈希运算得到第一候选哈希值这一步骤。If all the transaction data of the block to be accessed in the data packet are valid, perform a hash operation based on the acquired data packet and the node data stored by the node itself to obtain the first candidate hash value .
在其中一个实施例中,所述获取其他节点广播的第二候选哈希值的步骤之后包括:In one of the embodiments, the step of obtaining the second candidate hash value broadcast by other nodes includes:
基于所述第一候选哈希值和第二候选哈希值,根据第二预设规则判断所述第一候选哈希值是否满足广播条件;Based on the first candidate hash value and the second candidate hash value, determine whether the first candidate hash value satisfies the broadcast condition according to a second preset rule;
若所述第一候选哈希值满足广播条件,则将所述第一候选哈希值向所述区块链所在的区块链网络广播。If the first candidate hash value satisfies the broadcast condition, broadcast the first candidate hash value to the blockchain network where the blockchain is located.
在其中一个实施例中,所述根据第二预设规则判断所述第一候选哈希值是否满足广播条件的步骤包括:In one embodiment, the step of judging whether the first candidate hash value satisfies the broadcast condition according to the second preset rule includes:
解析第二预设规则,当解析结果为候选哈希值中的最小候选哈希值为目标哈希值时,若所述第一候选哈希值小于所述第二候选哈希值,则所述第一候选哈希值满足广播条件。Parse the second preset rule, when the parsing result is that the minimum candidate hash value among the candidate hash values is the target hash value, if the first candidate hash value is smaller than the second candidate hash value, then the The first candidate hash value satisfies the broadcast condition.
在其中一个实施例中,所述确定区块链中末位区块的记账节点,基于末位区块的记账节点,获取数据包的步骤之前包括:In one embodiment, the determining the accounting node of the last block in the blockchain, based on the accounting node of the last block, before the step of acquiring the data packet includes:
所述末位区块的记账节点确定准备与末位区块连接的待接入区块的交易数据;The accounting node of the last block determines the transaction data of the block to be accessed that is to be connected with the last block;
所述末位区块的记账节点基于所述待接入区块的交易数据,生成数据包,将该数据包向区块链所在的区块链网络广播。The accounting node of the last block generates a data packet based on the transaction data of the block to be accessed, and broadcasts the data packet to the blockchain network where the blockchain is located.
在其中一个实施例中,所述末位区块的记账节点基于所述待接入区块的交易数据,生成数据包,将该数据包向区块链所在的区块链网络广播的步骤包括:In one embodiment, the accounting node of the last block generates a data packet based on the transaction data of the block to be accessed, and broadcasts the data packet to the blockchain network where the blockchain is located. include:
所述末位区块的记账节点基于所述交易数据和末位区块的特征值,进行哈希运算得到第二哈希值;The accounting node of the last block performs a hash operation based on the transaction data and the characteristic value of the last block to obtain a second hash value;
所述末位区块的记账节点基于所述交易数据、特征值和第二哈希值生成数据包,并将该数据包向所述区块链所在的区块链网络广播。The accounting node of the last block generates a data packet based on the transaction data, the characteristic value and the second hash value, and broadcasts the data packet to the blockchain network where the blockchain is located.
此外,为实现上述目的,本发明还提供一种区块链系统,所述区块链系统包括多个节点,所述节点包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的基于哈希运算的共识建立程序,所述基于哈希运算的共识建立程序被所述处理器执行时实现如上述基于哈希运算的共识建立方法的步骤。In addition, in order to achieve the above object, the present invention also provides a blockchain system, the blockchain system includes a plurality of nodes, and the nodes include: a memory, a processor, and storage on the memory and available in the A consensus establishment program based on hash operation running on the processor, when the consensus establishment program based on hash operation is executed by the processor, the steps of the above consensus establishment method based on hash operation are implemented.
此外,为实现上述目的,本发明还提供一种存储介质,所述存储介质上存储有基于哈希运算的共识建立程序,所述基于哈希运算的共识建立程序被处理器执行时实现如上述基于哈希运算的共识建立方法的步骤。In addition, in order to achieve the above object, the present invention also provides a storage medium on which a consensus establishment program based on hash operation is stored, and when the consensus establishment program based on hash operation is executed by a processor, the above-mentioned Steps of a hash-based consensus building method.
本发明实施例基于末位区块的记账节点确定待接入区块的交易数据,组成数据包,因为末位区块的记账节点是确定的,所以所述待接入区块的交易数据具有一定的唯一性和确定性,进而使得待接入区块唯一确定,便于该待接入区块的顺利创建;由区块链网络中各节点基于各自节点数据和所述数据包进行哈希运算得到候选哈希值(第一候选哈希值和第二候选哈希值),因为哈希算法不可逆的特点,可以保证候选哈希值完全单向不可预测,即使数据包基于末位区块的记账节点而确定,该末位区块的记账节点也无法因此调整自己的节点数据以作弊方式使得自己的候选哈希值成为目标哈希值,因而排除了末位区块的记账节点作恶的可能,同时,候选哈希值完全单向不可预测,可进一步增强候选哈希值的随机性,即保证待接入区块的记账节点是随机产生的,使得区块链中各节点在竞争记账权时不因算力或权益等其他因素而处于弱势地位,保证区块链中各节点完全平等地竞争记账权,可鼓励更多人参与到区块链中,有利于区块链的推广和应用;因哈希运算的不可逆,哈希值的不可预测,使得记账节点的选择类似于一种抽签机制,故本方案主体名称为基于哈希运算的共识建立方法;在所述候选哈希值中确定唯一的目标哈希值,进而确定广播该唯一目标候选哈希值的节点为待接入区块的记账节点,进而达成区块链共识。In the embodiment of the present invention, the transaction data of the block to be accessed is determined based on the accounting node of the last block to form a data packet. Because the accounting node of the last block is determined, the transaction of the block to be accessed is determined. The data has a certain uniqueness and certainty, so that the block to be accessed is uniquely determined, which facilitates the smooth creation of the block to be accessed; each node in the blockchain network conducts hashing based on their own node data and the data packet. The candidate hash value (the first candidate hash value and the second candidate hash value) is obtained by the hash operation. Because of the irreversible characteristics of the hash algorithm, the candidate hash value can be guaranteed to be completely one-way unpredictable, even if the data packet is based on the last bit area. It is determined by the accounting node of the block, and the accounting node of the last block cannot adjust its own node data to cheat so that its candidate hash value becomes the target hash value, thus excluding the accounting node of the last block. It is possible for the account node to do evil, and at the same time, the candidate hash value is completely one-way unpredictable, which can further enhance the randomness of the candidate hash value, that is, to ensure that the account nodes to be connected to the block are randomly generated, making the blockchain Each node is not in a disadvantaged position due to other factors such as computing power or rights when competing for accounting rights, ensuring that all nodes in the blockchain compete for accounting rights completely and equally, which can encourage more people to participate in the blockchain, which is beneficial to The promotion and application of blockchain; because the hash operation is irreversible and the hash value is unpredictable, the selection of accounting nodes is similar to a lottery mechanism, so the main name of this scheme is the consensus establishment method based on hash operation; A unique target hash value is determined among the candidate hash values, and then the node that broadcasts the unique target candidate hash value is determined as the billing node of the block to be accessed, thereby reaching a blockchain consensus.
附图说明Description of drawings
图1是本发明实施例的区块链系统示意图;1 is a schematic diagram of a blockchain system according to an embodiment of the present invention;
图2是本发明实施例的节点终端结构示意图;2 is a schematic structural diagram of a node terminal according to an embodiment of the present invention;
图3为本发明基于哈希运算的共识建立方法第一实施例的流程示意图;3 is a schematic flowchart of a first embodiment of a method for establishing a consensus based on hash operation according to the present invention;
图4为本发明基于哈希运算的共识建立方法第三实施例的流程示意图;4 is a schematic flowchart of a third embodiment of a method for establishing a consensus based on hash operation according to the present invention;
图5为本发明基于哈希运算的共识建立方法第五实施例的流程示意图;5 is a schematic flowchart of a fifth embodiment of a consensus building method based on hash operation of the present invention;
图6为本发明实施例将图5中的步骤S51细化后的流程示意图;FIG. 6 is a schematic flowchart of the refinement of step S51 in FIG. 5 according to an embodiment of the present invention;
图7为本发明基于哈希运算的共识建立方法第六实施例的场景示意图;FIG. 7 is a schematic diagram of a scenario of a sixth embodiment of a hash operation-based consensus building method according to the present invention;
图8为本发明基于哈希运算的共识建立方法第六实施例的流程示意图;8 is a schematic flowchart of a sixth embodiment of a method for establishing a consensus based on hash operation according to the present invention;
图9为本发明基于哈希运算的共识建立方法第七实施例的流程示意图。FIG. 9 is a schematic flowchart of a seventh embodiment of a method for establishing a consensus based on hash operation according to the present invention.
本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization, functional characteristics and advantages of the present invention will be further described with reference to the accompanying drawings in conjunction with the embodiments.
具体实施方式Detailed ways
应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。It should be understood that the specific embodiments described herein are only used to explain the present invention, but not to limit the present invention.
在后续的描述中,使用用于表示元件的诸如“模块”、“部件”或“单元”的后缀仅为了有利于本发明的说明,其本身没有特定的意义。因此,“模块”、“部件”或“单元”可以混合地使用。In the following description, suffixes such as 'module', 'component' or 'unit' used to represent elements are used only to facilitate the description of the present invention and have no specific meaning per se. Thus, "module", "component" or "unit" may be used interchangeably.
如图1所示,图1是本发明实施例的区块链系统示意图。As shown in FIG. 1 , FIG. 1 is a schematic diagram of a blockchain system according to an embodiment of the present invention.
所述区块链系统包含多个节点,在创建新区块时,某个或某些节点执行特定程序或特定功能,本发明实施例将其记为记账节点,区块链系统中的其他节点为普通节点,每个已创建的区块都有其确定的记账节点。记账节点和普通节点并不是固定的、特定的某些节点,而是会根据区块链的共识算法变化。The blockchain system includes multiple nodes. When a new block is created, one or some nodes execute a specific program or a specific function, which is recorded as an accounting node in the embodiment of the present invention, and other nodes in the blockchain system. For ordinary nodes, each created block has its own accounting node. Accounting nodes and ordinary nodes are not fixed and specific nodes, but will change according to the consensus algorithm of the blockchain.
所述记账节点,用于:The accounting node is used for:
确定准备与末位区块连接的待接入区块的交易数据;Determine the transaction data of the block to be accessed that is to be connected to the last block;
基于所述待接入区块的交易数据,生成数据包,将该数据包向区块链所在的区块链网络广播。Based on the transaction data of the block to be accessed, a data packet is generated, and the data packet is broadcast to the blockchain network where the blockchain is located.
所述记账节点或普通节点,用于:The accounting node or common node is used for:
确定区块链中末位区块的记账节点,基于末位区块的记账节点,获取数据包,所述数据包至少包含准备与末位区块连接的待接入区块的交易数据;Determine the accounting node of the last block in the blockchain, and obtain a data packet based on the accounting node of the last block, and the data packet at least contains the transaction data of the block to be accessed that is to be connected to the last block. ;
基于获取的所述数据包和本节点自存的节点数据,进行哈希运算得到第一候选哈希值;Based on the acquired data packet and the node data stored by the node, a hash operation is performed to obtain a first candidate hash value;
获取其他节点广播的第二候选哈希值,根据第一预设规则在所述第一候选哈希值和第二候选哈希值中选择目标哈希值,该目标哈希值的节点为所述待接入区块的记账节点。Obtain the second candidate hash value broadcast by other nodes, select a target hash value from the first candidate hash value and the second candidate hash value according to the first preset rule, and the node of the target hash value is the Describe the accounting node of the block to be accessed.
所述节点终端可以是服务器、PC,也可以是智能手机、平板电脑、电子书阅读器、MP3(Moving Picture Experts Group Audio Layer III,动态影像专家压缩标准音频层面3)播放器、MP4(Moving Picture Experts Group Audio Layer IV,动态影像专家压缩标准音频层面3)播放器、便携计算机等具有显示功能的可移动式终端设备。The node terminal can be a server, a PC, or a smart phone, a tablet computer, an e-book reader, an MP3 (Moving Picture Experts Group Audio Layer III, moving picture expert compression standard audio layer 3) player, an MP4 (Moving Picture Experts Group Audio Layer IV, moving image expert compression standard audio layer 3) Players, portable computers and other portable terminal devices with display functions.
如图2所示,所述节点可以包括:处理器1001,例如CPU,通信总线1002,用户接口1003,网络接口1004,存储器1005。其中,通信总线1002用于实现这些组件之间的连接通信。用户接口1003可以包括显示屏(Display)、输入单元比如键盘(Keyboard),可选用户接口1003还可以包括标准的有线接口、无线接口。网络接口1004可选的可以包括标准的有线接口、无线接口(如WI-FI接口)。存储器1005可以是高速RAM存储器,也可以是稳定的存储器(non-volatile memory),例如磁盘存储器。存储器1005可选的还可以是独立于前述处理器1001的存储装置。As shown in FIG. 2 , the node may include: a
本领域技术人员可以理解,图1中示出的系统组成部件、图2中示出的节点终端结构,并不构成对系统或节点终端的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。Those skilled in the art can understand that the system components shown in FIG. 1 and the node terminal structure shown in FIG. 2 do not constitute a limitation on the system or the node terminal, and may include more or less components than those shown in the drawings , or a combination of certain components, or a different arrangement of components.
如图2所示,本实施例中,该节点终端包括处理器1001,通信总线1002,用户接口1003,网络接口1004,存储器1005。作为一种计算机存储介质的存储器1005中包括基于哈希运算的共识建立程序。As shown in FIG. 2 , in this embodiment, the node terminal includes a
在图2所示的终端中,网络接口1004主要用于连接后台服务器,与后台服务器进行数据通信;用户接口1003主要用于连接客户端(用户端),与客户端进行数据通信。In the terminal shown in FIG. 2 , the
而处理器1001可以用于调用存储器1005中存储的基于哈希运算的共识建立程序,并执行以下操作:And the
确定区块链中末位区块的记账节点,基于末位区块的记账节点,获取数据包,所述数据包至少包含准备与末位区块连接的待接入区块的交易数据;Determine the accounting node of the last block in the blockchain, and obtain a data packet based on the accounting node of the last block, and the data packet at least contains the transaction data of the block to be accessed that is to be connected to the last block. ;
基于获取的所述数据包和本节点自存的节点数据,进行哈希运算得到第一候选哈希值;Based on the acquired data packet and the node data stored by the node, a hash operation is performed to obtain a first candidate hash value;
获取其他节点广播的第二候选哈希值,根据第一预设规则在所述第一候选哈希值和第二候选哈希值中选择目标哈希值,该目标哈希值的节点为所述待接入区块的记账节点。Obtain the second candidate hash value broadcast by other nodes, select a target hash value from the first candidate hash value and the second candidate hash value according to the first preset rule, and the node of the target hash value is the Describe the accounting node of the block to be accessed.
所述根据预设规则在第一候选哈希值和第二候选哈希值中选择目标哈希值的步骤包括:The step of selecting the target hash value from the first candidate hash value and the second candidate hash value according to the preset rule includes:
在所述第一候选哈希值和第二候选哈希值中确定最小的候选哈希值,该最小候选哈希值为目标哈希值。The smallest candidate hash value is determined among the first candidate hash value and the second candidate hash value, and the smallest candidate hash value is the target hash value.
所述基于获取的所述数据包和本节点自存的节点数据,进行哈希运算得到第一候选哈希值的步骤包括:The step of performing a hash operation to obtain the first candidate hash value based on the acquired data packet and the node data stored by the node itself includes:
获取所述数据包中待接入区块的交易数据,基于该交易数据和末位区块的特征值进行哈希运算,得到第一哈希值;Obtain the transaction data of the block to be accessed in the data packet, and perform a hash operation based on the transaction data and the characteristic value of the last block to obtain a first hash value;
基于自存的私钥对所述第一哈希值进行签名,将签名后的所述第一哈希值进行哈希运算,得到第一候选哈希值。The first hash value is signed based on the self-stored private key, and the signed first hash value is subjected to a hash operation to obtain a first candidate hash value.
所述获取数据包的步骤之后还包括:After the step of obtaining the data packet, it also includes:
根据区块链中的历史交易数据,验证所述数据包中待接入区块的交易数据是否全部有效;According to the historical transaction data in the blockchain, verify whether the transaction data of the block to be accessed in the data packet is all valid;
若该数据包中所述待接入区块的交易数据全部有效,则执行所述基于获取的所述数据包和本节点自存的节点数据,进行哈希运算得到第一候选哈希值这一步骤。If all the transaction data of the to-be-accessed block in the data packet are valid, then perform the hash operation based on the acquired data packet and the node data stored by the node itself, and perform a hash operation to obtain the first candidate hash value. one step.
所述获取其他节点广播的第二候选哈希值的步骤之后还包括:The step of obtaining the second candidate hash value broadcast by other nodes further includes:
基于所述第一候选哈希值和第二候选哈希值,根据第二预设规则判断所述第一候选哈希值是否满足广播条件;Based on the first candidate hash value and the second candidate hash value, determine whether the first candidate hash value satisfies the broadcast condition according to a second preset rule;
若所述第一候选哈希值满足广播条件,则将所述第一候选哈希值向所述区块链所在的区块链网络广播。If the first candidate hash value satisfies the broadcast condition, broadcast the first candidate hash value to the blockchain network where the blockchain is located.
所述根据第二预设规则判断所述第一候选哈希值是否满足广播条件的步骤包括:The step of judging whether the first candidate hash value satisfies the broadcast condition according to the second preset rule includes:
解析第二预设规则,当解析结果为候选哈希值中的最小候选哈希值为目标哈希值时,若所述第一候选哈希值小于所述第二候选哈希值,则所述第一候选哈希值满足广播条件。Parse the second preset rule, when the parsing result is that the minimum candidate hash value among the candidate hash values is the target hash value, if the first candidate hash value is smaller than the second candidate hash value, then the The first candidate hash value satisfies the broadcast condition.
所述确定区块链中末位区块的记账节点,基于末位区块的记账节点,获取数据包的步骤之前包括:Described determining the accounting node of the last block in the blockchain, based on the accounting node of the last block, before the step of acquiring the data packet includes:
所述末位区块的记账节点确定准备与末位区块连接的待接入区块的交易数据;The accounting node of the last block determines the transaction data of the block to be accessed that is to be connected with the last block;
所述末位区块的记账节点基于所述待接入区块的交易数据,生成数据包,将该数据包向区块链所在的区块链网络广播。The accounting node of the last block generates a data packet based on the transaction data of the block to be accessed, and broadcasts the data packet to the blockchain network where the blockchain is located.
所述末位区块的记账节点基于所述待接入区块的交易数据,生成数据包,将该数据包向区块链所在的区块链网络广播的步骤包括:The billing node of the last block generates a data packet based on the transaction data of the block to be accessed, and the steps of broadcasting the data packet to the blockchain network where the blockchain is located include:
所述末位区块的记账节点基于所述交易数据和末位区块的特征值,进行哈希运算得到第二哈希值;The accounting node of the last block performs a hash operation based on the transaction data and the characteristic value of the last block to obtain a second hash value;
所述末位区块的记账节点基于所述交易数据、特征值和第二哈希值生成数据包,并将该数据包向所述区块链所在的区块链网络广播。The accounting node of the last block generates a data packet based on the transaction data, the characteristic value and the second hash value, and broadcasts the data packet to the blockchain network where the blockchain is located.
参照图3,在本发明基于哈希运算的共识建立方法第一实施例中,所述基于哈希运算的共识建立方法包括:Referring to FIG. 3 , in the first embodiment of the method for establishing consensus based on hash operation of the present invention, the method for establishing consensus based on hash operation includes:
步骤S10,确定区块链中末位区块的记账节点,基于末位区块的记账节点,获取数据包,所述数据包至少包含准备与末位区块连接的待接入区块的交易数据;Step S10, determining the accounting node of the last block in the blockchain, and obtaining a data packet based on the accounting node of the last block, the data packet at least containing the block to be accessed that is to be connected to the last block transaction data;
为便于理解本发明方案,以下首先对区块链相关特点进行简单介绍。In order to facilitate the understanding of the solution of the present invention, the following briefly introduces the relevant features of the blockchain.
广义来讲,区块链技术是利用块链式数据结构来验证与存储数据、利用分布式节点共识算法来生成和更新数据、利用密码学的方式保证数据传输和访问的安全、利用由自动化脚本代码组成的智能合约来编程和操作数据的一种全新的分布式基础架构与计算范式。Broadly speaking, blockchain technology is the use of blockchain data structures to verify and store data, the use of distributed node consensus algorithms to generate and update data, the use of cryptography to ensure the security of data transmission and access, and the use of automated scripts. A new distributed infrastructure and computing paradigm for programming and manipulating data using smart contracts composed of code.
狭义来讲,区块链是一串使用密码学方法相关联产生的数据区块,是一种按照时间顺序将数据区块以顺序相连的方式组合成的一种链式数据结构。每一个数据块中包含交易信息,区块链中的每一笔交易都通过密码学方法与相邻两个区块串联,因此可追溯到任何一笔交易的历史,因此可实现信息有效性的验证和生成下一个区块。In a narrow sense, a blockchain is a series of data blocks that are associated using cryptographic methods. Each data block contains transaction information, and each transaction in the blockchain is concatenated with two adjacent blocks through cryptographic methods, so it can be traced back to the history of any transaction, so it can realize the validity of information. Validate and generate the next block.
区块链网络是由众多节点共同组成的一个端到端网络,每台设备都可作为一个节点,节点间基于一套共识机制,通过竞争计算共同维护整个区块链。节点可获得完整的区块链副本(狭义上的区块链,相当于数据库),这种节点一般为中继节点,也可仅获取部分区块链副本,如仅保存区块头信息,通过P2P(点对点)的方式按图索骥的找到中继节点,从而搜索到所需信息。The blockchain network is an end-to-end network composed of many nodes. Each device can be used as a node. Based on a consensus mechanism, the nodes jointly maintain the entire blockchain through competitive computing. Nodes can obtain a complete copy of the blockchain (blockchain in the narrow sense, equivalent to a database). This kind of node is generally a relay node, or only a partial copy of the blockchain can be obtained. For example, only the block header information is saved, and the P2P (Peer-to-peer) way to find the relay node according to the map, so as to search for the required information.
区块链中的所有数据信息是公开的,区块链上所有交易对所有节点可见。区块链的每一个区块有各自的记账节点。All data information in the blockchain is public, and all transactions on the blockchain are visible to all nodes. Each block of the blockchain has its own accounting node.
本实施例中的区块链为狭义上的区块链,即按照时间顺序将数据区块以顺序相连的方式组合成的一种链式数据结构。末位区块指区块链最新产生的一个区块,从区块链的链式结构上说,末位区块指区块链的最后一个区块。本实施例中的待接入区块指即将创建但尚未创建的新区块。The blockchain in this embodiment is a blockchain in a narrow sense, that is, a chain data structure formed by combining data blocks in a sequential manner according to time sequence. The last block refers to the latest block generated by the blockchain. From the chain structure of the blockchain, the last block refers to the last block of the blockchain. The block to be accessed in this embodiment refers to a new block to be created but not yet created.
现有技术中的记账节点指创建区块的节点,该节点可以为单个,也可为多个(多个的情形为小组形式)。但本实施例中,末位区块的记账节点并非指确定末位区块交易数据的节点,而是指确定待接入区块交易数据的、与末位区块有名义上的记账关系的节点,末位区块确定,末位区块的记账节点也是确定的。确定区块链中末位区块的记账节点,包括不限于下述方式:可以通过查询该末位区块上的签名信息来确定,例如,若该末位区块上有某节点的私钥签名,则该节点为末位区块的记账节点。An accounting node in the prior art refers to a node that creates a block, and the node may be single or multiple (in the case of multiple, the node is in the form of a small group). However, in this embodiment, the accounting node of the last block does not refer to the node that determines the transaction data of the last block, but refers to the node that determines the transaction data of the block to be accessed and has nominal accounting with the last block. The node of the relationship, the last block is determined, and the accounting node of the last block is also determined. Determining the accounting node of the last block in the blockchain includes but is not limited to the following methods: It can be determined by querying the signature information on the last block. For example, if the last block has a private key signature, the node is the accounting node of the last block.
本实施例中的数据包,至少包含末位区块的记账节点确定的、准备与末位区块连接的待接入区块的交易数据,数据包包括但不限于以下几种组成方式:所述数据包可以仅包含待接入区块的交易数据;可以是将待接入区块的交易数据进行哈希运算得到的哈希值与所述待接入区块的交易数据的集合;也可以是将待接入区块的交易数据与其他数据,如末位区块的特征值、扰动因子进行哈希运算得到的哈希值与所述待接入区块的交易数据的集合,其中末位区块的特征值可以指将末位区块的交易数据进行哈希运算得到的哈希值。The data packet in this embodiment at least includes the transaction data of the block to be accessed that is determined by the accounting node of the last block and is prepared to be connected to the last block, and the data packet includes but is not limited to the following several composition modes: The data packet may only contain the transaction data of the block to be accessed; it may be a collection of a hash value obtained by performing a hash operation on the transaction data of the block to be accessed and the transaction data of the block to be accessed; It can also be a set of hash values obtained by hashing the transaction data of the block to be accessed and other data, such as the characteristic value of the last block and the disturbance factor, and the transaction data of the block to be accessed, The characteristic value of the last block may refer to a hash value obtained by hashing the transaction data of the last block.
本实施例中,由区块链网络中的各节点基于末位区块的记账节点,获取数据包,末位区块的记账节点还可以获取所述数据包,参与待接入区块记账节点的竞选(此时,末位区块的记账节点可直接对所述数据包进行下一步操作),也可以将其排除在竞选之外。普通节点直接接收末位区块的记账节点广播的所述数据包。In this embodiment, each node in the blockchain network obtains the data packet based on the accounting node of the last block, and the accounting node of the last block can also obtain the data packet and participate in the block to be accessed. The election of the accounting node (at this time, the accounting node of the last block can directly perform the next operation on the data packet), or it can be excluded from the election. The ordinary node directly receives the data packet broadcast by the accounting node of the last block.
步骤S11,基于获取的所述数据包和本节点自存的节点数据,进行哈希运算得到第一候选哈希值;Step S11, based on the acquired data packet and the node data stored by the node itself, perform a hash operation to obtain a first candidate hash value;
本实施例中,节点数据为确定的、节点无法在短时间内变更的,在一个程度上独属于节点的数据,可以为节点私钥,或者其他节点标识信息。In this embodiment, the node data is definite, the node cannot be changed in a short time, and to a certain extent, the data unique to the node may be the node private key or other node identification information.
区块链各节点接收到所述数据包后(若末位区块的记账节点参与竞选,末位区块的记账节点直接对存储在本地的数据包进行后续操作),可根据所述数据包包含的数据内容确定下一步操作,若所述数据包仅包含待接入区块的交易数据,则可直接对该待接入区块的交易数据进行一定操作,若所述数据包除了包括待接入区块的交易数据外还包括其他值,则可将所述数据包中的所有或者部分内容进行一定操作后,与自存的节点数据进行哈希运算。After each node of the blockchain receives the data packet (if the accounting node of the last block participates in the election, the accounting node of the last block directly performs subsequent operations on the data packet stored locally), it can be The data content contained in the data packet determines the next operation. If the data packet only contains the transaction data of the block to be accessed, a certain operation can be directly performed on the transaction data of the block to be accessed. If other values are included in addition to the transaction data of the block to be accessed, all or part of the content in the data packet may be subjected to a certain operation, and then a hash operation may be performed with the self-stored node data.
基于所述数据包和自存的节点数据,进行哈希运算,可以是直接将所述数据包包含的所有内容和各自的节点数据进行哈希运算,也可以是将节点数据或所述数据包进行相关处理后再进行哈希运算。The hash operation is performed based on the data packet and the self-stored node data, which may be to directly perform a hash operation on all the contents contained in the data packet and the respective node data, or to perform a hash operation on the node data or the data packet. After the relevant processing is performed, the hash operation is performed.
所述相关处理可以包括但不限于:The relevant processing may include, but is not limited to:
若所述数据包仅包含待接入区块的交易数据,则可将该交易数据进行哈希运算得到哈希值,将该哈希值与节点数据再次进行哈希运算得到第一候选哈希值(下文称HASH1);或者将该交易数据进行哈希运算得到哈希值,将该哈希值+该交易数据+节点数据再次进行哈希运算得到HASH1。If the data packet only contains the transaction data of the block to be accessed, the transaction data can be hashed to obtain a hash value, and the hash value and the node data can be hashed again to obtain the first candidate hash value (hereinafter referred to as HASH1); or perform a hash operation on the transaction data to obtain a hash value, and perform a hash operation on the hash value + the transaction data + node data again to obtain HASH1.
若所述数据包包含待接入区块的交易数据和该交易数据的哈希值,则可只选择其中的交易数据的哈希值,将该哈希值与节点数据再次进行哈希运算得到HASH1;或者可将该交易数据和该交易数据的哈希值进行哈希运算后得到次哈希值,将该次哈希值+节点数据进行哈希运算,得到HASH1。If the data packet contains the transaction data of the block to be accessed and the hash value of the transaction data, only the hash value of the transaction data in the data packet can be selected, and the hash value and the node data can be hashed again to obtain HASH1; or the transaction data and the hash value of the transaction data can be hashed to obtain a secondary hash value, and the secondary hash value + node data can be hashed to obtain HASH1.
若所述数据包不仅包含待接入区块的交易数据和该交易数据的哈希值,还包括其他数据,如末位区块的特征值,则可将其中某些数据进行哈希运算后,再将哈希结果与节点数据进行哈希运算得到HASH1。If the data packet includes not only the transaction data of the block to be accessed and the hash value of the transaction data, but also other data, such as the characteristic value of the last block, some of the data can be hashed after , and then perform a hash operation on the hash result and the node data to obtain HASH1.
也可将节点数据和所述数据包进行某些运算后,对运算结果进行哈希运算,得到HASH1。譬如,若节点数据为私钥,可使用私钥对所述数据包进行签名后,再将签名后的信息进行哈希运算。After some operations are performed on the node data and the data packet, a hash operation may be performed on the operation result to obtain HASH1. For example, if the node data is a private key, the private key can be used to sign the data packet, and then the signed information can be hashed.
本实施例中的第一候选哈希值(即HASH1)指区块链网络中的节点为竞争记账权所产生的哈希值。The first candidate hash value (ie, HASH1 ) in this embodiment refers to a hash value generated by nodes in the blockchain network competing for the accounting right.
步骤S12,获取其他节点广播的第二候选哈希值,根据第一预设规则在所述第一候选哈希值和第二候选哈希值中选择目标哈希值,该目标哈希值的节点为所述待接入区块的记账节点。Step S12: Obtain the second candidate hash value broadcasted by other nodes, and select a target hash value from the first candidate hash value and the second candidate hash value according to the first preset rule. The node is the accounting node of the block to be accessed.
本实施例中的第二候选哈希值(下文称HASH2)指,相对于本节点的其他节点产生的哈希值。如区块链网络中有A、B、C、D四节点,站在A的角度,A自己产生的候选哈希值为第一候选哈希值(HASH1),B、C、D产生的候选哈希值为第二候选哈希值(HASH2),但如果站在B的角度,B自己产生的候选哈希值为HASH1,A、C、D产生的候选哈希值为HASH2。候选哈希值指区块链网络中各节点为了竞争记账权而生成的哈希值。本实施例中的第一、第二仅为区分本节点和其他节点产生的候选哈希值。HASH2可以有多个。The second candidate hash value (hereinafter referred to as HASH2) in this embodiment refers to a hash value generated by other nodes relative to this node. For example, there are four nodes A, B, C, and D in the blockchain network. From the perspective of A, the candidate hash value generated by A itself is the first candidate hash value (HASH1), and the candidate hash value generated by B, C, and D is the first candidate hash value (HASH1). The hash value is the second candidate hash value (HASH2), but from the perspective of B, the candidate hash value generated by B itself is HASH1, and the candidate hash value generated by A, C, and D is HASH2. The candidate hash value refers to the hash value generated by each node in the blockchain network in order to compete for the accounting rights. The first and second in this embodiment are only candidate hash values generated by distinguishing this node from other nodes. HASH2 can have more than one.
本实施例中的第一预设规则是用于确定目标哈希值的规则,可以存储在区块链的特定地址上,当需要选举记账节点时可直接调用该第一预设规则。The first preset rule in this embodiment is a rule for determining the target hash value, which can be stored in a specific address of the blockchain, and the first preset rule can be directly invoked when an accounting node needs to be elected.
根据该第一预设规则应当可以在多个所述候选哈希值中选择出唯一的一个哈希值(即目标哈希值),可为候选哈希值中的最大值,也可为根据特定算法确定的大小序号,如将所有候选哈希值进行大小排序,根据特定算法确定第N个候选哈希值为目标哈希值。该目标哈希值的节点指广播该目标哈希值的节点。According to the first preset rule, it should be possible to select a unique hash value (that is, the target hash value) among the plurality of candidate hash values, which may be the maximum value among the candidate hash values, or may be based on The size sequence number determined by a specific algorithm, such as sorting all candidate hash values by size, and determining the Nth candidate hash value according to the specific algorithm as the target hash value. The node of the target hash value refers to the node that broadcasts the target hash value.
区块链中各节点均可获得已广播的候选哈希值,所以在确定目标哈希值时,区块链中各节点可根据第一预设规则,在所有候选哈希值中选出目标哈希值。Each node in the blockchain can obtain the broadcast candidate hash value, so when determining the target hash value, each node in the blockchain can select the target from all the candidate hash values according to the first preset rule hash value.
可选地,步骤S12中根据预设规则在第一候选哈希值和第二候选哈希值中选择目标哈希值这一步骤包括:Optionally, the step of selecting the target hash value from the first candidate hash value and the second candidate hash value according to a preset rule in step S12 includes:
步骤S13,在所述第一候选哈希值和第二候选哈希值中确定最小的候选哈希值,该最小候选哈希值为目标哈希值。Step S13: Determine the smallest candidate hash value among the first candidate hash value and the second candidate hash value, where the smallest candidate hash value is the target hash value.
本实施例中,第一预设规则规定最小的候选哈希值为目标哈希值。In this embodiment, the first preset rule specifies that the minimum candidate hash value is the target hash value.
区块链中各节点将接收的所有第二候选哈希值(HASH2不止一个)和各自节点产生的第一候选哈希值(HASH1)进行大小比较(也包括HASH2间的比较),选出其中最小的哈希值,即目标哈希值。Each node in the blockchain compares the size of all the second candidate hash values (more than one HASH2) received with the first candidate hash value (HASH1) generated by their respective nodes (including the comparison between HASH2), and selects one of them. The smallest hash value, the target hash value.
本实施例将最小候选哈希值确定为目标哈希值,因为大小判断容易实现,所以计算量不大,本实施例较易实现,同时,本实施例明确了目标哈希值的确定规则,进一步确定待接入区块的记账节点。In this embodiment, the minimum candidate hash value is determined as the target hash value. Because the size judgment is easy to implement, the amount of calculation is not large. This embodiment is relatively easy to implement. At the same time, this embodiment clarifies the determination rules for the target hash value. Further determine the accounting node of the block to be accessed.
在本实施例中,基于末位区块的记账节点确定待接入区块的交易数据,组成数据包,因为末位区块的记账节点是确定的,所以所述待接入区块的交易数据具有一定的唯一性和确定性,进而使得待接入区块唯一确定,便于该待接入区块的顺利创建;In this embodiment, the transaction data of the block to be accessed is determined based on the accounting node of the last block to form a data packet. Because the accounting node of the last block is determined, the block to be accessed is determined. The transaction data has certain uniqueness and certainty, so that the block to be accessed is uniquely determined, which is convenient for the smooth creation of the block to be accessed;
由区块链网络中各节点基于各自节点数据和所述数据包进行哈希运算得到候选哈希值(第一候选哈希值和第二候选哈希值),因为哈希算法不可逆的特点,可以保证候选哈希值完全单向不可预测,即使数据包基于末位区块的记账节点而确定,该末位区块的记账节点也无法因此调整自己的节点数据以作弊方式使得自己的候选哈希值成为目标哈希值,因而排除了末位区块的记账节点作恶的可能,同时,候选哈希值完全单向不可预测,可进一步增强候选哈希值的随机性,即保证待接入区块的记账节点是随机产生的,使得区块链中各节点在竞争记账权时不因算力或权益等其他因素而处于弱势地位,保证区块链中各节点完全平等地竞争记账权,可鼓励更多人参与到区块链中,有利于区块链的推广和应用;因哈希运算的不可逆,哈希值的不可预测,使得记账节点的选择类似于一种抽签机制,故本方案主体名称为基于哈希运算的共识建立方法;The candidate hash values (the first candidate hash value and the second candidate hash value) are obtained by each node in the blockchain network based on the respective node data and the data packet by performing hash operations. Because of the irreversible characteristics of the hash algorithm, It can ensure that the candidate hash value is completely one-way unpredictable. Even if the data packet is determined based on the accounting node of the last block, the accounting node of the last block cannot adjust its own node data to cheat its own node data. The candidate hash value becomes the target hash value, thus eliminating the possibility of malicious acts by the accounting node of the last block. At the same time, the candidate hash value is completely one-way unpredictable, which can further enhance the randomness of the candidate hash value, that is, guarantee The accounting nodes to be connected to the block are randomly generated, so that each node in the blockchain will not be in a weak position due to other factors such as computing power or rights when competing for accounting rights, and ensure that all nodes in the blockchain are completely equal. Competing for the right to bookkeeping can encourage more people to participate in the blockchain, which is conducive to the promotion and application of the blockchain; due to the irreversibility of the hash operation and the unpredictability of the hash value, the selection of accounting nodes is similar to that of a A lottery mechanism, so the name of the main body of this scheme is a consensus building method based on hash operation;
在所述候选哈希值中确定唯一候选哈希值,进而确定广播该唯一候选哈希值的节点为待接入区块的记账节点,进而达成区块链共识。A unique candidate hash value is determined among the candidate hash values, and then the node that broadcasts the unique candidate hash value is determined as the billing node of the block to be accessed, thereby reaching a blockchain consensus.
本发明实施例基于哈希运算的共识建立方法第二实施例中,基于该方法的第一实施例,步骤S11包括:In the second embodiment of the hash operation-based consensus establishment method according to the embodiment of the present invention, based on the first embodiment of the method, step S11 includes:
步骤S20,获取所述数据包中待接入区块的交易数据,基于该交易数据和末位区块的特征值进行哈希运算,得到第一哈希值;Step S20, acquiring the transaction data of the block to be accessed in the data packet, and performing a hash operation based on the transaction data and the characteristic value of the last block to obtain a first hash value;
步骤S21,基于自存的私钥对所述第一哈希值进行签名,将签名后的所述第一哈希值进行哈希运算,得到第一候选哈希值。Step S21: Sign the first hash value based on the self-stored private key, and perform a hash operation on the signed first hash value to obtain a first candidate hash value.
为了确定待接入区块的唯一性,其交易数据需由某特定节点确定,本实施例中,当前区块的交易数据均由上一区块的记账节点确定,即待接入区块的交易数据由末位区块的记账节点确定,末位区块的记账节点确定了待接入区块的交易数据后,将至少包含该待接入区块的交易数据的数据包向区块链网络广播。In order to determine the uniqueness of the block to be accessed, its transaction data needs to be determined by a specific node. In this embodiment, the transaction data of the current block is determined by the accounting node of the previous block, that is, the block to be accessed. The transaction data of the last block is determined by the accounting node of the last block. After the accounting node of the last block determines the transaction data of the block to be accessed, it sends the data packet containing at least the transaction data of the block to be accessed to the Blockchain webcast.
本实施例中,末位区块的特征值指将末位区块所包含的所有内容进行哈希运算所获得的哈希值或将末位区块交易数据的集合进行哈希运算所获得的哈希值。In this embodiment, the characteristic value of the last block refers to a hash value obtained by performing a hash operation on all the contents contained in the last block or a hash value obtained by performing a hash operation on the set of transaction data of the last block. hash value.
基于该待接入区块的交易数据和末位区块的特征值进行哈希运算,可以指直接将该待接入区块的交易数据和末位区块的特征值进行哈希运算,也可指将该待接入区块的交易数据和末位区块的特征值进行前期处理再进行哈希运算,前期处理可指将该待接入区块的交易数据进行一次哈希运算。Performing a hash operation based on the transaction data of the block to be accessed and the characteristic value of the last block may refer to directly performing a hash operation on the transaction data of the block to be accessed and the characteristic value of the last block, or It can refer to pre-processing the transaction data of the block to be accessed and the characteristic value of the last block and then performing a hash operation, and the pre-processing can refer to performing a hash operation on the transaction data of the block to be accessed.
区块链网络中各节点均可获得区块链副本,所以,末位区块的特征值可自行获取。因为第一哈希值是基于接入区块的交易数据和末位区块的特征值进行哈希运算获得,所以,区块链网络中所有节点产生的第一哈希值相等。Each node in the blockchain network can obtain a copy of the blockchain, so the characteristic value of the last block can be obtained by itself. Because the first hash value is obtained by performing a hash operation based on the transaction data of the access block and the characteristic value of the last block, the first hash values generated by all nodes in the blockchain network are equal.
获得第一哈希值后,区块链网络中各节点使用自己的私钥对第一哈希值进行签名,再将签名后的第一哈希值进行哈希运算,得到HASH1。After obtaining the first hash value, each node in the blockchain network signs the first hash value with its own private key, and then performs a hash operation on the signed first hash value to obtain HASH1.
本实施例中,通过各节点基于数据包中待接入区块的交易数据生成第一哈希值,再基于私钥对所述第一哈希值的签名结果,生成用于竞选的候选哈希值,因为哈希运算的不可逆性,两次哈希运算可进一步增强哈希值的不可预测性,可防止末位区块的记账节点作恶,也可保证候选哈希值的随机生成,竞选记账节点可完全随机,各节点公平竞选,机会平等,吸引更多人使用区块链,推动区块链的发展。In this embodiment, each node generates a first hash value based on the transaction data of the block to be accessed in the data packet, and then generates a candidate hash value for election based on the result of signing the first hash value with the private key. Hash value, because of the irreversibility of the hash operation, two hash operations can further enhance the unpredictability of the hash value, prevent the accounting node of the last block from doing evil, and also ensure the random generation of candidate hash values. The election bookkeeping node can be completely random, each node is fair and has equal opportunities, attracting more people to use the blockchain and promoting the development of the blockchain.
参照图4,在本发明基于哈希运算的共识建立方法第三实施例中,基于该方法的第一实施例或第二实施例,步骤S10之后还包括:Referring to FIG. 4 , in the third embodiment of the hash operation-based consensus establishment method of the present invention, based on the first embodiment or the second embodiment of the method, after step S10, the method further includes:
步骤S30,查询区块链中的历史交易数据;Step S30, query the historical transaction data in the blockchain;
步骤S31,根据区块链中的历史交易数据,验证所述数据包中待接入区块的交易数据是否全部有效;Step S31, according to the historical transaction data in the blockchain, verify whether the transaction data of the block to be accessed in the data packet is all valid;
步骤S32,若该数据包中所述待接入区块的交易数据全部有效,则执行所述基于获取的所述数据包和本节点自存的节点数据,进行哈希运算得到第一候选哈希值的步骤;Step S32, if all the transaction data of the to-be-accessed block in the data packet are valid, execute the hash operation based on the acquired data packet and the node data stored by the node itself, and obtain the first candidate hash. the value of the steps;
步骤S33,若该数据包中所述待接入区块的交易数据中存在无效交易数据,则所述数据包无效,重新确定末位区块的记账节点。Step S33, if invalid transaction data exists in the transaction data of the block to be accessed in the data packet, the data packet is invalid, and the accounting node of the last block is re-determined.
解析所述数据包,首先验证其中的待接入区块的交易数据是否全部有效,因为每一个区块中包含交易信息,区块链中的每一笔交易都通过密码学方法与相邻两个区块串联,因此可追溯到任何一笔交易的历史,所以各参与节点可通过自存的完整的区块链或部分区块链中存储的历史交易数据,验证所述数据中的待接入区块的交易数据是否全部有效。Parse the data packet, first verify whether the transaction data of the block to be accessed is all valid, because each block contains transaction information, and each transaction in the blockchain is encrypted with the adjacent two through the cryptographic method. Each block is connected in series, so it can be traced back to the history of any transaction, so each participating node can verify the pending transaction data in the data through the self-stored complete blockchain or historical transaction data stored in the partial blockchain. Whether the transaction data entered into the block is all valid.
若所述交易数据全部有效,则基于所述数据包和自存的节点数据进行哈希运算,可以直接将所述数据包中所有内容和自存的节点数据进行哈希运算,也可将所述数据包中部分内容和自存的节点数据进行哈希运算,也可将所述数据包和自存的节点数据进行前期处理再进行哈希运算,例如,获取所述数据包中的待接入区块的交易数据,将所述数据包中待接入区块的交易数据进行哈希运算后得到哈希值,各节点使用私钥将该哈希值签名后,将签名结果进行哈希运算。If all the transaction data are valid, hash operation is performed based on the data packet and the self-stored node data, and all contents in the data packet and the self-stored node data can be directly hashed, or all the data in the data packet can be directly hashed. Hash operation is performed on part of the content in the data packet and the self-stored node data, or the data packet and the self-stored node data can also be pre-processed and then hashed, for example, to obtain the pending data in the data packet. Enter the transaction data of the block, hash the transaction data of the block to be accessed in the data packet to obtain a hash value, and each node uses the private key to sign the hash value, and then hash the signature result. operation.
若所述数据包中待接入区块的交易数据中,存在无效交易数据,则因为所述待接入区块的交易数据是基于末位区块的记账节点获得的,出现无效交易,则说明存在末位区块的记账节点为恶节点的可能,为减少恶节点作恶,对末位区块的记账节点进行一定惩罚。惩罚措施可以罚款,也可以剥夺记账权,需重新确定末位区块的记账节点。If there is invalid transaction data in the transaction data of the block to be accessed in the data packet, because the transaction data of the block to be accessed is obtained based on the accounting node of the last block, an invalid transaction occurs, It means that there is a possibility that the accounting node of the last block is an evil node. In order to reduce the evil of the evil node, the accounting node of the last block will be punished to a certain extent. Penalties can be fined or deprived of the accounting right, and the accounting node of the last block needs to be re-determined.
本实施例验证该数据包中待接入区块的交易数据是否全部有效,若该数据包中所述待接入区块的交易数据全部有效,则对该数据包进行数字签名,再将该签名后的数据包进行哈希运算,得到第一候选哈希值,参与竞选;若该数据包中存在无效交易数据,则因为该数据包中的交易数据由末位区块的记账节点确定,所以,存在该末位区块的记账节点为恶节点的可能,所以该末位区块的记账节点确定的数据包无效,重新确定末位区块的记账节点,因而通过验证所述交易数据的有效性,排除恶节点作恶的可能性,还可增大恶节点的作恶成本,以降低节点作恶可能,维护区块链的正常运行;同时,基于所述数据包和各节点自存的独特的节点数据进行哈希运算,可保证获得唯一的第一候选哈希值,可保证后续唯一的目标哈希值的确定,进而成功确定待接入区块的记账节点。This embodiment verifies whether the transaction data of the block to be accessed in the data packet is all valid. If the transaction data of the block to be accessed in the data packet is all valid, the data packet is digitally signed, and then the data packet is digitally signed. The signed data packet is hashed to obtain the first candidate hash value and participate in the election; if there is invalid transaction data in the data packet, because the transaction data in the data packet is determined by the accounting node of the last block , therefore, there is a possibility that the billing node of the last block is an evil node, so the data packet determined by the billing node of the last block is invalid, and the billing node of the last block is re-determined, so that by verifying all The validity of the transaction data described above can eliminate the possibility of malicious nodes doing evil, and can also increase the cost of malicious nodes, so as to reduce the possibility of malicious nodes and maintain the normal operation of the blockchain; at the same time, based on the data packets and the The unique node data stored in the hash operation can be guaranteed to obtain a unique first candidate hash value, which can ensure the subsequent determination of the unique target hash value, and then successfully determine the accounting node of the block to be accessed.
在本发明基于哈希运算的共识建立方法第四实施例中,基于该方法的第一实施例或者第二实施例或者第三实施例,步骤S12中获取其他节点广播的第二候选哈希值的步骤之后还包括:In the fourth embodiment of the hash operation-based consensus establishment method of the present invention, based on the first embodiment or the second embodiment or the third embodiment of the method, the second candidate hash value broadcast by other nodes is obtained in step S12 The steps also include:
步骤S40,基于所述第一候选哈希值和第二候选哈希值,根据第二预设规则判断所述第一候选哈希值是否满足广播条件;Step S40, based on the first candidate hash value and the second candidate hash value, according to a second preset rule, determine whether the first candidate hash value satisfies the broadcast condition;
本实施例中的第二预设规则指确定目标哈希值的规则。所述第二预设规则可以存储在区块链的特定地址上,当需要确定记账节点时可直接调用该第二预设规则。该第二预设规则可以但不限于为:选择候选哈希值中最大的候选哈希值;选择最小的候选哈希值;根据一定算法获取的唯一候选哈希值。The second preset rule in this embodiment refers to a rule for determining the target hash value. The second preset rule can be stored on a specific address of the blockchain, and the second preset rule can be directly invoked when the billing node needs to be determined. The second preset rule may be, but is not limited to: selecting the largest candidate hash value among the candidate hash values; selecting the smallest candidate hash value; and the only candidate hash value obtained according to a certain algorithm.
本实施例中的广播条件需根据第二预设规则确定。例如:第二预设规则为获取候选哈希值中最大的候选哈希值,则广播条件可以为:第一候选哈希值大于第二候选哈希值。The broadcast conditions in this embodiment need to be determined according to the second preset rule. For example, if the second preset rule is to obtain the largest candidate hash value among the candidate hash values, the broadcast condition may be: the first candidate hash value is greater than the second candidate hash value.
具体地,步骤S40中根据第二预设规则判断所述第一候选哈希值是否满足广播条件这一步骤包括:Specifically, the step of judging whether the first candidate hash value satisfies the broadcast condition according to the second preset rule in step S40 includes:
步骤S41,解析第二预设规则,当解析结果为候选哈希值中的最小候选哈希值为目标哈希值时,若所述第一候选哈希值小于所述第二候选哈希值,则所述第一候选哈希值满足广播条件。Step S41, parsing the second preset rule, when the parsing result is that the minimum candidate hash value among the candidate hash values is the target hash value, if the first candidate hash value is smaller than the second candidate hash value , the first candidate hash value satisfies the broadcast condition.
解析第二预设规则,本实施例中,第二预设规则为:候选哈希值中最小的候选哈希值为目标哈希值,则广播条件为第一候选哈希值小于第二候选哈希值。因为,预设规则规定最小的候选哈希值为目标哈希值,所以,当第一候选哈希值大于第二候选哈希值时,该第一候选哈希值的节点不可能成功竞争到记账权,所以,该第一候选哈希值没有必要广播。(数据量减少,节省计算资源)若第一候选哈希值小于第二候选哈希值,则该第一候选哈希值的节点还有可能竞争到记账权,此时需要广播该第一候选哈希值。Parse the second preset rule. In this embodiment, the second preset rule is: the smallest candidate hash value among the candidate hash values is the target hash value, and the broadcast condition is that the first candidate hash value is smaller than the second candidate hash value. hash value. Because the preset rule stipulates that the minimum candidate hash value is the target hash value, when the first candidate hash value is greater than the second candidate hash value, the node of the first candidate hash value cannot successfully compete for the target hash value. Accounting right, so the first candidate hash value does not need to be broadcast. (The amount of data is reduced, and computing resources are saved) If the first candidate hash value is smaller than the second candidate hash value, the node of the first candidate hash value may still compete for the accounting right. At this time, it is necessary to broadcast the first candidate hash value. Candidate hash value.
本实施例中,由预设规则确定广播条件为第一候选哈希值小于第二候选哈希值,使得在区块链中各节点处可首先进行一轮比较,当第一候选哈希值小于第二候选哈希值,因为第一候选哈希值的节点仍旧有竞争成功的可能,所以可将该第一候选哈希值广播,该第一候选哈希值满足广播条件,可将确定目标哈希值的计算量分担给区块链中各节点,提升竞选效率。In this embodiment, the preset rule determines that the broadcast condition is that the first candidate hash value is smaller than the second candidate hash value, so that each node in the blockchain can first perform a round of comparison, when the first candidate hash value is is smaller than the second candidate hash value, because the nodes of the first candidate hash value still have the possibility of successful competition, so the first candidate hash value can be broadcast, the first candidate hash value satisfies the broadcast conditions, and the determination can be The calculation amount of the target hash value is shared among the nodes in the blockchain to improve the campaign efficiency.
步骤S42,若所述第一候选哈希值满足广播条件,则将所述第一候选哈希值向所述区块链所在的区块链网络广播。Step S42, if the first candidate hash value satisfies the broadcast condition, broadcast the first candidate hash value to the blockchain network where the blockchain is located.
若所述第一候选哈希值满足广播条件,表明所述第一候选哈希值有可能竞争成为待接入区块的记账节点,则需要将所述第一候选哈希值向区块链所在的区块链网络广播,以参与记账节点的竞选。若所述第一候选哈希值不满足广播条件,则无需将第一候选哈希值向所述区块链所在的区块链网络广播If the first candidate hash value satisfies the broadcast condition, indicating that the first candidate hash value may compete to become the accounting node of the block to be accessed, it is necessary to send the first candidate hash value to the block The blockchain network where the chain is located broadcasts to participate in the election of the accounting node. If the first candidate hash value does not meet the broadcast conditions, there is no need to broadcast the first candidate hash value to the blockchain network where the blockchain is located
本实施例通过设定广播条件,在区块链各节点处就进行第一轮筛选,将竞选待接入区块记账节点有希望的节点的候选哈希值广播,可降低计算量,提升竞选效率,尽快选定待接入区块的记账节点。In this embodiment, by setting the broadcast conditions, the first round of screening is performed at each node of the blockchain, and the candidate hash values of the nodes that are promising candidates for the block accounting node to be accessed are broadcast, which can reduce the amount of calculation and improve the Efficiency of the election campaign, as soon as possible to select the accounting node to be connected to the block.
参照图5,在本发明基于哈希运算的共识建立方法第五实施例中,基于该方法的第一实施例或者第二实施例或者第三实施例或者第四实施例,步骤S10之前包括:5 , in the fifth embodiment of the hash operation-based consensus establishment method of the present invention, based on the first embodiment or the second embodiment or the third embodiment or the fourth embodiment of the method, before step S10 :
步骤S50,末位区块的记账节点确定准备与末位区块连接的待接入区块的交易数据;Step S50, the accounting node of the last block determines the transaction data of the block to be accessed that is to be connected with the last block;
步骤S51,末位区块的记账节点基于所述待接入区块的交易数据,生成数据包,将该数据包向区块链所在的区块链网络广播。Step S51, the accounting node of the last block generates a data packet based on the transaction data of the block to be accessed, and broadcasts the data packet to the blockchain network where the blockchain is located.
本实施例由末位区块的记账节点确定待接入区块的交易数据及各交易的连接顺序,并基于所述待接入区块的交易数据生成数据包。本实施例中,基于所述待接入区块的交易数据生成数据包,所述数据包应该至少包含待接入区块的交易数据,数据包包括但不限于以下几种组成方式:所述数据包可以仅包含待接入区块的交易数据;可以是将待接入区块的交易数据进行哈希运算得到的哈希值与所述待接入区块的交易数据的集合;也可以是将待接入区块的交易数据与其他数据,如末位区块的特征值或扰动因子进行哈希运算得到的哈希值与所述待接入区块的交易数据的集合,其中末位区块的特征值可以指将末位区块的交易数据进行哈希运算得到的哈希值。In this embodiment, the accounting node of the last block determines the transaction data of the block to be accessed and the connection sequence of each transaction, and generates a data packet based on the transaction data of the block to be accessed. In this embodiment, a data packet is generated based on the transaction data of the block to be accessed, and the data packet should at least contain the transaction data of the block to be accessed. The data packet includes but is not limited to the following composition modes: the The data packet may only contain the transaction data of the block to be accessed; it may be a collection of a hash value obtained by performing a hash operation on the transaction data of the block to be accessed and the transaction data of the block to be accessed; or It is a collection of the hash value obtained by hashing the transaction data of the block to be accessed and other data, such as the characteristic value or disturbance factor of the last block, and the transaction data of the block to be accessed, where the last The feature value of the bit block may refer to the hash value obtained by hashing the transaction data of the last block.
生成所述数据包后,需要向区块链网络广播,以便其他节点获取。After the data packet is generated, it needs to be broadcast to the blockchain network so that other nodes can obtain it.
本实施例通过由末位区块的记账节点确定待接入区块的交易数据及各交易的连接顺序,确保了待接入区块的交易数据的唯一性,使得待接入区块顺利生成;基于待接入区块的交易数据生成数据包,向区块链网络广播,可发起待接入区块记账节点的竞选,以便顺利选出待接入区块的记账节点。In this embodiment, the transaction data of the block to be accessed and the connection sequence of each transaction are determined by the accounting node of the last block, so as to ensure the uniqueness of the transaction data of the block to be accessed, and make the block to be accessed smoothly Generated; based on the transaction data of the block to be accessed, a data packet is generated and broadcast to the blockchain network, and the election of the billing node of the block to be accessed can be initiated, so as to successfully select the billing node of the block to be accessed.
具体地,参照图6,步骤S51包括:Specifically, referring to FIG. 6, step S51 includes:
步骤S52,末位区块的记账节点基于所述交易数据和末位区块的特征值,进行哈希运算得到第二哈希值;Step S52, the accounting node of the last block performs a hash operation based on the transaction data and the characteristic value of the last block to obtain a second hash value;
步骤S53,末位区块的记账节点基于所述交易数据、特征值和第二哈希值生成数据包,并将该数据包向所述区块链所在的区块链网络广播。Step S53, the accounting node of the last block generates a data packet based on the transaction data, the characteristic value and the second hash value, and broadcasts the data packet to the blockchain network where the blockchain is located.
本实施例确定数据包的一种组成方式,即:数据包包括待接入区块的交易数据、末位区块的特征值和第二哈希值。其中,第二哈希值指将前述待接入区块的交易数据和末位区块的特征值进行哈希运算获得的哈希值。In this embodiment, a composition mode of the data packet is determined, that is, the data packet includes transaction data of the block to be accessed, the characteristic value of the last block, and the second hash value. The second hash value refers to a hash value obtained by hashing the transaction data of the block to be accessed and the characteristic value of the last block.
本实施例通过将基于末位区块的记账节点获得的待接入区块的交易数据和末位区块的特征值进行哈希运算,并该哈希运算值和所述末位区块的特征值、交易数据组合成数据包广播。使得区块链中各节点可基于包含了一次哈希运算的哈希值进行二次哈希运算,因为哈希运算的不可逆性,两次哈希运算可进一步增强哈希值的不可预测性,可防止末位区块的记账节点作恶;同时,本实施例将末位区块的特征值作为数据包的内容,可建立末位区块与待接入区块的联系,进而保证待接入区块与区块链的联系,将待接入区块的交易数据作为数据包的一部分,可保证待接入区块的顺利生成。In this embodiment, a hash operation is performed on the transaction data of the block to be accessed obtained by the accounting node based on the last block and the characteristic value of the last block, and the hash operation value is combined with the last block. The eigenvalues and transaction data are combined into a packet broadcast. It enables each node in the blockchain to perform a second hash operation based on the hash value containing one hash operation. Because of the irreversibility of the hash operation, the two hash operations can further enhance the unpredictability of the hash value. It can prevent the billing node of the last block from doing evil; at the same time, in this embodiment, the characteristic value of the last block is used as the content of the data packet, and the connection between the last block and the block to be accessed can be established, thereby ensuring the waiting The connection between the incoming block and the blockchain, the transaction data of the to-be-connected block is taken as part of the data package, which can ensure the smooth generation of the to-be-connected block.
进一步的,为便于理解本方案,提出基于哈希运算的共识建立方法的第六实施例。如图7为第六实施例的场景示意图,如图8为第六实施例的流程示意图。Further, in order to facilitate the understanding of this solution, a sixth embodiment of a consensus building method based on hash operation is proposed. FIG. 7 is a schematic diagram of a scene of the sixth embodiment, and FIG. 8 is a schematic flowchart of the sixth embodiment.
区块链网络中,只要节点在线都可以提交自己记录的交易数据,也可以提交扰动因子或者什么都不干。图7中,A、B、C、D均为区块链网络中在线的节点,A、B均有交易数据输入,D输入扰动因子,C没有输入。图7仅示出部分节点(A\B\C\D),还包括其他未示出的节点。In the blockchain network, as long as the node is online, it can submit the transaction data recorded by itself, or submit the disturbance factor or do nothing. In Figure 7, A, B, C, and D are all online nodes in the blockchain network. Both A and B have transaction data input, D inputs the disturbance factor, and C has no input. FIG. 7 only shows some nodes (A\B\C\D), and also includes other nodes not shown.
图7所示的第N区块为末位区块,后面的第N+1区块为待接入区块,中间的A、B、C、D的数据输入为待接入区块的交易数据。The Nth block shown in FIG. 7 is the last block, the N+1th block behind is the block to be accessed, and the data inputs of A, B, C, and D in the middle are the transactions of the block to be accessed. data.
首先确定第N区块的记账节点,由第N区块的记账节点确定待接入区块的交易数据(如图6中的A、B、C、D数据输入),并将第N区块的特征值即第N区块的哈希值加上待接入区块的交易数据进行哈希运算,得到第一哈希结果,由第N区块的记账节点签名后,将所述第一哈希结果和待接入区块的交易数据向A、B、C、D节点所在的区块链网络广播。First determine the accounting node of the Nth block, determine the transaction data of the block to be accessed by the accounting node of the Nth block (data input of A, B, C, and D in Figure 6), and put the Nth block The characteristic value of the block is the hash value of the Nth block plus the transaction data of the block to be accessed to perform a hash operation to obtain the first hash result, which is signed by the accounting node of the Nth block. The first hash result and the transaction data of the block to be accessed are broadcast to the blockchain network where nodes A, B, C, and D are located.
区块链网络中各节点接收到第N区块的记账节点广播的哈希值和待接入区块的交易数据后,验证待接入区块的交易数据是否全部有效,若全部有效,则各个节点使用自己的私钥对所述第一哈希结果进行签名,并将签名结果再次进行哈希运算,各节点均得到一个第二哈希结果(记为2HASH)。After each node in the blockchain network receives the hash value broadcast by the accounting node of the Nth block and the transaction data of the block to be accessed, it verifies whether the transaction data of the block to be accessed is all valid. Then, each node signs the first hash result with its own private key, and performs hash operation on the signature result again, and each node obtains a second hash result (denoted as 2HASH).
各节点基于所述2HASH进行抽签选举,其实现过程如下:Each node conducts a lottery election based on the 2HASH, and the implementation process is as follows:
1.任意节点(比如A)首先广播自己计算2HASH-A;1. Any node (such as A) first broadcasts itself to calculate 2HASH-A;
2.其它节点(比如B)计算自己的结果2HASH-B,与2HASH-A进行比较;2. Other nodes (such as B) calculate their own result 2HASH-B and compare it with 2HASH-A;
3.如果2HASH-B<2HASH-A,则广播2HASH-B,否则不广播意味(B节点)抽签选举失败;3. If 2HASH-B<2HASH-A, broadcast 2HASH-B, otherwise no broadcast means (B node) lottery election failure;
4.其它节点与B节点类似判断,最终选举出N+1块记账节点。4. Other nodes make similar judgments as node B, and finally elect N+1 block accounting nodes.
进一步的,参照图9,为便于理解本方案,提出基于哈希运算的共识建立方法的第七实施例。Further, referring to FIG. 9 , in order to facilitate understanding of the present solution, a seventh embodiment of a consensus establishment method based on hash operation is proposed.
步骤S50,末位区块的记账节点确定准备与末位区块连接的待接入区块的交易数据;Step S50, the accounting node of the last block determines the transaction data of the block to be accessed that is to be connected with the last block;
步骤S52,末位区块的记账节点基于所述交易数据和末位区块的特征值,进行哈希运算得到第二哈希值;Step S52, the accounting node of the last block performs a hash operation based on the transaction data and the characteristic value of the last block to obtain a second hash value;
步骤S53,末位区块的记账节点基于所述交易数据、特征值和第二哈希值生成数据包,并将该数据包向所述区块链所在的区块链网络广播;Step S53, the accounting node of the last block generates a data packet based on the transaction data, the characteristic value and the second hash value, and broadcasts the data packet to the blockchain network where the blockchain is located;
步骤S10,确定区块链中末位区块的记账节点,基于末位区块的记账节点,获取数据包,所述数据包至少包含准备与末位区块连接的待接入区块的交易数据;Step S10, determining the accounting node of the last block in the blockchain, and obtaining a data packet based on the accounting node of the last block, the data packet at least containing the block to be accessed that is to be connected to the last block transaction data;
步骤S30,查询区块链中的历史交易数据;Step S30, query the historical transaction data in the blockchain;
步骤S31,根据区块链中的历史交易数据,验证所述数据包中待接入区块的交易数据是否全部有效;Step S31, according to the historical transaction data in the blockchain, verify whether the transaction data of the block to be accessed in the data packet is all valid;
步骤S32,若该数据包中所述待接入区块的交易数据全部有效,则执行步骤S20;Step S32, if the transaction data of the block to be accessed in the data packet is all valid, then step S20 is performed;
步骤S33,若该数据包中所述待接入区块的交易数据中存在无效交易数据,则所述数据包无效,重新确定末位区块的记账节点;Step S33, if there is invalid transaction data in the transaction data of the block to be accessed in the data packet, the data packet is invalid, and the accounting node of the last block is re-determined;
步骤S20,获取所述数据包中待接入区块的交易数据,基于该交易数据和末位区块的特征值进行哈希运算,得到第一哈希值;Step S20, acquiring the transaction data of the block to be accessed in the data packet, and performing a hash operation based on the transaction data and the characteristic value of the last block to obtain a first hash value;
步骤S21,基于自存的私钥对所述第一哈希值进行签名,将签名后的所述第一哈希值进行哈希运算,得到第一候选哈希值;Step S21, signing the first hash value based on the self-stored private key, and performing a hash operation on the signed first hash value to obtain a first candidate hash value;
步骤S121,获取其他节点广播的第二候选哈希值,Step S121, obtaining the second candidate hash value broadcast by other nodes,
步骤S41,基于所述第一候选哈希值和第二候选哈希值,解析第二预设规则,当解析结果为候选哈希值中的最小候选哈希值为目标哈希值时,若所述第一候选哈希值小于所述第二候选哈希值,则所述第一候选哈希值满足广播条件;Step S41, based on the first candidate hash value and the second candidate hash value, parse the second preset rule, when the analysis result is that the minimum candidate hash value in the candidate hash value is the target hash value, if If the first candidate hash value is smaller than the second candidate hash value, then the first candidate hash value satisfies the broadcast condition;
步骤S42,若所述第一候选哈希值满足广播条件,则将所述第一候选哈希值向所述区块链所在的区块链网络广播;Step S42, if the first candidate hash value satisfies the broadcast condition, broadcast the first candidate hash value to the blockchain network where the blockchain is located;
步骤S13,在所述第一候选哈希值和第二候选哈希值中确定最小的候选哈希值,该最小候选哈希值为目标哈希值;Step S13, determining the smallest candidate hash value among the first candidate hash value and the second candidate hash value, and the smallest candidate hash value is the target hash value;
步骤S123,该目标哈希值的节点为所述待接入区块的记账节点。Step S123, the node of the target hash value is the accounting node of the block to be accessed.
此外,本发明实施例还提出一种存储介质,所述存储介质上存储有基于哈希运算的共识建立程序,所述基于哈希运算的共识建立程序被处理器执行时实现如上述实施例所述的步骤。因本发明存储介质的具体实施例同上述身份认证方法的各个实施例基本相同,在此不做赘述。In addition, an embodiment of the present invention also provides a storage medium, where a consensus establishment program based on hash operation is stored on the storage medium, and when the consensus establishment program based on hash operation is executed by a processor, the implementation is as described in the above embodiments. the steps described. Since the specific embodiments of the storage medium of the present invention are basically the same as the above-mentioned embodiments of the identity authentication method, the details are not repeated here.
需要说明的是,本发明所有实施例所述的技术特征中的某些特征之间可相互组合。It should be noted that some of the technical features described in all the embodiments of the present invention may be combined with each other.
在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者系统不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者系统所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者系统中还存在另外的相同要素。As used herein, the terms "comprising", "comprising" or any other variation thereof are intended to encompass a non-exclusive inclusion such that a process, method, article or system comprising a series of elements includes not only those elements, but also includes no explicit Other elements listed, or those inherent to such a process, method, article or system. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in the process, method, article or system that includes the element.
上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。The above-mentioned serial numbers of the embodiments of the present invention are only for description, and do not represent the advantages or disadvantages of the embodiments.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本发明各个实施例所述的方法。From the description of the above embodiments, those skilled in the art can clearly understand that the method of the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is better implementation. Based on such understanding, the technical solutions of the present invention can be embodied in the form of software products in essence or the parts that make contributions to the prior art, and the computer software products are stored in a storage medium (such as ROM/RAM) as described above. , magnetic disk, optical disk), including several instructions to make a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) execute the methods described in the various embodiments of the present invention.
以上仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。The above are only preferred embodiments of the present invention, and are not intended to limit the scope of the present invention. Any equivalent structure or equivalent process transformation made by using the contents of the description and drawings of the present invention, or directly or indirectly applied in other related technical fields , are similarly included in the scope of patent protection of the present invention.
Claims (9)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201710737728.6A CN107566124B (en) | 2017-08-24 | 2017-08-24 | Hash operation-based consensus establishing method, block chain system and storage medium |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201710737728.6A CN107566124B (en) | 2017-08-24 | 2017-08-24 | Hash operation-based consensus establishing method, block chain system and storage medium |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN107566124A CN107566124A (en) | 2018-01-09 |
| CN107566124B true CN107566124B (en) | 2020-06-19 |
Family
ID=60976700
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201710737728.6A Active CN107566124B (en) | 2017-08-24 | 2017-08-24 | Hash operation-based consensus establishing method, block chain system and storage medium |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN107566124B (en) |
Families Citing this family (46)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN108269090B (en) * | 2018-01-19 | 2021-04-20 | 中国科学院软件研究所 | Consensus method and device for block chain system based on non-negotiation random drawing |
| CN108335208B (en) * | 2018-02-28 | 2022-11-08 | 北京京东尚科信息技术有限公司 | Method and apparatus for processing information |
| CN108509615B (en) * | 2018-03-30 | 2022-04-19 | 深圳市元征科技股份有限公司 | Consensus establishing method and device based on drawing mechanism and readable storage medium |
| CN108512652B (en) * | 2018-04-02 | 2021-04-09 | 陆雷钦 | Decentralized consensus method and system based on time certification and block chain system |
| JP7101031B2 (en) * | 2018-04-13 | 2022-07-14 | 株式会社bitFlyer Blockchain | Blockchain network and confirmation method for it |
| CN108737375B (en) * | 2018-04-13 | 2021-01-19 | 中山大学 | A blockchain consensus method and system |
| CN108615151B (en) * | 2018-04-24 | 2022-04-15 | 深圳市元征科技股份有限公司 | Data processing method, block chain server and node equipment |
| CN108596621B (en) * | 2018-04-28 | 2020-10-27 | 三亚京牛数字科技有限公司 | Block chain accounting node generation method and device, computer equipment and storage medium |
| CN108616363B (en) * | 2018-05-11 | 2021-08-06 | 北京奇虎科技有限公司 | A kind of accounting right confirmation method, device and computer storage medium |
| CN108712486B (en) * | 2018-05-11 | 2021-10-08 | 北京奇虎科技有限公司 | Workload proof method and device |
| CN108804706B (en) * | 2018-06-20 | 2020-09-18 | 南方科技大学 | Block chain data processing method, device, equipment and storage medium |
| CN108961017B (en) * | 2018-06-21 | 2022-09-13 | 中科新松有限公司 | Block chain consensus mechanism and block chain system based on same |
| CN108984662B (en) * | 2018-06-28 | 2021-02-09 | 杭州复杂美科技有限公司 | Block chain data synchronization method |
| CN108985772B (en) * | 2018-07-02 | 2022-03-18 | 上海达家迎信息科技有限公司 | Block chain verification method, device, equipment and storage medium |
| CN108881287A (en) * | 2018-07-18 | 2018-11-23 | 电子科技大学 | A kind of Internet of things node identity identifying method based on block chain |
| CN109067516B (en) * | 2018-07-20 | 2021-05-11 | 杭州复杂美科技有限公司 | Lottery drawing method, consensus method, device and storage medium |
| CN109246084B (en) * | 2018-08-13 | 2021-07-27 | 中国联合网络通信集团有限公司 | New block generation method, device, electronic device and storage medium |
| CN109102287B (en) * | 2018-08-13 | 2021-09-07 | 中国联合网络通信集团有限公司 | Blockchain accounting method, device, equipment and storage medium |
| CN109360091B (en) * | 2018-08-30 | 2020-09-01 | 阿里巴巴集团控股有限公司 | Random object selection method and device based on block chain |
| CN110880968A (en) * | 2018-09-05 | 2020-03-13 | 元一科技控股有限公司 | Block transmission and recording method and device and computer storage medium |
| CN109391684B (en) * | 2018-09-25 | 2021-04-23 | 莆田市烛火信息技术有限公司 | A method and system for selecting a blockchain accounting node associated with a related chain |
| CN111008835B (en) * | 2018-10-08 | 2024-05-28 | 上海派链信息科技有限公司 | Method, apparatus, computer readable storage medium and computer program product for determining a transaction verification node of a blockchain |
| CN109472594B (en) * | 2018-10-11 | 2023-11-28 | 平安科技(深圳)有限公司 | Block chain-based automobile data sharing method, device, equipment and storage medium |
| CN111104678B (en) * | 2018-10-25 | 2022-03-18 | 北京国盾量子信息技术有限公司 | Block chain consensus method and device |
| CN109525648A (en) * | 2018-10-26 | 2019-03-26 | 全链通有限公司 | Block chain common recognition mechanism, equipment and computer readable storage medium |
| CN109684408A (en) * | 2018-12-07 | 2019-04-26 | 深圳市智税链科技有限公司 | Data managing method, device, medium and the electronic equipment of block catenary system |
| CN109684519B (en) * | 2018-12-12 | 2020-04-03 | 杭州基尔区块链科技有限公司 | Decentralized chip research and development transaction data storage method and system based on block chain |
| CN111327436B (en) * | 2018-12-13 | 2023-04-07 | 北京果仁宝软件技术有限责任公司 | Method, device and system for predicting block link-out block node of block |
| KR102226258B1 (en) * | 2018-12-29 | 2021-03-12 | 어드밴스드 뉴 테크놀로지스 씨오., 엘티디. | System and method for detecting replay attacks |
| CN110223438B (en) * | 2019-06-13 | 2020-10-02 | 北京瑞策科技有限公司 | Lottery random number issuing method and device applying block chain |
| CN110223436B (en) * | 2019-06-13 | 2020-12-25 | 北京瑞策科技有限公司 | Lottery random number issuing method and device applying block chain |
| CN110233722B (en) * | 2019-06-17 | 2020-10-30 | 北京瑞策科技有限公司 | Block output method and device on block chain |
| CN112491935B (en) * | 2019-08-20 | 2024-09-06 | 本无链科技(深圳)有限公司 | Water wave type broadcasting method and system for block chain |
| CN110545170A (en) * | 2019-09-16 | 2019-12-06 | 福建中科中欣智能科技有限公司 | Block chain consensus method, device and equipment based on password drawing |
| CN110647582B (en) * | 2019-09-17 | 2024-01-02 | 腾讯科技(深圳)有限公司 | Method, device, storage medium and computer equipment for block chain network consensus verification |
| CN110941613B (en) * | 2019-11-19 | 2023-07-18 | 北京工业大学 | Block chain consensus method, device and electronic equipment |
| CN110958317B (en) * | 2019-11-29 | 2022-08-09 | 腾讯科技(深圳)有限公司 | Data processing method and equipment |
| CN111786772B (en) * | 2019-12-10 | 2024-05-07 | 北京铭泰恒通信息技术有限公司 | Non-deterministic selection method, system and storage medium based on determination of blockchain |
| CN111178885B (en) * | 2019-12-18 | 2023-08-04 | 达闼机器人股份有限公司 | Blockchain-based data processing method, device, data processing equipment and system |
| CN111177263A (en) * | 2019-12-27 | 2020-05-19 | 中思博安科技(北京)有限公司 | Block chain consensus method and node |
| CN111292187B (en) * | 2020-01-20 | 2023-08-22 | 深圳市万向信息科技有限公司 | Blockchain billing personnel qualification competitive choice method |
| CN111314436A (en) * | 2020-01-20 | 2020-06-19 | 柏建华 | Hierarchical block chain system and implementation method |
| CN111431696B (en) * | 2020-03-26 | 2023-10-17 | 深圳市欧欣泰科技有限公司 | Block chain seal mechanism based on identity |
| CN111597264B (en) * | 2020-05-15 | 2023-06-23 | 中国联合网络通信集团有限公司 | A blockchain bookkeeping method and device |
| CN111815845B (en) * | 2020-07-08 | 2022-03-15 | 中钞信用卡产业发展有限公司杭州区块链技术研究院 | Method, device, system, device and medium for lottery based on heterogeneous blockchain |
| CN115687507A (en) * | 2021-07-27 | 2023-02-03 | 深圳中经量子科技有限公司 | Consensus computing method, system and storage medium suitable for block chain operating system |
Family Cites Families (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106385319B (en) * | 2016-09-29 | 2020-11-27 | 江苏通付盾科技有限公司 | Method and system for verifying information in blockchain network |
| CN106789908B (en) * | 2016-11-23 | 2019-09-06 | 江苏通付盾科技有限公司 | Block common recognition method for building up and system in block chain |
| CN106411503B (en) * | 2016-11-28 | 2019-11-08 | 中国银行股份有限公司 | The bookkeeping methods and system, ballot and accounting nodes of block chain ballot accounting mode |
| CN106850536B (en) * | 2016-11-30 | 2020-01-07 | 北京瑞卓喜投科技发展有限公司 | Block chain consensus method and system |
| CN106790431B (en) * | 2016-12-05 | 2020-11-27 | 同济大学 | Blockchain-based cloud manufacturing service transaction information recording system and method |
| JP6636183B2 (en) * | 2016-12-23 | 2020-01-29 | 深▲せん▼前海達闥云端智能科技有限公司Cloudminds (Shenzhen) Robotics Systems Co.,Ltd. | Block generation method, apparatus and block chain network |
| EP3461060A4 (en) * | 2016-12-23 | 2019-07-24 | Cloudminds (Shenzhen) Robotics Systems Co., Ltd. | Block of blockchain generation method, device, node, and signature device and system |
-
2017
- 2017-08-24 CN CN201710737728.6A patent/CN107566124B/en active Active
Also Published As
| Publication number | Publication date |
|---|---|
| CN107566124A (en) | 2018-01-09 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN107566124B (en) | Hash operation-based consensus establishing method, block chain system and storage medium | |
| US10698728B1 (en) | Systems and methods for forming application-specific blockchains | |
| CN108876365B (en) | Intelligent contract for generating block release mechanism | |
| US20190182029A1 (en) | Method of generating block chain and apparatus and method for generating blocks | |
| CN108769163B (en) | Consortium chain consensus reaching method, device and computer-readable storage medium | |
| WO2022267715A1 (en) | Oracle machine node screening method and apparatus, and storage medium and electronic apparatus | |
| WO2020258252A1 (en) | Consensus method for block chain data and related device | |
| US20130007864A1 (en) | System and method for location-aware social networking authentication | |
| US11354629B1 (en) | Controlling initiation of a blockchain election using a burn quota | |
| US11062280B1 (en) | Network consensus-based data processing | |
| CN114143021B (en) | News information credit score system based on block chain | |
| CN108243250A (en) | A Fast Shard Selection Method Based on Distributed Network | |
| WO2022183518A1 (en) | Cloud-computing-oriented high-performance blockchain architecture method | |
| CN111488626A (en) | Blockchain-based data processing method, device, equipment and medium | |
| US11290280B1 (en) | Cryptocurrency mining using a single-leader election algorithm | |
| CN110460471B (en) | Super node election method, device and storage medium | |
| CN110990790B (en) | Data processing method and equipment | |
| CN116614519B (en) | Lightweight and trusted chain-up method for videos and related information based on optimized consensus algorithm | |
| CN112801791A (en) | Authorization-based block chain consensus method and system | |
| KR102628770B1 (en) | A Neural consensus-based blockchain network system that performs random consensus proof using non-random consensus proof-based blockchain network | |
| CN117332871A (en) | Federal learning processing method based on blockchain and related equipment | |
| US11515999B1 (en) | Systems and methods for selectively processing blockchain data | |
| CN114372588A (en) | Consensus node selection method and related device | |
| KR20220148396A (en) | A neural consensus node apparatus for using a non-random consensus proof-based blockchain network as a random consensus proof-based blockchain network, and its operation method | |
| KR20220148397A (en) | A neural consensus proof based block chain network platform system constructed by using a non-random consensus proof-based blockchain network |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant | ||
| PE01 | Entry into force of the registration of the contract for pledge of patent right |
Denomination of invention: Consensus building method, blockchain system and storage medium based on hash operation Effective date of registration: 20210520 Granted publication date: 20200619 Pledgee: Shenzhen Longgang sub branch of Agricultural Bank of China Ltd. Pledgor: SHENZHEN ECHIEV AUTONOMOUS DRIVING TECHNOLOGY Co.,Ltd. Registration number: Y2021980003808 |
|
| PE01 | Entry into force of the registration of the contract for pledge of patent right | ||
| PC01 | Cancellation of the registration of the contract for pledge of patent right |
Date of cancellation: 20220607 Granted publication date: 20200619 Pledgee: Shenzhen Longgang sub branch of Agricultural Bank of China Ltd. Pledgor: SHENZHEN ECHIEV AUTONOMOUS DRIVING TECHNOLOGY Co.,Ltd. Registration number: Y2021980003808 |
|
| PC01 | Cancellation of the registration of the contract for pledge of patent right | ||
| PE01 | Entry into force of the registration of the contract for pledge of patent right |
Denomination of invention: Consensus building method, blockchain system and storage medium based on hash operation Granted publication date: 20200619 Pledgee: Bank of Guangzhou Co.,Ltd. Shenzhen Huaqiang Sub Branch Pledgor: SHENZHEN ECHIEV AUTONOMOUS DRIVING TECHNOLOGY Co.,Ltd. Registration number: Y2025980031323 |
|
| PE01 | Entry into force of the registration of the contract for pledge of patent right |