WO2018112949A1 - 区块链的挖矿方法、装置和节点设备 - Google Patents

区块链的挖矿方法、装置和节点设备 Download PDF

Info

Publication number
WO2018112949A1
WO2018112949A1 PCT/CN2016/111860 CN2016111860W WO2018112949A1 WO 2018112949 A1 WO2018112949 A1 WO 2018112949A1 CN 2016111860 W CN2016111860 W CN 2016111860W WO 2018112949 A1 WO2018112949 A1 WO 2018112949A1
Authority
WO
WIPO (PCT)
Prior art keywords
node device
hash
blocks
mining
slot corresponding
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.)
Ceased
Application number
PCT/CN2016/111860
Other languages
English (en)
French (fr)
Inventor
张跃洋
谢辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Cloudminds Shenzhen Robotics Systems Co Ltd
Original Assignee
Cloudminds Shenzhen Robotics Systems Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Cloudminds Shenzhen Robotics Systems Co Ltd filed Critical Cloudminds Shenzhen Robotics Systems Co Ltd
Priority to CN201680003221.1A priority Critical patent/CN107078903B/zh
Priority to US16/314,986 priority patent/US10664485B2/en
Priority to PCT/CN2016/111860 priority patent/WO2018112949A1/zh
Publication of WO2018112949A1 publication Critical patent/WO2018112949A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3236Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions
    • H04L9/3239Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions involving non-keyed hash functions, e.g. modification detection codes [MDCs], MD5, SHA or RIPEMD
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2465Query processing support for facilitating data mining operations in structured databases
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/06Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
    • H04L9/0643Hash functions, e.g. MD5, SHA, HMAC or f9 MAC
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/12Applying verification of the received information
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/06Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
    • H04L9/0618Block ciphers, i.e. encrypting groups of characters of a plain text message using fixed encryption transformation
    • H04L9/0637Modes of operation, e.g. cipher block chaining [CBC], electronic codebook [ECB] or Galois/counter mode [GCM]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0861Generation of secret information including derivation or calculation of cryptographic keys or passwords
    • H04L9/0869Generation of secret information including derivation or calculation of cryptographic keys or passwords involving random numbers or seeds
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2216/00Indexing scheme relating to additional aspects of information retrieval not explicitly covered by G06F16/00 and subgroups
    • G06F2216/03Data mining
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees

