WO2023185046A1 - 区块链系统中共识节点的轮换方法、节点和区块链系统 - Google Patents

区块链系统中共识节点的轮换方法、节点和区块链系统 Download PDF

Info

Publication number
WO2023185046A1
WO2023185046A1 PCT/CN2022/135275 CN2022135275W WO2023185046A1 WO 2023185046 A1 WO2023185046 A1 WO 2023185046A1 CN 2022135275 W CN2022135275 W CN 2022135275W WO 2023185046 A1 WO2023185046 A1 WO 2023185046A1
Authority
WO
WIPO (PCT)
Prior art keywords
node
nodes
consensus
random number
transaction
Prior art date
Application number
PCT/CN2022/135275
Other languages
English (en)
French (fr)
Inventor
石杰
邓福喜
闫莺
徐文博
曾超
王江
Original Assignee
蚂蚁区块链科技(上海)有限公司
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 蚂蚁区块链科技(上海)有限公司 filed Critical 蚂蚁区块链科技(上海)有限公司
Publication of WO2023185046A1 publication Critical patent/WO2023185046A1/zh

Links

Images

Classifications

    • 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
    • H04L67/1044Group management mechanisms 
    • H04L67/1051Group master selection mechanisms
    • 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
    • H04L67/1059Inter-group management mechanisms, e.g. splitting, merging or interconnection of groups