Definitions

  • the invention relates to the field of blockchain, in particular to a mining method, device and node device for a blockchain.
  • Blockchain technology is a distributed, decentralized, and trusted network data consensus storage technology. It implements distributed computing based on a unique block generation mechanism and P2P (Point to Point) network communication mechanism. Synchronization issue. Generally speaking, in the process of forming a blockchain, each node participating in the calculation enjoys the authority to calculate the block. The calculation block is commonly called “mining”, and the related technology guarantees the most through a specific mining mechanism. Long chains are effective chains.
  • which node device generates a block is related to the computing power of the node device, and the stronger the computing power of a node device, the more likely it is to generate a block. For example, when the computing power of a node device exceeds the computing power of all other nodes in the entire network, basically every time this node device generates a block. Therefore, under the condition that the computing power of each node device is different, the existing mining mechanism cannot guarantee that each node device in the blockchain network has the opportunity of fair mining.
  • the main object of the present invention is to provide a method, a device and a node device for mining a blockchain, which are used to solve the technical problem that the mining opportunities of the various node devices in the blockchain network are not fair.
  • a first aspect of the present invention provides a method for mining a blockchain, the method Applied to a node device in a blockchain network, the method comprising:
  • N is a positive integer greater than or equal to 2;
  • a second aspect of the present invention provides a mining apparatus for a node device in a blockchain network, the apparatus comprising:
  • An obtaining module configured to acquire a current number of blocks of the blockchain
  • a judging module configured to determine whether a hash slot corresponding to the number of blocks is consistent with a hash slot corresponding to the node device, where each node device in the blockchain network is distributed by a hash algorithm In N hash slots, N is a positive integer greater than or equal to 2;
  • a determining module configured to determine, according to the determination result, whether the node device performs mining this time.
  • a third aspect of the present invention provides a node device, including:
  • processor unit a processor unit, a communication interface, a memory, and a communication bus; the processor unit, the communication interface, and the memory complete communication with each other through the communication bus;
  • the memory is for storing program code
  • the processor unit is operative to execute the program code to implement the method of the first aspect.
  • a fourth aspect of the invention provides a computer readable storage medium for storing a computer program, the computer program comprising instructions for performing the method of the first aspect.
  • FIG. 1 is a schematic diagram of a blockchain network according to an embodiment of the present invention.
  • FIG. 2 is a schematic flow chart of a method for mining a blockchain according to an embodiment of the present invention
  • FIG. 3 is a schematic diagram of a node device in a hash slot according to an embodiment of the present disclosure
  • FIG. 4A is a schematic structural view of a mining device according to an embodiment of the present invention.
  • FIG. 4B is a schematic structural view of another mining device according to an embodiment of the present invention.
  • FIG. 5 is a schematic structural diagram of a node device according to an embodiment of the present invention.
  • a blockchain is a decentralized distributed database system in which all nodes in a blockchain network participate in maintenance. It is composed of a series of data blocks generated by cryptography, and each block is a blockchain. One block. According to the order of generation time, the blocks are linked in an orderly manner From the beginning, a data chain is formed, which is aptly called a blockchain.
  • the blockchain is generated and validated by its special blocks and transactions, with unchangeable, unforgeable and fully traceable security features.
  • Each block in the blockchain includes some recent transactions, references to the previous block, and other data, as well as an answer to the calculation difficulty, which is unique to each block. If the new block does not have the correct answer, it cannot be sent to the network.
  • the process of “mining” is essentially “solving” the current block in the competition.
  • the mathematical problems in each block are difficult to solve, but once an effective solution is found, other network nodes can easily verify the correctness of the solution.
  • “mining” is actually the process of bookkeeping. Bitcoin operations use a mechanism called “Proof of Work (PoW)”, in order to find out who has more Powerful computing skills, each time a math problem will be issued, only the computer that solves this problem the fastest can record.
  • PoW Proof of Work
  • nodes participate in mining, and some nodes may only have the function of querying and publishing transactions.
  • the nodes involved in mining are called miners nodes, and the nodes described in this paper are miners nodes.
  • the node devices of certain data establish a connection with each other through the p2p network to form a basic network of the blockchain.
  • each node device in the network uses the current block number as a seed to generate a very large random number file.
  • Each node device will continuously traverse the random number in the random number file and do the hash hash (random number) operation.
  • the node device finds a hash(v) ⁇ target random number v from the file it indicates the current round.
  • the first node device in all node devices that finds the v value gets the write block permission.
  • An embodiment of the present invention provides a method for mining a blockchain.
  • the method is applied to a node device in a blockchain network. As shown in FIG. 2, the method includes:
  • the blockchain is synchronized locally on the node device. Therefore, the node device can obtain the current number of blocks by querying the locally stored blockchain.
  • Each of the node devices in the blockchain network is distributed in N hash slots by a hash algorithm, where N is a positive integer greater than or equal to 2.
  • the node device needs to go through step S202 to determine whether it is currently mining.
  • the account information of each node device is hashed by MD5 (Message Digest Algorithm MD5, Chinese name message digest algorithm fifth version), and the hash result is randomly distributed, and the mining account is taken to N.
  • MD5 Message Digest Algorithm MD5, Chinese name message digest algorithm fifth version
  • the modulo operation that is, the remainder for N), so that each account will correspond to a hash slot numbered between 0 and N-1.
  • the account information of the node device described in this document refers to the current account information of the node device, that is, one of the node device corresponding to the blockchain network.
  • Account number for ease of understanding, the node device described in this article can be considered as an account in the blockchain network.
  • each hash slot corresponds to approximately one-quarter of the node devices in the blockchain network.
  • the blockchain network there are eight node devices in the node devices 1 to 8, and the hash values obtained by using the MD5 algorithm for the account information of each node device are: 63, 17, 46, 27, 36, respectively. 82, 24, 41, the values obtained for modulo 4 are: 3, 1, 2, 3, 0, 2, 0, 1.
  • the node device 5 and the node device 7 correspond to the hash slot 0, the node device 2 and the node device 8 correspond to the hash slot 1, the node device 3 and the node device 6 correspond to the hash slot 2, and the node device 1 and the node device 4 correspond to each other. Hitch 3.
  • the embodiment of the present invention may further distribute all the node devices in the respective hash slots by using other hashing algorithms, which is not limited in the present invention.
  • the calculation of the hash slot corresponding to the number of blocks may be: using the current block number to perform modulo operation on N, and the obtained value is the corresponding hash slot. The number.
  • the hash slot corresponding to the current block is the hash slot 0.
  • the foregoing step S203 The method may include: when the hash slot corresponding to the number of the blocks is consistent with the hash slot corresponding to the node device, determining that the node device does not perform mining currently; and hashing corresponding to the number of blocks When the slot is inconsistent with the hash slot corresponding to the node device, it is determined that the node device performs mining this time.
  • the node devices 2 and 8 corresponding to the hash slot 1 do not participate in the next block.
  • Mining After the other node equipment mines the next block, the number of blocks in the block chain is 2, and the sum of 4 is equal to 2, then the node device 3 and the node device 6 corresponding to the hash slot 2 do not participate in the third block. Mining of the block.
  • the corresponding hash slots are also constantly changing due to the increasing number of blocks, so that the node devices participating in the mining also change, and the same node device cannot generate blocks several times in succession. The fairness of node equipment mining.
  • the embodiment of the present invention may further include: determining that the node device performs mining this time when the hash slots corresponding to the number of blocks acquired in consecutive M times are consistent with the hash slots corresponding to the node device, M is a positive integer greater than or equal to 2. That is to say, if the number of blocks acquired by a node device in consecutive M times has not changed, resulting in its continuous M-1 times without participating in mining, the node device can perform mining at the Mth time. The normal operation of the blockchain network is guaranteed.
  • the specific value of M can be preset according to the actual situation. Still taking FIG. 3 as an example, if the current block number of the blockchain acquired by the node device 1 is 7, since the hash slot corresponding to the block number 7 is the hash slot 3, the node device 1 does not participate this time. Mining of the 8th block. In the next mining, if the current block number of the blockchain acquired by the node device 1 is still 7, it indicates that the other node equipment of the previous mining did not participate. Thus, in the case where M is equal to 2, the node Equipment 1 determines this mining.
  • M is equal to 4
  • the node device 1 if the node device 1 still does not perform mining, the next time if the number of blocks increases, it indicates that other node devices resume normal mining, and if the number of blocks does not change for four consecutive times, the node Equipment 1 determines the mining, thus ensuring the normal operation of the blockchain network.
  • the mining method provided by the embodiment of the present invention further includes: receiving a block sent by another node device in the blockchain network, where the block includes account information of the another node device; When the hash slot corresponding to the number of blocks is inconsistent with the hash slot corresponding to the other node device, the workload is proved to be performed on the block.
  • the node device 3 broadcasts the block to other node devices, and after receiving the block broadcast by the node device 3, the node device 1 accesses the account of the node device 3.
  • the information is subjected to the MD5 hash operation to obtain a hash value, and the hash value is used to calculate the remainder, thereby determining that the node device 3 corresponds to the hash slot 2, and then determining the current region according to the current block number of the blockchain.
  • the hash slot corresponding to the number of blocks if the hash slot corresponding to the current number of blocks is inconsistent with the hash slot corresponding to the node device 3, indicating that the node device 3 is legally mined this time, and the workload can be proved for the block. If the hash slot corresponding to the current number of blocks is the same as the hash slot corresponding to the node device 3, indicating that the node device 3 is illegally mined, the node device 1 may discard the block to refuse to add the block to the block. Blockchain.
  • the node device 1 can consider the node device 3 The secondary mining law can further prove the workload of the block.
  • the node 1 can comprehensively determine whether the current mining of the node 3 is legal by combining the hash slot and the time difference between the block and the previous block.
  • the step S203 may further include: determining, when the hash slot corresponding to the number of blocks is consistent with the hash slot corresponding to the node device, The device performs mining this time; the hash slot corresponding to the number of blocks and the node device pair When the corresponding hash slots are inconsistent, it is determined that the node device does not perform mining this time.
  • the node devices 2 and 8 corresponding to the hash slot 1 participate in the next block.
  • Mining all other node equipment does not participate in the mining of the next block.
  • the number of blocks in the block chain is 2, and the ratio of 4 to 4 is equal to 2, and the node device 3 and the node device 6 corresponding to the hash slot 2 participate in the pair.
  • the other node equipment does not participate in the mining of the third block.
  • the corresponding hash slots are also constantly changing due to the increasing number of blocks, so that the node devices participating in the mining also change, and the same node device cannot generate blocks several times in succession. The fairness of node equipment mining.
  • the embodiment of the present invention may further include: if the hash slots corresponding to the number of blocks acquired in consecutive L times are inconsistent with the hash slots corresponding to the node device, determining that the node device performs mining this time, L is A positive integer greater than or equal to N.
  • N hash slots normally, every N times of mining, one node device will participate at least once. If a node device does not participate in mining for L-1 times in a row, it indicates that other node devices A fault may occur. Therefore, the node device can perform mining when the hash slot corresponding to the number of blocks determined for the Lth time is inconsistent with the corresponding hash slot, thereby ensuring the normal operation of the blockchain network.
  • the node device may be configured according to a specific service to determine whether to perform mining each time.
  • all node devices on the blockchain are classified into four hash slots by the account MD5 hash value. Use the number of blocks to modulo 4, which will hit the slot from hash slot 0 to hash slot 3.
  • Each node device in the slot will be periodically prohibited from participating in mining. It is forbidden to mine the power of the powerful computing node equipment, and finally avoid the difficulty of the powerful computing node equipment monopolizing the blockchain and improving the double-flower attack of the attacker.
  • the existing workload proofing mechanism enables a double-flower attack as long as there is a strong computing power node device. After the embodiment of the present invention is implemented, at least four strong computing power nodes are required to implement the double-flower attack, thereby improving the attacker's The cost of crime.
  • the fault tolerance and anti-attack capabilities of the embodiments of the present invention are analyzed below. If the probability of failure of each node device is 2.5%, the probability of each node device being maliciously attacked is 25%, the number of hash slots is 4, and the total number of node devices is X, then the other node devices are faulty, available. When the total number of node devices is less than X/4 and they are all in the same slot, the freeze will occur, that is, the node device that is not involved in mining. The probability distribution of this case is consistent with the cumulative binomial distribution.
  • the blockchain network of the mining method has high fault tolerance.
  • the method provided by the embodiment of the present invention ensures that the opportunity of each node device in the blockchain network is more fair under the premise of ensuring that the blockchain network has sufficient fault tolerance and anti-attack capability.
  • the embodiment of the present invention further provides a mining device 40, which is used for a node device in a blockchain network, and is used for implementing a blockchain mining method provided by the above method embodiment, as shown in the figure.
  • the mining device 40 includes:
  • An obtaining module 401 configured to acquire a current number of blocks of the blockchain
  • the determining module 402 is configured to determine whether the hash slot corresponding to the number of blocks is related to the node device Corresponding hash slots are consistent, wherein each of the node devices in the blockchain network is distributed in N hash slots by a hash algorithm, where N is a positive integer greater than or equal to 2;
  • the determining module 403 is configured to determine, according to the determination result, whether the node device performs mining this time.
  • the determining module 403 is configured to: when the hash slot corresponding to the number of the blocks is consistent with the hash slot corresponding to the node device, determine that the node device does not perform mining this time; When the hash slot corresponding to the number of blocks is inconsistent with the hash slot corresponding to the node device, it is determined that the node device performs mining this time.
  • the determining unit 403 is configured to determine that the node device performs the current digging when the hash slots corresponding to the number of blocks acquired in consecutive M times are consistent with the hash slots corresponding to the node device.
  • Mine M is a positive integer greater than or equal to 2.
  • the mining device 40 further includes: a calculating unit 404, configured to perform a modulo operation on the N by using the number of blocks to obtain a first modulo value;
  • the account information is subjected to a modulo operation on the N according to the MD5 algorithm to obtain a second modulo value;
  • the determining module 402 is configured to determine whether the first modulo value and the second modulo value are consistent, wherein The first modulo value is consistent with the second modulo value, indicating that the hash slot corresponding to the number of blocks is consistent with the hash slot corresponding to the node device, and the first modulo value and the second
  • the modulo value inconsistency indicates that the hash slot corresponding to the number of blocks is inconsistent with the hash slot corresponding to the node device.
  • the mining device 40 further includes: a receiving module 405, configured to receive a block sent by another node device in the blockchain network, where the block includes the Account information of another node device; a workload verification module 406, configured to determine the number of blocks corresponding to When the hash slot is inconsistent with the hash slot corresponding to the other node device, the workload is proved to be performed on the block.
  • a receiving module 405 configured to receive a block sent by another node device in the blockchain network, where the block includes the Account information of another node device
  • a workload verification module 406 configured to determine the number of blocks corresponding to When the hash slot is inconsistent with the hash slot corresponding to the other node device, the workload is proved to be performed on the block.
  • the embodiment of the present invention further provides a node device 50, which is used to implement a blockchain mining method provided by the foregoing method embodiment.
  • the node device 50 includes:
  • the processor unit 501, the communication interface 502, the memory 503, and the communication bus 504; the processor unit 501, the communication interface 502, and the memory 503 complete communication with each other through the communication bus 504.
  • the processor unit 501 may be a multi-core CPU or an ASIC (Application Specific Integrated Circuit) or one or more integrated circuits configured to implement embodiments of the present invention.
  • ASIC Application Specific Integrated Circuit
  • the memory 503 is for storing program code, and the program code includes computer operation instructions and a network flow diagram.
  • the memory 503 may carry a high speed RAM memory and may also include a non-volatile memory such as at least one disk memory.
  • the communication interface 502 is configured to implement connection communication between the node devices.
  • the processor unit 501 executes a program code, which is used to implement a method for mining a blockchain provided by the foregoing method embodiment.
  • the method includes:
  • N is a positive integer greater than or equal to 2;
  • the determining, according to the determination result, whether the node device performs mining currently includes:
  • the determining, according to the determination result, whether the node device performs mining currently includes:
  • M is a positive integer greater than or equal to 2.
  • the determining whether the hash slot corresponding to the number of the blocks is consistent with the hash slot corresponding to the node device including:
  • the first modulo value is consistent with the second modulo value, wherein the first modulo value and the second modulo value are consistent to indicate a hash slot corresponding to the number of blocks
  • the hash slots corresponding to the node devices are consistent, and the first modulo value is inconsistent with the second modulo value, indicating that the hash slot corresponding to the number of the blocks is inconsistent with the hash slot corresponding to the node device.
  • the method further includes:
  • the workload is proved to be performed on the block.
  • the modules described as separate components may or may not be physically separated.
  • the components displayed as modules may or may not be physical modules, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional module in each embodiment of the present invention may be integrated into one processing unit, or each module may exist physically separately, or two or more modules may be integrated into one module.
  • the above integrated modules can be implemented in the form of hardware or in the form of hardware plus software function modules.
  • the above-described integrated modules implemented in the form of software function modules can be stored in a computer readable storage medium.
  • the software functional modules described above are stored in a storage medium and include instructions for causing a computer device (which may be a personal computer, server, or network device, etc.) to perform some of the steps of the methods described in various embodiments of the present invention.
  • the foregoing storage medium includes: a U disk, a mobile hard disk, a random access memory (RAM), a magnetic disk, or an optical disk, and the like, which can store data. That is, an embodiment of the present invention further provides a computer readable storage medium for storing a computer program, the computer program comprising instructions for executing a mining method of the blockchain described above.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Power Engineering (AREA)
  • Fuzzy Systems (AREA)
  • Mathematical Physics (AREA)
  • Probability & Statistics with Applications (AREA)
  • Software Systems (AREA)
  • Computational Linguistics (AREA)
  • Computer Hardware Design (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

一种区块链的挖矿方法、装置和节点设备,用以解决区块链网络中的各个节点设备的挖矿机会不够公平的技术问题。所述方法包括:获取所述区块链当前的区块数;判断所述区块数对应的哈希槽是否与节点设备对应的哈希槽一致,其中,所述区块链网络中的每一所述节点设备通过哈希算法分布在N个哈希槽,N为大于或等于2的正整数;根据判断结果确定所述节点设备本次是否进行挖矿。

Description

区块链的挖矿方法、装置和节点设备 技术领域
本发明涉及区块链领域,尤其涉及一种区块链的挖矿方法、装置和节点设备。
背景技术
区块链技术是一种分布式、去中心、去信任的网络数据共识存储技术,其基于独特的区块(Block)生成机制和P2P(Point to Point,点对点)网络通信机制实现了分布式计算的同步性问题。通常意义上,在区块链的形成过程中,每一个参与计算的节点均享有计算区块的权限,其中,计算区块俗称“挖矿”,相关技术通过特定的挖矿机制,保证了最长的链为有效链。
现有的区块链网络中,由哪一个节点设备产生区块是跟节点设备的计算能力相关,一个节点设备的算力越强,其越可能产生区块。例如,当一个节点设备的算力超过全网其它所有节点的算力时,则基本上每次都会是这一个节点设备产生区块。因此,在各个节点设备的算力差异较大的情况下,现有的挖矿机制无法保证区块链网络中的各个节点设备具有公平挖矿的机会。
由上可知,基于现有的挖矿机制,若同一用户或组织控制了区块链网络中的大部分算力,就可能形成垄断,并且阻碍区块链的正常运行,对区块链的数据进行破坏,威胁区块链网络的安全。
发明内容
本发明的主要目的是提供一种区块链的挖矿方法、装置和节点设备,用以解决区块链网络中的各个节点设备的挖矿机会不够公平的技术问题。
为了实现上述目的,本发明第一方面提供区块链的挖矿方法,所述方法 应用于区块链网络中的节点设备,所述方法包括:
获取所述区块链当前的区块数;
判断所述区块数对应的哈希槽是否与所述节点设备对应的哈希槽一致,其中,所述区块链网络中的每一所述节点设备通过哈希算法分布在N个哈希槽,N为大于或等于2的正整数;
根据判断结果确定所述节点设备本次是否进行挖矿。
本发明第二方面提供一种挖矿装置,所述挖矿装置用于区块链网络中的节点设备,所述装置包括:
获取模块,用于获取所述区块链当前的区块数;
判断模块,用于判断所述区块数对应的哈希槽是否与所述节点设备对应的哈希槽一致,其中,所述区块链网络中的每一所述节点设备通过哈希算法分布在N个哈希槽,N为大于或等于2的正整数;
确定模块,用于根据判断结果确定所述节点设备本次是否进行挖矿。
本发明第三方面提供一种节点设备,包括:
处理器单元、通信接口、存储器和通信总线;所述处理器单元、所述通信接口和所述存储器通过所述通信总线完成相互间的通信;
所述存储器用于存储程序代码;
所述处理器单元用于执行所述程序代码以实现第一方面所述的方法。
本发明第四方面提供一种计算机可读存储介质,所述计算机可读存储介质用于存储计算机程序,所述计算机程序包括用于执行第一方面所述的方法的指令。
采用上述技术方案,区块链网络中的所有节点设备均匀分布在不同的哈希槽,随着当前区块链的区块数每次的增加,进行挖矿的节点设备也发生变化,保证了同一节点设备无法连续产生区块。从而降低了算力强的节点设备挖矿的几率,增加了算力弱的节点设备挖矿的几率,使得区块链网络中各节 点设备挖矿机会更加公平。
附图说明
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本发明实施例提供的一种区块链网络的示意图;
图2为本发明实施例提供的一种区块链的挖矿方法的流程示意图;
图3为本发明实施例提供的一种节点设备在哈希槽分布的示意图;
图4A为本发明实施例提供的一种挖矿装置的结构示意图;
图4B为本发明实施例提供的另一种挖矿装置的结构示意图;
图5为本发明实施例提供的一种节点设备的结构示意图。
具体实施方式
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
为了使本领域技术人员更容易理解本发明实施例提供的技术方案,下面首先对涉及到的相关技术进行简单介绍。
区块链是由区块链网络中所有节点共同参与维护的去中心化分布式数据库系统,它是由一系列基于密码学方法产生的数据块组成,每个数据块即为区块链中的一个区块。根据产生时间的先后顺序,区块被有序地链接在一 起,形成一个数据链条,被形象地称为区块链。区块链由其特别的区块和交易产生、验证协议,具有不可更改,不可伪造、完全可追溯的安全特性。
区块链中的每个区块包括一些近期交易、前一个区块的引用、以及其他数据,还包括一个计算难度的答案,该答案对每个区块是唯一的。新区块如果没有正确答案,不能被发送到网络中。也就是说“挖矿”的过程本质上即是在竞争中“解决”当前区块。每个区块中的数学问题难以解决,但是一旦发现了一个有效解,其他网络节点很容易验证这个解的正确性。具体在比特币中,“挖矿”实际上就是记账的过程,比特币的运算采用了一种称为“工作量证明(Proof of Work,PoW)”的机制,系统为了找出谁有更强大的计算能力,每次会出一道数学题,只有最快解出这道题目的计算机才能进行记账。
另外,区块链网络中,不是所有节点均参与挖矿,一些节点可能只具备查询和发布交易的功能。其中,参与挖矿的节点称为矿工节点,本文以下所描述的节点均为矿工节点。
下面基于图1具体介绍区块链及其挖矿过程。如图1所示,一定数据的节点设备通过p2p网络相互建立连接,形成区块链的基础网络。在挖矿时,首先需要根据区块链既定的协议计算出当前区块对应的target值,即target=F,其中F为前一个区块中target值以及前一个区块和当前区块之间的时间差。然后网络中各节点设备通过当前区块号作为种子,产生一个非常大的随机数文件。每个节点设备将在随机数文件中不断的遍历随机数并做哈希hash(随机数)的运算,当节点设备从文件中找到一个hash(v)<target的随机数v时,说明本轮挖矿结束,所有节点设备中第一个找到v值的节点设备获得写区块权限。
基于上述过程可知,在所有节点设备均参与每一次挖矿的情况下,算力越高的节点设备挖矿产生区块的概率越大。若攻击者控制了区块链网络中的大部分算力,形成“51%攻击”,则可以对区块链网络的数据进行破坏。
本发明实施例提供一种区块链的挖矿方法,所述方法应用于区块链网络中的节点设备,如图2所示,该方法包括:
S201、获取所述区块链当前的区块数。
其中,区块链是同步在节点设备的本地的,因此,节点设备可以通过查询本地存储的区块链获取到当前的区块数。
S202、判断所述区块数对应的哈希槽是否与所述节点设备对应的哈希槽一致。
其中,所述区块链网络中的每一所述节点设备通过哈希算法分布在N个哈希槽,N为大于或等于2的正整数。
S203、根据判断结果确定所述节点设备本次是否进行挖矿。
也就是说,在每次挖矿前,节点设备需要经过步骤S202,确定自身本次是否进行挖矿。
采用上述方法,区块链网络中的所有节点设备均匀分布在不同的哈希槽,随着当前区块链的区块数每次的增加,进行挖矿的节点设备也发生变化,保证了同一节点设备无法连续产生区块。从而降低了算力强的节点设备挖矿的几率,增加了算力弱的节点设备挖矿的几率,使得区块链网络中各节点设备挖矿机会更加公平。
为了使本领域技术人员更加理解本发明实施例提供的技术方案,下面对上述步骤进行详细的说明。
首先举例说明如何实现区块链网络中的各节点设备在N个哈希槽均匀分布。
将每个节点设备的账号信息进行MD5(Message Digest Algorithm MD5,中文名为消息摘要算法第五版)哈希运算,利用哈希结果具有随机均匀分布的特性,将挖矿的账号对N进行取模运算(即对N求余数),这样每个账号都会对应一个编号在0至N-1之间的哈希槽。
值得说明的是,同一个节点设备可能存在有多个账号可以登录的情况,本文所描述的节点设备的账号信息是指节点设备当前的账号信息,即一个节点设备对应区块链网络中的一个账号,为了方便理解,本文所描述的节点设备可以认为是区块链网络中的账号。
如图3所示,当N等于4时,对节点设备的账户信息利用MD5算法求取哈希值后,由于哈希值具有随机均匀分布的特性,因此利用哈希值对N求取余数后,所有节点设备可以均匀分布到哈希槽0、哈希槽1、哈希槽2和哈希槽3中。也就是说,每一个哈希槽对应区块链网络中大概四分之一的节点设备。例如,区块链网络中存在节点设备1至8共八个节点设备,依次对每一个节点设备的账户信息利用MD5算法求得的哈希值分别为:63、17、46、27、36、82、24、41,对4取模得到的值为:3、1、2、3、0、2、0、1。可得节点设备5和节点设备7对应哈希槽0,节点设备2和节点设备8对应哈希槽1,节点设备3和节点设备6对应哈希槽2,节点设备1和节点设备4对应哈希槽3。
值得说明的是,采用上述方法,在区块链网络中增加新的节点设备时,只需要计算新增加的节点设备对应的哈希槽,而无需对已经存在的节点设备的哈希槽做调整,方便区块链网络的扩展。
另外,上述只是举例说明,本发明实施例还可以采用其他哈希算法将所有节点设备均匀分布在各个哈希槽,本发明对此不做限定。
这样,在获取到区块链当前的区块数后,区块数对应的哈希槽的计算可以是:利用当前区块数对N进行取模运算,得到的值即为对应的哈希槽的编号。
仍以图3进行举例说明,若区块链当前的区块数为8728,对4进行求余得到0,则当前区块对应的哈希槽即为哈希槽0。
进一步地,在本发明实施例的一种可能的实现方式中,上述步骤S203 具体可以包括:在所述区块数对应的哈希槽与所述节点设备对应的哈希槽一致时,确定所述节点设备本次不进行挖矿;在所述区块数对应的哈希槽与所述节点设备对应的哈希槽不一致时,确定所述节点设备本次进行挖矿。
示例地,如图3所示,若区块链当前的区块数为1,区块数对4求余等于1,则哈希槽1对应的节点设备2和8不参与对下一个区块的挖矿。在其他节点设备挖矿产生下一个区块后,区块链的区块数为2,对4求余等于2,则哈希槽2对应的节点设备3和节点设备6不参与对第3个区块的挖矿。按照上述流程依次进行,由于区块数的不断增加,对应的哈希槽也不断变化,从而每次参与挖矿的节点设备也发生变化,进而同一节点设备无法连续数次产生区块,提升了节点设备挖矿的公平性。
值得说明的是,考虑到节点设备可能出现故障导致无法挖矿,区块链网络中可能存在某一次挖矿没有节点设备参与的情况。例如,在图3中,当前区块数为3,区块数对4求余等于3,则哈希槽3对应的节点设备1和4不参与对下一个区块的挖矿,若其他节点设备均发生故障无法挖矿,那么本次就会出现没有节点设备挖矿的情况,区块链的区块数也不会增加。
因此,本发明实施例还可以包括:在连续M次获取到的区块数对应的哈希槽均与所述节点设备对应的哈希槽一致时,确定所述节点设备本次进行挖矿,M是大于或等于2的正整数。也就是说,若某一节点设备在连续M次获取到的区块数均未发生变化,导致自身连续M-1次未参与挖矿,则该节点设备可以在第M次时进行挖矿,保证了区块链网络的正常运行。
其中,M的具体取值可以根据实际情况预先设置。仍然以图3进行举例说明,若节点设备1获取到的区块链当前的区块数为7,由于区块数7对应的哈希槽是哈希槽3,因此节点设备1本次不参与对第8区块的挖矿。在下一次挖矿时,若节点设备1获取到的区块链当前的区块数仍然为7,则表明上一次挖矿其他节点设备也没有参与。这样,在M等于2的情况下,节点 设备1确定本次进行挖矿。在M等于4的情况下,若节点设备1本次仍不进行挖矿,等到下一次若区块数增加,表明其他节点设备恢复正常挖矿,若区块数连续4次不变,则节点设备1确定挖矿,从而保证了区块链网络的正常运行。
进一步地,本发明实施例还可以在产生区块后,根据哈希槽位的判断验证节点设备本次产生区块是否合法。具体地,本发明实施例提供的挖矿方法还包括:接收所述区块链网络中的另一节点设备发送的区块,所述区块包括所述另一节点设备的账户信息;在确定所述区块数对应的哈希槽与所述另一节点设备对应的哈希槽不一致时,对所述区块进行工作量证明。
示例地,如图3所示,节点设备3在本次挖矿成功后,将区块广播至其他节点设备,节点设备1在接收到节点设备3广播的区块后,对节点设备3的账户信息进行MD5哈希运算,得到哈希值,利用哈希值对4求余,从而确定节点设备3对应哈希槽2,再根据区块链当前的区块数对4求余,确定当前区块数对应的哈希槽,若当前区块数对应的哈希槽与节点设备3对应的哈希槽不一致,表明节点设备3本次挖矿合法,可以对所述区块进行工作量证明。若当前区块数对应的哈希槽与节点设备3对应的哈希槽一致,表明节点设备3本次挖矿不合法,节点设备1可以丢弃所述区块,以拒绝将该区块添加到区块链。可替换地,在当前区块数对应的哈希槽与节点设备3对应的哈希槽一致,且当前区块链的区块数已经M次未变化时,节点设备1可以认为节点设备3本次挖矿合法,可以进一步对所述区块进行工作量证明。在具体实施时,节点1可以结合哈希槽位以及所述区块与上一区块之间的时间差综合判断节点3本次挖矿是否合法。
在本发明实施例的另一种可能的实现方式中,上述步骤S203还可以包括:在所述区块数对应的哈希槽与所述节点设备对应的哈希槽一致时,确定所述节点设备本次进行挖矿;在所述区块数对应的哈希槽与所述节点设备对 应的哈希槽不一致时,确定所述节点设备本次不进行挖矿。
示例地,如图3所示,若区块链当前的区块数为1,区块数对4求余等于1,则哈希槽1对应的节点设备2和8参与对下一个区块的挖矿,其他所有节点设备不参与对下一个区块的挖矿。在节点设备2或者节点设备8挖矿产生下一个区块后,区块链的区块数为2,对4求余等于2,则哈希槽2对应的节点设备3和节点设备6参与对第3个区块的挖矿,其他节点设备不参与对第3个区块的挖矿。按照上述流程依次进行,由于区块数的不断增加,对应的哈希槽也不断变化,从而每次参与挖矿的节点设备也发生变化,进而同一节点设备无法连续数次产生区块,提升了节点设备挖矿的公平性。
同样,考虑到节点设备可能出现故障导致无法挖矿,区块链网络中可能存在某一次挖矿没有节点设备参与的情况。本发明实施例还可以包括,在连续L次获取到的区块数对应的哈希槽均与所述节点设备对应的哈希槽不一致,则确定所述节点设备本次进行挖矿,L是大于或等于N的正整数。
也就是说,对于N个哈希槽,正常情况下,每N次挖矿,一个节点设备会至少会参与一次,若某一节点设备连续L-1次没有参与挖矿,则表明其他节点设备可能发生故障,因此,该节点设备可以在连续第L次确定区块数对应的哈希槽与自身对应的哈希槽不一致时,进行挖矿,从而保证了区块链网络的正常运行。
上述两种可能的实现方式只是举例说明,在具体实施时,可以根据具体的业务配置节点设备以何种方式判断每次是否进行挖矿。
下面针对上述第一种可能的实现方式分析采用本发明实施例提供的挖矿方法具体能够达到的效果。
以图3进行举例说明,将区块链上的所有节点设备通过账号MD5哈希值划入4个哈希槽中。利用区块数对4取模运算,这样将会从哈希槽0到哈希槽3依次击中槽位。槽位中的各节点设备将周期性的被禁止参与挖矿,实 现禁止强算力节点设备挖矿的目的,最终避免强算力节点设备对区块链的垄断和提高攻击者进行双花攻击的难度。现有的工作量证明机制使得只要有一个强算力节点设备就可以实现双花攻击,采用本发明实施例后,要实现双花攻击至少要4个强算力的节点,从而提高攻击者的犯罪代价。
以下分析本发明实施例的故障容错能力和抗攻击能力。若每个节点设备故障的可能性为2.5%,每个节点设备被恶意攻击的可能性为25%,哈希槽位数为4,节点设备总数为X,则在其他节点设备出现故障,可用节点设备总数小于X/4且都在同一个槽位时,才会出现冻结,即没有参与挖矿的节点设备的情况,该种情况的概率分布符合累积二项式分布,实验结果表明当X=5时,出现冻结的概率为1.914E-6,即百万分之一的概率,并且随着X的增加,出现冻结的概率将逐渐趋近0,表明了采用本发明实施例提供的挖矿方法的区块链网络具备较高的故障容错能力。
对于抗攻击能力,当由于被攻击原因导致可用节点设备总数小于X/4且都在同一个槽位时,才会出现整个区块的写入被入侵者完全掌握的情况。这种概率也符合累积二项式分布,实验结果表明当X=18时,出现被控制的概率为3.9482E-6,之后随着X的增加,概率将逐渐趋近0。表明了采用本发明实施例提供的挖矿方法的区块链网络具备较高的抗攻击能力。
由此可知,采用本发明实施例提供的方法,在保证了区块链网络具有足够的故障容错能力和抗攻击能力的前提下,区块链网络中各个节点设备挖矿的机会更加公平。
本发明实施例还提供一种挖矿装置40,所述挖矿装置40用于区块链网络中的节点设备,用于实施上述方法实施例提供的一种区块链挖矿方法,如图4A所示,所述挖矿装置40包括:
获取模块401,用于获取所述区块链当前的区块数;
判断模块402,用于判断所述区块数对应的哈希槽是否与所述节点设备 对应的哈希槽一致,其中,所述区块链网络中的每一所述节点设备通过哈希算法分布在N个哈希槽,N为大于或等于2的正整数;
确定模块403,用于根据判断结果确定所述节点设备本次是否进行挖矿。
采用上述挖矿装置,区块链网络中的所有节点设备均匀分布在不同的哈希槽,随着当前区块链的区块数每次的增加,进行挖矿的节点设备也发生变化,保证了同一节点设备无法连续产生区块。从而降低了算力强的节点设备挖矿的几率,增加了算力弱的节点设备挖矿的几率,使得区块链网络中各节点设备挖矿机会更加公平。
可选地,所述确定模块403用于,在所述区块数对应的哈希槽与所述节点设备对应的哈希槽一致时,确定所述节点设备本次不进行挖矿;在所述区块数对应的哈希槽与所述节点设备对应的哈希槽不一致时,确定所述节点设备本次进行挖矿。
可选地,所述确定单元403用于,在连续M次获取到的区块数对应的哈希槽均与所述节点设备对应的哈希槽一致时,确定所述节点设备本次进行挖矿,M是大于或等于2的正整数。
可选地,如图4B所示,所述挖矿装置40还包括:计算单元404,用于利用所述区块数对N进行取模运算,得到第一取模值;利用所述节点设备的账户信息根据MD5算法对N进行取模运算,得到第二取模值;所述判断模块402用于,判断所述第一取模值与所述第二取模值是否一致,其中,所述第一取模值与所述第二取模值一致表明所述区块数对应的哈希槽与所述节点设备对应的哈希槽一致,所述第一取模值与所述第二取模值不一致表明所述区块数对应的哈希槽与所述节点设备对应的哈希槽不一致。
可选地,如图4B所示,所述挖矿装置40还包括:接收模块405,用于接收所述区块链网络中的另一节点设备发送的区块,所述区块包括所述另一节点设备的账户信息;工作量证明模块406,用于在确定所述区块数对应的 哈希槽与所述另一节点设备对应的哈希槽不一致时,对所述区块进行工作量证明。
本领域的技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。上述描述功能模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
本发明实施例还提供一种节点设备50,用于实施上述方法实施例提供的一种区块链挖矿方法,如图5所示,所述节点设备50包括:
处理器单元501、通信接口502、存储器503和通信总线504;所述处理器单元501、所述通信接口502和所述存储器503通过所述通信总线504完成相互间的通信。
处理器单元501可能是一个多核中央处理器CPU,或者是ASIC(Application Specific Integrated Circuit,特定集成电路),或者是被配置成实施本发明实施例的一个或多个集成电路。
存储器503用于存放程序代码,所述程序代码包括计算机操作指令和网络流图。存储器503可能携带高速RAM存储器,也可能还包括非易失性存储器(non-volatile memory),例如至少一个磁盘存储器。
所述通信接口502,用于实现这些节点设备之间的连接通信。
所述处理器单元501执行程序代码,所述程序代码在运行时用于实现上述方法实施例提供的一种区块链的挖矿方法,所述方法包括:
获取所述区块链当前的区块数;
判断所述区块数对应的哈希槽是否与所述节点设备对应的哈希槽一致,其中,所述区块链网络中的每一所述节点设备通过哈希算法分布在N个哈希槽,N为大于或等于2的正整数;
根据判断结果确定所述节点设备本次是否进行挖矿。
可选地,所述根据判断结果确定所述节点设备本次是否进行挖矿,包括:
在所述区块数对应的哈希槽与所述节点设备对应的哈希槽一致时,确定所述节点设备本次不进行挖矿;
在所述区块数对应的哈希槽与所述节点设备对应的哈希槽不一致时,确定所述节点设备本次进行挖矿。
可选地,所述根据判断结果确定所述节点设备本次是否进行挖矿,包括:
若连续M次获取到的区块数对应的哈希槽均与所述节点设备对应的哈希槽一致,则确定所述节点设备本次进行挖矿,M是大于或等于2的正整数。
可选地,所述判断所述区块数对应的哈希槽是否与所述节点设备对应的哈希槽一致,包括:
利用所述区块数对N进行取模运算,得到第一取模值;
利用所述节点设备的账户信息根据MD5算法对N进行取模运算,得到第二取模值;
判断所述第一取模值与所述第二取模值是否一致,其中,所述第一取模值与所述第二取模值一致表明所述区块数对应的哈希槽与所述节点设备对应的哈希槽一致,所述第一取模值与所述第二取模值不一致表明所述区块数对应的哈希槽与所述节点设备对应的哈希槽不一致。
可选地,所述方法还包括:
接收所述区块链网络中的另一节点设备发送的区块,所述区块包括所述另一节点设备的账户信息;
在确定所述区块数对应的哈希槽与所述另一节点设备对应的哈希槽不一致时,对所述区块进行工作量证明。
在本申请所提供的几个实施例中,应该理解到,所公开的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的, 例如,所述功能模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理模块,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。
另外,在本发明各个实施例中的各功能模块可以集成在一个处理单元中,也可以是各个模块单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用硬件加软件功能模块的形式实现。
上述以软件功能模块的形式实现的集成的模块,可以存储在一个计算机可读取存储介质中。上述软件功能模块存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的部分步骤。而前述的存储介质包括:U盘、移动硬盘、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储数据的介质。也就是说,本发明实施例还提供一种计算机可读存储介质,所述计算机可读存储介质用于存储计算机程序,所述计算机程序包括用于执行上述区块链的挖矿方法的指令。
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到的变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以权利要求的保护范围为准。

Claims (12)

  1. 一种区块链的挖矿方法,其特征在于,所述方法应用于区块链网络中的节点设备,所述方法包括:
    获取所述区块链当前的区块数;
    判断所述区块数对应的哈希槽是否与所述节点设备对应的哈希槽一致,其中,所述区块链网络中的每一所述节点设备通过哈希算法分布在N个哈希槽,N为大于或等于2的正整数;
    根据判断结果确定所述节点设备本次是否进行挖矿。
  2. 根据权利要求1所述的方法,其特征在于,所述根据判断结果确定所述节点设备本次是否进行挖矿,包括:
    在所述区块数对应的哈希槽与所述节点设备对应的哈希槽一致时,确定所述节点设备本次不进行挖矿;
    在所述区块数对应的哈希槽与所述节点设备对应的哈希槽不一致时,确定所述节点设备本次进行挖矿。
  3. 根据权利要求1所述的方法,其特征在于,所述根据判断结果确定所述节点设备本次是否进行挖矿,包括:
    若连续M次获取到的区块数对应的哈希槽均与所述节点设备对应的哈希槽一致,则确定所述节点设备本次进行挖矿,M是大于或等于2的正整数。
  4. 根据权利要求1至3任一项所述的方法,其特征在于,所述判断所述区块数对应的哈希槽是否与所述节点设备对应的哈希槽一致,包括:
    利用所述区块数对N进行取模运算,得到第一取模值;
    利用所述节点设备的账户信息根据MD5算法对N进行取模运算,得到 第二取模值;
    判断所述第一取模值与所述第二取模值是否一致,其中,所述第一取模值与所述第二取模值一致表明所述区块数对应的哈希槽与所述节点设备对应的哈希槽一致,所述第一取模值与所述第二取模值不一致表明所述区块数对应的哈希槽与所述节点设备对应的哈希槽不一致。
  5. 根据权利要求1至3任一项所述的方法,其特征在于,所述方法还包括:
    接收所述区块链网络中的另一节点设备发送的区块,所述区块包括所述另一节点设备的账户信息;
    在确定所述区块数对应的哈希槽与所述另一节点设备对应的哈希槽不一致时,对所述区块进行工作量证明。
  6. 一种挖矿装置,其特征在于,所述挖矿装置用于区块链网络中的节点设备,所述装置包括:
    获取模块,用于获取所述区块链当前的区块数;
    判断模块,用于判断所述区块数对应的哈希槽是否与所述节点设备对应的哈希槽一致,其中,所述区块链网络中的每一所述节点设备通过哈希算法分布在N个哈希槽,N为大于或等于2的正整数;
    确定模块,用于根据判断结果确定所述节点设备本次是否进行挖矿。
  7. 根据权利要求6所述的装置,其特征在于,所述确定模块用于,在所述区块数对应的哈希槽与所述节点设备对应的哈希槽一致时,确定所述节点设备本次不进行挖矿;
    在所述区块数对应的哈希槽与所述节点设备对应的哈希槽不一致时,确 定所述节点设备本次进行挖矿。
  8. 根据权利要求6所述的装置,其特征在于,所述确定单元用于,
    在连续M次获取到的区块数对应的哈希槽均与所述节点设备对应的哈希槽一致时,确定所述节点设备本次进行挖矿,M是大于或等于2的正整数。
  9. 根据权利要求6至8任一项所述的装置,其特征在于,所述装置还包括:计算单元,用于利用所述区块数对N进行取模运算,得到第一取模值;利用所述节点设备的账户信息根据MD5算法对N进行取模运算,得到第二取模值;
    所述判断模块用于,判断所述第一取模值与所述第二取模值是否一致,其中,所述第一取模值与所述第二取模值一致表明所述区块数对应的哈希槽与所述节点设备对应的哈希槽一致,所述第一取模值与所述第二取模值不一致表明所述区块数对应的哈希槽与所述节点设备对应的哈希槽不一致。
  10. 根据权利要求6至8任一项所述的装置,其特征在于,所述装置还包括:
    接收模块,用于接收所述区块链网络中的另一节点设备发送的区块,所述区块包括所述另一节点设备的账户信息;
    工作量证明模块,用于在确定所述区块数对应的哈希槽与所述另一节点设备对应的哈希槽不一致时,对所述区块进行工作量证明。
  11. 一种节点设备,其特征在于,包括:
    处理器单元、通信接口、存储器和通信总线;所述处理器单元、所述通信接口和所述存储器通过所述通信总线完成相互间的通信;
    所述存储器用于存储程序代码;
    所述处理器单元用于执行所述程序代码以实现权利要求1至5任一项所述的方法。
  12. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质用于存储计算机程序,所述计算机程序包括用于执行权利要求1至5任一项所述的方法的指令。
PCT/CN2016/111860 2016-12-23 2016-12-23 区块链的挖矿方法、装置和节点设备 Ceased WO2018112949A1 (zh)

Priority Applications (3)

Application Number Priority Date Filing Date Title
CN201680003221.1A CN107078903B (zh) 2016-12-23 2016-12-23 区块链的挖矿方法、装置和节点设备
US16/314,986 US10664485B2 (en) 2016-12-23 2016-12-23 Block chain mining method, device, and node apparatus
PCT/CN2016/111860 WO2018112949A1 (zh) 2016-12-23 2016-12-23 区块链的挖矿方法、装置和节点设备

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2016/111860 WO2018112949A1 (zh) 2016-12-23 2016-12-23 区块链的挖矿方法、装置和节点设备

Publications (1)

Publication Number Publication Date
WO2018112949A1 true WO2018112949A1 (zh) 2018-06-28

Family

ID=59624459

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/111860 Ceased WO2018112949A1 (zh) 2016-12-23 2016-12-23 区块链的挖矿方法、装置和节点设备

Country Status (3)

Country Link
US (1) US10664485B2 (zh)
CN (1) CN107078903B (zh)
WO (1) WO2018112949A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109376115A (zh) * 2018-08-31 2019-02-22 北京智云芯科技有限公司 一种基于工作量证明的计算装置及计算方法
CN113836147A (zh) * 2021-11-26 2021-12-24 广东辰宜信息科技有限公司 链标识生成方法及装置、链集群管理方法、系统、介质
CN114169008A (zh) * 2021-12-06 2022-03-11 国网山东省电力公司威海供电公司 基于区块链的保护定值远程配置系统及方法

Families Citing this family (36)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107368507B (zh) * 2017-03-28 2020-03-27 创新先进技术有限公司 一种基于区块链的共识方法及装置
US10762479B2 (en) * 2017-04-05 2020-09-01 Samsung Sds Co., Ltd. Method and system for processing blockchain-based real-time transaction
US10812270B2 (en) * 2017-04-07 2020-10-20 Citizen Hex Inc. Techniques for increasing the probability that a transaction will be included in a target block of a blockchain
CN108241926B (zh) * 2017-08-25 2020-07-10 杭州复杂美科技有限公司 一种区块链授权共识方法
CN107733651B (zh) * 2017-09-11 2020-06-19 联动优势科技有限公司 一种区块链生成方法、节点及系统
CN107911819B (zh) * 2017-11-30 2020-11-27 江苏通付盾科技有限公司 基于手机号码选取打包节点的方法及系统
CN110109913B (zh) * 2018-01-15 2021-05-04 北京比特大陆科技有限公司 一种zerocash挖矿算法的硬件实现方法及装置
CN108512650B (zh) * 2018-02-28 2021-03-09 南京思利华信息科技有限公司 面向区块链的动态哈希计算方法、装置、节点及存储介质
CN108306898B (zh) * 2018-04-23 2021-02-05 北京奇宝科技有限公司 区块链攻击事件的感知方法、装置、计算设备及存储介质
CN108566398B (zh) * 2018-04-23 2020-10-27 北京奇虎科技有限公司 区块链攻击事件感知方法、装置及计算机存储介质
CN108596617B (zh) * 2018-04-23 2020-11-20 北京奇虎科技有限公司 区块链攻击事件感知方法、装置及计算机存储介质
CN108551454B (zh) * 2018-04-23 2020-10-30 北京奇虎科技有限公司 区块链攻击事件感知方法、装置及计算机存储介质
CN109033832B (zh) * 2018-06-22 2021-02-09 深圳前海益链网络科技有限公司 一种防范对区块链网络进行短暂分叉双花攻击的方法
GB201811263D0 (en) * 2018-07-10 2018-08-29 Netmaster Solutions Ltd A method and system for managing digital using a blockchain
CN109242676B (zh) * 2018-07-27 2023-10-27 创新先进技术有限公司 区块发布方法及装置、电子设备
CN109238758B (zh) * 2018-08-02 2020-12-18 李淑芹 一种区块链矿机故障的检测方法和检测装置
CN109194718A (zh) * 2018-08-09 2019-01-11 玄章技术有限公司 一种区块链网络及其任务调度方法
CN108989464A (zh) * 2018-08-29 2018-12-11 上海常仁信息科技有限公司 一种基于区块链的挖矿机器人系统
CN109242491A (zh) * 2018-08-31 2019-01-18 深圳付贝科技有限公司 挖矿身份认证方法、挖矿机及区块链系统
US10834122B2 (en) * 2018-09-05 2020-11-10 International Business Machines Corporation Prevention of majority attacks
CN109410050B (zh) * 2018-09-27 2021-08-06 杭州复杂美科技有限公司 挖矿耗时修正方法、设备和存储介质
CN109462641B (zh) * 2018-10-30 2021-12-10 深圳市元征科技股份有限公司 一种用户通信方法及系统、设备、计算机可读存储介质
CN109993511B (zh) * 2019-04-01 2021-07-06 北京众享比特科技有限公司 一种区块验证方法
CA3060101C (en) * 2019-04-26 2021-06-08 Alibaba Group Holding Limited Anti-replay attack authentication protocol
CN110113172B (zh) * 2019-04-29 2022-04-15 深圳市元征科技股份有限公司 一种难度调整的方法及相关设备
CN110222537B (zh) * 2019-06-17 2021-01-29 北京瑞策科技有限公司 应用于区块链节点的验证方法及装置
CN110245950B (zh) * 2019-06-17 2020-08-04 北京瑞策科技有限公司 涉及区块链的出块方法及装置
TWI706346B (zh) * 2019-10-31 2020-10-01 鴻海精密工業股份有限公司 限制礦機算力的方法、礦機、儲存介質
CN110991955B (zh) * 2019-11-27 2023-04-18 太原理工大学 一种基于信息矩的组群数量多样性估计方法
CN110989934B (zh) * 2019-12-05 2023-08-25 达闼机器人股份有限公司 区块链节点数据存储方法、区块链系统及区块链节点
US12099997B1 (en) 2020-01-31 2024-09-24 Steven Mark Hoffberg Tokenized fungible liabilities
CN111324489B (zh) * 2020-02-18 2023-04-07 杭州复杂美科技有限公司 主链游戏结果展示方法、设备和存储介质
CN111355608A (zh) * 2020-02-18 2020-06-30 杭州复杂美科技有限公司 一种区块链回滚异常识别方法和系统、设备及存储介质
US11682095B2 (en) 2020-02-25 2023-06-20 Mark Coast Methods and apparatus for performing agricultural transactions
CN111683120A (zh) * 2020-05-22 2020-09-18 哈尔滨工程大学 一种支持验证节点动态变化的联盟节点存储方法
CN113259186B (zh) * 2021-07-07 2021-10-08 发明之家(北京)科技有限公司 一种区块链的新区块监控方法和系统

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105469510A (zh) * 2014-10-12 2016-04-06 吴思进 可预告延时支付或找回的加密货币钱包
US20160218879A1 (en) * 2015-01-23 2016-07-28 Daniel Robert Ferrin Method and apparatus for the limitation of the mining of blocks on a block chain
CN106060036A (zh) * 2016-05-26 2016-10-26 布比(北京)网络技术有限公司 去中心化共识方法及装置

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DK3095044T3 (da) * 2013-11-19 2020-12-21 Top Galore Ltd Block mining fremgangsmåde og apparat
US9256549B2 (en) * 2014-01-17 2016-02-09 Netapp, Inc. Set-associative hash table organization for efficient storage and retrieval of data in a storage system
US9268653B2 (en) * 2014-01-17 2016-02-23 Netapp, Inc. Extent metadata update logging and checkpointing
CN106296184A (zh) * 2015-06-05 2017-01-04 地气股份有限公司 电子货币管理方法及电子货币系统
US20170345011A1 (en) * 2016-05-26 2017-11-30 Hitfin, Inc. System and method executed on a blockchain network
US10454765B2 (en) * 2016-07-15 2019-10-22 Mastercard International Incorporated Method and system for node discovery and self-healing of blockchain networks
US10726346B2 (en) * 2016-11-09 2020-07-28 Cognitive Scale, Inc. System for performing compliance operations using cognitive blockchains
US10628491B2 (en) * 2016-11-09 2020-04-21 Cognitive Scale, Inc. Cognitive session graphs including blockchains
US10621233B2 (en) * 2016-11-09 2020-04-14 Cognitive Scale, Inc. Cognitive session graphs including blockchains

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105469510A (zh) * 2014-10-12 2016-04-06 吴思进 可预告延时支付或找回的加密货币钱包
US20160218879A1 (en) * 2015-01-23 2016-07-28 Daniel Robert Ferrin Method and apparatus for the limitation of the mining of blocks on a block chain
CN106060036A (zh) * 2016-05-26 2016-10-26 布比(北京)网络技术有限公司 去中心化共识方法及装置

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109376115A (zh) * 2018-08-31 2019-02-22 北京智云芯科技有限公司 一种基于工作量证明的计算装置及计算方法
CN113836147A (zh) * 2021-11-26 2021-12-24 广东辰宜信息科技有限公司 链标识生成方法及装置、链集群管理方法、系统、介质
CN114169008A (zh) * 2021-12-06 2022-03-11 国网山东省电力公司威海供电公司 基于区块链的保护定值远程配置系统及方法

Also Published As

Publication number Publication date
CN107078903B (zh) 2019-12-06
US10664485B2 (en) 2020-05-26
US20190310980A1 (en) 2019-10-10
CN107078903A (zh) 2017-08-18

Similar Documents

Publication Publication Date Title
WO2018112949A1 (zh) 区块链的挖矿方法、装置和节点设备
US12200108B2 (en) Systems and methods for blockchains with serial proof of work
US10630463B2 (en) Meta block chain
US11902290B2 (en) Systems and methods for hybrid blockchain control
CN110599160B (zh) 用于基于随机数证明来选择分布式共识节点的方法和装置
Aniello et al. A prototype evaluation of a tamper-resistant high performance blockchain-based transaction log for a distributed database
US20220173888A1 (en) Blockchain consensus methods and systems
US12093247B2 (en) Blockchain system and method
CN109218348B (zh) 一种区块链中区块的确定方法及节点设备
JP2020532169A (ja) ブロックチェーンにおける擬似乱数生成
US12079804B2 (en) Transaction assignment method and apparatus based on structured directed acyclic graph
CN114556864B (zh) 安全共生挖掘的方法和装置
Cai et al. Hardening distributed and encrypted keyword search via blockchain
CN112968883A (zh) 一种安全性高的区块链异构共识方法及终端
CN109639436A (zh) 基于盐值的数据持有性验证方法及终端设备
KR20180014537A (ko) 분산 스토리지 환경에서 데이터 무결성 검증을 위한 장치 및 방법
WO2017211077A1 (zh) 一种跨平台的互联文档id生成方法
KR20210127231A (ko) 동력화된 ID (Energized Identity) 기반 블록체인
Snegireva Review of Modern Blockchain Platforms
CN120406833A (zh) 一种数据存储方法、装置、设备及介质
CN121979920A (zh) 一种基于分布式点函数的区块链隐私保护查询方法
Lee SASEUL: Universal Computer
CN111125259A (zh) 一种基于区块链底层的随机种子提供方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16924792

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 15/10/2019)

122 Ep: pct application non-entry in european phase

Ref document number: 16924792

Country of ref document: EP

Kind code of ref document: A1