Definitions

  • the embodiments of this specification belong to the field of blockchain technology, and particularly relate to a rotation method of consensus nodes in a blockchain system, a first node, and a blockchain system.
  • Blockchain is a new application model of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
  • data blocks are combined into a chained data structure in a chronological manner and are cryptographically guaranteed to be an untamperable and unforgeable distributed ledger. Due to the characteristics of blockchain, such as decentralization, non-tamperable information, and autonomy, blockchain has also received more and more attention and applications.
  • the purpose of the present invention is to provide a method for rotating consensus nodes in a blockchain system, a first node and a blockchain system.
  • a method for rotating consensus nodes in a blockchain system includes a plurality of first nodes currently serving as consensus nodes and a number of second nodes currently serving as non-consensus nodes.
  • a smart contract is deployed in the blockchain system, and a first set is stored in the contract state of the smart contract.
  • the first set includes the identities of the plurality of first nodes.
  • the method consists of the first set. node execution.
  • the method includes: obtaining a first transaction, the first transaction request calling the smart contract to instruct a third node among the plurality of first nodes to be set as a non-consensus node, and setting the plurality of second nodes to a non-consensus node.
  • a fourth node among the nodes is set as a consensus node; based on the first transaction, the identity of the third node is replaced with the identity of the fourth node in the first set.
  • a blockchain node in a blockchain system includes a plurality of first nodes currently serving as consensus nodes and a number of second nodes currently serving as non-consensus nodes, so A smart contract is deployed in the blockchain system, and a first set is stored in the contract state of the smart contract, and the first set includes the identifiers of the plurality of first nodes.
  • the blockchain node includes: a transaction acquisition unit configured to acquire a first transaction, and the first transaction request calls the smart contract to instruct a third node among the plurality of first nodes to be set to non- a consensus node, setting the fourth node among the plurality of second nodes as a consensus node; a transaction execution unit configured to replace the identification of the third node with the identifier of the third node in the first set based on the first transaction The identification of the fourth node.
  • a blockchain system including a plurality of first nodes currently serving as consensus nodes and a number of second nodes currently serving as non-consensus nodes.
  • Smart contracts are deployed in the blockchain system, and the A first set is stored in the contract state of the smart contract, and the first set includes the identities of the plurality of first nodes; wherein the first node is used to obtain the first transaction, and the first transaction request calls
  • the smart contract is used to instruct the third node among the plurality of first nodes to be set as a non-consensus node, and the fourth node among the plurality of second nodes to be set as a consensus node; based on the first
  • the transaction replaces the identity of the third node with the identity of the fourth node in the first set.
  • a fourth aspect provides a computer-readable storage medium on which a computer program is stored.
  • the computing device is caused to perform the method described in the first aspect.
  • a computing device including a memory and a processor.
  • a computer program is stored in the memory.
  • the processor executes the computer program, the method described in the first aspect is implemented.
  • the first node currently serving as the consensus node can obtain the first transaction that calls the smart contract, and then based on the first transaction in the first set stored in the contract status of the smart contract, the first node currently serving as the consensus node
  • the identification of the three nodes is replaced with the identification of the fourth node as the consensus node, thereby completing the rotation of the consensus nodes in the blockchain nodes by updating the identification of the blockchain nodes in the set, which is conducive to improving the area. Fairness and security of blockchain systems.
  • FIG. 1 is a schematic diagram of the consensus process in the PBFT consensus algorithm provided in the embodiment of this specification;
  • FIG. 2 is a schematic diagram of the blockchain system provided as an example in the embodiment of this specification.
  • Figure 3 is a flow chart of a rotation method of consensus nodes in a blockchain system provided in the embodiment of this specification;
  • Figure 4 is a flow chart of a method for generating a third random number provided in an exemplary embodiment of this specification
  • Figure 5 is a schematic diagram of an exemplary technical scenario of rotating consensus nodes
  • Figure 6 is a schematic diagram of a first node in a blockchain system provided in the embodiment of this specification.
  • a decentralized (or multi-centered) distributed ledger constructed using a chain block structure is stored on each node (or most nodes, such as consensus nodes) in the distributed blockchain network.
  • a blockchain system needs to solve the problem of consistency and correctness of respective ledger data on multiple decentralized (or multi-centered) nodes.
  • Each node runs a blockchain program.
  • the consensus mechanism is used to ensure that all loyal nodes have the same transaction, thereby ensuring that all loyal nodes have consistent execution results for the same transaction, and the transaction is Packaged into blocks and updated world state based on execution results of the same transaction.
  • the current mainstream consensus mechanisms include but are not limited to: Proof of Work (POW), Proof of Stake (POS), Delegated Proof of Stake (DPOS), Practical Byzantine Fault Tolerance (Practical Byzantine) Fault Tolerance (PBFT) algorithm, Honey Badger Byzantine Fault Tolerance (HoneyBadgerBFT) algorithm, etc.
  • POW Proof of Work
  • POS Proof of Stake
  • DPOS Delegated Proof of Stake
  • PBFT Practical Byzantine Fault Tolerance
  • PBFT Practical Byzantine Fault Tolerance
  • HoneyBadgerBFT Honey Badger Byzantine Fault Tolerance
  • FIG. 1 is a schematic diagram of the consensus process in the PBFT consensus algorithm provided as an example in the embodiment of this specification.
  • the consensus process can be divided into four stages: request, preparation, preparation and submission.
  • a blockchain includes four consensus nodes, node n1 - node n4, where node n1 is, for example, the master node, and node n2 - node n4, for example, are slave nodes.
  • the user of the blockchain can send a request to the node n1 through its user device, and the request is, for example, in the form of a blockchain transaction.
  • node n1 can package the multiple transactions into a consensus proposal, and send the consensus proposal and node n1's signature to the consensus proposal to other consensus nodes. (i.e., node n2 - node n4) to generate blocks.
  • the consensus proposal may include information such as the transaction body of the multiple transactions and the submission order of the multiple transactions.
  • each slave node can sign the consensus proposal and send it to each other node.
  • each consensus node signs the consensus proposal in the submission phase and sends it to each other consensus node.
  • each consensus node can confirm that the submission phase is completed and the consensus success. For example, after receiving and verifying the signatures of the submission phase of node n2 and node n3, node n1 determines that the submission phase is completed. Therefore, node n1 can execute the multiple transactions according to the consensus proposal, generate and store the multiple transactions including the multiple transactions.
  • the transaction block (for example, block B1) updates the world state based on the execution results of multiple transactions and returns the execution results of multiple transactions to the user device.
  • node n2 and node n3 execute the multiple transactions, generate and store block B1, and update the world state according to the execution results of the multiple transactions.
  • the storage consistency of node n1, node n2 and node n3 is achieved.
  • nodes n1-node n4 can still achieve successful consensus on the consensus proposal in the presence of a malicious node, and then complete the execution of the block.
  • Transactions in the blockchain field can refer to task units that are executed and recorded in the blockchain. Transactions usually include sending fields (From), receiving fields (To) and data fields (Data). Among them, when the transaction is a transfer transaction, the From field represents the account address that initiated the transaction (that is, initiated a transfer task to another account), the To field represents the account address that received the transaction (that is, received the transfer), and the Data field Include transfer amount.
  • the From field indicates the account address that initiated the transaction
  • the To field indicates the account address of the contract called by the exchange
  • the Data field includes the function name in the calling contract and the corresponding Data such as the incoming parameters of the function are used to obtain the code of the function from the blockchain and execute the code of the function when the transaction is executed.
  • Smart contracts on the blockchain are contracts that can be triggered and executed by transactions on the blockchain system. Smart contracts can be defined in the form of code. Calling a smart contract in the blockchain is to initiate a transaction pointing to the smart contract address, allowing each node in the blockchain to run the smart contract code in a distributed manner. It should be noted that in addition to smart contracts that can be created by users, smart contracts can also be set by the system in the genesis block. This type of contract is generally called a creation contract. Generally, some blockchain data structures, parameters, properties and methods can be set in the genesis contract. In addition, accounts with system administrator rights can create system-level contracts or modify system-level contracts (referred to as system contracts). Among them, the system contract can be used to add data structures for different business data in the blockchain.
  • a transaction containing smart contract creation information (i.e., deployment contract) can be sent to the blockchain system.
  • the data field of the transaction includes the code of the contract to be created (such as bytecode or machine code).
  • the to field of the transaction is empty to indicate that the transaction is used to deploy the contract.
  • the transaction for calling the smart contract can be sent to the blockchain system.
  • the from field of the transaction is the address of the account of the transaction initiator, and the to field is the contract address of the called smart contract.
  • the data field of the transaction includes the methods and parameters for calling the smart contract.
  • a small number of nodes can be selected from the large-scale nodes as consensus nodes to participate in the execution of the consensus mechanism.
  • the consensus results obtained by participating in the execution of the consensus mechanism by a relatively small number of consensus nodes can be distributed by the consensus nodes to other non-consensus nodes among large-scale nodes that have not been selected as consensus nodes, thereby improving the efficiency of the blockchain system. Consensus efficiency.
  • Node 1, Node 2, Node 3 and Node 4 can be selected as consensus nodes to form a consensus node set.
  • Non-consensus nodes other than consensus nodes can, for example, It is divided into node group 1, node group 2, node group 3 and node group 4 corresponding to the aforementioned four consensus nodes; after the aforementioned four consensus nodes jointly execute a certain consensus mechanism to obtain the consensus result, each consensus node can respond to its corresponding The non-consensus nodes in the node group distribute the consensus results so that the non-consensus nodes obtain the corresponding blocks based on the consensus results and update their stored world state accordingly.
  • the aforementioned consensus results can be blocks or related data used to generate blocks.
  • the consensus node can directly send the consensus result to its corresponding non-consensus node.
  • Node 1 can completely send the consensus result to n non-consensus nodes such as node 11 ⁇ node 1n in node group 1.
  • the consensus node can also use an erasure coding algorithm to split the consensus results to obtain multiple data blocks, and distribute different data blocks to different corresponding non-consensus nodes; non-consensus nodes can broadcast their consensus results to each other.
  • the data blocks received by the node so that after a single non-consensus node receives a corresponding number of data blocks from the consensus node and/or other non-consensus nodes, it can decode the collected data blocks to obtain the aforementioned consensus results.
  • the amount of data distributed by consensus nodes to non-consensus nodes will not increase with the increase in the size of non-consensus nodes.
  • the amount of data distributed by consensus nodes to non-consensus nodes is relatively small, and large-scale distribution can be completed more quickly.
  • Non-consensus nodes distribute consensus results with relatively high efficiency.
  • the embodiments of this specification provide a rotation method of consensus nodes in a blockchain system, a first node, and a blockchain system.
  • the first node currently serving as the consensus node can obtain the first transaction that calls the smart contract, and then replace the identity of the third node currently serving as the consensus node in the first set stored in the contract state of the smart contract based on the first transaction.
  • the fourth node As the consensus node, and then realize the rotation of the consensus node in the blockchain node by updating the identity of the blockchain node in the set, it is conducive to improving the fairness of the blockchain system. sex and safety.
  • Figure 3 is a rotation method of consensus nodes in the blockchain system provided in the embodiment of this specification.
  • the blockchain system includes multiple first nodes currently serving as consensus nodes and several second nodes currently serving as non-consensus nodes.
  • Smart contracts are deployed in the blockchain system, and the contract status of the smart contracts stores a third node.
  • a set, the first set includes the identities of the plurality of first nodes mentioned above, and the method can be executed by any first node currently serving as a consensus node.
  • the method may include but is not limited to the following steps 32 and 34.
  • Step 32 Obtain the first transaction.
  • the first transaction request calls the smart contract to instruct the third node among the plurality of first nodes to be set as a non-consensus node, and the fourth node among the plurality of second nodes to be set as Consensus node.
  • the blockchain node can learn whether it is currently the first node serving as a consensus node through the first set stored in the contract state of the smart contract (hereinafter referred to as contract c1). Please continue to refer to Figure 2.
  • the first node currently serving as a consensus node includes, for example, Node 1, Node 2, Node 3 and Node 4.
  • the identities of the aforementioned four nodes are all stored in the set c1.
  • the aforementioned four nodes can be found by Its own identity is stored in the set c1 and it is known that it is currently used as a consensus node.
  • the contract state of the smart contract can also store several second sets (hereinafter referred to as set c2). Different sets c2 correspond to different first nodes. A single set c2 contains one and or more third sets that are currently non-consensus nodes. The identifier of the second node. Please continue to refer to Figure 2. The n second nodes currently located in node group 1, such as Node 11 ⁇ Node 1n, correspond to the same consensus node Node 1.
  • the contract state of the smart contract can store the set c2 corresponding to Node 1, which Set c2 contains the respective identities of n second nodes such as Node 11 to Node 1n; similarly, the contract state of the smart contract can also store the set c2 corresponding to Node 2, the node c2 corresponding to Node 3, and the storage The combination c2 corresponding to Node 4.
  • the blockchain node currently serving as a consensus node can also generate corresponding third random numbers (hereinafter referred to as random number x1) and fourth random numbers (hereinafter referred to as random number x2), and then based on the random number x1 from the current consensus Determine the third node to be rotated among the multiple first nodes of the node, and determine the fourth node that will serve as the consensus node from the number of second nodes currently serving as non-consensus nodes based on the random number x2, thus ensuring the consensus node
  • the rotation process is random, so that each blockchain node has a chance to be selected as a consensus node.
  • a set of random number nodes can also be stored through the contract state of the smart contract.
  • the set of random number nodes can store the identifiers of multiple fifth nodes.
  • the aforementioned fifth node is Selected from multiple first nodes or several second nodes.
  • the blockchain node can discover whether it is used as the fifth node for generating random numbers based on the random number node set. If so, based on the random number node, it can achieve multi-party collaborative generation with the remaining fifth nodes. Verify but unpredictable secure random number x3, and then generate unpredictable random number x1 and random number x2 based on random number x3. For example, use random number x3 as a random seed to generate random number x1 and the aforementioned random number x2.
  • the random number x3 can be stored in the block generated in the corresponding block time. For example, it is stored in the block header generated in the corresponding block time for transactions in the block to which the random number x3 belongs or for transactions in other blocks after the block to which the random number x3 belongs.
  • the blockchain node currently serving as a consensus node can specifically read the random number x3 from the latest generated block, for example, read the random number x3 from the block header of the latest generated block, and based on the read
  • the random number x3 generates the aforementioned random number x1 and the aforementioned random number x2; the latest generated block may be the block to which the first transaction belongs or the block preceding the block to which the first transaction belongs.
  • the rotation process of the consensus node can be triggered according to a certain preset time interval or block height increment, that is, according to the preset time interval or block height increment, the latest generated zone can be periodically executed according to the preset time interval or block height increment.
  • the aforementioned random number x3 is read from the block, and the aforementioned step 32 is initiated based on the read random number x3.
  • the aforementioned plurality of fifth nodes may be the same as the aforementioned plurality of first nodes.
  • the aforementioned set of random number nodes may be the aforementioned set c1.
  • each first node can use its own private key share based on the threshold signature algorithm to sign the original message containing the unique value of the original transaction list in this consensus, and generate Sign the share and add the signature share to the broadcast commit message; after each first node collects at least a threshold number of commit messages, it passes at least the threshold number of signature shares through the recovery function corresponding to the private key share generated by the threshold signature algorithm.
  • each first node obtains a third random number based on the complete signature.
  • the first node when it generates the block containing the first transaction, it can also generate the corresponding third random number through the aforementioned process during the commit phase of the PBFT corresponding to the block.
  • the newly generated third random number The random number may be stored, for example, in the block to which the first transaction belongs, specifically, for example, to the block header of the block to which the first transaction belongs.
  • each first node uses its own private key share to sign the original message containing the unique value of the original transaction list in this consensus based on the threshold signature algorithm, generates a signature share, and Add this signature share to the broadcast commit message.
  • Threshold signature is an important branch of ordinary digital signature and a combination of threshold secret sharing technology and digital signature.
  • the traditional signature scheme can be implemented using the RSA algorithm.
  • the RSA algorithm is an asymmetric encryption algorithm jointly proposed by Ron Rivest, Adi Shamir and Leonard Adleman in 1977.
  • the RSA algorithm can complete decryption without directly transmitting the key, which can ensure the security of the information and avoid the risk of information being cracked caused by directly transmitting the key.
  • RSA includes a private key and a public key, and the private key and public key are in pairs.
  • the RSA signature mechanism can ensure the integrity of the message delivery process. For example, node A needs to transmit a message to node B, and it may be transited by several nodes in the process. Then A can use the RSA signature mechanism to transmit the message together with the signature to B through several intermediate nodes, and B's verification of the signature can confirm that the received message was sent by A and has not been tampered with during the transmission process. .
  • the process of an RSA signature is as follows:
  • A generates a pair of keys (public key and private key).
  • the private key is not made public and is kept by itself.
  • the public key is public and can be obtained by anyone.
  • b2 A signs the hash value of the original message with its own private key, and passes the original message and the signature result to B together. As mentioned before, this delivery process may be forwarded by several intermediate nodes.
  • the hash algorithm also known as the hash algorithm, can map the original content into a fixed-length sequence, and this sequence is the hash value.
  • hash algorithms such as sha256, sha384, and sha512.
  • the result of sha256 is 256 bits, which can represent 2 to the 256th power of the original content.
  • sha384 is 384bits
  • sha512 is 512bits.
  • These hash algorithms can target original content with more content and larger volume, so the hash value can be relatively smaller than the original content.
  • a good hash algorithm can ensure that different original contents are mapped to different hash values with a high probability. At the same time, this mapping is messy, that is, it is impossible to predict the correlation of hash values obtained from different original contents; and it is also resistant to inverse operations. That is, the original content cannot be obtained from the hash value.
  • the original message may have a lot of content and be large in size.
  • Using the private key to directly calculate the signature of the original message may be time-consuming and computationally intensive. Therefore, the original message can be calculated into a hash value using a hash algorithm, so that the hash value is smaller in length and can completely represent the original message. Then, the hash value is encrypted and calculated using the private key, and the result is the signature.
  • B After receiving the message, B uses A’s public key to verify the signature.
  • B can use the same hash algorithm as A to calculate the hash value of the original message, which is calculated as hash1; on the other hand, B uses A's public key to decrypt the signature result and obtain hash2. If hash1 and hash2 are the same, it can be determined that the original message received was sent by A and has not been tampered with during the transmission process.
  • the threshold signature scheme first includes 1 total public key and n public-private key pairs.
  • One public key in each public-private key pair is called a public key share, and one private key in each public-private key pair is called a private key share.
  • This recovery function can restore the signature shares of at least a threshold number of different private key share signatures into a complete signature.
  • This generated complete signature can also be The total public key mentioned above is used to verify the correctness. Any signature share less than the threshold number cannot restore the complete signature.
  • threshold signature mechanism based on RSA
  • ECDSA Elliptic Curve Digital Signature Algorithm, Elliptic Curve Digital Signature Algorithm
  • Schnorr a knowledge proof mechanism based on discrete logarithm problems
  • Threshold signature mechanism threshold signature mechanism based on BLS (Boneh-Lynn-Shacham Signature), etc.
  • the number of private key shares can be equal to the number of the first node, and the minimum number of signature shares (ie, the threshold number) required for the recovery function to generate a complete signature can be equal to quorum in the PBFT algorithm.
  • the number of private keys may not be equal to the number of the first node, and the number of minimum signature shares required by the recovery function to generate a complete signature may not be equal to the quorum in the PBFT algorithm.
  • the following uses the former as an example.
  • the 1 total public key and n public-private key pairs can be generated by a centralized dealer and distributed to n first nodes of the blockchain.
  • This is a centralized key distribution method.
  • n private key shares can be held by the first node of each blockchain.
  • the first node of each blockchain can hold the same 1 total public key.
  • there is a decentralized key distribution method that is, the dealer is cancelled, but n first nodes negotiate to obtain n public-private key pairs and 1 total public key through the key agreement process. Each first node still obtains n public-private key pairs and 1 total public key.
  • the node individually holds one of the n private key shares, and each first node holds the same total public key.
  • each first node can use its own unique private key (for example, in a blockchain network containing 4 nodes and using PBFT as the consensus algorithm, node 0, node 1, node 2, node 3.
  • the private key shares held by the threshold signature algorithm are sk0, sk1, sk2, sk3 respectively (the subscript number can represent the node number) to sign the original message containing the unique value of the original transaction list in this consensus, and we get Signature result.
  • the unique value of the original transaction list can be used as the original message for the signature.
  • the unique value of the original transaction list can include the original transaction list itself or the hash value of the original transaction list.
  • the original message can at least include the original transaction list or its hash value, so that the properties of the hash function are enough to distinguish the random number seeds generated after the completion of the consensus process corresponding to different blocks.
  • the block number (that is, the number) can also be as the content in the original message.
  • block generation is sequential, which can be reflected as the block number of the latter block is The block number of the previous block +1. Therefore, the block number is used as the content in the original message. Even if the original transaction list contained in the N+1th block is the same as the original transaction list contained in the Nth block, each node still uses its own private transaction list.
  • the key gets different signatures based on (original transaction list + block number).
  • the master node still cannot match the signatures of other nodes, so it is impossible to predict the complete signature of the N+1 block, so the master node cannot use the N+1 block.
  • the public random number seed is used to predict the random number seed of block N+1, achieving the purpose of being unpredictable. Similar to the number, the timestamp is also unique to a block, and the timestamp of the next block is after the previous block. Therefore, the timestamp can also be used as the content in the original message.
  • the signed object can also add other content, such as the random number seed generated in the previous block, that is, the original message can also include the random number seed generated in the previous block.
  • each node can generate the m-th block based on the consensus transaction data. Since the m-th block is independently generated locally by each node, if the blockchain nodes do not broadcast the hash value of the previous block they generated to each other and compare it, each node may not be able to determine the block.
  • the random number seeds in the same block should be the same, and the random number seeds in different blocks should be different, so the random number seeds can be added to the original message. In this way, if the random number seeds corresponding to the m-th block generated by each node are different, depending on the nature of the threshold signature algorithm, it may not be possible to pass the recovery function in the process of generating the random number seeds for the m+1-th block.
  • the method obtains a complete signature, which can help the first node confirm whether the previous block is consistent according to the solution of this application.
  • the hash value of the previous block can also be used to replace the random number seed of the previous block. Since the hash value of a block is generally unique, it can also help the first node confirm whether the previous block is consistent.
  • the unique value of the original transaction list that can be included in this original message can be the original transaction list.
  • the original transaction list has been broadcast in the PP phase of PBFT, and if the commit message broadcast in the C phase is smaller, it is more conducive to dissemination and bandwidth saving, so the unique value of the original transaction list can be the hash value of the original transaction list.
  • the original message contains multiple contents, such as the original transaction list hash value, block number, and random number seed generated in the previous block, you can first calculate the hash value of the original message and then use the private key share Sign the hash value of the original message to obtain the signature result.
  • each node participating in the consensus sends a commit message to the other first node, and adds the commit message it sends to the local Log (representing its own approval), and each node Also receives commit messages broadcast by other nodes.
  • each first node collects at least a threshold number of submission messages and applies the at least threshold number of signature shares to a recovery method corresponding to the private key share generated by the threshold signature algorithm to obtain a complete signature.
  • the threshold signature algorithm can generate 1 total public key and n public-private key pairs, and can generate recovery functions corresponding to the n public-private key pairs. As mentioned above, this recovery function can recover at least a threshold number of signatures that have been verified correctly to generate a complete signature.
  • the threshold value of the threshold signature algorithm that is, the threshold number can be set to w.
  • a complete signature can also be generated through this recovery function. That is to say, when the number of correct signatures is greater than or equal to the threshold number w, a complete signature can be generated through the recovery function, and the complete signature generated is certain and will not change due to the number of correct signatures entered (as long as Greater than or equal to w).
  • the complete signature generated can be verified for correctness by the total public key.
  • any node or other device holding the total public key can use the total public key to verify the correctness of the complete signature.
  • the total public key can be used to verify the integrity of the complete signature.
  • the total public key can be used to perform cryptographic operations on the complete signature to obtain the first hash, and the original message can be hashed to obtain the second hash. hash, if the first hash is consistent with the second hash, the integrity of the complete signature can be determined. The integrity includes that the complete signature is for the original message, and the original message has not been tampered with.
  • node 1 after node 1 generates a complete signature, it can send the complete signature, the total public key and the original message to a device outside the blockchain, and the device can use the total public key and the original message to verify the complete signature.
  • the correctness of the principle is the same as above and will not be repeated.
  • the original text of the message here is still the aforementioned content that contains the unique value of the original transaction list in this consensus, or it also includes the block number and/or timestamp of the current block and/or the random number seed generated in the previous block. .
  • each first node may collect each commit message, use the corresponding public key share to verify the signature share in the received commit message, and then pass at least a threshold number of signature shares through all
  • the recovery function corresponding to the private key share generated by the threshold signature algorithm obtains a complete signature.
  • the method of using the public key share to verify each signature share, and then restoring it to the complete signature through the recovery function after passing the verification can determine which signature is wrong. This way it can be determined which node may be the evil node.
  • each first node has 1 total public key and 1 private key share among n public-private key pairs and the corresponding 1 public key share. As mentioned above, it can be generated by the dealer and The distributed one can also be negotiated by each first node.
  • Each first node can use the corresponding public key share to verify the signature share in the received commit message.
  • node 0 broadcasts the signature share ⁇ 3,0 generated by itself to nodes 1, 2, and 3 in step 42, where ⁇ 3,0
  • the subscript 3 of can represent the block number, and 0 can represent that this is the signature share of node 0; in step 44, node 0 also receives the signature shares ⁇ 3,1 and ⁇ 3,2 broadcast by nodes 1 and 2 respectively.
  • node 0 has collected at least 3 signature shares, including the signature share ⁇ 3,0 broadcast by itself and the signature shares ⁇ 3,1 and ⁇ 3,2 broadcast by nodes 1 and 2 .
  • node 0 can also collect all the signature shares ⁇ 3,0 , ⁇ 3,1 , ⁇ 3,2 and ⁇ 3,3 , which of course satisfies at least the quorum number.
  • node 0 can use the corresponding public key share to verify the collected ⁇ 3,0 , ⁇ 3,1 , ⁇ 3,2 or also include ⁇ 3,3 (or ⁇ 3,0 , ⁇ 3,1 , ⁇ 3,3 or also includes ⁇ 3,2 , or ⁇ 3,1 , ⁇ 3,2 , ⁇ 3,3 or also includes ⁇ 3,0 , or ⁇ 3,0 , ⁇ 3,2 , ⁇ 3, 3 or also includes the correctness of ⁇ 3,1 ).
  • node 0 can use the corresponding public key share to calculate the signature share ⁇ 3,1 , and obtain a hash value, recorded as hash 3,1 ; node 0 can also perform the same hash calculation on the original message.
  • Get hash′ 3,1 If hash 3,1 is equal to hash′ 3,1 , it can be proved that the original message was sent by node 1 and has not been tampered with during the transmission process. In this way, the correctness of ⁇ 3,1 is verified. Similarly, node 0 can verify ⁇ 1, 2 , etc., which will not be described again.
  • node 1 can use the corresponding public key share to verify the collected ⁇ 3,0 , ⁇ 3,1 , ⁇ 3,2 or also include ⁇ 3,3 (or ⁇ 3,0 , ⁇ 3,1 , ⁇ 3,3 or also includes ⁇ 3,2 , or ⁇ 3,1 , ⁇ 3,2 , ⁇ 3,3 or also includes ⁇ 3,0 , or ⁇ 3,0 , ⁇ 3,2 , ⁇ 3 ,3 or also includes the correctness of ⁇ 3,1 ).
  • node 2 can use the corresponding public key share to verify the collected ⁇ 3,0 , ⁇ 3,1 , ⁇ 3,2 or also include ⁇ 3,3 (or ⁇ 3,0 , ⁇ 3,1 , ⁇ 3,3 or also includes ⁇ 3,2 , or ⁇ 3,1 , ⁇ 3,2 , ⁇ 3,3 or also includes ⁇ 3,0 , or ⁇ 3,0 , ⁇ 3,2 , ⁇ 3 ,3 or also includes the correctness of ⁇ 3,1 ).
  • node 3 can use the corresponding public key share to verify the collected ⁇ 3,0 , ⁇ 3,1 , ⁇ 3,2 or also include ⁇ 3,3 (or ⁇ 3,0 , ⁇ 3,1 , ⁇ 3,3 or also includes ⁇ 3,2 , or ⁇ 3,1 , ⁇ 3,2 , ⁇ 3,3 or also includes ⁇ 3,0 , or ⁇ 3,0 , ⁇ 3,2 , ⁇ 3 ,3 or also includes the correctness of ⁇ 3,1 ).
  • each first node obtains a random number seed based on the complete signature.
  • Random seed refers to the initial value used to generate pseudo-random numbers in a pseudo-random number generator.
  • a pseudo-random number generator starting from the same random number seed, the same random number sequence can be obtained.
  • the random number seed can be determined by the current status of the computer, such as the current time.
  • the same random number seed must be generated on each node to generate the same random number based on the same random number seed in system contracts/business contracts/blockchain platform functions, etc., and should not Random numbers are generated by any node in a controllable, predictable, and revocable manner. This needs to be determined jointly by the nodes participating in the consensus.
  • distributed networks are often asynchronous networks or semi-synchronous networks, from the perspective of immediacy, random numbers need to be generated and used when the transactions in the current block are executed.
  • each first node can obtain the same complete signature under normal circumstances.
  • each first node can use the same random number seed generation algorithm to generate a random number seed.
  • a relatively simple random number seed generation algorithm is, for example, the sha256 algorithm.
  • the random number seed/third random number can be generated on the blockchain.
  • the blockchain node currently serving as a consensus node can discover the identities of multiple first nodes currently serving as consensus nodes based on the set c1. Therefore, the consensus node can also conduct the first transaction based on the set c1 with other first nodes other than itself. Consensus, for example, through the various consensus mechanisms mentioned above, a consensus proposal containing the first transaction is reached. After the multiple first nodes currently acting as consensus nodes reach a consensus on the first transaction, that is, the multiple first nodes reach a consensus on the consensus proposal. After reaching consensus, the multiple first nodes can generate a block containing the first transaction and update the world state by executing each transaction in the block.
  • step 34 the identity of the third node is replaced with the identity of the fourth node in the first set based on the first transaction. That is, after the multiple first nodes currently acting as consensus nodes successfully reach a consensus on the first transaction, each first node acting as a consensus node can execute the first transaction, more specifically, execute its request based on the first transaction.
  • the smart contract is called to complete the replacement of the identity of the third node with the identity of the fourth node in the set c1.
  • the contract state of the smart contract can also store several sets c2, and the identity of the fourth node may be located in a certain set c2.
  • the identifier of the fourth node can be replaced with the identifier of the third node in the set c2 to which the identifier of the fourth node belongs by executing the first transaction.
  • the third node For the third node currently serving as a consensus node, it needs to distribute the consensus results to each second node corresponding to the third node after multiple first nodes complete consensus on the consensus proposal including the first transaction. ; In addition, the third node also needs to update the world state based on the execution result of the first transaction, so that it finds that it has been regarded as a non-consensus node based on the updated set c1. For the fourth node that is currently a non-consensus node, it can obtain the corresponding consensus obtained after multiple first nodes reach consensus on the consensus proposal including the first transaction through the various consensus result distribution methods exemplarily described above. As a result, and based on the consensus result, at least each transaction including the first transaction is executed to update its stored world state, so that based on the updated set c1, it is found that it has been used as a consensus node.
  • Node 1, Node 2, Node 3 and Node 4 currently serving as consensus nodes can update their respective stored world states, for example, at least replace the identity of Node 1 with the identity of Node 11 in set c1, so Node 1 can find based on set c1 that it will no longer be used as a consensus node in the subsequent time.
  • Node 1 can also distribute the corresponding consensus results to the n corresponding Node 11 ⁇ Node 1n that are currently non-consensus nodes, such as distributing the block including the first transaction, so that Node 11 ⁇ Node 1n can Based on the consensus result distributed by Node 1 to Seven, each transaction including the first transaction is executed, and each updates its own stored world state.
  • the identity of Node 1 is replaced by the identity of Node 11, so Node 11 can find that based on the updated set c1, it will serve as a consensus node in the subsequent time to execute the corresponding consensus mechanism with other consensus nodes such as Node 2, Node 3, and Node 4.
  • the blockchain node currently serving as the consensus node can also receive a second transaction from other blockchain nodes set by the user.
  • the second transaction request calls the smart contract to instruct the sixth node among the plurality of second nodes to be set as the consensus node; Then based on the second transaction, the identifier of the sixth node is added to the first set, thereby completing the creation of a new consensus node in the blockchain system.
  • the blockchain node currently serving as the consensus node can also receive a third transaction from the user device or other blockchain nodes.
  • the third transaction request calls the smart contract to instruct the seventh node among the plurality of first nodes to be set to non- Consensus node; delete the identity of the seventh node in the first set based on the third transaction, thereby completing the reduction of consensus nodes in the blockchain system.
  • the blockchain node currently serving as a consensus node can also rotate the fifth node in the aforementioned random number node set.
  • the process of rotating the fifth node is similar to the aforementioned method of rotating consensus nodes, and will not be described again here.
  • the embodiments of this specification also provide a first node in a blockchain system.
  • the blockchain system includes a plurality of first nodes currently serving as consensus nodes and a plurality of first nodes currently serving as non-consensus nodes.
  • a smart contract is deployed in the blockchain system, a first set is stored in the contract state of the smart contract, and the first set includes the identifiers of the multiple first nodes .
  • the first node includes: a transaction acquisition unit 62, configured to acquire a first transaction, and the first transaction request calls the smart contract to instruct the transaction of the plurality of first nodes.
  • the third node is set as a non-consensus node, and the fourth node among the plurality of second nodes is set as a consensus node; the transaction execution unit 64 is configured to execute the first transaction in the first set based on the first transaction.
  • the identifier of the third node is replaced with the identifier of the fourth node.
  • the transaction execution unit 64 is further configured to replace the identity of the third node with the identity of the fourth node in the first set based on the first transaction.
  • the method further includes: a consensus processing unit configured to compare the first node among the first set and the plurality of first nodes except the blockchain node. consensus on a transaction.
  • it also includes: a random processing unit configured to generate a first random number and a second random number; a node selection unit configured to select from the plurality of first nodes according to the first random number. The third node is determined, and the fourth node is determined from the plurality of second nodes according to the second random number.
  • the random number processing unit is further configured to obtain a third random number collaboratively generated by a plurality of fifth nodes, and the fifth node is obtained from the plurality of first nodes or all The first random number and the second random number are selected from the plurality of second nodes, and the first random number and the second random number are generated based on the third random number.
  • the random number processing unit is configured to read the third random number from the latest generated block.
  • the random number processing unit is specifically configured to read the third random number from the latest generated block based on a preset time step or block height increment. .
  • the plurality of fifth nodes are the same as the plurality of first nodes; in the submission phase of the PBFT corresponding to the latest generated block, each of the first nodes is based on a threshold
  • the signature algorithm uses its own private key share to sign the original message containing the unique value of the original transaction list in this consensus, generates a signature share and adds the signature share to the broadcast submission message; each first node collects all After at least a threshold number of submission messages, the at least threshold number of signature shares are passed through the recovery function corresponding to the private key share generated by the threshold signature algorithm to obtain a complete signature; each first node obtains a complete signature based on the complete signature. Describe the third random number.
  • These computer program instructions may also be stored in a computer-readable memory that causes a computer or other programmable data processing apparatus to operate in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction means, the instructions
  • the device implements the functions specified in a process or processes of the flowchart and/or a block or blocks of the block diagram.
  • These computer program instructions may also be loaded onto a computer or other programmable data processing device, causing a series of operating steps to be performed on the computer or other programmable device to produce computer-implemented processing, thereby executing on the computer or other programmable device.
  • Instructions provide steps for implementing the functions specified in a process or processes of a flowchart diagram and/or a block or blocks of a block diagram.
  • a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
  • processors CPUs
  • input/output interfaces network interfaces
  • memory volatile and non-volatile memory
  • Memory may include non-permanent storage in computer-readable media, random access memory (RAM) and/or non-volatile memory in the form of read-only memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
  • RAM random access memory
  • ROM read-only memory
  • flash RAM flash random access memory
  • Computer-readable media includes both persistent and non-volatile, removable and non-removable media that can be implemented by any method or technology for storage of information.
  • Information may be computer-readable instructions, data structures, modules of programs, or other data.
  • Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), and read-only memory.
  • PRAM phase change memory
  • SRAM static random access memory
  • DRAM dynamic random access memory
  • RAM random access memory
  • read-only memory read-only memory
  • ROM read-only memory
  • EEPROM electrically erasable programmable read-only memory
  • flash memory or other memory technology
  • compact disc read-only memory CD-ROM
  • DVD digital versatile disc
  • Magnetic tape magnetic tape storage
  • graphene storage or other magnetic storage devices or any other non-transmission medium
  • computer-readable media does not include transient computer-readable media (transitory media), such as modulated data signals and carrier waves.
  • one or more embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, one or more embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment that combines software and hardware aspects. Furthermore, one or more embodiments of the present description may employ a computer program implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein. Product form.
  • computer-usable storage media including, but not limited to, disk storage, CD-ROM, optical storage, etc.
  • program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types.
  • program modules may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network.
  • program modules may be located in both local and remote computer storage media including storage devices.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Theoretical Computer Science (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种区块链系统中共识节点的轮换方法、节点和区块链系统。区块链系统中包括当前作为共识节点的多个第一节点和当前作为非共识节点的若干第二节点,区块链系统中部署有智能合约,智能合约的合约状态中存储有第一集合,第一集合中包括多个第一节点的标识,方法由第一节点执行。该方法包括:获取第一交易,第一交易请求调用智能合约,用于指示将多个第一节点中的第三节点设置为非共识节点,并将若干第二节点中的第四节点设置为共识节点;基于第一交易在第一集合中将第三节点的标识替换为第四节点的标识。

Description

区块链系统中共识节点的轮换方法、节点和区块链系统
本申请要求于2022年3月31日提交中国国家知识产权局、申请号为202210333393.2、申请名称为“区块链系统中共识节点的轮换方法、节点和区块链系统”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本说明书实施例属于区块链技术领域,尤其涉及一种区块链系统中共识节点的轮换方法、第一节点和区块链系统。
背景技术
区块链(Blockchain)是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链系统中按照时间顺序将数据区块以顺序相连的方式组合成链式数据结构,并以密码学方式保证的不可篡改和不可伪造的分布式账本。由于区块链具有去中心化、信息不可篡改、自治性等特性,区块链也受到人们越来越多的重视和应用。
发明内容
本发明的目的在于提供一种区块链系统中共识节点的轮换方法、第一节点和区块链系统。
第一方面,提供了一种区块链系统中共识节点的轮换方法,所述区块链系统中包括当前作为共识节点的多个第一节点和当前作为非共识节点的若干第二节点,所述区块链系统中部署有智能合约,所述智能合约的合约状态中存储有第一集合,所述第一集合中包括所述多个第一节点的标识,所述方法由所述第一节点执行。所述方法包括:获取第一交易,所述第一交易请求调用所述智能合约,用于指示将所述多个第一节点中的第三节点设置为非共识节点,将所述若干第二节点中的第四节点设置为共识节点;基于所述第一交易在所述第一集合中将所述第三节点的标识替换为所述第四节点的标识。
第二方面,提供了一种区块链系统中的区块链节点,所述区块链系统中包括当前作为共识节点的多个第一节点和当前作为非共识节点的若干第二节点,所述区块链系 统中部署有智能合约,所述智能合约的合约状态中存储有第一集合,所述第一集合中包括所述多个第一节点的标识。所述区块链节点包括:交易获取单元,配置为获取第一交易,所述第一交易请求调用所述智能合约,用于指示将所述多个第一节点中的第三节点设置为非共识节点,将所述若干第二节点中的第四节点设置为共识节点;交易执行单元,配置为基于所述第一交易在所述第一集合中将所述第三节点的标识替换为所述第四节点的标识。
第三方面,提供了一种区块链系统,包括当前作为共识节点的多个第一节点和当前作为非共识节点的若干第二节点,所述区块链系统中部署有智能合约,所述智能合约的合约状态中存储有第一集合,所述第一集合中包括所述多个第一节点的标识;其中,所述第一节点用于获取第一交易,所述第一交易请求调用所述智能合约,用于指示将所述多个第一节点中的第三节点设置为非共识节点,并将所述若干第二节点中的第四节点设置为共识节点;基于所述第一交易在所述第一集合中将所述第三节点的标识替换为所述第四节点的标识。
第四方面,提供了一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算设备中执行时,令计算设备执行第一方面中所述的方法。
第五方面,提供了一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器执行所述计算机程序时,实现第一方面中所述的方法。
上述实施例中,当前作为共识节点的第一节点可以获取调用智能合约的第一交易,然后基于该第一交易在智能合约的合约状态所存储的第一集合中,将当前作为共识节点的第三节点的标识替换为将作为共识节点的第四节点的标识,进而实现通过对该集合中区块链节点的标识进行更新来完成对区块链节点中的共识节点进行轮换,有利于提高区块链系统的公平性和安全性。
附图说明
为了更清楚地说明本说明书实施例的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本说明书中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为本说明书实施例中示例性提供的PBFT共识算法中的共识过程示意图;
图2为本说明书实施例中示例性提供的区块链系统的示意图;
图3为本说明书实施例中提供的一种区块链系统中共识节点的轮换方法的流程图;
图4为本说明书实施例中示例性提供的生成第三随机数的方法的流程图;
图5为示例性提供的轮换共识节点的技术场景的示意图;
图6为本说明书实施例中提供的一种区块链系统中的第一节点的示意图。
具体实施方式
为了使本技术领域的人员更好地理解本说明书中的技术方案,下面将结合本说明书实施例中的附图,对本说明书实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本说明书一部分实施例,而不是全部的实施例。基于本说明书中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都应当属于本说明书保护的范围。
区块链系统中,不同参与方通过部署的节点(Node)可以建立一个分布式的区块链网络。利用链式区块结构构造的去中心化(或称为多中心化)的分布式账本,保存于分布式的区块链网络中的每个节点(或大多数节点,如共识节点)上。这样的区块链系统需要解决去中心化(或多中心化)的多个节点上各自的账本数据的一致性和正确性的问题。每个节点上都运行着区块链程序,在一定容错需求的设计下,通过共识(consensus)机制保证所有忠诚节点具有相同的交易,从而保证所有忠诚节点对相同交易的执行结果一致,将交易打包成区块并基于相同交易的执行结果更新世界状态。其中当前主流的共识机制包括但不限于:工作量证明(Proof of Work,POW)、股权证明(Proof of Stake,POS)、委任权益证明(Delegated Proof of Stake,DPOS)、实用拜占庭容错(Practical Byzantine Fault Tolerance,PBFT)算法,蜜獾拜占庭容错(HoneyBadgerBFT)算法等等。
图1为本说明书实施例中示例性提供的PBFT共识算法中的共识过程示意图。如图1所示,根据PBFT共识算法,可将共识过程划分为请求、预备、准备和提交四个阶段。假设一区块链中包括节点n1-节点n4四个共识节点,其中,节点n1例如为主节点,节点n2-节点n4例如为从节点,根据PBFT算法,在节点n1-节点n4中可容忍f=1个恶意节点。具体是,在请求阶段,区块链的用户可通过其用户设备向节点n1发送请求,该请求例如为区块链交易的形式。在预备阶段,节点n1在从一个或多个用户设备接收到多个交易之后,可将该多个交易打包为共识提议,将该共识提议及节点n1对该共识提议的签名发送给其他共识节点(即节点n2-节点n4),以用于生成区块,该共识提议中可包括该多个交易的交易体和该多个交易的提交顺序等信息。在准备阶段,各个从节点可对共识提议进行签名并发送给其他各个节点。假设节点n4为恶意节点,节点n1、节点n2 和节点n3在分别接收到2f=2个其他共识节点的对共识提议的签名之后,可确定准备阶段完成,可进入提交阶段。例如,节点n1在接收到节点n2和节点n3的签名之后,验证节点n2和节点n3的签名都是正确的对共识提议的签名,则确定准备阶段完成,节点n2在接收到节点n3的签名和预备阶段节点n1的签名并验证通过之后,确定准备阶段完成。在提交阶段,各个共识节点对共识提议进行提交阶段的签名并发送给其他各个共识节点,各个共识节点在接收到2f=2个其他共识节点的提交阶段的签名之后,可确定提交阶段完成,共识成功。例如,节点n1在接收到节点n2和节点n3的提交阶段的签名并验证之后,确定提交阶段完成,从而,节点n1可执行根据共识提议执行所述多个交易,生成并存储包括所述多个交易的区块(例如区块B1),根据多个交易的执行结果更新世界状态,并将多个交易的执行结果返回给用户设备。类似地,节点n2和节点n3在确定提交阶段完成之后,执行所述多个交易,生成并存储区块B1,并根据多个交易的执行结果更新世界状态。通过上述示例性的共识过程,实现了节点n1、节点n2和节点n3的存储一致性。也就是说,节点n1-节点n4在存在一个恶意节点的情况下仍可以实现对共识提议的共识成功,进而完成对区块的执行。
区块链领域中的交易可以指在区块链中执行并记录在区块链中的任务单元。交易中通常包括发送字段(From)、接收字段(To)和数据字段(Data)。其中,在交易为转账交易的情况中,From字段表示发起该交易(即发起对另一个账户的转账任务)的账户地址,To字段表示接收该交易(即接收转账)的账户地址,Data字段中包括转账金额。在交易调用区块链中的智能合约的情况中,From字段表示发起该交易的账户地址,To字段表示交易所调用的合约的账户地址,Data字段中包括调用合约中的函数名、及对该函数的传入参数等数据,以用于在交易执行时从区块链中获取该函数的代码并执行该函数的代码。
区块链中可提供智能合约的功能。区块链上的智能合约是在区块链系统上可以被交易触发执行的合约。智能合约可以通过代码的形式定义。在区块链中调用智能合约,是发起一笔指向智能合约地址的交易,使得区块链中每个节点分布式地运行智能合约代码。需要说明的是,除了可以由用户创建智能合约,也可以在创世块中由系统设置智能合约。这类合约一般称为创世合约。一般的,创世合约中可以设置一些区块链的数据结构、参数、属性和方法。此外,具有系统管理员权限的账户可以创建系统级的合约,或者修改系统级的合约(简称为系统合约)。其中,所述系统合约可用于在区块链中增加不同业务的数据的数据结构。
在部署合约的场景中,可以将包含创建智能合约信息(即部署合约)的交易发送到区块链系统中,交易的data字段包括待创建的合约的代码(如字节码或者机器码),交易的to字段为空,以表示该交易用于部署合约。各节点通过前述各种共识机制达成共识后,确定合约的合约地址,并在状态数据库中添加与该智能合约的合约地址对应的合约账户,分配与该合约账户对应的状态存储,并将合约代码保存在该合约的状态存储中,从而合约创建成功。
在调用合约的场景中,可以将用于调用智能合约的交易发送到区块链系统中,该交易的from字段是交易发起方的账户的地址,to字段是被调用的智能合约的合约地址,交易的data字段包括调用智能合约的方法和参数。在区块链系统中对该交易进行共识之后,区块链系统中的各个节点可分别执行该交易,从而分别执行该合约,基于该合约的执行更新状态数据库。
对于由大规模节点组建的区块链系统,可以从大规模节点中选取少量节点作为参与执行共识机制的共识节点。由数量相对较少的共识节点参与执行共识机制以得到的共识结果,可以由共识节点将其分发到大规模节点中未被选取为共识节点的其它非共识节点,从而可以提高区块链系统的共识效率。参见图2示例性提供的区块链系统,该区块链系统中例如可以选取Node 1、Node 2、Node 3和Node 4作为共识节点组成共识节点集合,除共识节点以外的非共识节点例如可以划分为与前述4个共识节点对应的节点分组1、节点分组2、节点分组3和节点分组4;前述4个共识节点联合执行某种共识机制获得共识结果后,各共识节点均可以向其对应的节点分组中的非共识节点分发共识结果,以便非共识节点基于共识结果获得相应的区块并对应的更新其存储的世界状态。前述共识结果可以为区块或者用于生成区块的相关数据。
共识节点可以向与其对应的非共识节点直接发送共识结果,例如Node 1可以向节点分组1中的节点11~节点1n等n个非共识节点完整发送共识结果。或者,共识节点也可以采用纠删码算法对共识结果进行拆分以得到多个数据块,并向与其对应的不同的非共识节点分发不同的数据块;非共识节点之间可以广播其从共识节点接收的数据块,进而使得单个非共识节点从共识节点和/或其余非共识节点接收到满足相应数量的数据块后,可以对其搜集的这些数据块进行解码以获得前述共识结果。如此,共识节点向非共识节点分发的数据量并不会随非共识节点的规模的增大而增大,共识节点向非共识节点的数据量相对较小,可以更为快速的完成向大规模非共识节点分发共识结果,效率相对较高。
然而参见图2示例性提供的区块链系统,共识节点的数量相对较少的情况下,如果存在某些区块链节点长期作为共识节点,将会影响整个区块链系统的安全性和公平性。
本说明书实施例中提供了一种区块链系统中共识节点的轮换方法、第一节点和区块链系统。当前作为共识节点的第一节点可以获取调用智能合约的第一交易,然后基于该第一交易在智能合约的合约状态所存储的第一集合中,将当前作为共识节点的第三节点的标识替换为将作为共识节点的第四节点的标识,进而实现通过对该集合中区块链节点的标识进行更新来完成对区块链节点中的共识节点进行轮换,有利于提高区块链系统的公平性和安全性。
图3为本说明书实施例中提供的一种区块链系统中共识节点的轮换方法。该区块链系统中包括当前作为共识节点的多个第一节点和当前作为非共识节点的若干第二节点,该区块链系统中部署有智能合约,该智能合约的合约状态中存储有第一集合,该第一集合中包括前述多个第一节点的标识,该方法可以由当前作为共识节点的任意第一节点执行。请参见图3,该方法可以包括但不限于如下步骤32和步骤34。
步骤32,获取第一交易,该第一交易请求调用智能合约,用于指示将多个第一节点中的第三节点设置为非共识节点,并将若干第二节点中的第四节点设置为共识节点。
区块链节点可以通过智能合约的合约状态中存储的第一集合(以下记为合约c1),获知其自身在当前是否是作为共识节点的第一节点。请继续参见图2,当前作为共识节点的第一节点例如包含Node 1、Node 2、Node 3和Node 4,前述4个节点的标识均被存储于集合c1中,前述4个节点可以通过发现其自身的标识被存储于集合c1而获知其自身在当前被作为共识节点。
智能合约的合约状态中还可以存储若干第二集合(以下记为集合c2),不同的集合c2与不同的第一节点对应,单个集合c2中包含一个和或多个当前作为非共识节点的第二节点的标识。请继续参见图2,当前位于节点分组1中的Node 11~Node 1n等n个第二节点对应相同的共识节点Node 1,则智能合约的合约状态中可以存储与Node 1对应的集合c2,该集合c2中包含Node 11~Node 1n等n个第二节点各自的标识;类似的,智能合约的合约状态中还可以存储与Node 2对应的集合c2,存储与Node 3对应的节点c2,以及存储与Node 4对应的结合c2。
当前作为共识节点的区块链节点还可以生成相互对应的第三随机数(以下记为随机数x1)和第四随机数(以下记为随机数x2),进而基于随机数x1从当前作为共识节点的多个第一节点中确定出待轮换的第三节点,并基于随机数x2从当前作为非共识节 点的若干第二节点中确定出将作为共识节点的第四节点,如此可以确保共识节点的轮换过程具有随机性,使得每个区块链节点均有机会被选取为共识节点。例如可以对多个第一节点按顺序编号,利用多个第一节点的数量对随机数x1进行取模运算,将编号与取模运算的结果相同的第一节点选取为第三节点;类似的,例如可以对若干第二节点按顺序编号,利用若干第二节点的数量对随机数x2进行取模运算,将编号与取模运算的结果相同的第二节点选取为第四节点。
其中为了确保随机数x1和随机数x2具有不可预测性,还可以通过智能合约的合约状态存储随机数节点集合,该随机数节点集合中可以存储多个第五节点的标识,前述第五节点是从多个第一节点或若干第二节点中选取的。与之相应的,区块链节点可以基于随机数节点集合发现其自身是否被作为用于生成随机数的第五节点,如果是则基于该随机数节点结合与其余第五节点实现多方协同生成可验证却不可预测的安全随机数x3,进而基于随机数x3生成不可预测的随机数x1和随机数x2,例如以随机数x3为随机种子生成随机数x1和前述随机数x2。
区块链系统中通常可以设置由当前选择的多个第五节点在每个区块时间内均生成1个随机数x3,随机数x3可以存储于对应的区块时间内生成的区块中,例如存储在对应的区块时间内生成的区块头中,以供随机数x3所属区块内的交易或者供位于随机数x3所属区块之后的其它区块中的交易使用。换而言之即当前作为共识节点的区块链节点具体可以从最新生成的区块中读取随机数x3,例如从最新生成的区块的区块头中读取随机数x3,并基于读取的随机数x3生成前述随机数x1和前述随机数x2;其中该最新生成的区块可能为第一交易所属的区块或者第一交易所属区块的前一个区块。更具体地,可以按照某个预设时间间隔或区块高度增量来触发共识节点的轮换过程,即可以按照预设的时间间隔或区块高度增量,周期性的执行从最新生成的区块中读取前述随机数x3,并基于读取的随机数x3实现发起前述步骤32。
更具体地说,前述多个第五节点可以相同于前述的多个第一节点,换而言之即前述的随机数节点集合可以为前述的集合c1。在最新生成的区块对应的PBFT的提交(commit)阶段,每个第一节点可以基于门限签名算法采用自身私钥份额对包含本次共识中原始交易列表特有值的原始报文进行签名,生成签名份额并将该签名份额加入到广播的commit消息中;每个第一节点收集齐至少门限数量的commit消息后将至少门限数量的签名份额经过门限签名算法产生的私钥份额所对应的恢复函数得到完整签名;每个第一节点基于完整签名得到第三随机数。换而言之,第一节点在生成包含第一交 易的区块的过程中,同样可以在该区块对应的PBFT的commit阶段,通过前述过程生成相应的第三随机数,新生成的第三随机数例如可以被存储到第一交易所属的区块中,具体例如存储至第一交易所属区块的区块头中。
下面结合图4详细描述生成第三随机数的过程,其中该第三随机数也被表述为随机种子。
首先,在步骤42,在PBFT的提交阶段,每个第一节点基于门限签名算法,采用自身私钥份额对包含本次共识中原始交易列表特有值的原始报文进行签名,生成签名份额,并将该签名份额加入到广播的提交消息中。
门限签名是普通数字签名的一个重要分支,是门限秘密共享技术和数字签名的一种结合。传统的签名方案,可以采用RSA算法实现。RSA算法是一种非对称加密算法,由罗纳德·李维斯特(Ron Rivest)、阿迪·萨莫尔(Adi Shamir)和伦纳德·阿德曼(Leonard Adleman)于1977年一起提出。RSA算法可以在不直接传递密钥的情况下完成解密,这能够确保信息的安全性的同时,避免直接传递密钥所造成的信息被破解的风险。RSA中包括私钥和公钥,这个私钥和公钥是成对。一个信息由公钥加密后,只能由对应的私钥解密;类似的,一个信息由私钥加密后,只能由对应的公钥解密。之所以具有这样的性质,是因为成对的私钥和公钥之间在数学原理上具有相关性,例如一种底层原理是根据数论,寻求两个大素数比较简单,而将它们的乘积进行因式分解却极其困难,因此可以将乘积公开作为加密密钥,从而可以保证安全性。私钥通常要严格保密,不能泄露,而公钥是公开的(且可以由多人持有)。由于私钥是由持有者严格保密的,其他人在无法获得私钥的前提下,就无法伪造私钥持有者的签名。
RSA签名机制,可以保证报文传递过程中的完整性。例如节点A需要将报文传送至节点B,且中间可能经过若干个节点的中转。则A可以采用RSA签名机制,将报文连同签名一并经由若干个中间节点传送至B,而B对签名的验证可以确信收到的报文是A发出的,且在传送过程中没有经过篡改。一种RSA签名的过程如下:
b1:A生成一对密钥(公钥和私钥),私钥不公开,自己保留。公钥为公开的,任何人可以获取。
b2:A用自己的私钥对原始报文的hash值进行签名,并将原始报文和签名结果一并传递给B。如前所述,这个传递过程可能经过若干个中间节点的转发。
hash算法也称为散列算法,可以将原始内容映射为一个固定长度的序列,这个序列即为hash值。一般有sha256,sha384,sha512等hash算法。sha256的结果是256个bits, 可以表示2的256次方个原始内容。类似的,sha384的结果是384bits,sha512的结果是512bits。这些hash算法,可以针对内容较多体积较大的原始内容,因而hash值相对来说可以比原始内容小很多。好的hash算法可以确保不同原始内容有极大概率映射为不同的hash值,同时这种映射是杂乱无章的,即无法预测不同的原始内容得到的hash值的关联性;而且也是抗逆运算的,即无法由hash值倒推得到原始内容。
原始报文可能内容较多,体积较大,采用私钥直接对原始报文进行签名计算可能比较费时和耗费算力。因此,可以将原始报文采用一种hash算法计算到一个hash值,这样这个hash值长度较小,又可以完全代表原始报文。进而,采用私钥对这个hash值进行加密计算,得到的结果即为签名。
b3:B收到消息后,采用A的公钥进行验签。
一方面,B可以采用与A相同的hash算法来计算原始报文的hash值,计为hash1;另一方面,B采用A的公钥对签名结果进行解密计算,得到hash2。如果hash1与hash2相同,则可以确定收到的原始报文是A发出的,且在传送过程中没有被篡改过。
门限签名方案,首先是包括1个总公钥和n个公私钥对。每个公私钥对中的1个公钥称为公钥份额,每个公私钥对中的1个私钥称为私钥份额。其次,存在与这个总公钥和n个公私钥对对应的恢复函数,该恢复函数可以将至少门限数量个不同私钥份额签名的签名份额恢复成一个完整签名,这个生成的完整签名也可以由所述的那1个总公钥来验证正确性。而任意少于门限数量的签名份额则无法恢复生成该完整签名。
除了可以采用基于RSA的门限签名机制外,还可以采用基于ECDSA(Elliptic Curve Digital Signature Algorithm,椭圆曲线数字签名算法)的门限签名机制、基于Schnorr(一种基于离散对数难题的知识证明机制)的门限签名机制、基于BLS(Boneh-Lynn-Shacham Signature)的门限签名机制等。
需要说明的是,在区块链中所采用的门限签名,私钥份额的个数可以等于第一节点的个数,恢复函数产生完整签名的最少签名份额的个数(即门限数量)可以等于PBFT算法中的quorum。当然,私钥的个数也可以不等于第一节点的个数,恢复函数产生完整签名的最少签名份额的个数可以不等于PBFT算法中的quorum。以下以前者为例说明。
所述1个总公钥和n个公私钥对,可以由一个中心化的dealer生成,并分发给n个区块链第一节点,这种属于中心化的密钥分配方式。这样,结合共识算法,n个私钥份额可以是每个区块链第一节点持有其中一个。同时,每个区块链第一节点可以持有相同的1个总公钥。此外,还存在去中心化的密钥分配方式,即取消dealer,而是由n个第一 节点通过密钥协商过程协商得到n个公私钥对和1个总公钥,仍然是每个第一节点单独持有n个私钥份额中的一个,且各第一节点持有同一个总公钥。
采用门限签名算法,每个第一节点都可以采用自身特有的那一份私钥(如包含4个节点且采用PBFT作为共识算法的区块链网络中,节点0、节点1、节点2、节点3采用门限签名算法所持有的私钥份额分别是sk0,sk1,sk2,sk3,下标数字可以表示节点的编号)对包含本次共识中原始交易列表特有值的原始报文进行签名,得到签名结果。这里,原始交易列表的特有值可以作为签名所针对的原始报文。
原始交易列表的特有值,可以包括原始交易列表本身或者原始交易列表的hash值。一般来说,不同的交易,交易内容是不同的,这样,不同的原始交易列表或其hash值一般都不相同。因此,原始报文中可以至少包括原始交易列表或其hash值,这样由hash函数的性质,足以区分不同区块对应的共识过程完毕后所生成的随机数种子。
考虑到共识过程中会为本次共识的内容生成一个编号,如果共识完成,生成的编号可以作为本次共识所对应的区块的区块号,因此,区块号(也就是编号)也可以作为原始报文中的内容。不论第N+1个区块中所包含的原始交易列表与第N个区块中所包含的原始交易表是否相同,区块生成是顺序的,可以体现为后一区块的区块号是前一区块的区块号+1。因此,区块号作为原始报文中的内容,即使第N+1个区块中所包含的原始交易列表与第N个区块中所包含的原始交易表相同,仍然由各个节点采用自身私钥基于(原始交易列表+区块号)得到不同的签名,主节点仍然无法与其它节点的签名,从而无法预测第N+1号区块的完整签名,因此主节点无法使用第N号块已公开的随机数种子来预测第N+1号块的随机数种子,达到了不可预测的目的。与编号类似的,时间戳也是一个区块特有的,且后一区块的时间戳在前一区块之后。因此,时间戳也可以作为原始报文中的内容。
除了原始交易列表的特有值之外,签名的对象还可以加入其它内容,例如上一区块中产生的随机数种子,即原始报文中还可以包括上一区块中产生的随机数种子。前述a140执行之后,如前所述,各个节点可以各自以共识的交易数据为基础,生成第m个区块。由于第m个区块是各个节点在本地各自独立生成的,因此,如果区块链节点之间没有相互广播自身生成的上一区块的hash值并比对,各个节点可能都无法确定区块链网络中生成的第m个区块是否相同,或者从区块链系统整体可用的角度来说是否有至少quorum数量的第一节点上生成的第m个区块是相同的。经过本申请中随机数种子的生成过程,相同区块的随机数种子应当是相同的,不同区块中的随机数种子应当 是不同的,因此可以将随机数种子加入到原始报文中。这样,如果各个节点各自生成的第m个区块对应的随机数种子有所不同,根据门限签名算法的性质,可能无法在第m+1号区块的产生随机数种子的过程中通过恢复函数方法得出完整签名,从而可以根据本申请的方案帮助第一节点确认上一区块是否一致。也可采用上一区块的hash值来代替上一区块的随机数种子,由于一个区块的hash值一般是唯一的,因此也可以帮助第一节点确认上一区块是否一致。
采用自身私钥份额对包含本次共识中原始交易列表特有值的原始报文进行签名,这个原始报文里可以包括的原始交易列表的特有值,可以是原始交易列表。一般在PBFT的PP阶段已经广播过原始交易列表,且C阶段广播的commit消息较小的话更利于传播及节省带宽,因此原始交易列表特有值可以是原始交易列表的hash值。
对于原始报文包括多个内容,例如包括原始交易列表hash值、区块号、上一区块中产生的随机数种子的情况下,可以先计算原始报文的hash值,进而采用私钥份额对该原始报文hash值进行签名,得到签名结果。
对原始报文进行签名,生成的签名结果和原始报文可以一并加入到广播的commit消息中。这样,在commit阶段,参与共识的节点中的每个个都发送commit消息给其他的第一节点,并将自己发送的commit消息添加到本地Log中(代表自己的认可),而且,每个节点还接收其他节点广播的commit消息。
接着,在步骤44,每个第一节点收集齐至少门限数量的提交消息后将所述至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复方法得到完整签名。
如前所述,门限签名算法在应用中,可以产生1个总公钥和n个公私钥对,并可以产生该n个公私钥对所对应的恢复函数。前述提到,该恢复函数可以将验证正确的至少门限数量个签名恢复生成一个完整签名,门限签名算法的门限值即门限数量可以设为w。当然,正确的签名多于w个时也可以通过该恢复函数生成一个完整签名。也就是说,正确的签名大于等于门限数量w时,都可以通过该恢复函数生成一个完整签名,且生成的这个完整签名是确定的,不会因为输入的正确签名的个数而发生变化(只要大于等于w)。
这个生成的完整签名可以由所述的那1个总公钥来验证正确性。这样,任何持有这个总公钥的节点或其它设备都可以采用该总公钥来验证这个完整签名的正确性。例如,节点1生成完整签名后,可以采用总公钥验证该完整签名的完整性,例如采用总公钥对 完整签名进行密码学运算得到第一hash,并对原始报文进行hash运算得到第二hash,如果第一hash与第二hash一致则可以确定该完整签名的完整性。所述完整性包括该完整签名是针对所述原始报文的,且该原始报文没有经过篡改。再例如,节点1生成完整签名后,可以将该完整签名、总公钥和原始报文发送至区块链以外的一个设备,该设备可以采用所述总公钥和原始报文验证这个完整签名的正确性,原理同上不再赘述。这里的报文原文仍然是前述的包含本次共识中原始交易列表特有值的内容,或还包括当前区块的区块号和/或时间戳和/或上一区块中产生的随机数种子。
此外也可以是每个第一节点收集每个commit消息后,采用对应的公钥份额对所述接收到的commit消息中的签名份额进行验证,然后再将所述至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复函数得到完整签名。相对于采用总公钥对生成的完整签名进行验证的方式,采用公钥份额对每个签名份额进行验证,验证通过后再经恢复函数恢复为完整签名的方式,能够确定哪个签名是错误的,从而能够确定哪个节点可能是作恶节点。
门限签名算法中,每个第一节点都具有1个总公钥和n个公私钥对中的1个私钥份额和对应的1个公钥份额,如前所述,可以是由dealer生成并分发的,也可以是各第一节点协商得到的。
每个第一节点可以采用对应的公钥份额对接收到的commit消息中的签名份额进行验证。具体的,例如在包含4个第一节点的采用PBFT共识算法的联盟链中,节点0在步骤42中向节点1、2、3广播自身生成的签名份额σ 3,0,其中σ 3,0的下标3可以表示区块号,0可以表示这是节点0的签名份额;在步骤44中,节点0也接收到节点1、2分别广播的签名份额σ 3,1、σ 3,2。这样,节点0已经收齐至少3个签名份额,其中包括自身广播的签名份额σ 3,0和节点1、2广播的签名份额σ 3,1、σ 3,2。当然,节点0也可以收集齐所有的签名份额σ 3,0、σ 3,1、σ 3,2和σ 3,3,这样也当然满足至少quorum数量。
进而,节点0可以用对应的公钥份额来验证收集的σ 3,0、σ 3,1、σ 3,2或还包括σ 3,3(或者是σ 3,0、σ 3,1、σ 3,3或还包括σ 3,2,或者是σ 3,1、σ 3,2、σ 3,3或还包括σ 3,0,或者是σ 3,0、σ 3,2、σ 3,3或还包括σ 3,1)的正确性。具体的,例如,节点0可以采用对应的公钥份额来对签名份额σ 3,1进行计算,得到一个hash值,记为hash 3,1;节点0还可以对原始报文进行同样的hash计算得到hash′ 3,1。如果hash 3,1与hash′ 3,1相等,可以证明原始报文是节点1发出的,且在传送过程中没有被篡改过。这样,σ 3,1的正确性得到验证。类似的,节点0可以对σ 1,2等进行验证,不再赘述。
同样的,节点1可以用对应的公钥份额来验证收集的σ 3,0、σ 3,1、σ 3,2或还包括σ 3,3(或者是σ 3,0、σ 3,1、σ 3,3或还包括σ 3,2,或者是σ 3,1、σ 3,2、σ 3,3或还包括σ 3,0,或者是σ 3,0、σ 3,2、σ 3,3或还包括σ 3,1)的正确性。
同样的,节点2可以用对应的公钥份额来验证收集的σ 3,0、σ 3,1、σ 3,2或还包括σ 3,3(或者是σ 3,0、σ 3,1、σ 3,3或还包括σ 3,2,或者是σ 3,1、σ 3,2、σ 3,3或还包括σ 3,0,或者是σ 3,0、σ 3,2、σ 3,3或还包括σ 3,1)的正确性。
同样的,节点3可以用对应的公钥份额来验证收集的σ 3,0、σ 3,1、σ 3,2或还包括σ 3,3(或者是σ 3,0、σ 3,1、σ 3,3或还包括σ 3,2,或者是σ 3,1、σ 3,2、σ 3,3或还包括σ 3,0,或者是σ 3,0、σ 3,2、σ 3,3或还包括σ 3,1)的正确性。
接着,在步骤46:每个第一节点基于所述完整签名得到随机数种子。
随机数种子(random seed),是指在伪随机数生成器中用于生成伪随机数的初始数值。对于一个伪随机数生成器,从相同的随机数种子出发,可以得到相同的随机数序列。对于单机来说,随机数种子可以由当前计算机的状态确定,如当前的时间。而对于分布式系统来说,要在各个节点上产生相同的随机数种子,以在系统合约/业务合约/区块链平台功能等中基于相同的随机数种子产生相同的随机数,且不应由任一节点以其可操控的、可预测的、可撤销的方式产生随机数。这就需要由参与共识的节点共同确定。而且,考虑到分布式网络往往是异步网络或半同步网络,从即时性出发,还需要在当前区块中的交易执行时即可以产生随机数并采用。
经过上述步骤42~步骤46的过程,正常情况下每个第一节点都可以得到相同的完整签名。当然,考虑到分布式系统的容错特性,在采用PBFT共识算法的区块链网络中至少应当有quorum数量的第一节点各自都可以分别得到相同的完整签名。这样,基于完整签名,各第一节点可以采用相同的随机数种子生成算法生成随机数种子。一种较为简单的随机数种子生成算法例如是sha256算法。当然,也可以直接将完整签名作为随机数种子。
经过上述过程,即可在区块链上产生随机数种子/第三随机数。
当前作为共识节点的区块链节点可以基于集合c1发现当前作为共识节点的多个第一节点的标识,因而共识节点还可以基于集合c1与除其自身以外的其余第一节点对第一交易进行共识,例如通过前述各种共识机制对包含第一交易的共识提议进行共识,当前作为共识节点的多个第一节点达成对该第一交易的共识后,即多个第一节点达成对共识提议的共识后,该多个第一节点即可生成包含第一交易的区块,并通过执行该 区块中的各个交易来更新世界状态。
回到图3,在步骤34,基于第一交易在第一集合中将第三节点的标识替换为第四节点的标识。即当前作为共识节点的多个第一节点成功达成对第一交易的共识后,各个作为共识节点的第一节点即可以执行该第一交易,更具体地说是基于该第一交易执行其请求调用的智能合约,从而完成在集合c1中将第三节点的标识替换为第四节点的标识。
此外如前所述的是智能合约的合约状态中还可以存储若干集合c2,第四节点的标识可能位于某个集合c2中。因而与之相应的是,步骤34中具体还可以通过对第一交易的执行,完成在第四节点的标识所属的集合c2中,将第四节点的标识替换为第三节点的标识。
对于当前作为共识节点的第三节点而言,其需要在多个第一节点完成对包含第一交易在内的共识提议达成共识后,将共识结果分发至与第三节点对应的各个第二节点;此外该第三节点还需要基于第一交易的执行结果更新世界状态,从而基于更新后的集合c1发现其自身已被作为非共识节点。对于当前作为非共识节点的第四节点,其可以通过前文示例性描述的各种共识结果的分发方法,获得多个第一节点对包含第一交易在内的共识提议达成共识后对应得到的共识结果,并基于该共识结果至少执行包含第一交易在内的各个交易以更新其存储的世界状态,从而基于更新后的集合c1发现其自身已被作为共识节点。
请参见图5,当前作为共识节点的Node 1、Node 2、Node 3和Node 4可以更新其各自存储的世界状态,例如至少在集合c1中将Node 1的标识替换为Node 11的标识,如此Node 1可以基于集合c1发现其自身在后续时间内将不再被作为共识节点。此外Node 1还可以向与其对应的并且当前作为非共识节点的Node 11~Node 1n等n个分发相应的共识结果,例如分发包含第一交易在内的区块,进而使得Node 11~Node 1n可以基于Node 1向七分发的共识结果执行包含第一交易在内的各个交易,并各自更新其自身存储的世界状态,例如至少在集合c1中将Node 1的标识替换为Node 11的标识,如此Node 11可以基于更新后的集合c1发现其自身在后续时间内将作为共识节点与Node 2、Node 3和Node 4等其余共识节点执行相应的共识机制。
当前作为共识节点的区块链节点还可以从用户设其它区块链节点接收第二交易,第二交易请求调用智能合约,用于指示将若干第二节点中的第六节点设置为共识节点;然后基于该第二交易在第一集合中增加第六节点的标识,从而完成在区块链系统中新 增共识节点。
当前作为共识节点的区块链节点还可以从用户设备或其它区块链节点接收第三交易,第三交易请求调用智能合约,用于指示将多个第一节点中的第七节点设置为非共识节点;基于该第三交易在第一集合中删除第七节点的标识,从而完成在区块链系统中减少共识节点。
当前作为共识节点的区块链节点还可以对前述随机数节点集合中的第五节点进行轮换,对第五节点进行轮换的过程与前述轮换共识节点的方法相似,此处不再赘述。
与前述方法实施例基于相同的构思,本说明书实施例中还提供了区块链系统中的第一节点,所述区块链系统中包括当前作为共识节点的多个第一节点和当前作为非共识节点的若干第二节点,所述区块链系统中部署有智能合约,所述智能合约的合约状态中存储有第一集合,所述第一集合中包括所述多个第一节点的标识。如图6所示,所述第一节点包括:交易获取单元62,配置为获取第一交易,所述第一交易请求调用所述智能合约,用于指示将所述多个第一节点中的第三节点设置为非共识节点,并将所述若干第二节点中的第四节点设置为共识节点;交易执行单元64,配置为基于所述第一交易在所述第一集合中将所述第三节点的标识替换为所述第四节点的标识。
在一种可能的实施方式中,所述交易执行单元64,还配置为基于所述第一交易在所述第一集合中将所述第三节点的标识替换为所述第四节点的标识。
在一种可能的实施方式中,还包括:共识处理单元,配置为基于所述第一集合与所述多个第一节点中除所述区块链节点以外的其余第一节点对所述第一交易进行共识。
在一种可能的实施方式中,还包括:随机处理单元,配置为生成第一随机数和第二随机数;节点选择单元,配置为根据所述第一随机数从所述多个第一节点中确定所述第三节点,并根据所述第二随机数从所述若干第二节点中确定出所述第四节点。
在一种可能的实施方式中,所述随机数处理单元,还配置为获取由多个第五节点协同生成的第三随机数,所述第五节点是从所述多个第一节点或所述若干第二节点中选择的,所述第一随机数和所述第二随机数基于所述第三随机数生成。
在一种可能的实施方式中,所述随机数处理单元,配置为从最新生成的区块中读取所述第三随机数。
在一种可能的实施方式中,所述随机数处理的那元,具体配置为基于预设的时间步长或区块高度增量,从最新生成的区块中读取所述第三随机数。
在一种可能的实施方式中,所述多个第五节点相同于所述多个第一节点;在所述 最新生成的区块对应的PBFT的提交阶段,每个所述第一节点基于门限签名算法采用自身私钥份额对包含本次共识中原始交易列表特有值的原始报文进行签名,生成签名份额并将该签名份额加入到广播的提交消息中;每个所述第一节点收集齐至少门限数量的提交消息后将所述至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复函数得到完整签名;每个所述第一节点基于所述完整签名得到所述第三随机数。
虽然本说明书一个或多个实施例提供了如实施例或流程图所述的方法操作步骤,但基于常规或者无创造性的手段可以包括更多或者更少的操作步骤。实施例中列举的步骤顺序仅仅为众多步骤执行顺序中的一种方式,不代表唯一的执行顺序。在实际中的装置或终端产品执行时,可以按照实施例或者附图所示的方法顺序执行或者并行执行(例如并行处理器或者多线程处理的环境,甚至为分布式数据处理环境)。术语“包括”、“包括”或者其任何其他变体意在涵盖非排他性的包括,从而使得包括一系列要素的过程、方法、产品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、产品或者设备所固有的要素。在没有更多限制的情况下,并不排除在包括所述要素的过程、方法、产品或者设备中还存在另外的相同或等同要素。例如若使用到第一,第二等词语用来表示名称,而并不表示任何特定的顺序。
本发明是参照根据本发明实施例的方法、装置(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每个流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算 机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储、石墨烯存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。
本领域技术人员应明白,本说明书一个或多个实施例可提供为方法、系统或计算机程序产品。因此,本说明书一个或多个实施例可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本说明书一个或多个实施例可采用在一个或多个其中包括有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本说明书一个或多个实施例可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本本说明书一个或多个实施例,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参 见方法实施例的部分说明即可。在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包括于本说明书的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不必须针对的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任一个或多个实施例或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本领域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或示例的特征进行结合和组合。
以上所述仅为本说明书一个或多个实施例的实施例而已,并不用于限制本本说明书一个或多个实施例。对于本领域技术人员来说,本说明书一个或多个实施例可以有各种更改和变化。凡在本说明书的精神和原理之内所作的任何修改、等同替换、改进等,均应包括在权利要求范围之内。

Claims (19)

  1. 一种区块链系统中共识节点的轮换方法,所述区块链系统中包括当前作为共识节点的多个第一节点和当前作为非共识节点的若干第二节点,所述区块链系统中部署有智能合约,所述智能合约的合约状态中存储有第一集合,所述第一集合中包括所述多个第一节点的标识,所述方法由所述第一节点执行,所述方法包括:
    获取第一交易,所述第一交易请求调用所述智能合约,用于指示将所述多个第一节点中的第三节点设置为非共识节点,并将所述若干第二节点中的第四节点设置为共识节点;
    基于所述第一交易在所述第一集合中将所述第三节点的标识替换为所述第四节点的标识。
  2. 根据权利要求1所述的方法,所述方法还包括:基于所述第一集合与所述多个第一节点中的其余第一节点对所述第一交易进行共识。
  3. 根据权利要求1所述的方法,所述智能合约的合约状态中存储有第二集合,所述第二集合中至少包括所述第四节点的标识;所述方法还包括:基于所述第一交易在所述第二集合中将所述第四节点的标识替换为所述第三节点的标识。
  4. 根据权利要求1-3中任一项所述的方法,所述方法还包括:生成第一随机数和第二随机数;根据所述第一随机数从所述多个第一节点中确定所述第三节点,并根据所述第二随机数从所述若干第二节点中确定出所述第四节点。
  5. 根据权利要求4所述的方法,所述方法还包括:获取由多个第五节点协同生成的第三随机数,所述第五节点是从所述多个第一节点或所述若干第二节点中选择的,所述第一随机数和所述第二随机数基于所述第三随机数生成。
  6. 根据权利要求5所述的方法,所述获取获取由多个第五节点协同生成的第三随机数,包括:从最新生成的区块中读取所述第三随机数。
  7. 根据权利要求6所述的方法,所述从最新生成的区块中读取所述第三随机数,包括:基于预设的时间步长或区块高度增量,从最新生成的区块中读取所述第三随机数。
  8. 根据权利要求5所述的方法,所述多个第五节点相同于所述多个第一节点;在所述最新生成的区块对应的实用拜占庭容错PBFT算法的提交阶段,每个所述第一节点基于门限签名算法采用自身私钥份额对包含本次共识中原始交易列表特有值的原始报文进行签名,生成签名份额并将该签名份额加入到广播的提交消息中;每个所述第 一节点收集齐至少门限数量的提交消息后将所述至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复函数得到完整签名;每个所述第一节点基于所述完整签名得到所述第三随机数。
  9. 一种区块链系统中的第一节点,所述区块链系统中包括当前作为共识节点的多个第一节点和当前作为非共识节点的若干第二节点,所述区块链系统中部署有智能合约,所述智能合约的合约状态中存储有第一集合,所述第一集合中包括所述多个第一节点的标识,所述第一节点包括:
    交易获取单元,配置为获取第一交易,所述第一交易请求调用所述智能合约,用于指示将所述多个第一节点中的第三节点设置为非共识节点,并将所述若干第二节点中的第四节点设置为共识节点;
    交易执行单元,配置为基于所述第一交易在所述第一集合中将所述第三节点的标识替换为所述第四节点的标识。
  10. 根据权利要求9所述的第一节点,所述交易执行单元,还配置为基于所述第一交易在所述第一集合中将所述第三节点的标识替换为所述第四节点的标识。
  11. 根据权利要求9所述的区块链节点,还包括:共识处理单元,配置为基于所述第一集合与所述多个第一节点中除所述区块链节点以外的其余第一节点对所述第一交易进行共识。
  12. 根据权利要求9-11中任一项所述的第一节点,还包括:随机处理单元,配置为生成第一随机数和第二随机数;节点选择单元,配置为根据所述第一随机数从所述多个第一节点中确定所述第三节点,并根据所述第二随机数从所述若干第二节点中确定出所述第四节点。
  13. 根据权利要求12所述的第一节点,所述随机数处理单元,还配置为获取由多个第五节点协同生成的第三随机数,所述第五节点是从所述多个第一节点或所述若干第二节点中选择的,所述第一随机数和所述第二随机数基于所述第三随机数生成。
  14. 根据权利要求13所述的第一节点,所述随机数处理单元,配置为从最新生成的区块中读取所述第三随机数。
  15. 根据权利要求14所述的第一节点,所述随机数处理的那元,具体配置为基于预设的时间步长或区块高度增量,从最新生成的区块中读取所述第三随机数。
  16. 根据权利要求13所述的第一节点,所述多个第五节点相同于所述多个第一节点;在所述最新生成的区块对应的实用拜占庭容错PBFT算法的提交阶段,所述第一 节点基于门限签名算法采用自身私钥份额对包含本次共识中原始交易列表特有值的原始报文进行签名,生成签名份额并将该签名份额加入到广播的提交消息中;所述第一节点收集齐至少门限数量的提交消息后将所述至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复函数得到完整签名;所述第一节点基于所述完整签名得到所述第三随机数。
  17. 一种区块链系统,包括当前作为共识节点的多个第一节点和当前作为非共识节点的若干第二节点,所述区块链系统中部署有智能合约,所述智能合约的合约状态中存储有第一集合,所述第一集合中包括所述多个第一节点的标识;其中,所述第一节点用于获取第一交易,所述第一交易请求调用所述智能合约,用于指示将所述多个第一节点中的第三节点设置为非共识节点,并将所述若干第二节点中的第四节点设置为共识节点;基于所述第一交易在所述第一集合中将所述第三节点的标识替换为所述第四节点的标识。
  18. 一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算设备中执行时,令计算设备执行权利要求1-8中任一项的所述的方法。
  19. 一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器执行所述计算机程序时,实现权利要求1-8中任一项所述的方法。
PCT/CN2022/135275 2022-03-31 2022-11-30 区块链系统中共识节点的轮换方法、节点和区块链系统 WO2023185046A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210333393.2 2022-03-31
CN202210333393.2A CN114710504A (zh) 2022-03-31 2022-03-31 区块链系统中共识节点的轮换方法、节点和区块链系统

Publications (1)

Publication Number Publication Date
WO2023185046A1 true WO2023185046A1 (zh) 2023-10-05

Family

ID=82170101

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/135275 WO2023185046A1 (zh) 2022-03-31 2022-11-30 区块链系统中共识节点的轮换方法、节点和区块链系统

Country Status (2)

Country Link
CN (1) CN114710504A (zh)
WO (1) WO2023185046A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114710504A (zh) * 2022-03-31 2022-07-05 蚂蚁区块链科技(上海)有限公司 区块链系统中共识节点的轮换方法、节点和区块链系统
CN115665176A (zh) * 2022-09-30 2023-01-31 蚂蚁区块链科技(上海)有限公司 区块链系统中节点类型的转换方法、装置及区块链系统

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018111295A1 (en) * 2016-12-16 2018-06-21 Hitachi, Ltd. Blockchain monitoring and management
US20200027005A1 (en) * 2018-07-18 2020-01-23 Salesforce.Com, Inc. Systems and methods for accelerating execution of processes based on artificial intelligence (ai) prediction of blockchain consensus
CN111444210A (zh) * 2020-03-26 2020-07-24 腾讯科技(深圳)有限公司 区块链共识节点管理方法、装置、设备以及存储介质
CN111464353A (zh) * 2020-03-31 2020-07-28 财付通支付科技有限公司 区块链节点管理方法、装置、计算机以及可读存储介质
CN112132579A (zh) * 2020-09-30 2020-12-25 深圳前海微众银行股份有限公司 一种区块链共识节点更新方法及装置
CN114710504A (zh) * 2022-03-31 2022-07-05 蚂蚁区块链科技(上海)有限公司 区块链系统中共识节点的轮换方法、节点和区块链系统

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108810077A (zh) * 2018-04-19 2018-11-13 深圳市网心科技有限公司 区块链共识处理方法、电子装置及计算机可读存储介质
CN112953981A (zh) * 2019-11-26 2021-06-11 北京沃东天骏信息技术有限公司 节点选择方法、区块链共识方法及装置、系统、设备
CN111556120B (zh) * 2020-04-23 2023-04-07 财付通支付科技有限公司 基于区块链的数据处理方法、装置、存储介质及设备
CN113837758A (zh) * 2021-09-27 2021-12-24 深圳前海微众银行股份有限公司 一种区块链系统的共识方法及装置

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018111295A1 (en) * 2016-12-16 2018-06-21 Hitachi, Ltd. Blockchain monitoring and management
US20200027005A1 (en) * 2018-07-18 2020-01-23 Salesforce.Com, Inc. Systems and methods for accelerating execution of processes based on artificial intelligence (ai) prediction of blockchain consensus
CN111444210A (zh) * 2020-03-26 2020-07-24 腾讯科技(深圳)有限公司 区块链共识节点管理方法、装置、设备以及存储介质
CN111464353A (zh) * 2020-03-31 2020-07-28 财付通支付科技有限公司 区块链节点管理方法、装置、计算机以及可读存储介质
CN112132579A (zh) * 2020-09-30 2020-12-25 深圳前海微众银行股份有限公司 一种区块链共识节点更新方法及装置
CN114710504A (zh) * 2022-03-31 2022-07-05 蚂蚁区块链科技(上海)有限公司 区块链系统中共识节点的轮换方法、节点和区块链系统

Also Published As

Publication number Publication date
CN114710504A (zh) 2022-07-05

Similar Documents

Publication Publication Date Title
Huba et al. Papaya: Practical, private, and scalable federated learning
WO2023185046A1 (zh) 区块链系统中共识节点的轮换方法、节点和区块链系统
CN110832825B (zh) 通过防篡改数据提高验证速度的网络的方法和节点
CN111681003B (zh) 资源跨链转移方法、装置、计算机设备以及存储介质
Ghosh et al. Leveraging public-private blockchain interoperability for closed consortium interfacing
JP2020511807A (ja) 分散システムにおけるネットワークノード間のコンセンサスを実現すること
JP7328237B2 (ja) コンピュータにより実施される投票処理およびシステム
CN111066285A (zh) 基于sm2签名恢复公钥的方法
CN111625593A (zh) 基于区块链的数据处理方法、装置、计算机设备
WO2023185045A1 (zh) 一种区块链上产生随机数种子的方法、系统和共识节点
WO2023185051A1 (zh) 一种区块链上产生随机数种子的方法、系统和共识节点
Wan et al. HIBEChain: A hierarchical identity-based blockchain system for large-scale IoT
CN114640451A (zh) 区块链上实现分布式密钥生成的方法、系统和共识节点
CN113988831A (zh) 一种基于联盟链的转账方法
CN112565314B (zh) 一种计算集群和计算集群中的计算节点
WO2024092936A1 (zh) 一种区块链上实现分布式密钥生成的方法、系统和节点
WO2024092935A1 (zh) 一种区块链上实现分布式密钥生成的方法、系统和节点
CN115174069A (zh) 一种拟态分布式sm9快速标识密钥生成方法及系统
da Costa et al. DLCP: A protocol for securing light client operation in blockchains
Song et al. Enabling Transparent Deduplication and Auditing for Encrypted Data in Cloud
Ren et al. Flexico: An efficient dual-mode consensus protocol for blockchain networks
CN116171555A (zh) 具有多个子网的分布式网络
JP2023550886A (ja) 分散ネットワークにおける検証鍵生成
CN115296843B (zh) 区块链系统中的交易执行方法、第一节点和第二节点
CN111784338A (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: 22934864

Country of ref document: EP

Kind code of ref document: A1