WO2023185045A1 - Method and system for generating random seed on blockchain, and consensus node - Google Patents

Method and system for generating random seed on blockchain, and consensus node Download PDF

Info

Publication number
WO2023185045A1
WO2023185045A1 PCT/CN2022/135233 CN2022135233W WO2023185045A1 WO 2023185045 A1 WO2023185045 A1 WO 2023185045A1 CN 2022135233 W CN2022135233 W CN 2022135233W WO 2023185045 A1 WO2023185045 A1 WO 2023185045A1
Authority
WO
WIPO (PCT)
Prior art keywords
signature
consensus
node
share
threshold
Prior art date
Application number
PCT/CN2022/135233
Other languages
French (fr)
Chinese (zh)
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 WO2023185045A1 publication Critical patent/WO2023185045A1/en

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/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
    • 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/3247Cryptographic 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 involving digital signatures

Definitions

  • the embodiments of this specification belong to the field of blockchain technology, and particularly relate to a method, system and consensus node for generating random number seeds on a blockchain.
  • 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 this specification is to provide a method, system and consensus node for generating random number seeds on the blockchain.
  • a method of generating random number seeds on the blockchain including: in the Sign-share phase of the SBFT-like consensus, each consensus node uses its own private key share pair to contain the unique value of the original transaction list in this consensus based on the threshold signature algorithm. Sign the original message, generate a signature share, and add the signature share to the Sign-share message and send it to at least one collection node; after the collection node collects at least a threshold number of Sign-share messages, at least a threshold number of them The number of signature shares passes the recovery function corresponding to the private key share generated by the threshold signature algorithm to obtain a complete signature; the collection node broadcasts a full-commit-proof message containing the complete signature to the consensus node; receiving the full-commit- Each consensus node of the proof message obtains a random number seed based on the complete signature.
  • a method of generating random number seeds on the blockchain including: in the Pre-Commit/Commit voting stage of the Hotstuff-like consensus, each consensus node uses its own private key share pair to contain the original in this consensus based on the threshold signature algorithm. Sign the original message with the unique value of the transaction list, generate a signature share, and add the signature share to the broadcast message and send it to the collection node; after the collection node collects at least a threshold number of broadcast messages, at least a threshold number of them The signature share is obtained through the recovery function corresponding to the private key share generated by the threshold signature algorithm to obtain a complete signature, and a message containing the complete signature is broadcast to the consensus node; each consensus node that receives the broadcast message is based on the complete signature therein Get the random number seed.
  • the key share signs the original message containing the voting value in this consensus, generates a signature share, and sends the signature share to at least one collection node; the collection node will collect at least a threshold number of signature shares through the
  • the recovery function corresponding to the private key share generated by the threshold signature algorithm obtains a complete signature; the collection node broadcasts the complete signature to the consensus node; each consensus node that receives the complete signature obtains a random number seed based on the complete signature.
  • the key share signs the original message containing the voting value in this consensus, generates a signature share, and sends the signature share to at least one collection node; the collection node will collect at least a threshold number of signature shares through the
  • the recovery function corresponding to the private key share generated by the threshold signature algorithm obtains a complete signature; the collection node broadcasts the complete signature to the consensus node; each consensus node that receives the complete signature obtains a random number seed based on the complete signature.
  • the above scheme provided in this manual combines the threshold signature algorithm with the SBFT consensus algorithm, so that after the original transaction list corresponding to each block reaches consensus through the SBFT algorithm, the complete signature can be obtained through the adopted threshold signature algorithm, thus obtaining The random number seed can be used in the process of executing the transactions in the original transaction list corresponding to this block. In this way, no additional waiting is required to execute the transactions in this block.
  • each consensus node generates the same random number seed based on a complete signature. Therefore, when each blockchain node executes the same transaction in the same block, for which The same random number generation process can generate the same random number based on the same random number seed to complete business logic such as lottery, red envelope issuing, blind box, or complete system contract/blockchain platform functions, and on each node Get consistent execution results.
  • voting-based consensus algorithms there is often a final round of voting.
  • the messages in the last round of voting can be collected by a node, aggregated and then broadcast to other nodes, such as the commit message in Hotsguff and the Sign-share message in SBFT.
  • the solution provided in this manual is applicable to the situation where there is a final round of voting in the consensus algorithm before executing the transaction, so as to reach a consensus on the transaction list to be executed and at the same time reach a consistent random number seed, which meets the requirements of consistency, immediacy, and impossibility. Predictable, uncontrollable and irrevocable.
  • FIG. 1 is a schematic diagram of the conventional phase of a practical Byzantine fault-tolerant algorithm in an embodiment
  • Figure 2 is a schematic diagram of the view switching stage of a practical Byzantine fault-tolerant algorithm in an embodiment
  • Figure 3 is a schematic diagram of the normal phase of the practical Byzantine fault-tolerance algorithm in an embodiment when no consensus node is down;
  • Figure 4 is a flow chart for generating random number seeds on the blockchain in an embodiment of this specification
  • Figure 5 is a schematic diagram of the block header structure in an embodiment of this specification.
  • Figure 6 is a flow chart for generating random number seeds on the blockchain in an embodiment of this specification
  • Figure 7 is a flow chart of the SBFT algorithm in an embodiment of this specification.
  • Figure 8 is a flow chart of the HotStuff algorithm in an embodiment of this specification.
  • the blockchain 1.0 era usually refers to the development stage of blockchain applications between 2009 and 2014. They are mainly dedicated to solving the decentralization problem of currency and payment methods. Since 2014, developers have increasingly focused on solving the technical and scalability deficiencies of the aforementioned solutions. At the end of 2013, Vitalik Buterin introduced smart contracts into the blockchain, opening up the application of blockchain beyond the currency field, thus opening the blockchain 2.0 era.
  • a decentralized (or multi-centralized) distributed ledger constructed using a chain block structure is stored on each node (or on 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 (or multiple nodes) runs a blockchain program.
  • the consensus mechanism is used to ensure that all loyal nodes have the same transactions, thereby ensuring that all loyal nodes have the same transactions.
  • the execution results are consistent, and the transaction and execution results are packaged to generate blocks.
  • a smart contract is an automatically executed computer contract based on specified triggering rules. It can also be regarded as a digital version of a traditional contract.
  • the concept of smart contracts was first proposed in 1994 by Nick Szabo, a cross-field legal scholar and cryptography researcher. This technology was once not used in actual industries due to the lack of programmable digital systems and related technologies, until the emergence of blockchain technology provided a reliable execution environment. Since blockchain technology uses a blockchain ledger, the data generated cannot be tampered with or deleted, and the entire ledger will continuously add ledger data, thus ensuring the traceability of historical data; at the same time, the decentralized operating mechanism avoids centralization influence of factors.
  • Smart contracts based on blockchain technology can not only take advantage of smart contracts in terms of cost and efficiency, but also avoid malicious behavior from interfering with the normal execution of the contract. Smart contracts are written into the blockchain in digital form, and the characteristics of the blockchain technology ensure that the entire process of storage, reading, and execution is transparent, traceable, and cannot be tampered with.
  • Blockchain development and application diversification Some business logic is edited into smart contracts and executed on the blockchain platform. Specifically, these smart contracts containing business logic can run on every node (or on most nodes, such as consensus nodes) in the blockchain network. Compared with the problem of single point of failure caused by the centralized business logic execution environment, which makes the entire centralized system unavailable, the execution of smart contracts in the blockchain environment is also called the "world computer". This is because of the distributed area. There are many nodes in the blockchain network that execute smart contracts independently. As mentioned before, smart contracts that execute the same logic on these different nodes need to obtain the same execution results to ensure that the ledgers saved by most of these nodes are consistent.
  • each node (or multiple nodes) runs a blockchain program.
  • the consensus mechanism ensures that all loyal nodes have the same transactions, thereby ensuring that all loyal nodes have the same transactions.
  • the execution results are consistent, and the transactions and execution results are packaged to generate blocks.
  • the current mainstream consensus mechanisms include: Proof of Work (POW), Proof of Stake (POS), Delegated Proof of Stake (DPOS), Practical Byzantine Fault Tolerance (PBFT) ) algorithm, Honey Badger Byzantine Fault Tolerance (HoneyBadgerBFT, also referred to as HBBFT) algorithm, etc.
  • a set of a certain number of replicas required to ensure the data consistency and fault tolerance requirements of all replicas is generally a set composed of most nodes in a distributed system, forming a majority (Quorum).
  • the Quorum is 2f+1. In this way, for a distributed system containing four nodes, any three nodes can form a Quorum.
  • PBFT includes two processes: Normal Case Phase and View Change Phase.
  • Figure 1 is the flow chart of the Normal Case Phase (normal phase) process. Normal Case Phase mainly includes three stages: PRE-PREPARE (preparation), PREPARE (preparation) and COMMIT (commit).
  • Node 3 for example, can represent a downed node (indicated by ⁇ in Figure 1).
  • the master node fails (indicated by ⁇ in Figure 2, for example, the master node Primary, that is, Replica 0 (replica 0) fails before changing the view)
  • the view change process needs to be started to make adjustments when the system fails.
  • Replace a new primary node for example, Replica 1 is the primary node after changing the view).
  • Figure 2 is a schematic diagram of View Change Phase.
  • the client can set a timeout mechanism. If the timeout occurs, the client can broadcast the request message to all replica nodes. After the replica node detects that the master node has done something evil or gone offline, it can also initiate the View Change protocol phase to replace the master node (often referred to as "switching the master"). In addition, it may also be due to the master node initiating an incorrect proposal that the three-phase consensus process of PRE-PREPARE, PREPARE and COMMIT may fail, or the PREPARE and COMMIT phases may not reach the number of Quorum (such as 2f+1 of 3f+1 nodes, Also known as a quorum), consensus cannot be achieved. In these cases, the View Change protocol phase may also be initiated to replace the master node.
  • the View Change protocol phase may also be initiated to replace the master node.
  • node 0 serves as the master node and collects a certain number of transactions to be agreed upon (or read and write sets, etc., which will be explained later using transactions as examples), and then initiates the pre-preparation process (i.e. the aforementioned PRE-PREPARE, also referred to as the PP phase), and then nodes 1, 2, and 3 enter the preparation process (the aforementioned PREPARE, also referred to as the P phase), and then nodes 0, 1, 2, and 3 enter the submission process (the aforementioned COMMIT, also referred to as phase C).
  • the PP stage, P stage, and C stage are generally collectively referred to as the three stages of PBFT.
  • each consensus node can execute these transactions sequentially based on the consensus transaction data and in accordance with the order and content of the consensus transaction data, thereby generating world status and receipts.
  • each node can build a Merkle tree (including tree structures such as MPT trees) based on local consensus transaction data.
  • MPT is called Merkle Patricia Tree, which is a combination of Merkle Tree (Merkle Tree) and Patricia Tree (compression prefix).
  • the block header of the m-1th block may include the aforementioned block number, transaction root hash, status root hash, receipt root hash and other information.
  • the block body may include a transaction data set, a world state set and a receipt set. In this way, the m-1th block is generated.
  • node 0 serves as the master node and after collecting a certain number of transactions to be agreed upon, initiates the PP process, and then nodes 1, 2, and 3 enter the P process, and then nodes 0, 1, 2, 3 Enter the C process.
  • the three-stage process of the r-th round of PBFT is completed, and the consensus of the transaction data corresponding to the m-th block is completed.
  • the block number and other information of this block are also generated.
  • Each node can execute these transactions sequentially based on the consensus transaction data and in accordance with the order and content of the consensus transaction data, thereby generating world status and receipts.
  • the block header of the m-th block may include the aforementioned block number, transaction root hash, status root hash, receipt root hash and other information.
  • the block body may include a transaction data set, a world state set and a receipt set. In this way, the m-th block is generated. Similarly, the m+1th block is generated, and this process includes the three-stage process of the r+1th round of PBFT as shown in Figure 3.
  • each consensus node includes a Normal Case Phase process of PBFT in the generation process of each block. As blocks continue to be generated, each consensus node will repeat this consensus process.
  • Figure 3 only illustrates the r-1, r, and r+1 rounds of consensus processes. Among them, some consensus nodes serve as the main node in PBFT, and some consensus nodes serve as the backup node in PBFT.
  • master node 0 collects a certain number of transactions to be agreed upon, it sorts and packages the transactions to be agreed into messages m (also called the original transaction list), send pre-prepare requests to backup nodes 1, 2, and 3.
  • the pre-prepare requests include message m; a120: (PREPARE preparation phase)
  • Nodes 1, 2, and 3 receive pre-prepare
  • the hash value of the received message m will be broadcast through the prepare message (the content of the broadcast generally does not include the message m itself, because the message m includes several original transaction requests, and the volume is generally relatively large. ).
  • node 1 diffuses the prepare message to nodes 0, 2, and 3
  • node 2 diffuses the prepare message to nodes 0, 1, and 3
  • node 3 diffuses the prepare message to nodes 0, 1, and 2.
  • each node also receives prepare messages broadcast by other nodes.
  • Each node adds the prepare message it sends (which contains the hash value of message m, representing its own approval) and the prepared message it receives (which contains the hash value of message m, which represents the approval of other nodes) to the local log ( Log). If a node collects at least Quorum number of legal pp messages/p messages from different nodes (including pre-prepare, prepare messages sent by itself, and prepare messages received), it changes to the prepared state.
  • each node participating in the consensus After entering the prepared state, each node participating in the consensus sends a commit message to other consensus nodes, 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. If a node collects legal commit messages of at least Quorum from different nodes and adds them to the local Log (plus the total Quorum it added to the local Log), it changes to the committed state.
  • a140 The node that changes to the committed state outputs message m as the consensus result of this round.
  • Which transactions are included in the message m, and the order of the included transactions, are generally determined by the master node in a110. Determining which transactions are included and the sequence of included transactions are two important aspects of the consensus mechanism.
  • the blockchain network may receive many transaction requests. Which transactions are packaged by the master node in a110 determines which transactions will be processed by the blockchain network, and the execution results of the transactions will be uploaded to the chain. Even for the same set of transactions, different execution sequences will lead to different final results, which affects whether the ledgers on each node are consistent.
  • This specification provides a method for generating random number seeds on the blockchain, which can be implemented in conjunction with the above three-stage PBFT process. As shown in Figure 4, it includes: S110: In the commit phase of PBFT, each consensus 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, and generates a signature. share and add the signed 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: b1: 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 consensus nodes, and the minimum number of signature shares (ie, the threshold number) required by the recovery function to generate a complete signature can be equal to PBFT. quorum in algorithms.
  • the number of private keys may not be equal to the number of consensus nodes, 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 blockchain consensus nodes.
  • n private key shares can be held by each blockchain consensus node.
  • each blockchain consensus node can hold the same 1 total public key.
  • there is a decentralized key distribution method that is, the dealer is cancelled, but n consensus nodes negotiate to obtain n public-private key pairs and 1 total public key through the key agreement process.
  • Each consensus node is still independent Holds one of n private key shares, and each consensus node holds the same total public key.
  • each consensus 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 obtain the 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 consensus node confirm whether the previous block is consistent according to the scheme of this manual.
  • 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 consensus 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 other consensus nodes, 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.
  • 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 consensus 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 consensus 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 and distributed by the dealer. , or it can be obtained through negotiation among the consensus nodes.
  • Each consensus 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 S110, where ⁇ 3,0 is Mark 3 can represent the block number, and 0 can represent that this is the signature share of node 0; in S120, 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 ⁇ 3, 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 consensus 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 consensus node can obtain the same complete signature.
  • PBFT consensus algorithm there should be at least a quorum of consensus nodes in a blockchain network using the PBFT consensus algorithm, each of which can obtain the same complete signature.
  • each consensus node can use the same random number seed generation algorithm to generate random number seeds.
  • a relatively simple random number seed generation algorithm is, for example, the sha256 algorithm.
  • a random number seed can be generated on the blockchain.
  • the chain platform code can be executed based on the random number seed of S130.
  • the mt19937(r) method provided by the C++ standard library or the boost library can be used to construct a cross-platform consistent random number engine, where the parameter r is the random number seed.
  • the random library in python and the random library in java also provide similar random number generation methods.
  • the same random number can be generated under the same random number generation algorithm.
  • the same random number generation process can generate the same random number based on the same random number seed, thereby completing tasks such as lottery, red envelope issuing, blind business logic such as boxes, or complete system contract/blockchain platform functions, and obtain consistent execution results on each node.
  • S140 Each consensus node puts the obtained random number seed into the block header of the current block generated.
  • Figure 4 is a schematic structural diagram of a block header.
  • the block header of each block includes several fields, such as the previous block hash previous_Hash (Prev Hash in the figure), Nonce (this is the random number involved in the workload proof, and this The random number seeds in the instructions are different, and this nonce is not enabled in some alliance chains), timestamp Timestamp, previous block number Block Num, state root hash State Root, transaction root hash Transaction Root, receipt root hash Hope Receipt Root et al.
  • the Prev Hash in the block header of the next block (such as block N+1) points to the previous block (such as block N), which is the hash value of the previous block, that is, the hash value of the previous block.
  • the hash value of the block header can be the hash value calculated by a certain hash algorithm after sequentially splicing the fields contained in the block header. In this way, the next block locks the previous block through the block header on the blockchain.
  • state root is the hash value of the root of the MPT tree composed of the status of all accounts in the current block
  • the point pointing to state_root is a state trie in the form of MPT.
  • Transaction Root is generally the hash value of the tree root node after the original transaction list contained in this block is organized into a tree structure.
  • Receipt Root is generally all the receipts generated after the transactions included in this block are executed, organized into a tree structure.
  • this instruction can add a field in the block header - "random number seed", which is the random number seed in S130.
  • random number seed generated in this block can be recorded on the blockchain ledger.
  • the transactions involving random numbers in the block can be played back according to the random number seed in the block header.
  • the above scheme provided in this manual combines the threshold signature algorithm with the PBFT consensus algorithm, so that after the original transaction list corresponding to each block reaches consensus through the PBFT algorithm, the complete signature can be obtained through the adopted threshold signature algorithm, thus obtaining The random number seed can be used in the process of executing the transactions in the original transaction list corresponding to this block. In this way, no additional waiting is required to execute the transactions in this block.
  • each consensus node can recover the same complete signature through the recovery function based on at least a threshold number of signature shares, and then generate the same random number seed. Therefore, each block
  • the same random number generation process can generate the same random number based on the same random number seed, thereby completing business logic such as lottery, red envelope issuance, and blind box. Or complete the system contract/blockchain platform functions and obtain consistent execution results on each node.
  • the above solution provided in this manual combines the threshold signature algorithm with the PBFT consensus algorithm, making it impossible for any consensus node to predict the complete signature before the consensus is completed. Even the master node of PBFT cannot predict the complete signature, and therefore cannot predict the random number. Seeds and random numbers.
  • the threshold quorum
  • the complete signatures are the same, and the random number seeds generated by this quorum number of nodes must also be the same.
  • Consistency means that these f nodes cannot manipulate or revoke the generated complete signature, random number seed and random number.
  • the method in this specification can be implemented in the process of generating each block, so that the block header of each block can include the random number seed field. Even if the block body of a certain block does not contain transactions involving random numbers, the generation process of the block can still include the process of generating random number seeds.
  • voting-based consensus algorithms there is often a final round of voting, which can be broadcast directly to each other or through gossip protocols, such as commit messages in PBFT, pre-commit messages in Tendermint, and user messages in HoneyBadger. Messages decrypted at thresholds, etc.
  • the solution provided in this manual is applicable to the situation where there is a final round of voting in the consensus algorithm before executing the transaction, so as to reach a consensus on the transaction list to be executed and at the same time reach a consistent random number seed, which meets the requirements of consistency, immediacy, and impossibility. Predictable, uncontrollable and irrevocable.
  • the consensus node executes the content as shown in Figure 6: S210: The consensus node uses its own private key share to process the original message based on the threshold signature algorithm. Sign, generate a signature share, and add the signature share to the broadcast message.
  • the consensus node can use its own unique private key share to sign the original message containing the unique value of the original transaction list in this consensus to obtain the 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 block number (that is, the number) and/or the timestamp can also be used as the content of 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 list can also include the random number seed generated in the previous block, so that The solution in this manual can be used to help the consensus node confirm whether the previous block is consistent.
  • S220 After the consensus node collects at least a threshold number of the 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.
  • 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 consensus 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 consensus 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 and distributed by the dealer. , or it can be obtained through negotiation among the consensus nodes.
  • Each consensus 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 S210, where the lower part of ⁇ 3,0 Mark 3 can represent the block number, and 0 can represent that this is the signature share of node 0; in S220, 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 ⁇ 3, 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 ).
  • the consensus node obtains a random number seed based on the complete signature.
  • the consensus node can obtain a complete signature under normal circumstances. In this way, based on the complete signature, the consensus node can use a 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. Of course, you can also directly use the complete signature as a random number seed.
  • a random number seed can be generated on the local blockchain of the consensus node.
  • the above process can be applied to the last stage of PBFT (commit message broadcast and interaction in the submission stage), or to the Aux message in the BA (Binary Agreement) stage of HBBFT. Broadcasting and interaction can also be message broadcasting and interaction in the threshold decryption stage using the threshold encryption algorithm), or pre-commit message broadcasting and interaction applicable to Tendermint.
  • This specification also provides a method for generating a block header. Based on the above S210-S230 method, it may also include: the consensus node puts the obtained random number seed into the generated block header of the current block.
  • This specification also provides a method for generating random numbers on the blockchain. Based on the above S210-S230 method, it may also include: the consensus node generates random numbers based on the generated random number seeds.
  • SBFT uses the view change protocol like PBFT.
  • Each view has one replica as primary, and other replicas as backups. Unlike PBFT, these backups can also have other identities, commit collector (c-collector) and execution collector (execution collector, e-collector).
  • SBFT includes two modes, namely fast path and Linear-PBFT. Fast path is the default execution mode. When fast path cannot reach consensus, Linear-PBFT is used. As shown in Figure 6, through this collector communication mode, SBFT no longer sends the message to each replica, but to the collector, which then broadcasts it to all replicas.
  • the entire system has (3f+2c+1) nodes (ie Replicas), numbered from 1 to (3f+2c+1).
  • SBFT uses threshold signatures. For n replicas, only a subset of replicas needs to sign the transaction set to verify. The replicas in the subset are signed with their own private keys and sent to a recipient. Threshold signatures are divided into three groups.
  • the signature of the first group is set to ⁇ , and the signature threshold can be set to (3f+c+1).
  • the signature of the second group is set to ⁇ , and the signature threshold can be set to (f+1).
  • the SBFT process is as follows:
  • the client (c in the figure) initiates a transaction request to the primary node (Primary).
  • Primary the process of a client initiating a transaction request.
  • Each transaction request can be sent directly to the Primary or forwarded to the Primary through other nodes.
  • Pre-prepare phase After the Primary collects a certain amount of transaction requests, it sorts these transaction requests, packages them into a transaction list and places them in a pre-prepare message (pre-prepare message), and broadcasts the pre-prepare message to other parties. Replicas.
  • Signature share stage Each Replica signs the pre-prepare message with its own private key share in the first group, generates a signature share, and sends a Sign-share message containing the signature share to each C- Collector (1 C-Collector in the picture).
  • Each C-Collector collects at least the first threshold signature shares of the first group and recovers the first complete signature ⁇ , and broadcasts a full commit containing the first complete signature ⁇ . Prove (full-commit-proof) to Replicas.
  • Sign-state phase Each time a full-commit-proof Replica is received, the first set of total public keys can be used to verify the first complete signature ⁇ . After the verification is passed, the transaction list can be submitted and executed sequentially. transaction, and use the private key share in the second group to sign the execution result (generally the state set after execution, which can be represented by the hash value of the root node after the state set is organized into a tree structure) to generate a signature state , and then send the signature status to each E-Collector.
  • the execution result generally the state set after execution, which can be represented by the hash value of the root node after the state set is organized into a tree structure
  • Each E-Collector collects at least the second threshold signature share of the second group and recovers the second complete signature ⁇ , and broadcasts the full-execute proof containing the complete signature ⁇ ( full-execute-proof) to Replicas.
  • the second complete signature ⁇ can be verified through the total public key of the second group.
  • Execution confirmation (Execute-ack): Any E-Collector can also send an execution confirmation (execute-ack) message to the requesting client.
  • the request can be resent to all Replicas.
  • SBFT Compared with PBFT, SBFT only needs to send 1/3 of its number of messages and reaches consensus faster.
  • this specification provides a method for generating random number seeds on the blockchain, as shown in Figure 7, including: S310: In the Sign-share stage of SBFT, each consensus node uses the threshold signature algorithm. The own private key share signs 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 Sign-share message and sends it to at least one collection node.
  • 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.
  • the threshold signature mechanism can use threshold signature algorithms based on BLS, RSA, ECDSA, Schnorr, Boneh-Lynn-Shacham Signature, etc.
  • each consensus node can use its own unique private key (for example, in a blockchain network containing 4 nodes and using SBFT as the consensus algorithm, node 1, node 2, node 3, node 4
  • the private key shares held by the threshold signature algorithm are sk1, sk2, sk3, sk4 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 obtain the 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. Whether the m-th block generated in the chain network is the same, or whether the m-th block generated on at least a quorum number of consensus nodes is the same from the perspective of the overall availability of the blockchain system.
  • 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.
  • the method obtains a complete signature, which can help the consensus node confirm whether the previous block is consistent according to the scheme of this manual.
  • 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 consensus 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 Pre-Prepare phase of SBFT, and if the commit message broadcast in the Sign-share 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 share.
  • S320 After collecting at least a threshold number of Sign-share messages, the collection node passes at least a threshold number of signature shares among them through the recovery function 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. .
  • the collection node may also collect each Sign-share message, use the corresponding public key share to verify the signature shares in the received Sign-share message, and then add at least a threshold number of signature shares A complete signature is obtained through the recovery function corresponding to the private key share generated by the threshold signature algorithm. Compared with the method of using the total public key to verify the complete signature generated, 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 consensus 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 and distributed by the dealer. , or it can be obtained through negotiation among the consensus nodes.
  • the collection node can use the corresponding public key share to verify the signature share in the received Sign-share message. Specifically, the collection node can use the corresponding public key share to calculate the signature share and obtain a hash value, recorded as hash 1 . It can also perform the same hash calculation on the original message to obtain hash′ 1 . If hash 1 and hash′ 1 are equal, 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 the signature share is verified. Similarly, other signature shares can also be verified, which will not be described again.
  • S330 The collection node broadcasts the full-commit-proof message containing the complete signature to the consensus node.
  • the collection node collects at least the first threshold signature share and recovers the first complete signature ⁇ , it can broadcast the full-commit-proof containing the first complete signature ⁇ to Replicas.
  • Each consensus node that receives the full-commit-proof message obtains a random number seed based on the complete signature therein.
  • Random number 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 consensus node can obtain the same complete signature.
  • SBFT consensus algorithm there should be at least a quorum of consensus nodes in a blockchain network using the SBFT consensus algorithm, each of which can obtain the same complete signature.
  • each consensus node can use the same random number seed generation algorithm to generate random number seeds.
  • a relatively simple random number seed generation algorithm is, for example, the sha256 algorithm.
  • each consensus node Before generating the random number seed, each consensus node can also use the threshold signature algorithm to generate the total public key corresponding to the private key share to verify the correctness of the complete signature.
  • a random number seed can be generated on the blockchain.
  • PBFT is difficult to apply to large-scale networks, that is, it is difficult to expand.
  • HotStuff also solved the scalability problem. It uses technologies such as threshold signatures, linear view changes, and consensus state trees.
  • the core of HotStuff revolves around three rounds of consensus voting.
  • the original paper proposed three forms: simple HotStuff (Basic HotStuff), chained HotStuff (Chained HotStuff), and event-driven HotStuff (Event-Driven HotStuff).
  • Basic HotStuff is the basic process of the latter two consensuses. Among them, the views are continuously switched in a monotonically increasing manner. There is a unique master node in each view that is responsible for proposing, collecting and forwarding messages, and generating QC.
  • the QC is the abbreviation of Quorum Certificate, which means certificate.
  • the master node After the master node receives the voting message (with signature) of at least quorum nodes for a proposal, it uses the threshold signature to synthesize it into a QC.
  • This QC can be understood as the complete signature generated by the threshold signature, indicating that a consensus has been reached on the proposal.
  • the entire process of Basic HotStuff can be shown in Figure 8, including: New-View: Each node sends the previous round of view number, block hash and its own prepareQC to the Leader node through New-View.
  • the New-View message may include the view number v-1 of the previous round and the hash value H (Block-1) of the previous block.
  • the Leader node (also called the collection node in this manual) calculates the highest QC based on the highest prepareQC in the status tree sent by each node included in the received quorum New-View message.
  • the Leader node broadcasts Prepare messages to other consensus nodes.
  • the Prepare message can include the view number v (correctly it should be the view number of the previous round + 1), and can also include the ordered transaction set packaged by the Leader node.
  • each consensus node After each consensus node receives the Prepare message and passes the verification, it sends a Prepare-Vote message for the current proposal to the Leader node. Among them, each consensus node uses its own private key share for signature. Each consensus node sends a Prepare-Vote message to the Leader node.
  • the Prepare-Vote message can include the hash value of the ordered transaction set packaged by the Leader (can be expressed as H (block)), and can also include the consensus node using its own private key share pair including (Prepare-Vote, v, H (block) The first signature share of the content (here set to PartialSig1).
  • the Leader master node When the Leader master node receives Prepare-Vote messages for the current proposal from at least quorum different consensus nodes, it obtains the first complete signature by aggregating at least quorum PartialSig1, and then broadcasts the Precommit message to each consensus node.
  • Precommit voting stage After each other consensus node receives the Precommit message and passes the verification, it sends a Precommit-Vote message to the master node. Similarly, the Precommit-Vote message contains the second signature share (here set to PartialSig2) generated by the consensus node using its own private key.
  • the second signature share here set to PartialSig2
  • the Leader node collects at least quorum Precommit-vote messages, obtains the second complete signature by aggregating at least quorum PartialSig2, and then broadcasts it to other consensus nodes through Commit messages.
  • the Commit message sent by the master node is similar to the COMMIT phase in PBFT.
  • Commit voting stage After each other consensus node receives the Commit message and passes the verification, it sends a Commit-Vote message to the master node. Similarly, the Commit-Vote message contains the third signature share generated by the consensus node using its own private key (here set to PartialSig3).
  • the Leader node collects at least quorum Commit-vote messages, it obtains the third complete signature by aggregating at least quorum PartialSig3, and then broadcasts it to other consensus nodes through Decide messages.
  • each consensus node that receives the broadcast message obtains a random number seed based on the complete signature therein.
  • the complete signature can be a complete signature obtained by the Leader node after aggregating at least quorum PartialSig2.
  • each consensus node that receives the broadcast message obtains a random number seed based on the complete signature therein.
  • the complete signature can be a complete signature obtained by the Leader node after aggregating at least quorum PartialSig3. Furthermore, each consensus node that receives the broadcast message obtains a random number seed based on the complete signature therein.
  • PartialSig2 or PartialSig3 can be a signature share generated by the consensus node using 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.
  • the unique value of the original transaction list may include: the original transaction list itself or a hash value of the original transaction list.
  • the original message also includes the random number seed or block hash generated in the previous block.
  • the collection node collects at least a threshold number of signature shares and before obtaining a complete signature, it further includes: verifying each signature share using the corresponding public key share.
  • the method further includes: verifying the complete signature using a total public key.
  • the number of private key shares/public key shares of the threshold signature algorithm is equal to the number of consensus nodes, and the threshold value of the threshold signature algorithm is equal to the quorum of the consensus algorithm used by the blockchain.
  • the method may also include: each consensus node puts the obtained random number seed into the block header of the current block generated.
  • the method may also include: each consensus node generates random numbers based on the generated random number seeds.
  • voting-based consensus algorithms there is often a final round of voting, which can be broadcast directly to each other or through gossip protocols, such as commit messages in PBFT, pre-commit messages in Tendermint, and HoneyBadger. Messages used for threshold decryption, etc.
  • the messages in the last round of voting can also be collected by a node, aggregated and then broadcast to other nodes, such as the commit message in Hotstuff, and the Sign-share message in SBFT.
  • the solution provided in this manual is applicable to the situation where there is a final round of voting in the consensus algorithm before executing the transaction, so as to reach a consensus on the transaction list to be executed and at the same time reach a consistent random number seed, which meets the requirements of consistency, immediacy, and impossibility. Predictable, uncontrollable and irrevocable.
  • This specification provides a method for generating random number seeds on the blockchain, including: in the last round of voting before transaction execution, each consensus node uses its own private key share to include the votes in this consensus based on the threshold signature algorithm. Sign the original message with the value, generate a signature share, and send the signature share to at least one collection node;
  • the collection node passes the collected signature shares of at least a threshold number through the recovery function corresponding to the private key share generated by the threshold signature algorithm to obtain a complete signature; the collection node broadcasts the complete signature to the consensus node; the received Each consensus node of the complete signature obtains a random number seed based on the complete signature.
  • the voting value includes: the original transaction list itself or the hash value of the original transaction list.
  • the original message also includes a block number and/or a timestamp.
  • the original message also includes the random number seed or block hash generated in the previous block.
  • the collection node collects at least a threshold number of signature shares and before obtaining a complete signature, it further includes: verifying each signature share using the corresponding public key share.
  • the method further includes: verifying the complete signature using a total public key.
  • the number of private key shares/public key shares of the threshold signature algorithm is equal to the number of consensus nodes, and the threshold value of the threshold signature algorithm is equal to the quorum of the consensus algorithm used by the blockchain.
  • a method of generating a block header also includes: each consensus node puts the obtained random number seed into the block header of the current block generated.
  • a method of generating random numbers on the blockchain also includes: each consensus node generates random numbers based on the generated random number seeds.
  • the signatures recovered by all nodes must be consistent, and the signature is uncontrollable and unpredictable, and it must be jointly signed by nodes that reach the threshold to be successfully recovered, so it is consistent with the randomness on the chain. number requirements.
  • Embodiments of this specification also provide a method for generating random number seeds on the blockchain, which is applied to a system including several consensus nodes and collection nodes, including: in the last round of voting before transaction execution, each consensus node generates a random number seed based on a threshold.
  • Signature algorithm uses its own private key share to sign the original message containing the voting value in this consensus, generates a signature share, and sends the signature share to at least one collection node; the collection node will collect at least a threshold number
  • the signature share is passed through the recovery function corresponding to the private key share generated by the threshold signature algorithm to obtain a complete signature; the collection node broadcasts the complete signature to the consensus node; each consensus node that receives the complete signature is based on the The complete signature gets the random number seed.
  • PLD Programmable Logic Device
  • FPGA Field Programmable Gate Array
  • HDL Hardware Description Language
  • the controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer readable medium storing computer readable program code (eg, software or firmware) executable by the (micro)processor. , logic gates, switches, Application Specific Integrated Circuit (ASIC), programmable logic controllers and embedded microcontrollers.
  • controllers include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, For Microchip PIC18F26K20 and Silicone Labs C8051F320, the memory controller can also be implemented as part of the memory's control logic.
  • the controller in addition to implementing the controller in the form of pure computer-readable program code, the controller can be completely programmed with logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded logic by logically programming the method steps. Microcontroller, etc. to achieve the same function. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the means for implementing various functions can be considered as structures within hardware components as well as software modules implementing the methods.
  • the systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions.
  • a typical implementation device is a server system.
  • the computer that implements the functions of the above embodiments may be, for example, a personal computer, a laptop computer, a vehicle-mounted human-computer interaction device, a cellular phone, a camera phone, a smart phone, or a personal digital assistant. , media player, navigation device, email device, game console, tablet, wearable device, or a combination of any of these devices.
  • the functions are divided into various modules and described separately.
  • the functions of each module can be implemented in the same or multiple software and/or hardware, or the modules that implement the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. .
  • the device embodiments described above are only illustrative.
  • the division of the units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components may be combined or integrated. to another system, or some features can be ignored, or not implemented.
  • the coupling or direct coupling or communication connection between each other shown or discussed may be through some interfaces, and the indirect coupling or communication connection of the devices or units may be in electrical, mechanical or other forms.
  • 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 can be used to store information that can be accessed by a computing device.
  • computer-readable media does not include 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.

Abstract

A method and system for generating a random seed on a blockchain, and a consensus node. The method comprises: in a Sign-share phase of SBFT-like consensus, each consensus node signs, by using a private key share of the consensus node, on the basis of a threshold signature algorithm, an original packet containing an original transaction list specific value in the consensus, to generate a signature share, and adds the signature share into a Sign-share message and sends the message to at least one collection node; after collecting at least a threshold number of Sign-share messages, the collection node applies a recovery function corresponding to the private key share generated by the threshold signature algorithm to at least the threshold number of the signature shares to obtain a complete signature; the collection node broadcasts a full-commit-proof message containing the complete signature to the consensus node; and each consensus node receiving the full-commit-proof message obtains a random seed on the basis of the complete signature in the full-commit-proof message.

Description

一种区块链上产生随机数种子的方法、系统和共识节点A method, system and consensus node for generating random number seeds on the blockchain 技术领域Technical field
本说明书实施例属于区块链技术领域,尤其涉及一种区块链上产生随机数种子的方法、系统和共识节点。The embodiments of this specification belong to the field of blockchain technology, and particularly relate to a method, system and consensus node for generating random number seeds on a blockchain.
背景技术Background technique
区块链(Blockchain)是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链系统中按照时间顺序将数据区块以顺序相连的方式组合成链式数据结构,并以密码学方式保证的不可篡改和不可伪造的分布式账本。由于区块链具有去中心化、信息不可篡改、自治性等特性,区块链也受到人们越来越多的重视和应用。Blockchain is a new application model of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. In the blockchain system, 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.
发明内容Contents of the invention
本说明书的目的在于提供一种区块链上产生随机数种子的方法、系统和共识节点。The purpose of this specification is to provide a method, system and consensus node for generating random number seeds on the blockchain.
一种区块链上产生随机数种子的方法,包括:在类SBFT共识的Sign-share阶段,每一共识节点基于门限签名算法,采用自身私钥份额对包含本次共识中原始交易列表特有值的原始报文进行签名,生成签名份额,并将该签名份额加入到Sign-share消息中发送至至少一个收集节点;所述收集节点收集齐至少门限数量的Sign-share消息后将其中的至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复函数得到完整签名;所述收集节点广播包含该完整签名的full-commit-proof消息至共识节点;接收到full-commit-proof消息的每一共识节点基于其中的完整签名得到随机数种子。A method of generating random number seeds on the blockchain, including: in the Sign-share phase of the SBFT-like consensus, each consensus node uses its own private key share pair to contain the unique value of the original transaction list in this consensus based on the threshold signature algorithm. Sign the original message, generate a signature share, and add the signature share to the Sign-share message and send it to at least one collection node; after the collection node collects at least a threshold number of Sign-share messages, at least a threshold number of them The number of signature shares passes the recovery function corresponding to the private key share generated by the threshold signature algorithm to obtain a complete signature; the collection node broadcasts a full-commit-proof message containing the complete signature to the consensus node; receiving the full-commit- Each consensus node of the proof message obtains a random number seed based on the complete signature.
一种区块链上产生随机数种子的方法,包括:在类Hotstuff共识的对Pre-Commit/Commit投票阶段,每一共识节点基于门限签名算法,采用自身私钥份额对包含本次共识中原始交易列表特有值的原始报文进行签名,生成签名份额,并将该签名份额加入到广播的消息中发送至收集节点;所述收集节点收集齐至少门限数量的广播消息后将其中的至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复函数得到完整签名,广播包含该完整签名的消息至共识节点;接收到所述广播消息的每一共识节点基于其中的完整签名得到随机数种子。A method of generating random number seeds on the blockchain, including: in the Pre-Commit/Commit voting stage of the Hotstuff-like consensus, each consensus node uses its own private key share pair to contain the original in this consensus based on the threshold signature algorithm. Sign the original message with the unique value of the transaction list, generate a signature share, and add the signature share to the broadcast message and send it to the collection node; after the collection node collects at least a threshold number of broadcast messages, at least a threshold number of them The signature share is obtained through the recovery function corresponding to the private key share generated by the threshold signature algorithm to obtain a complete signature, and a message containing the complete signature is broadcast to the consensus node; each consensus node that receives the broadcast message is based on the complete signature therein Get the random number seed.
一种区块链上产生随机数种子的方法,应用于包括若干共识节点和收集节点的系统,包括:在交易执行前的最后一轮投票阶段,每一共识节点基于门限签名算法,采用自身私钥份额对包含本次共识中投票值的原始报文进行签名,生成签名份额,并将该签名份额发送至至少一个收集节点;所述收集节点将收集齐的至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复函数得到完整签名;所述收集节点广播该完整签名至共识节点;接收到该完整签名的每一共识节点基于其中的完整签名得到随机数种子。A method of generating random number seeds on the blockchain, applied to a system including several consensus nodes and collection nodes, including: in the last round of voting before transaction execution, each consensus node uses its own private signature algorithm based on the threshold signature algorithm. The key share signs the original message containing the voting value in this consensus, generates a signature share, and sends the signature share to at least one collection node; the collection node will collect at least a threshold number of signature shares through the The recovery function corresponding to the private key share generated by the threshold signature algorithm obtains a complete signature; the collection node broadcasts the complete signature to the consensus node; each consensus node that receives the complete signature obtains a random number seed based on the complete signature.
一种区块链上产生随机数种子的方法,应用于包括若干共识节点和收集节点的系统,包括:在交易执行前的最后一轮投票阶段,每一共识节点基于门限签名算法,采用自身私钥份额对包含本次共识中投票值的原始报文进行签名,生成签名份额,并将该签名份额发送至至少一个收集节点;所述收集节点将收集齐的至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复函数得到完整签名;所述收集节点广播该完整签名至共识节点;接收到该完整签名的每一共识节点基于其中的完整签名得到随机数种子。A method of generating random number seeds on the blockchain, applied to a system including several consensus nodes and collection nodes, including: in the last round of voting before transaction execution, each consensus node uses its own private signature algorithm based on the threshold signature algorithm. The key share signs the original message containing the voting value in this consensus, generates a signature share, and sends the signature share to at least one collection node; the collection node will collect at least a threshold number of signature shares through the The recovery function corresponding to the private key share generated by the threshold signature algorithm obtains a complete signature; the collection node broadcasts the complete signature to the consensus node; each consensus node that receives the complete signature obtains a random number seed based on the complete signature.
本说明书提供的上述方案,将门限签名算法与SBFT共识算法相结合,使得对应每个区块的原始交易列表在通过SBFT算法达成共识后,即可通过采用的门限签名算法得到完整签名,从而得到随机数种子,在执行本区块对应的原始交易列表中的交易的过程中,即可以采用随机数,这样,执行本区块的交易不需要额外的等待。The above scheme provided in this manual combines the threshold signature algorithm with the SBFT consensus algorithm, so that after the original transaction list corresponding to each block reaches consensus through the SBFT algorithm, the complete signature can be obtained through the adopted threshold signature algorithm, thus obtaining The random number seed can be used in the process of executing the transactions in the original transaction list corresponding to this block. In this way, no additional waiting is required to execute the transactions in this block.
本说明书提供的上述方案,基于门限签名算法的性质,各共识节点各自分别基于完整签名生成相同的随机数种子,从而,各个区块链节点各自分别执行相同区块中的相同 交易时,对于其中相同的随机数生成过程可以基于相同随机数种子产生相同的随机数,从而完成诸如摇号、发红包、盲盒之类的业务逻辑,或完成系统合约/区块链平台功能,并在各个节点上得到一致的执行结果。The above solution provided in this manual is based on the nature of the threshold signature algorithm. Each consensus node generates the same random number seed based on a complete signature. Therefore, when each blockchain node executes the same transaction in the same block, for which The same random number generation process can generate the same random number based on the same random number seed to complete business logic such as lottery, red envelope issuing, blind box, or complete system contract/blockchain platform functions, and on each node Get consistent execution results.
在基于投票的共识算法中,往往有最后一轮投票。最后一轮投票中的消息可以是由某一节点收集、聚合后再广播给其他节点,例如Hotsguff中的commit消息等,SBFT中的Sign-share消息。本说明书提供的方案适用于此类执行交易前的共识算法中具有最后一轮投票的情形,以在对待执行的交易列表达成共识的同时达成一致的随机数种子,满足一致性、即时性、不可预测、不可操控和不可撤销。In voting-based consensus algorithms, there is often a final round of voting. The messages in the last round of voting can be collected by a node, aggregated and then broadcast to other nodes, such as the commit message in Hotsguff and the Sign-share message in SBFT. The solution provided in this manual is applicable to the situation where there is a final round of voting in the consensus algorithm before executing the transaction, so as to reach a consensus on the transaction list to be executed and at the same time reach a consistent random number seed, which meets the requirements of consistency, immediacy, and impossibility. Predictable, uncontrollable and irrevocable.
附图说明Description of drawings
图1是一实施例中实用拜占庭容错算法常规阶段的示意图;FIG. 1 is a schematic diagram of the conventional phase of a practical Byzantine fault-tolerant algorithm in an embodiment;
图2是一实施例中实用拜占庭容错算法视图切换阶段的示意图;Figure 2 is a schematic diagram of the view switching stage of a practical Byzantine fault-tolerant algorithm in an embodiment;
图3是一实施例中共识节点都没有宕机情况下实用拜占庭容错算法常规阶段的示意图;Figure 3 is a schematic diagram of the normal phase of the practical Byzantine fault-tolerance algorithm in an embodiment when no consensus node is down;
图4是本说明书一实施例中区块链上产生随机数种子的流程图;Figure 4 is a flow chart for generating random number seeds on the blockchain in an embodiment of this specification;
图5是本说明书一实施例中区块头结构的示意图;Figure 5 is a schematic diagram of the block header structure in an embodiment of this specification;
图6是本说明书一实施例中区块链上产生随机数种子的流程图;Figure 6 is a flow chart for generating random number seeds on the blockchain in an embodiment of this specification;
图7是本说明书一实施例中SBFT算法的流程图;Figure 7 is a flow chart of the SBFT algorithm in an embodiment of this specification;
图8是本说明书一实施例中HotStuff算法的流程图。Figure 8 is a flow chart of the HotStuff algorithm in an embodiment of this specification.
具体实施方式Detailed ways
为了使本技术领域的人员更好地理解本说明书中的技术方案,下面将结合本说明书实施例中的附图,对本说明书实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本说明书一部分实施例,而不是全部的实施例。基于本说明书中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都应当属于本说明书保护的范围。In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this specification. Obviously, the described The embodiments are only some of the embodiments of this specification, but not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by those of ordinary skill in the art without creative efforts should fall within the scope of protection of this specification.
区块链1.0时代通常是指在2009年到2014年之间,区块链应用发展阶段,它们主要致力于解决货币和支付手段的去中心化问题。从2014年开始,开发者们越来越注重于解决前述方案在技术和扩展性方面的不足。2013年底,Vitalik Buterin将智能合约引入区块链,打开了区块链在货币领域以外的应用,从而开启了区块链2.0时代。The blockchain 1.0 era usually refers to the development stage of blockchain applications between 2009 and 2014. They are mainly dedicated to solving the decentralization problem of currency and payment methods. Since 2014, developers have increasingly focused on solving the technical and scalability deficiencies of the aforementioned solutions. At the end of 2013, Vitalik Buterin introduced smart contracts into the blockchain, opening up the application of blockchain beyond the currency field, thus opening the blockchain 2.0 era.
区块链系统中,不同参与方通过部署的节点(Node)可以建立一个分布式的区块链网络。利用链式区块结构构造的去中心化(或称为多中心化)的分布式账本,保存于分布式的区块链网络中的每个节点(或大多节点上,如共识节点)上。这样的区块链系统需要解决去中心化(或多中心化)的多个节点上各自的账本数据的一致性和正确性的问题。每个节点(或多个节点)上都运行着区块链程序,在一定容错需求的设计下,通过共识(consensus)机制保证所有忠诚节点具有相同的交易,从而保证所有忠诚节点对相同交易的执行结果一致,并将交易及执行结果打包生成区块。In the blockchain system, different participants can establish a distributed blockchain network through deployed nodes. A decentralized (or multi-centralized) distributed ledger constructed using a chain block structure is stored on each node (or on most nodes, such as consensus nodes) in the distributed blockchain network. Such 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 (or multiple nodes) runs a blockchain program. Under the design of certain fault-tolerance requirements, the consensus mechanism is used to ensure that all loyal nodes have the same transactions, thereby ensuring that all loyal nodes have the same transactions. The execution results are consistent, and the transaction and execution results are packaged to generate blocks.
智能合约是一种基于规定触发规则的,可自动执行的计算机合约,也可以看作是传统合约的数字版本。智能合约这一概念最早由跨领域法律学者、密码学研究工作者尼克·萨博(Nick Szabo)在1994年提出。这项技术曾一度因为缺乏可编程数字系统和相关技术而没有被用于实际产业中,直到区块链技术的出现为其提供了可靠的执行环境。由于区块链技术采用块链式账本,产生的数据不可篡改或者删除,且整个账本将不断新增账本数据,从而保证了历史数据的可追溯;同时,去中心化的运行机制避免了中心化因素的影响。基于区块链技术的智能合约不仅可以发挥智能合约在成本、效率方面的优势,而且可以避免恶意行为对合约正常执行的干扰。将智能合约以数字化的形式写入区块链中,由区块链技术的特性保障存储、读取、执行整个过程透明可跟踪、不可篡改。A smart contract is an automatically executed computer contract based on specified triggering rules. It can also be regarded as a digital version of a traditional contract. The concept of smart contracts was first proposed in 1994 by Nick Szabo, a cross-field legal scholar and cryptography researcher. This technology was once not used in actual industries due to the lack of programmable digital systems and related technologies, until the emergence of blockchain technology provided a reliable execution environment. Since blockchain technology uses a blockchain ledger, the data generated cannot be tampered with or deleted, and the entire ledger will continuously add ledger data, thus ensuring the traceability of historical data; at the same time, the decentralized operating mechanism avoids centralization influence of factors. Smart contracts based on blockchain technology can not only take advantage of smart contracts in terms of cost and efficiency, but also avoid malicious behavior from interfering with the normal execution of the contract. Smart contracts are written into the blockchain in digital form, and the characteristics of the blockchain technology ensure that the entire process of storage, reading, and execution is transparent, traceable, and cannot be tampered with.
区块链发展及应用多样化。一些业务逻辑被编辑为智能合约并在区块链平台上执行。具体的,这些包含业务逻辑的智能合约可以运行于区块链网络中的每个节点(或大多节 点上,如共识节点)上。相对于中心化的业务逻辑执行环境所带来的单点故障导致整个中心化系统不可用的问题,区块链环境中执行智能合约也被称为“世界计算机”,这是因为分布式的区块链网络中有较多节点各自独立执行智能合约。如前所述,这些不同节点上执行相同逻辑的智能合约,需要获得相同的执行结果,从而保证这些节点中的多数保存的账本是一致的。Blockchain development and application diversification. Some business logic is edited into smart contracts and executed on the blockchain platform. Specifically, these smart contracts containing business logic can run on every node (or on most nodes, such as consensus nodes) in the blockchain network. Compared with the problem of single point of failure caused by the centralized business logic execution environment, which makes the entire centralized system unavailable, the execution of smart contracts in the blockchain environment is also called the "world computer". This is because of the distributed area. There are many nodes in the blockchain network that execute smart contracts independently. As mentioned before, smart contracts that execute the same logic on these different nodes need to obtain the same execution results to ensure that the ledgers saved by most of these nodes are consistent.
一些业务逻辑中,可能需要基于随机数产生一个结果,例如实现抽奖的业务逻辑,实现摇号的业务逻辑,或者实现一定范围内随机金额发红包或盲盒等的业务逻辑,这一般需要在智能合约中包含产生随机数的程序。再例如,一些系统合约中,可能需要实现对主节点的投票或对小规模委员会的投票,这个投票逻辑中可能采用随机的方式或者是用到随机数。如前所述,分布式的区块链网络中有一个显著特点,是为了保证分布式的区块链网络整体可用而需要多数节点中的账本是一致的,这也就需要多数节点中的智能合约产生的随机数是一致的。In some business logic, it may be necessary to generate a result based on random numbers, such as to implement the business logic of lottery, to implement the business logic of lottery, or to implement the business logic of issuing red envelopes or blind boxes with random amounts within a certain range. This generally needs to be done in a smart contract. Contains a program for generating random numbers. For another example, some system contracts may need to implement voting for master nodes or small-scale committees. This voting logic may use a random method or use random numbers. As mentioned before, a significant feature of the distributed blockchain network is that in order to ensure the overall availability of the distributed blockchain network, the ledgers in most nodes need to be consistent, which also requires intelligence in most nodes. The random numbers generated by the contract are consistent.
前述提到,每个节点(或多个节点)上都运行着区块链程序,在一定容错需求的设计下,通过共识机制保证所有忠诚节点具有相同的交易,从而保证所有忠诚节点对相同交易的执行结果一致,并将交易及执行结果打包生成区块。当前主流的共识机制包括:工作量证明(Proof of Work,POW)、股权证明(Proof of Stake,POS)、委任权益证明(Delegated Proof of Stake,DPOS)、实用拜占庭容错(Practical Byzantine Fault Tolerance,PBFT)算法,蜜獾拜占庭容错(HoneyBadgerBFT,也简称为HBBFT)算法等。As mentioned above, each node (or multiple nodes) runs a blockchain program. Under the design of certain fault-tolerance requirements, the consensus mechanism ensures that all loyal nodes have the same transactions, thereby ensuring that all loyal nodes have the same transactions. The execution results are consistent, and the transactions and execution results are packaged to generate blocks. The current mainstream consensus mechanisms include: Proof of Work (POW), Proof of Stake (POS), Delegated Proof of Stake (DPOS), Practical Byzantine Fault Tolerance (PBFT) ) algorithm, Honey Badger Byzantine Fault Tolerance (HoneyBadgerBFT, also referred to as HBBFT) algorithm, etc.
以PBFT为例,该算法是Miguel Castro(卡斯特罗)和Barbara Liskov(利斯科夫)在1999年提出来的,解决了原始拜占庭容错算法效率不高的问题,将算法复杂度由指数级降低到多项式级,使得拜占庭容错算法在实际系统应用中变得可行。该论文发表在1999年的操作系统设计与实现国际会议上(OSDI99)。PBFT算法中,所有的副本(replica)在一个被称为视图(View)的轮换过程(succession of configuration)中运行。在某个视图中,一个副本作为主节点(primary),其他的副本作为备份节点(backups)。视图是连续编号的整数。主节点可以由公式p=v mod|R|计算得到,这里v是视图编号,p是副本编号,|R|是副本集合的个数。该算法中假设,当最多存在f个副本(即节点)失效时,如果存在总数为至少3f+1个副本,就能保证在异步系统中提供安全性和活性。为了能够确保所有副本的数据一致性要求和容错要求而需要的一定数量副本的集合,一般是分布式系统中的大多数节点构成的集合,构成大多数(Quorum)。例如在总节点数n为3f+1(n=3f+2或n=3f的情况一般不会对容错效果带来提升)的情况下,Quorum为2f+1。这样,对于包含四个节点的分布式系统,任意三个节点可以构成一个Quorum。Take PBFT as an example. This algorithm was proposed by Miguel Castro (Castro) and Barbara Liskov (Liskov) in 1999. It solved the problem of inefficiency of the original Byzantine fault-tolerant algorithm and reduced the algorithm complexity from exponential to The level is reduced to the polynomial level, making the Byzantine fault-tolerant algorithm feasible in practical system applications. The paper was published at the 1999 International Conference on Operating System Design and Implementation (OSDI99). In the PBFT algorithm, all replicas run in a rotation process (succession of configuration) called views. In a certain view, one replica serves as the primary node and the other replicas serve as backups. Views are consecutively numbered integers. The master node can be calculated by the formula p=v mod|R|, where v is the view number, p is the replica number, and |R| is the number of replica sets. It is assumed in this algorithm that when at most f replicas (i.e. nodes) fail, if the total number of replicas is at least 3f+1, security and liveness can be guaranteed in an asynchronous system. A set of a certain number of replicas required to ensure the data consistency and fault tolerance requirements of all replicas is generally a set composed of most nodes in a distributed system, forming a majority (Quorum). For example, when the total number of nodes n is 3f+1 (n=3f+2 or n=3f generally does not improve the fault tolerance effect), the Quorum is 2f+1. In this way, for a distributed system containing four nodes, any three nodes can form a Quorum.
PBFT包括Normal Case Phase和View Change Phase两个过程,图1为Normal Case Phase(常规阶段)过程的流程图。Normal Case Phase中主要包括PRE-PREPARE(预准备)、PREPARE(准备)和COMMIT(提交)三个阶段,其中3号节点例如可以表示宕机的节点(图1中以×表示)。当主节点失效的时候(图2中以×表示,如更换视图前主节点Primary也就是Replica 0(副本0)失效)就需要启动视图更换(view change)过程,从而在系统存在故障时进行调整,更换新的主节点(如更换视图后Replica 1为主节点Primary)。图2为View Change Phase(视图切换)的示意图。如果主节点掉线或者作恶而不广播客户端的请求等,客户端可以设置超时机制。如果超时的话,客户端可以向所有副本节点广播请求消息。副本节点检测出主节点作恶或者下线后,也可以发起View Change协议阶段,以更换主节点(经常简称为“换主”)。此外,也可能由于主节点发起错误的提议导致PRE-PREPARE、PREPARE和COMMIT三阶段共识过程失败,或者,PREPARE、COMMIT阶段可能达不成Quorum数量(如3f+1个节点中的2f+1个,也称为法定数量)的一致,也都无法完成共识。这些情况下也可能发起View Change协议阶段,以更换主节点。PBFT includes two processes: Normal Case Phase and View Change Phase. Figure 1 is the flow chart of the Normal Case Phase (normal phase) process. Normal Case Phase mainly includes three stages: PRE-PREPARE (preparation), PREPARE (preparation) and COMMIT (commit). Node 3, for example, can represent a downed node (indicated by × in Figure 1). When the master node fails (indicated by × in Figure 2, for example, the master node Primary, that is, Replica 0 (replica 0) fails before changing the view), the view change process needs to be started to make adjustments when the system fails. Replace a new primary node (for example, Replica 1 is the primary node after changing the view). Figure 2 is a schematic diagram of View Change Phase. If the master node goes offline or does evil and does not broadcast the client's request, etc., the client can set a timeout mechanism. If the timeout occurs, the client can broadcast the request message to all replica nodes. After the replica node detects that the master node has done something evil or gone offline, it can also initiate the View Change protocol phase to replace the master node (often referred to as "switching the master"). In addition, it may also be due to the master node initiating an incorrect proposal that the three-phase consensus process of PRE-PREPARE, PREPARE and COMMIT may fail, or the PREPARE and COMMIT phases may not reach the number of Quorum (such as 2f+1 of 3f+1 nodes, Also known as a quorum), consensus cannot be achieved. In these cases, the View Change protocol phase may also be initiated to replace the master node.
在正常情况下,即共识节点都没有宕机,共识消息也能在一定时间内到达对方,即 不会发生换主的情况下,PBFT中的Normal Case Phase过程可以如图3所示,该图仍然以4个共识节点为例。Under normal circumstances, that is, the consensus nodes are not down, and the consensus message can reach the other party within a certain period of time, that is, when there is no change of owner, the Normal Case Phase process in PBFT can be shown in Figure 3. This figure Still taking 4 consensus nodes as an example.
在第r-1轮的Normal Case Phase过程,0号节点作为主节点收集一定数量的待共识交易(或读写集之类,后续以交易为例作说明)后,发起预准备过程(即前述的PRE-PREPARE,也简称为PP阶段),进而节点1、2、3进入准备过程(即前述的PREPARE,也简称为P阶段),之后节点0、1、2、3进入提交过程(即前述的COMMIT,也简称为C阶段)。PP阶段、P阶段、C阶段一般也合称为PBFT的三阶段。这样,在正常情况下就完成了第r-1轮PBFT的三阶段过程,也就完成了第m-1个区块对应的交易数据的共识,同时也产生了这个区块的区块号等信息。从而,各个共识节点可以各自以共识的交易数据为基础,按照共识的交易数据的顺序和内容,顺序执行这些交易,进而生成世界状态和收据。具体的,各个节点各自在本地基于共识的交易数据可以构建Merkle树(包括MPT树等树形结构,MPT全称为Merkle Patricia Tree,是结合了Merkle Tree(默克尔树)和Patricia Tree(压缩前缀树,一种更节省空间的Trie树,字典树)的一种树形结构)并生成这颗Merkle树的树根的hash(也称为交易根hash),类似的,可以基于世界状态数据构建Merkle树并生成这颗Merkle树的树根的hash(也称为状态根hash),可以基于收据数据构建Merkle树并生成这颗Merkle树的树根的hash(也称为收据根hash)。各个节点各自在本地生成这三个根hash后,可以在本地生成第m-1个区块。该第m-1个区块的区块头中可以包括前述区块号、交易根hash、状态根hash、收据根hash等信息,区块体可以包括交易数据集合、世界状态集合和收据集合。这样,就生成了第m-1个区块。In the Normal Case Phase process of the r-1 round, node 0 serves as the master node and collects a certain number of transactions to be agreed upon (or read and write sets, etc., which will be explained later using transactions as examples), and then initiates the pre-preparation process (i.e. the aforementioned PRE-PREPARE, also referred to as the PP phase), and then nodes 1, 2, and 3 enter the preparation process (the aforementioned PREPARE, also referred to as the P phase), and then nodes 0, 1, 2, and 3 enter the submission process (the aforementioned COMMIT, also referred to as phase C). The PP stage, P stage, and C stage are generally collectively referred to as the three stages of PBFT. In this way, under normal circumstances, the three-stage process of the r-1 round of PBFT is completed, and the consensus of the transaction data corresponding to the m-1 block is completed, and the block number of this block is also generated. information. Therefore, each consensus node can execute these transactions sequentially based on the consensus transaction data and in accordance with the order and content of the consensus transaction data, thereby generating world status and receipts. Specifically, each node can build a Merkle tree (including tree structures such as MPT trees) based on local consensus transaction data. MPT is called Merkle Patricia Tree, which is a combination of Merkle Tree (Merkle Tree) and Patricia Tree (compression prefix). tree, a more space-saving Trie tree, a tree structure of a dictionary tree) and generates the hash of the root of this Merkle tree (also called the transaction root hash). Similarly, it can be constructed based on world state data Merkle tree and generate the hash of the root of the Merkle tree (also called the state root hash). You can build the Merkle tree based on the receipt data and generate the hash of the root of the Merkle tree (also called the receipt root hash). After each node generates these three root hashes locally, it can generate the m-1th block locally. The block header of the m-1th block may include the aforementioned block number, transaction root hash, status root hash, receipt root hash and other information. The block body may include a transaction data set, a world state set and a receipt set. In this way, the m-1th block is generated.
在第m个区块的生成过程中,将重复PBFT中的三阶段过程。如图3中,对于第m个区块,0号节点作为主节点收集一定数量的待共识交易后,发起PP过程,进而节点1、2、3进入P过程,之后节点0、1、2、3进入C过程。这样,在正常情况下就完成了第r轮PBFT的三阶段过程,也就完成了第m个区块对应的交易数据的共识,同时也产生了这个区块的区块号等信息。各个节点可以各自以共识的交易数据为基础,按照共识的交易数据的顺序和内容,顺序执行这些交易,进而生成世界状态和收据。各个节点各自在本地生成如前所述的三个根hash后,可以在本地生成第m个区块。该第m个区块的区块头中可以包括前述区块号、交易根hash、状态根hash、收据根hash等信息,区块体可以包括交易数据集合、世界状态集合和收据集合。这样,就生成了第m个区块。类似的,生成第m+1个区块,在这个过程中包含如图3中所示的第r+1轮PBFT的三阶段过程。During the generation of the m-th block, the three-stage process in PBFT will be repeated. As shown in Figure 3, for the m-th block, node 0 serves as the master node and after collecting a certain number of transactions to be agreed upon, initiates the PP process, and then nodes 1, 2, and 3 enter the P process, and then nodes 0, 1, 2, 3 Enter the C process. In this way, under normal circumstances, the three-stage process of the r-th round of PBFT is completed, and the consensus of the transaction data corresponding to the m-th block is completed. At the same time, the block number and other information of this block are also generated. Each node can execute these transactions sequentially based on the consensus transaction data and in accordance with the order and content of the consensus transaction data, thereby generating world status and receipts. After each node generates the three root hashes locally, it can generate the m-th block locally. The block header of the m-th block may include the aforementioned block number, transaction root hash, status root hash, receipt root hash and other information. The block body may include a transaction data set, a world state set and a receipt set. In this way, the m-th block is generated. Similarly, the m+1th block is generated, and this process includes the three-stage process of the r+1th round of PBFT as shown in Figure 3.
可见,常规产生区块的情况下,每个共识节点在每个区块的产生过程中包含一次PBFT的Normal Case Phase过程。随着区块的不断产生,每个共识节点将会重复这个共识过程,图3中仅示例性的示出了第r-1、r和r+1轮共识过程。其中,有的共识节点作为PBFT中的主节点的角色,有的共识节点作为PBFT中的备份节点的角色。It can be seen that in the case of regular block generation, each consensus node includes a Normal Case Phase process of PBFT in the generation process of each block. As blocks continue to be generated, each consensus node will repeat this consensus process. Figure 3 only illustrates the r-1, r, and r+1 rounds of consensus processes. Among them, some consensus nodes serve as the main node in PBFT, and some consensus nodes serve as the backup node in PBFT.
在一次共识过程中,即一次PBFT的三阶段过程中,可以包括:a110:(PRE-PREPARE预准备阶段)主节点0收集一定数量的待共识交易后,将待共识交易排序并打包为消息m(也称为原始交易列表),发送pre-prepare请求至备份节点1、2、3,pre-prepare请求中包括消息m;a120:(PREPARE准备阶段)节点1、2、3收到pre-prepare请求后,如果检查消息m合法,则分别通过prepare消息广播其收到的消息m的hash值(广播的内容一般不包括消息m本身,因为消息m包括了若干个原始交易请求,体积一般比较大)。具体的,节点1将prepare消息扩散至节点0、2、3,节点2将prepare消息扩散至节点0、1、3,节点3将prepare消息扩散至节点0、1、2。相应的,每一节点还接收其他节点广播的prepare消息。每一节点将自己发送的prepare消息(其中包含消息m的hash值,代表自己的认可)和收到的prepare消息(其中包含消息m的hash值,代表其它节点的认可)都添加到本地日志(Log)中。如果某一节点收集齐来自不同节 点的至少Quorum个数量的合法的pp消息/p消息后(包括自身发出的pre-prepare、prepare消息,和收到的prepare消息),转变成prepared状态。In a consensus process, that is, a three-stage process of PBFT, it can include: a110: (PRE-PREPARE preparatory phase) After master node 0 collects a certain number of transactions to be agreed upon, it sorts and packages the transactions to be agreed into messages m (also called the original transaction list), send pre-prepare requests to backup nodes 1, 2, and 3. The pre-prepare requests include message m; a120: (PREPARE preparation phase) Nodes 1, 2, and 3 receive pre-prepare After the request, if the message m is checked to be legal, the hash value of the received message m will be broadcast through the prepare message (the content of the broadcast generally does not include the message m itself, because the message m includes several original transaction requests, and the volume is generally relatively large. ). Specifically, node 1 diffuses the prepare message to nodes 0, 2, and 3, node 2 diffuses the prepare message to nodes 0, 1, and 3, and node 3 diffuses the prepare message to nodes 0, 1, and 2. Correspondingly, each node also receives prepare messages broadcast by other nodes. Each node adds the prepare message it sends (which contains the hash value of message m, representing its own approval) and the prepared message it receives (which contains the hash value of message m, which represents the approval of other nodes) to the local log ( Log). If a node collects at least Quorum number of legal pp messages/p messages from different nodes (including pre-prepare, prepare messages sent by itself, and prepare messages received), it changes to the prepared state.
a130:(COMMIT提交阶段)参与共识的节点中的每一个在进入prepared状态后,发送commit消息给其他的共识节点,并将自己发送的commit消息添加到本地Log中(代表自己的认可),而且,每一节点还接收其他节点广播的commit消息。某一节点如果收集齐来自不同节点的至少Quorum数量的合法的commit消息后,添加到本地Log中(这时加上自己添加到本地Log中的共有Quorum个),转变成committed状态。a130: (COMMIT submission phase) After entering the prepared state, each node participating in the consensus sends a commit message to other consensus nodes, 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. If a node collects legal commit messages of at least Quorum from different nodes and adds them to the local Log (plus the total Quorum it added to the local Log), it changes to the committed state.
a140:转变为committed状态的节点将消息m输出为本轮的共识结果。a140: The node that changes to the committed state outputs message m as the consensus result of this round.
消息m中包含哪些交易,以及所包含的交易的前后顺序,一般是由主节点在a110中决定的。确定包含哪些交易,包含的交易的前后顺序,这两个是共识机制的重要内容。区块链网络中可能接收到很多交易请求,a110中主节点打包哪些交易,决定了哪些交易会被区块链网络处理,交易的执行结果会上链。即使一组相同的交易,前后执行顺序不同会导致最终结果不同,而这影响到各个节点上的账本是否一致。Which transactions are included in the message m, and the order of the included transactions, are generally determined by the master node in a110. Determining which transactions are included and the sequence of included transactions are two important aspects of the consensus mechanism. The blockchain network may receive many transaction requests. Which transactions are packaged by the master node in a110 determines which transactions will be processed by the blockchain network, and the execution results of the transactions will be uploaded to the chain. Even for the same set of transactions, different execution sequences will lead to different final results, which affects whether the ledgers on each node are consistent.
本说明书提供一种区块链上产生随机数种子的方法,可以结合上述PBFT三阶段的过程实现。如图4所示,包括:S110:在PBFT的commit阶段,每一共识节点基于门限签名算法,采用自身私钥份额对包含本次共识中原始交易列表特有值的原始报文进行签名,生成签名份额,并将该签名份额加入到广播的commit消息中。This specification provides a method for generating random number seeds on the blockchain, which can be implemented in conjunction with the above three-stage PBFT process. As shown in Figure 4, it includes: S110: In the commit phase of PBFT, each consensus 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, and generates a signature. share and add the signed share to the broadcast commit message.
门限签名是普通数字签名的一个重要分支,是门限秘密共享技术和数字签名的一种结合。传统的签名方案,可以采用RSA算法实现。RSA算法是一种非对称加密算法,由罗纳德·李维斯特(Ron Rivest)、阿迪·萨莫尔(Adi Shamir)和伦纳德·阿德曼(Leonard Adleman)于1977年一起提出。RSA算法可以在不直接传递密钥的情况下完成解密,这能够确保信息的安全性的同时,避免直接传递密钥所造成的信息被破解的风险。RSA中包括私钥和公钥,这个私钥和公钥是成对。一个信息由公钥加密后,只能由对应的私钥解密;类似的,一个信息由私钥加密后,只能由对应的公钥解密。之所以具有这样的性质,是因为成对的私钥和公钥之间在数学原理上具有相关性,例如一种底层原理是根据数论,寻求两个大素数比较简单,而将它们的乘积进行因式分解却极其困难,因此可以将乘积公开作为加密密钥,从而可以保证安全性。私钥通常要严格保密,不能泄露,而公钥是公开的(且可以由多人持有)。由于私钥是由持有者严格保密的,其他人在无法获得私钥的前提下,就无法伪造私钥持有者的签名。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. After a piece of information is encrypted by a public key, it can only be decrypted by the corresponding private key; similarly, after a piece of information is encrypted by a private key, it can only be decrypted by the corresponding public key. The reason for this property is that there is a correlation between pairs of private keys and public keys in mathematical principles. For example, an underlying principle is that according to number theory, it is relatively simple to find two large prime numbers, and their product is Factoring is extremely difficult, so security can be guaranteed by exposing the product as an encryption key. The private key is usually kept strictly confidential and cannot be leaked, while the public key is public (and can be held by multiple people). Since the private key is kept strictly confidential by the holder, others cannot forge the signature of the private key holder without obtaining the private key.
RSA签名机制,可以保证报文传递过程中的完整性。例如节点A需要将报文传送至节点B,且中间可能经过若干个节点的中转。则A可以采用RSA签名机制,将报文连同签名一并经由若干个中间节点传送至B,而B对签名的验证可以确信收到的报文是A发出的,且在传送过程中没有经过篡改。一种RSA签名的过程如下:b1:A生成一对密钥(公钥和私钥),私钥不公开,自己保留。公钥为公开的,任何人可以获取。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: b1: 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用自己的私钥对原始报文的hash值进行签名,并将原始报文和签名结果一并传递给B。如前所述,这个传递过程可能经过若干个中间节点的转发。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.
hash算法也称为散列算法,可以将原始内容映射为一个固定长度的序列,这个序列即为hash值。一般有sha256,sha384,sha512等hash算法。sha256的结果是256个bits,可以表示2的256次方个原始内容。类似的,sha384的结果是384bits,sha512的结果是512bits。这些hash算法,可以针对内容较多体积较大的原始内容,因而hash值相对来说可以比原始内容小很多。好的hash算法可以确保不同原始内容有极大概率映射为不同的hash值,同时这种映射是杂乱无章的,即无法预测不同的原始内容得到的hash值的关联性;而且也是抗逆运算的,即无法由hash值倒推得到原始内容。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. Generally, there are 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. Similarly, the result of sha384 is 384bits, and the result of 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.
原始报文可能内容较多,体积较大,采用私钥直接对原始报文进行签名计算可能比较费时和耗费算力。因此,可以将原始报文采用一种hash算法计算到一个hash值,这 样这个hash值长度较小,又可以完全代表原始报文。进而,采用私钥对这个hash值进行加密计算,得到的结果即为签名。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.
b3:B收到消息后,采用A的公钥进行验签。b3: After receiving the message, B uses A’s public key to verify the signature.
一方面,B可以采用与A相同的hash算法来计算原始报文的hash值,计为hash1;另一方面,B采用A的公钥对签名结果进行解密计算,得到hash2。如果hash1与hash2相同,则可以确定收到的原始报文是A发出的,且在传送过程中没有被篡改过。On the one hand, 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.
门限签名方案,首先是包括1个总公钥和n个公私钥对。每个公私钥对中的1个公钥称为公钥份额,每个公私钥对中的1个私钥称为私钥份额。其次,存在与这个总公钥和n个公私钥对对应的恢复函数,该恢复函数可以将至少门限数量个不同私钥份额签名的签名份额恢复成一个完整签名,这个生成的完整签名也可以由所述的那1个总公钥来验证正确性。而任意少于门限数量的签名份额则无法恢复生成该完整签名。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. Secondly, there is a recovery function corresponding to this total public key and n public-private key pairs. 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.
除了可以采用基于RSA的门限签名机制外,还可以采用基于ECDSA(Elliptic Curve Digital Signature Algorithm,椭圆曲线数字签名算法)的门限签名机制、基于Schnorr(一种基于离散对数难题的知识证明机制)的门限签名机制、基于BLS(Boneh-Lynn-Shacham Signature)的门限签名机制等。In addition to the threshold signature mechanism based on RSA, you can also use the threshold signature mechanism based on ECDSA (Elliptic Curve Digital Signature Algorithm, Elliptic Curve Digital Signature Algorithm), based on Schnorr (a knowledge proof mechanism based on discrete logarithm problems) Threshold signature mechanism, threshold signature mechanism based on BLS (Boneh-Lynn-Shacham Signature), etc.
需要说明的是,在区块链中所采用的门限签名,私钥份额的个数可以等于共识节点的个数,恢复函数产生完整签名的最少签名份额的个数(即门限数量)可以等于PBFT算法中的quorum。当然,私钥的个数也可以不等于共识节点的个数,恢复函数产生完整签名的最少签名份额的个数可以不等于PBFT算法中的quorum。以下以前者为例说明。It should be noted that for the threshold signature used in the blockchain, the number of private key shares can be equal to the number of consensus nodes, and the minimum number of signature shares (ie, the threshold number) required by the recovery function to generate a complete signature can be equal to PBFT. quorum in algorithms. Of course, the number of private keys may not be equal to the number of consensus nodes, 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.
所述1个总公钥和n个公私钥对,可以由一个中心化的dealer生成,并分发给n个区块链共识节点,这种属于中心化的密钥分配方式。这样,结合共识算法,n个私钥份额可以是每个区块链共识节点持有其中一个。同时,每个区块链共识节点可以持有相同的1个总公钥。此外,还存在去中心化的密钥分配方式,即取消dealer,而是由n个共识节点通过密钥协商过程协商得到n个公私钥对和1个总公钥,仍然是每个共识节点单独持有n个私钥份额中的一个,且各共识节点持有同一个总公钥。The 1 total public key and n public-private key pairs can be generated by a centralized dealer and distributed to n blockchain consensus nodes. This is a centralized key distribution method. In this way, combined with the consensus algorithm, n private key shares can be held by each blockchain consensus node. At the same time, each blockchain consensus node can hold the same 1 total public key. In addition, there is a decentralized key distribution method, that is, the dealer is cancelled, but n consensus nodes negotiate to obtain n public-private key pairs and 1 total public key through the key agreement process. Each consensus node is still independent Holds one of n private key shares, and each consensus node holds the same total public key.
采用门限签名算法,每一共识节点都可以采用自身特有的那一份私钥(如包含4个节点且采用PBFT作为共识算法的区块链网络中,节点0、节点1、节点2、节点3采用门限签名算法所持有的私钥份额分别是sk0,sk1,sk2,sk3,下标数字可以表示节点的编号)对包含本次共识中原始交易列表特有值的原始报文进行签名,得到签名结果。这里,原始交易列表的特有值可以作为签名所针对的原始报文。Using the threshold signature algorithm, each consensus 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 obtain the signature result. Here, the unique value of the original transaction list can be used as the original message for the signature.
原始交易列表的特有值,可以包括原始交易列表本身或者原始交易列表的hash值。一般来说,不同的交易,交易内容是不同的,这样,不同的原始交易列表或其hash值一般都不相同。因此,原始报文中可以至少包括原始交易列表或其hash值,这样由hash函数的性质,足以区分不同区块对应的共识过程完毕后所生成的随机数种子。The unique value of the original transaction list can include the original transaction list itself or the hash value of the original transaction list. Generally speaking, different transactions have different transaction contents, so different original transaction lists or their hash values are generally different. Therefore, 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.
考虑到共识过程中会为本次共识的内容生成一个编号,如果共识完成,生成的编号可以作为本次共识所对应的区块的区块号,因此,区块号(也就是编号)也可以作为原始报文中的内容。不论第N+1个区块中所包含的原始交易列表与第N个区块中所包含的原始交易表是否相同,区块生成是顺序的,可以体现为后一区块的区块号是前一区块的区块号+1。因此,区块号作为原始报文中的内容,即使第N+1个区块中所包含的原始交易列表与第N个区块中所包含的原始交易表相同,仍然由各个节点采用自身私钥基于(原始交易列表+区块号)得到不同的签名,主节点仍然无法与其它节点的签名,从而无法预测第N+1号区块的完整签名,因此主节点无法使用第N号块已公开的随机数种子来预测第N+1号块的随机数种子,达到了不可预测的目的。与编号类似的,时间戳也是一个区块特有的,且后一区块的时间戳在前一区块之后。因此,时间戳也可以作为原始报文中的内容。Considering that a number will be generated for the content of this consensus during the consensus process, if the consensus is completed, the generated number can be used as the block number of the block corresponding to this consensus. Therefore, the block number (that is, the number) can also be as the content in the original message. Regardless of whether the original transaction list contained in the N+1th block is the same as the original transaction list contained in the Nth block, 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.
除了原始交易列表的特有值之外,签名的对象还可以加入其它内容,例如上一区块 中产生的随机数种子,即原始报文中还可以包括上一区块中产生的随机数种子。前述a140执行之后,如前所述,各个节点可以各自以共识的交易数据为基础,生成第m个区块。由于第m个区块是各个节点在本地各自独立生成的,因此,如果区块链节点之间没有相互广播自身生成的上一区块的hash值并比对,各个节点可能都无法确定区块链网络中生成的第m个区块是否相同,或者从区块链系统整体可用的角度来说是否有至少quorum数量的共识节点上生成的第m个区块是相同的。经过本说明书中随机数种子的生成过程,相同区块的随机数种子应当是相同的,不同区块中的随机数种子应当是不同的,因此可以将随机数种子加入到原始报文中。这样,如果各个节点各自生成的第m个区块对应的随机数种子有所不同,根据门限签名算法的性质,可能无法在第m+1号区块的产生随机数种子的过程中通过恢复函数方法得出完整签名,从而可以根据本说明书的方案帮助共识节点确认上一区块是否一致。也可采用上一区块的hash值来代替上一区块的随机数种子,由于一个区块的hash值一般是唯一的,因此也可以帮助共识节点确认上一区块是否一致。In addition to the unique values of the original transaction list, 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. After the aforementioned a140 is executed, as mentioned above, 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. Whether the m-th block generated in the chain network is the same, or whether the m-th block generated on at least a quorum number of consensus nodes is the same from the perspective of the overall availability of the blockchain system. After the random number seed generation process in this manual, 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 consensus node confirm whether the previous block is consistent according to the scheme of this manual. 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 consensus node confirm whether the previous block is consistent.
采用自身私钥份额对包含本次共识中原始交易列表特有值的原始报文进行签名,这个原始报文里可以包括的原始交易列表的特有值,可以是原始交易列表。一般在PBFT的PP阶段已经广播过原始交易列表,且C阶段广播的commit消息较小的话更利于传播及节省带宽,因此原始交易列表特有值可以是原始交易列表的hash值。Use your own private key share to sign the original message containing the unique value of the original transaction list in this consensus. The unique value of the original transaction list that can be included in this original message can be the original transaction list. Generally, 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.
对于原始报文包括多个内容,例如包括原始交易列表hash值、区块号、上一区块中产生的随机数种子的情况下,可以先计算原始报文的hash值,进而采用私钥份额对该原始报文hash值进行签名,得到签名结果。If 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.
对原始报文进行签名,生成的签名结果和原始报文可以一并加入到广播的commit消息中。这样,在commit阶段,参与共识的节点中的每一个都发送commit消息给其他的共识节点,并将自己发送的commit消息添加到本地Log中(代表自己的认可),而且,每一节点还接收其他节点广播的commit消息。Sign the original message, and the generated signature result and the original message can be added to the broadcast commit message. In this way, during the commit phase, each node participating in the consensus sends a commit message to other consensus nodes, 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.
S120:每一共识节点收集齐至少门限数量的commit消息后将所述至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复方法得到完整签名。S120: After each consensus node collects at least a threshold number of commit messages, the signature share of at least the threshold number is obtained through the recovery method corresponding to the private key share generated by the threshold signature algorithm to obtain a complete signature.
如前所述,门限签名算法在应用中,可以产生1个总公钥和n个公私钥对,并可以产生该n个公私钥对所对应的恢复函数。前述提到,该恢复函数可以将验证正确的至少门限数量个签名恢复生成一个完整签名,门限签名算法的门限值即门限数量可以设为w。当然,正确的签名多于w个时也可以通过该恢复函数生成一个完整签名。也就是说,正确的签名大于等于门限数量w时,都可以通过该恢复函数生成一个完整签名,且生成的这个完整签名是确定的,不会因为输入的正确签名的个数而发生变化(只要大于等于w)。As mentioned before, in application, 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. Of course, when there are more than w correct signatures, 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).
这个生成的完整签名可以由所述的那1个总公钥来验证正确性。这样,任何持有这个总公钥的节点或其它设备都可以采用该总公钥来验证这个完整签名的正确性。例如,节点1生成完整签名后,可以采用总公钥验证该完整签名的完整性,例如采用总公钥对完整签名进行密码学运算得到第一hash,并对原始报文进行hash运算得到第二hash,如果第一hash与第二hash一致则可以确定该完整签名的完整性。所述完整性包括该完整签名是针对所述原始报文的,且该原始报文没有经过篡改。再例如,节点1生成完整签名后,可以将该完整签名、总公钥和原始报文发送至区块链以外的一个设备,该设备可以采用所述总公钥和原始报文验证这个完整签名的正确性,原理同上不再赘述。这里的报文原文仍然是前述的包含本次共识中原始交易列表特有值的内容,或还包括当前区块的区块号和/或时间戳和/或上一区块中产生的随机数种子。The complete signature generated can be verified for correctness by the total public key. In this way, any node or other device holding the total public key can use the total public key to verify the correctness of the complete signature. For example, after node 1 generates a complete signature, the total public key can be used to verify the integrity of the complete signature. For example, 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. For another example, 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. .
此外,也可以是每一共识节点收集每一commit消息后,采用对应的公钥份额对所述接收到的commit消息中的签名份额进行验证,然后再将所述至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复函数得到完整签名。相对于采用总公钥对生成的完整签名进行验证的方式,采用公钥份额对每一签名份额进行验证,验证 通过后再经恢复函数恢复为完整签名的方式,能够确定哪个签名是错误的,从而能够确定哪个节点可能是作恶节点。In addition, each consensus 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. Compared with the method of using the total public key to verify the complete signature generated, 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.
门限签名算法中,每个共识节点都具有1个总公钥和n个公私钥对中的1个私钥份额和对应的1个公钥份额,如前所述,可以是由dealer生成并分发的,也可以是各共识节点协商得到的。In the threshold signature algorithm, each consensus 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 and distributed by the dealer. , or it can be obtained through negotiation among the consensus nodes.
每个共识节点可以采用对应的公钥份额对接收到的commit消息中的签名份额进行验证。具体的,例如在包含4个共识节点的采用PBFT共识算法的联盟链中,节点0在S110中向节点1、2、3广播自身生成的签名份额σ 3,0,其中σ 3,0的下标3可以表示区块号,0可以表示这是节点0的签名份额;在S120中,节点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数量。 Each consensus node can use the corresponding public key share to verify the signature share in the received commit message. Specifically, for example, in a consortium chain using the PBFT consensus algorithm containing 4 consensus nodes, node 0 broadcasts the signature share σ 3,0 generated by itself to nodes 1, 2, and 3 in S110, where σ 3,0 is Mark 3 can represent the block number, and 0 can represent that this is the signature share of node 0; in S120, node 0 also receives the signature shares σ 3,1 and σ 3,2 broadcast by nodes 1 and 2 respectively. In this way, 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 . Of course, 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.
进而,节点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可以对σ 3,2等进行验证,不再赘述。 Furthermore, 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 ). Specifically, for example, 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 σ 3, 2 , etc., which will not be described again.
同样的,节点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)的正确性。 Similarly, 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 ).
同样的,节点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)的正确性。 Similarly, 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 ).
同样的,节点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)的正确性。 Similarly, 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 ).
S130:每一共识节点基于所述完整签名得到随机数种子。S130: Each consensus node obtains a random number seed based on the complete signature.
随机数种子(random seed),是指在伪随机数生成器中用于生成伪随机数的初始数值。对于一个伪随机数生成器,从相同的随机数种子出发,可以得到相同的随机数序列。对于单机来说,随机数种子可以由当前计算机的状态确定,如当前的时间。而对于分布式系统来说,要在各个节点上产生相同的随机数种子,以在系统合约/业务合约/区块链平台功能等中基于相同的随机数种子产生相同的随机数,且不应由任一节点以其可操控的、可预测的、可撤销的方式产生随机数。这就需要由参与共识的节点共同确定。而且,考虑到分布式网络往往是异步网络或半同步网络,从即时性出发,还需要在当前区块中的交易执行时即可以产生随机数并采用。Random seed refers to the initial value used to generate pseudo-random numbers in a pseudo-random number generator. For a pseudo-random number generator, starting from the same random number seed, the same random number sequence can be obtained. For a single machine, the random number seed can be determined by the current status of the computer, such as the current time. For distributed systems, 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. Moreover, considering that 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.
经过上述S110-S120的步骤,正常情况下每个共识节点都可以得到相同的完整签名。当然,考虑到分布式系统的容错特性,在采用PBFT共识算法的区块链网络中至少应当有quorum数量的共识节点各自都可以分别得到相同的完整签名。After the above steps S110-S120, under normal circumstances each consensus node can obtain the same complete signature. Of course, considering the fault-tolerant nature of the distributed system, there should be at least a quorum of consensus nodes in a blockchain network using the PBFT consensus algorithm, each of which can obtain the same complete signature.
这样,基于完整签名,各共识节点可以采用相同的随机数种子生成算法生成随机数种子。一种较为简单的随机数种子生成算法例如是sha256算法。当然,也可以直接将完整签名作为随机数种子。In this way, based on the complete signature, each consensus node can use the same random number seed generation algorithm to generate random number seeds. A relatively simple random number seed generation algorithm is, for example, the sha256 algorithm. Of course, you can also directly use the complete signature as a random number seed.
经过上述过程,即可在区块链上产生随机数种子。After the above process, a random number seed can be generated on the blockchain.
这样,区块链节点在执行当前共识完毕后输出共识结果的过程中,即执行确定了内容和顺序的一系列交易的过程中,如果其中包含需要使用随机数的智能合约/系统合约/ 区块链平台代码,可以基于S130的随机数种子来执行。例如,在C++语言编写的智能合约中,可以采用C++标准库或boost库提供的mt19937(r)方法来构造一个跨平台一致的随机数引擎,其中的参数r即为随机数种子。类似的,python中的random库,java中的random库,也都提供了类似的随机数生成方法。基于相同的随机数种子,在相同的随机数生成算法下可以生成相同的随机数。这样,例如各个区块链节点各自分别执行相同区块中的相同交易时,对于其中相同的随机数生成过程,可以基于相同随机数种子产生相同的随机数,从而完成诸如摇号、发红包、盲盒之类的业务逻辑,或完成系统合约/区块链平台功能,并在各个节点上得到一致的执行结果。In this way, in the process of the blockchain node outputting the consensus result after executing the current consensus, that is, in the process of executing a series of transactions with determined content and sequence, if it contains smart contracts/system contracts/blocks that require the use of random numbers, The chain platform code can be executed based on the random number seed of S130. For example, in a smart contract written in C++ language, the mt19937(r) method provided by the C++ standard library or the boost library can be used to construct a cross-platform consistent random number engine, where the parameter r is the random number seed. Similarly, the random library in python and the random library in java also provide similar random number generation methods. Based on the same random number seed, the same random number can be generated under the same random number generation algorithm. In this way, for example, when each blockchain node executes the same transaction in the same block, the same random number generation process can generate the same random number based on the same random number seed, thereby completing tasks such as lottery, red envelope issuing, blind business logic such as boxes, or complete system contract/blockchain platform functions, and obtain consistent execution results on each node.
此外,在上述方案基础上,还可以包括如下步骤:S140:每一共识节点将得到的随机数种子放至在生成的当前区块的区块头中。In addition, based on the above solution, the following steps may also be included: S140: Each consensus node puts the obtained random number seed into the block header of the current block generated.
图4是一个区块的区块头的结构示意图。由图5所示的结构中,每一区块的区块头包括若干字段,例如上一区块哈希previous_Hash(图中的Prev Hash),Nonce(这是工作量证明涉及的随机数,与本说明书中的随机数种子不同,且在一些联盟链中并不启用这个nonce),时间戳Timestamp,上一区块号Block Num,状态根哈希State Root,交易根哈希Transaction Root,收据根哈希Receipt Root等。其中,下一区块(如区块N+1)的区块头中的Prev Hash指向上一区块(如区块N),即为上一区块的hash值,也就是上一区块的区块头的hash值。区块头的hash值,可以是区块头中所包含的各个字段顺序拼接后经某种hash算法计算得到的hash值。通过这种方式,区块链上通过区块头实现了下一区块对上一区块的锁定。特别的,如前所述,state root是当前区块中所有账户的状态组成的MPT树的根的哈希值,指向state_root的为一颗MPT形式的状态树state trie。Transaction Root一般是本区块包含的原始交易列表的组织成一种树形结构后的树根节点的hash值,Receipt Root一般是本区块包含的交易经过执行后生成的所有收据组织成一种树形结构后的树根节点的hash值。Figure 4 is a schematic structural diagram of a block header. In the structure shown in Figure 5, the block header of each block includes several fields, such as the previous block hash previous_Hash (Prev Hash in the figure), Nonce (this is the random number involved in the workload proof, and this The random number seeds in the instructions are different, and this nonce is not enabled in some alliance chains), timestamp Timestamp, previous block number Block Num, state root hash State Root, transaction root hash Transaction Root, receipt root hash Hope Receipt Root et al. Among them, the Prev Hash in the block header of the next block (such as block N+1) points to the previous block (such as block N), which is the hash value of the previous block, that is, the hash value of the previous block. The hash value of the block header. The hash value of the block header can be the hash value calculated by a certain hash algorithm after sequentially splicing the fields contained in the block header. In this way, the next block locks the previous block through the block header on the blockchain. In particular, as mentioned above, state root is the hash value of the root of the MPT tree composed of the status of all accounts in the current block, and the point pointing to state_root is a state trie in the form of MPT. Transaction Root is generally the hash value of the tree root node after the original transaction list contained in this block is organized into a tree structure. Receipt Root is generally all the receipts generated after the transactions included in this block are executed, organized into a tree structure. The hash value of the tree root node after the structure.
这里需要注意的是,本说明书可以在区块头中增加一个字段——“随机数种子”,即S130中的随机数种子。这样,本区块产生的随机数种子,可以记录在区块链账本上,此外,对于回放区块来说,可以按照区块头中的随机数种子来回放区块中涉及随机数的交易。It should be noted here that this instruction can add a field in the block header - "random number seed", which is the random number seed in S130. In this way, the random number seed generated in this block can be recorded on the blockchain ledger. In addition, for the playback block, the transactions involving random numbers in the block can be played back according to the random number seed in the block header.
本说明书提供的上述方案,将门限签名算法与PBFT共识算法相结合,使得对应每个区块的原始交易列表在通过PBFT算法达成共识后,即可通过采用的门限签名算法得到完整签名,从而得到随机数种子,在执行本区块对应的原始交易列表中的交易的过程中,即可以采用随机数,这样,执行本区块的交易不需要额外的等待。The above scheme provided in this manual combines the threshold signature algorithm with the PBFT consensus algorithm, so that after the original transaction list corresponding to each block reaches consensus through the PBFT algorithm, the complete signature can be obtained through the adopted threshold signature algorithm, thus obtaining The random number seed can be used in the process of executing the transactions in the original transaction list corresponding to this block. In this way, no additional waiting is required to execute the transactions in this block.
本说明书提供的上述方案,基于门限签名算法的性质,各共识节点各自分别基于至少门限数量的签名份额通过恢复函数可以恢复出相同的完整签名,进而生成相同的随机数种子,从而,各个区块链节点各自分别执行相同区块中的相同交易时,对于其中相同的随机数生成过程可以基于相同随机数种子产生相同的随机数,从而完成诸如摇号、发红包、盲盒之类的业务逻辑,或完成系统合约/区块链平台功能,并在各个节点上得到一致的执行结果。The above scheme provided in this manual is based on the nature of the threshold signature algorithm. Each consensus node can recover the same complete signature through the recovery function based on at least a threshold number of signature shares, and then generate the same random number seed. Therefore, each block When the chain nodes each execute the same transaction in the same block, the same random number generation process can generate the same random number based on the same random number seed, thereby completing business logic such as lottery, red envelope issuance, and blind box. Or complete the system contract/blockchain platform functions and obtain consistent execution results on each node.
本说明书提供的上述方案,将门限签名算法与PBFT共识算法相结合,使得任一共识节点在共识完成前无法预测完整签名,即使是PBFT的主节点也无法预测完整签名,也就无法预测随机数种子和随机数。特别是当门限=quorum时,一旦完成共识,由于quorum数量的节点对交易列表的内容和顺序已达成一致,即生成新区块的基础内容已经确定,这时至少quorum数量的节点根据恢复函数得到的完整签名是相同的,这quorum数量的节点生成的随机数种子也必然相同,即使有不超过f个节点作恶而想要控制或撤销得到的随机数种子,这f个节点也不会影响系统的一致性,即这f个节点不可操控或撤销生成的完整签名、随机数种子和随机数。The above solution provided in this manual combines the threshold signature algorithm with the PBFT consensus algorithm, making it impossible for any consensus node to predict the complete signature before the consensus is completed. Even the master node of PBFT cannot predict the complete signature, and therefore cannot predict the random number. Seeds and random numbers. Especially when the threshold = quorum, once the consensus is completed, since the quorum number of nodes have reached an agreement on the content and order of the transaction list, that is, the basic content of generating a new block has been determined, at this time, at least the quorum number of nodes obtained according to the recovery function The complete signatures are the same, and the random number seeds generated by this quorum number of nodes must also be the same. Even if no more than f nodes do evil and want to control or revoke the random number seeds obtained, these f nodes will not affect the system. Consistency means that these f nodes cannot manipulate or revoke the generated complete signature, random number seed and random number.
本说明书中的方法,可以在每一区块生成的过程中实施,这样,每一区块的区块头 中都可以包括随机数种子这一字段。即使某一区块的区块体中并不包含涉及随机数的交易,该区块的生成过程中仍然可以包含生成随机数种子的过程。The method in this specification can be implemented in the process of generating each block, so that the block header of each block can include the random number seed field. Even if the block body of a certain block does not contain transactions involving random numbers, the generation process of the block can still include the process of generating random number seeds.
实际上,在基于投票的共识算法中,往往有最后一轮投票,该投票可以是互相直接广播或者通过gossip协议广播,例如PBFT中的commit消息,Tendermint中的pre-commit消息,HoneyBadger中的用于门限解密的消息等。本说明书提供的方案适用于此类执行交易前的共识算法中具有最后一轮投票的情形,以在对待执行的交易列表达成共识的同时达成一致的随机数种子,满足一致性、即时性、不可预测、不可操控和不可撤销。In fact, in voting-based consensus algorithms, there is often a final round of voting, which can be broadcast directly to each other or through gossip protocols, such as commit messages in PBFT, pre-commit messages in Tendermint, and user messages in HoneyBadger. Messages decrypted at thresholds, etc. The solution provided in this manual is applicable to the situation where there is a final round of voting in the consensus algorithm before executing the transaction, so as to reach a consensus on the transaction list to be executed and at the same time reach a consistent random number seed, which meets the requirements of consistency, immediacy, and impossibility. Predictable, uncontrollable and irrevocable.
以下在先共识交易列表后执行共识的交易列表中的交易的区块链网络中,以区块链网络中一个共识节点的角度介绍本说明书一种区块链上产生随机数种子的方法,且采用的共识算法中通过最后一阶段中相互广播消息来输出共识结果,则共识节点执行如图6所示内容:S210:所述共识节点基于门限签名算法,采用自身私钥份额对原始报文进行签名,生成签名份额,并将该签名份额加入到广播的所述消息中。The following describes a method of generating random number seeds on the blockchain from the perspective of a consensus node in the blockchain network in a blockchain network that first agrees on the transaction list and then executes the transactions in the consensus transaction list, and In the consensus algorithm adopted, consensus results are output by broadcasting messages to each other in the last stage. The consensus node executes the content as shown in Figure 6: S210: The consensus node uses its own private key share to process the original message based on the threshold signature algorithm. Sign, generate a signature share, and add the signature share to the broadcast message.
除了PBFT通过最后一阶段中相互广播提交提议来输出共识结果,还有一些共识算法也可以通过最后一阶段中相互广播提交提议来输出共识结果,后者例如为中国专利ZL202111175184.1、ZL202111178795.1、ZL202111178745.3、ZL202111178754.2、ZL202111175144.7、ZL202111175151.7以及中国专利申请CN202111178779.2。In addition to PBFT outputting consensus results by mutually broadcasting submission proposals in the final stage, there are also some consensus algorithms that can also output consensus results by mutually broadcasting submission proposals in the final stage. The latter are, for example, Chinese patents ZL202111175184.1 and ZL202111178795.1 , ZL202111178745.3, ZL202111178754.2, ZL202111175144.7, ZL202111175151.7 and Chinese patent application CN202111178779.2.
采用门限签名算法,共识节点可以采用自身特有的那一份私钥份额对包含本次共识中原始交易列表特有值的原始报文进行签名,得到签名结果。这里,原始交易列表的特有值可以作为签名所针对的原始报文。Using the threshold signature algorithm, the consensus node can use its own unique private key share to sign the original message containing the unique value of the original transaction list in this consensus to obtain the signature result. Here, the unique value of the original transaction list can be used as the original message for the signature.
原始交易列表的特有值,可以包括原始交易列表本身或者原始交易列表的hash值。区块号(也就是编号)和/或时间戳也可以作为原始报文中的内容。除了原始交易列表的特有值之外,签名的对象还可以加入其它内容,例如上一区块中产生的随机数种子,即原始列表中还可以包括上一区块中产生的随机数种子,这样可以根据本说明书的方案帮助共识节点确认上一区块是否一致。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 block number (that is, the number) and/or the timestamp can also be used as the content of the original message. In addition to the unique values of the original transaction list, the signed object can also add other content, such as the random number seed generated in the previous block, that is, the original list can also include the random number seed generated in the previous block, so that The solution in this manual can be used to help the consensus node confirm whether the previous block is consistent.
S220:所述共识节点收集齐至少门限数量的所述消息后将所述至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复函数得到完整签名。S220: After the consensus node collects at least a threshold number of the 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.
如前所述,门限签名算法在应用中,可以产生1个总公钥和n个公私钥对,并可以产生该n个公私钥对所对应的恢复函数。前述提到,该恢复函数可以将验证正确的至少门限数量个签名恢复生成一个完整签名,门限签名算法的门限值即门限数量可以设为w。当然,正确的签名多于w个时也可以通过该恢复函数生成一个完整签名。也就是说,正确的签名大于等于门限数量w时,都可以通过该恢复函数生成一个完整签名,且生成的这个完整签名是确定的,不会因为输入的正确签名的个数而发生变化(只要大于等于w)。As mentioned before, in application, 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. Of course, when there are more than w correct signatures, 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).
这个生成的完整签名可以由所述的那1个总公钥来验证正确性。这样,任何持有这个总公钥的节点或其它设备都可以采用该总公钥来验证这个完整签名的正确性。例如,节点1生成完整签名后,可以采用总公钥验证该完整签名的完整性,例如采用总公钥对完整签名进行密码学运算得到第一hash,并对原始报文进行hash运算得到第二hash,如果第一hash与第二hash一致则可以确定该完整签名的完整性。所述完整性包括该完整签名是针对所述原始报文的,且该原始报文没有经过篡改。再例如,节点1生成完整签名后,可以将该完整签名、总公钥和原始报文发送至区块链以外的一个设备,该设备可以采用所述总公钥和原始报文验证这个完整签名的正确性,原理同上不再赘述。这里的报文原文仍然是前述的包含本次共识中原始交易列表特有值的内容,或还包括当前区块的区块号和/或时间戳和/或上一区块中产生的随机数种子。The complete signature generated can be verified for correctness by the total public key. In this way, any node or other device holding the total public key can use the total public key to verify the correctness of the complete signature. For example, after node 1 generates a complete signature, the total public key can be used to verify the integrity of the complete signature. For example, 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. For another example, 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. .
此外,也可以是每一共识节点收集每一commit消息后,采用对应的公钥份额对所述接收到的commit消息中的签名份额进行验证,然后再将所述至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复函数得到完整签名。相对于采用总公钥对生成的完整签名进行验证的方式,采用公钥份额对每一签名份额进行验证,验证 通过后再经恢复函数恢复为完整签名的方式,能够确定哪个签名是错误的,从而能够确定哪个节点可能是作恶节点。In addition, each consensus 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. Compared with the method of using the total public key to verify the complete signature generated, 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.
门限签名算法中,每个共识节点都具有1个总公钥和n个公私钥对中的1个私钥份额和对应的1个公钥份额,如前所述,可以是由dealer生成并分发的,也可以是各共识节点协商得到的。In the threshold signature algorithm, each consensus 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 and distributed by the dealer. , or it can be obtained through negotiation among the consensus nodes.
每个共识节点可以采用对应的公钥份额对接收到的commit消息中的签名份额进行验证。具体的,例如在包含4个共识节点的采用PBFT共识算法的联盟链中,节点0在S210中向节点1、2、3广播自身生成的签名份额σ 3,0,其中σ 3,0的下标3可以表示区块号,0可以表示这是节点0的签名份额;在S220中,节点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数量。 Each consensus node can use the corresponding public key share to verify the signature share in the received commit message. Specifically, for example, in a consortium chain that uses the PBFT consensus algorithm and contains 4 consensus nodes, node 0 broadcasts the signature share σ 3,0 generated by itself to nodes 1, 2, and 3 in S210, where the lower part of σ 3,0 Mark 3 can represent the block number, and 0 can represent that this is the signature share of node 0; in S220, node 0 also receives the signature shares σ 3,1 and σ 3,2 broadcast by nodes 1 and 2 respectively. In this way, 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 . Of course, 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.
进而,节点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可以对σ 3,2等进行验证,不再赘述。 Furthermore, 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 ). Specifically, for example, 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 σ 3, 2 , etc., which will not be described again.
同样的,节点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)的正确性。 Similarly, 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 ).
同样的,节点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)的正确性。 Similarly, 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 ).
同样的,节点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)的正确性。 Similarly, 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 ).
S230:所述共识节点基于所述完整签名得到随机数种子。S230: The consensus node obtains a random number seed based on the complete signature.
经过上述S210-S220的步骤,正常情况下所述共识节点可以得到完整签名。这样,基于完整签名,所述共识节点可以采用随机数种子生成算法生成随机数种子。一种较为简单的随机数种子生成算法例如是sha256算法。当然,也可以直接将完整签名作为随机数种子。After the above steps S210-S220, the consensus node can obtain a complete signature under normal circumstances. In this way, based on the complete signature, the consensus node can use a 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. Of course, you can also directly use the complete signature as a random number seed.
经过上述过程,即可在所述共识节点本地的区块链上产生随机数种子。上述过程,可以适用于PBFT的最后一阶段(提交阶段的commit消息广播和交互)中,也可以是适用于HBBFT的最后一阶段(可以是BA(Binary Agreement,二进制一致性协议)阶段的Aux消息广播和交互,也可以是采用了门限加密算法的门限解密阶段中消息广播和交互),还可以是适用于Tendermint中的pre-commit消息广播和交互中。After the above process, a random number seed can be generated on the local blockchain of the consensus node. The above process can be applied to the last stage of PBFT (commit message broadcast and interaction in the submission stage), or to the Aux message in the BA (Binary Agreement) stage of HBBFT. Broadcasting and interaction can also be message broadcasting and interaction in the threshold decryption stage using the threshold encryption algorithm), or pre-commit message broadcasting and interaction applicable to Tendermint.
本说明书还提供一种生成区块头的方法,在上述S210-S230方法基础上还可以包括:所述共识节点将得到的随机数种子放至在生成的当前区块的区块头中。This specification also provides a method for generating a block header. Based on the above S210-S230 method, it may also include: the consensus node puts the obtained random number seed into the generated block header of the current block.
本说明书还提供一种区块链上产生随机数的方法,在上述S210-S230方法基础上还可以包括:所述共识节点基于产生的随机数种子产生随机数。This specification also provides a method for generating random numbers on the blockchain. Based on the above S210-S230 method, it may also include: the consensus node generates random numbers based on the generated random number seeds.
上述介绍了本说明书以结合PBFT三阶段为例的实现过程。以PBFT(以及HBBFT)为典型的多种共识算法中,使用了多对多(all-to-all)的消息模式来提交一个确认区块。这种多对多的消息模式,交互的消息数量会伴随着网络规模的增长而呈指数增长。The above introduces the implementation process of this manual using the three stages of PBFT as an example. Various consensus algorithms, typically PBFT (and HBBFT), use the many-to-all (all-to-all) message mode to submit a confirmation block. In this many-to-many messaging model, the number of interactive messages will grow exponentially as the network scale grows.
因此,此类多对多的消息交互,扩展性(Scalabillity)稍差,对于大规模网络节点的 情况很难较好的适用。Therefore, this type of many-to-many message interaction has poor scalability and is difficult to apply to large-scale network nodes.
在PBFT的基础上,后续演化出SBFT共识算法,解决了扩展性的问题。SBFT和PBFT一样使用了view change协议,每一个view有一个replica是primary,其它replicas是backups。与PBFT不同的是,这些backups还可以拥有其它身份,提交收集器(commit collector,c-collector)和执行收集器(execution collector,e-collector)。SBFT包括两种模式,分别是fast path和Linear-PBFT。fast path是默认的执行模式,当fast path无法达成共识时,就使用Linear-PBFT。如图6所示,SBFT通过这种收集器(collector)的通信模式,不再将消息发给每一个replica,而是发给collector,然后再由collector广播给所有replicas。每一个view中可以有c+1个c-collectors和c+1个e-collectors分别收集并组合门限签名和传播结果签名。On the basis of PBFT, the SBFT consensus algorithm was subsequently evolved to solve the scalability problem. SBFT uses the view change protocol like PBFT. Each view has one replica as primary, and other replicas as backups. Unlike PBFT, these backups can also have other identities, commit collector (c-collector) and execution collector (execution collector, e-collector). SBFT includes two modes, namely fast path and Linear-PBFT. Fast path is the default execution mode. When fast path cannot reach consensus, Linear-PBFT is used. As shown in Figure 6, through this collector communication mode, SBFT no longer sends the message to each replica, but to the collector, which then broadcasts it to all replicas. In each view, there can be c+1 c-collectors and c+1 e-collectors to collect and combine threshold signatures and propagation result signatures respectively.
整个系统有(3f+2c+1)个节点(即Replicas),编号从1至(3f+2c+1)。The entire system has (3f+2c+1) nodes (ie Replicas), numbered from 1 to (3f+2c+1).
SBFT使用了门限签名,对于n个replicas,只需要replicas的一个子集对交易集合进行签名就可以验证。子集中的replicas分别使用自己的私钥签名之后发送至一个接收方。门限签名分为三组。SBFT uses threshold signatures. For n replicas, only a subset of replicas needs to sign the transaction set to verify. The replicas in the subset are signed with their own private keys and sent to a recipient. Threshold signatures are divided into three groups.
第一组的签名设为σ,可以设置签名门限为(3f+c+1)。The signature of the first group is set to σ, and the signature threshold can be set to (3f+c+1).
第二组的签名设为π,可以设置签名门限为(f+1)。The signature of the second group is set to π, and the signature threshold can be set to (f+1).
如图7,SBFT的流程如下:请求:客户端(client,图中的c)向主节点(Primary)发起交易请求。这里示出了一个client发起交易请求的过程。实际上,可以是多个交易请求,且该多个交易请求可以由一个或多个不同的client发起至Primary,每个交易请求可以直接发送至Primary或通过其它节点转发至Primary。As shown in Figure 7, the SBFT process is as follows: Request: The client (c in the figure) initiates a transaction request to the primary node (Primary). Here is the process of a client initiating a transaction request. In fact, there can be multiple transaction requests, and the multiple transaction requests can be initiated to the Primary by one or more different clients. Each transaction request can be sent directly to the Primary or forwarded to the Primary through other nodes.
预准备阶段(Pre-prepare):Primary收集一定量的交易请求后,对这些交易请求排序、打包为交易列表并置于pre-prepare消息(pre-prepare message)中,广播pre-prepare消息至其它Replicas。Pre-prepare phase (Pre-prepare): After the Primary collects a certain amount of transaction requests, it sorts these transaction requests, packages them into a transaction list and places them in a pre-prepare message (pre-prepare message), and broadcasts the pre-prepare message to other parties. Replicas.
签名份额阶段(Sign-share):每一Replica对pre-prepare消息用自身的第一组中的私钥份额签名,生成签名份额,并发送包含该签名份额的Sign-share消息至每一C-Collector(图中为1个C-Collector)。Signature share stage (Sign-share): Each Replica signs the pre-prepare message with its own private key share in the first group, generates a signature share, and sends a Sign-share message containing the signature share to each C- Collector (1 C-Collector in the picture).
全提交证明阶段(Full-commit-Proof):每一C-Collector收集第一组的至少第一门限个签名份额后恢复得到第一完整签名σ,并广播包含该第一完整签名σ的全提交证明(full-commit-proof)至Replicas。Full-commit-Proof: Each C-Collector collects at least the first threshold signature shares of the first group and recovers the first complete signature σ, and broadcasts a full commit containing the first complete signature σ. Prove (full-commit-proof) to Replicas.
签名状态阶段(Sign-state):每一收到full-commit-proof的Replica,可以采用第一组的总公钥验证其中的第一完整签名σ,验证通过后可以提交该交易列表并顺序执行其中的交易,并用自身第二组中的私钥份额对执行结果(一般是执行后的状态集合,可以由状态集合组织成树形结构后的根节点的hash值来代表)签名,生成签名状态,进而发送签名状态至每一E-Collector。Sign-state phase (Sign-state): Each time a full-commit-proof Replica is received, the first set of total public keys can be used to verify the first complete signature σ. After the verification is passed, the transaction list can be submitted and executed sequentially. transaction, and use the private key share in the second group to sign the execution result (generally the state set after execution, which can be represented by the hash value of the root node after the state set is organized into a tree structure) to generate a signature state , and then send the signature status to each E-Collector.
全执行证明阶段(Full-execute-proof):每一E-Collector收集第二组的至少第二门限个签名份额后恢复得到第二完整签名π,并广播包含该完整签名π的全执行证明(full-execute-proof)至Replicas。Full-execute-proof phase: Each E-Collector collects at least the second threshold signature share of the second group and recovers the second complete signature π, and broadcasts the full-execute proof containing the complete signature π ( full-execute-proof) to Replicas.
收到该full-execute-proof的Replica,可以通过第二组的总公钥验证其中的第二完整签名π。After receiving the full-execute-proof Replica, the second complete signature π can be verified through the total public key of the second group.
执行确认(Execute-ack):任一E-Collector还可以发送执行确认(execute-ack)消息至请求的client。Execution confirmation (Execute-ack): Any E-Collector can also send an execution confirmation (execute-ack) message to the requesting client.
此外,如果client等待超时,可以重新发送该request至所有的Replicas。In addition, if the client times out, the request can be resent to all Replicas.
由于c-collectors和e-collectors这两种节点分别收集并组合门限签名和传播结果签名,因此这里可以称为收集节点。Since these two nodes, c-collectors and e-collectors, collect and combine threshold signatures and propagation result signatures respectively, they can be called collection nodes.
与PBFT相比,SBFT只需发送它的1/3消息数,达成共识的速度更快。Compared with PBFT, SBFT only needs to send 1/3 of its number of messages and reaches consensus faster.
基于上述SBFT的过程,本说明书提供一种区块链上产生随机数种子的方法,如图 7所示,包括:S310:在SBFT的Sign-share阶段,每一共识节点基于门限签名算法,采用自身私钥份额对包含本次共识中原始交易列表特有值的原始报文进行签名,生成签名份额,并将该签名份额加入到Sign-share消息中发送至至少一个收集节点。Based on the above-mentioned SBFT process, this specification provides a method for generating random number seeds on the blockchain, as shown in Figure 7, including: S310: In the Sign-share stage of SBFT, each consensus node uses the threshold signature algorithm. The own private key share signs 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 Sign-share message and sends it to at least one collection node.
如前所述,门限签名方案,首先是包括1个总公钥和n个公私钥对。每个公私钥对中的1个公钥称为公钥份额,每个公私钥对中的1个私钥称为私钥份额。其次,存在与这个总公钥和n个公私钥对对应的恢复函数,该恢复函数可以将至少门限数量个不同私钥份额签名的签名份额恢复成一个完整签名,这个生成的完整签名也可以由所述的那1个总公钥来验证正确性。而任意少于门限数量的签名份额则无法恢复生成该完整签名。As mentioned before, 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. Secondly, there is a recovery function corresponding to this total public key and n public-private key pairs. 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.
门限签名机制可以采用基于BLS、RSA、ECDSA、Schnorr、Boneh-Lynn-Shacham Signature等的门限签名算法。The threshold signature mechanism can use threshold signature algorithms based on BLS, RSA, ECDSA, Schnorr, Boneh-Lynn-Shacham Signature, etc.
采用门限签名算法,每一共识节点都可以采用自身特有的那一份私钥(如包含4个节点且采用SBFT作为共识算法的区块链网络中,节点1、节点2、节点3、节点4采用门限签名算法所持有的私钥份额分别是sk1,sk2,sk3,sk4,下标数字可以表示节点的编号)对包含本次共识中原始交易列表特有值的原始报文进行签名,得到签名结果。这里,原始交易列表的特有值可以作为签名所针对的原始报文。Using the threshold signature algorithm, each consensus node can use its own unique private key (for example, in a blockchain network containing 4 nodes and using SBFT as the consensus algorithm, node 1, node 2, node 3, node 4 The private key shares held by the threshold signature algorithm are sk1, sk2, sk3, sk4 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 obtain the signature result. Here, the unique value of the original transaction list can be used as the original message for the signature.
原始交易列表的特有值,可以包括原始交易列表本身或者原始交易列表的hash值。一般来说,不同的交易,交易内容是不同的,这样,不同的原始交易列表或其hash值一般都不相同。因此,原始报文中可以至少包括原始交易列表或其hash值,这样由hash函数的性质,足以区分不同区块对应的共识过程完毕后所生成的随机数种子。The unique value of the original transaction list can include the original transaction list itself or the hash value of the original transaction list. Generally speaking, different transactions have different transaction contents, so different original transaction lists or their hash values are generally different. Therefore, 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.
考虑到共识过程中会为本次共识的内容生成一个编号,如果共识完成,生成的编号可以作为本次共识所对应的区块的区块号,因此,区块号(也就是编号)也可以作为原始报文中的内容。不论第N+1个区块中所包含的原始交易列表与第N个区块中所包含的原始交易表是否相同,区块生成是顺序的,可以体现为后一区块的区块号是前一区块的区块号+1。因此,区块号作为原始报文中的内容,即使第N+1个区块中所包含的原始交易列表与第N个区块中所包含的原始交易表相同,仍然由各个节点采用自身私钥基于(原始交易列表+区块号)得到不同的签名,主节点仍然无法与其它节点的签名,从而无法预测第N+1号区块的完整签名,因此主节点无法使用第N号块已公开的随机数种子来预测第N+1号块的随机数种子,达到了不可预测的目的。与编号类似的,时间戳也是一个区块特有的,且后一区块的时间戳在前一区块之后。因此,时间戳也可以作为原始报文中的内容。Considering that a number will be generated for the content of this consensus during the consensus process, if the consensus is completed, the generated number can be used as the block number of the block corresponding to this consensus. Therefore, the block number (that is, the number) can also be as the content in the original message. Regardless of whether the original transaction list contained in the N+1th block is the same as the original transaction list contained in the Nth block, 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.
除了原始交易列表的特有值之外,签名的对象还可以加入其它内容,例如上一区块中产生的随机数种子,即原始报文中还可以包括上一区块中产生的随机数种子。如前所述,各个节点可以各自以共识的交易数据为基础,生成第m个区块。由于第m个区块是各个节点在本地各自独立生成的,因此,如果区块链节点之间没有相互广播自身生成的上一区块的hash值并比对,各个节点可能都无法确定区块链网络中生成的第m个区块是否相同,或者从区块链系统整体可用的角度来说是否有至少quorum数量的共识节点上生成的第m个区块是相同的。经过本说明书中随机数种子的生成过程,相同区块的随机数种子应当是相同的,不同区块中的随机数种子应当是不同的,因此可以将随机数种子加入到原始报文中。这样,如果各个节点各自生成的第m个区块对应的随机数种子有所不同,根据门限签名算法的性质,可能无法在第m+1号区块的产生随机数种子的过程中通过恢复函数方法得出完整签名,从而可以根据本说明书的方案帮助共识节点确认上一区块是否一致。也可采用上一区块的hash值来代替上一区块的随机数种子,由于一个区块的hash值一般是唯一的,因此也可以帮助共识节点确认上一区块是否一致。In addition to the unique values of the original transaction list, 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. As mentioned before, 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. Whether the m-th block generated in the chain network is the same, or whether the m-th block generated on at least a quorum number of consensus nodes is the same from the perspective of the overall availability of the blockchain system. After the random number seed generation process in this manual, 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 consensus node confirm whether the previous block is consistent according to the scheme of this manual. 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 consensus node confirm whether the previous block is consistent.
采用自身私钥份额对包含本次共识中原始交易列表特有值的原始报文进行签名,这个原始报文里可以包括的原始交易列表的特有值,可以是原始交易列表。一般在SBFT的Pre-Prepare阶段已经广播过原始交易列表,且Sign-share阶段广播的commit消息较 小的话更利于传播及节省带宽,因此原始交易列表特有值可以是原始交易列表的hash值。Use your own private key share to sign the original message containing the unique value of the original transaction list in this consensus. The unique value of the original transaction list that can be included in this original message can be the original transaction list. Generally, the original transaction list has been broadcast in the Pre-Prepare phase of SBFT, and if the commit message broadcast in the Sign-share 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.
对于原始报文包括多个内容,例如包括原始交易列表hash值、区块号、上一区块中产生的随机数种子的情况下,可以先计算原始报文的hash值,进而采用私钥份额对该原始报文hash值进行签名,得到签名份额。If 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 share.
对原始报文进行签名,生成的签名份额和原始报文可以一并加入到Sign-share消息中。这样,在Sign-share阶段,参与共识的节点中的每一个都发送Sign-share消息给收集节点。Sign the original message, and the generated signature share and the original message can be added to the Sign-share message. In this way, during the Sign-share phase, each of the nodes participating in the consensus sends a Sign-share message to the collection node.
S320:所述收集节点收集齐至少门限数量的Sign-share消息后将其中的至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复函数得到完整签名。S320: After collecting at least a threshold number of Sign-share messages, the collection node passes at least a threshold number of signature shares among them through the recovery function corresponding to the private key share generated by the threshold signature algorithm to obtain a complete signature.
如前所述,门限签名算法在应用中,可以产生1个总公钥和n个公私钥对,并可以产生该n个公私钥对所对应的恢复函数。前述提到,该恢复函数可以将验证正确的至少门限数量个签名恢复生成一个完整签名,门限签名算法的门限值即门限数量可以设为w。当然,正确的签名多于w个时也可以通过该恢复函数生成一个完整签名。也就是说,正确的签名大于等于门限数量w时,都可以通过该恢复函数生成一个完整签名,且生成的这个完整签名是确定的,不会因为输入的正确签名的个数而发生变化(只要大于等于w)。As mentioned before, in application, 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. Of course, when there are more than w correct signatures, 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).
这个生成的完整签名可以由所述的那1个总公钥来验证正确性。这样,任何持有这个总公钥的节点或其它设备都可以采用该总公钥来验证这个完整签名的正确性。例如,节点1生成完整签名后,可以采用总公钥验证该完整签名的完整性,例如采用总公钥对完整签名进行密码学运算得到第一hash,并对原始报文进行hash运算得到第二hash,如果第一hash与第二hash一致则可以确定该完整签名的完整性。所述完整性包括该完整签名是针对所述原始报文的,且该原始报文没有经过篡改。再例如,节点1生成完整签名后,可以将该完整签名、总公钥和原始报文发送至区块链以外的一个设备,该设备可以采用所述总公钥和原始报文验证这个完整签名的正确性,原理同上不再赘述。这里的报文原文仍然是前述的包含本次共识中原始交易列表特有值的内容,或还包括当前区块的区块号和/或时间戳和/或上一区块中产生的随机数种子。The complete signature generated can be verified for correctness by the total public key. In this way, any node or other device holding the total public key can use the total public key to verify the correctness of the complete signature. For example, after node 1 generates a complete signature, the total public key can be used to verify the integrity of the complete signature. For example, 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. For another example, 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. .
此外,也可以是收集节点收集每一Sign-share消息后,采用对应的公钥份额对所述接收到的Sign-share消息中的签名份额进行验证,然后再将所述至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复函数得到完整签名。相对于采用总公钥对生成的完整签名进行验证的方式,采用公钥份额对每一签名份额进行验证,验证通过后再经恢复函数恢复为完整签名的方式,能够确定哪个签名是错误的,从而能够确定哪个节点可能是作恶节点。In addition, the collection node may also collect each Sign-share message, use the corresponding public key share to verify the signature shares in the received Sign-share message, and then add at least a threshold number of signature shares A complete signature is obtained through the recovery function corresponding to the private key share generated by the threshold signature algorithm. Compared with the method of using the total public key to verify the complete signature generated, 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.
门限签名算法中,每个共识节点都具有1个总公钥和n个公私钥对中的1个私钥份额和对应的1个公钥份额,如前所述,可以是由dealer生成并分发的,也可以是各共识节点协商得到的。In the threshold signature algorithm, each consensus 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 and distributed by the dealer. , or it can be obtained through negotiation among the consensus nodes.
收集节点可以采用对应的公钥份额对接收到的Sign-share消息中的签名份额进行验证。具体的,收集节点可以采用对应的公钥份额来对签名份额进行计算,得到一个hash值,记为hash 1,还可以对原始报文进行同样的hash计算得到hash′ 1。如果hash 1与hash′ 1相等,可以证明原始报文是节点1发出的,且在传送过程中没有被篡改过。这样,该签名份额的正确性得到验证。类似的,其它签名份额也可以进行验证,不再赘述。 The collection node can use the corresponding public key share to verify the signature share in the received Sign-share message. Specifically, the collection node can use the corresponding public key share to calculate the signature share and obtain a hash value, recorded as hash 1 . It can also perform the same hash calculation on the original message to obtain hash′ 1 . If hash 1 and hash′ 1 are equal, 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 the signature share is verified. Similarly, other signature shares can also be verified, which will not be described again.
S330:所述收集节点广播包含该完整签名的full-commit-proof消息至共识节点。S330: The collection node broadcasts the full-commit-proof message containing the complete signature to the consensus node.
如前所述,收集节点收集至少第一门限个签名份额后恢复得到第一完整签名σ后,可以广播包含该第一完整签名σ的全提交证明(full-commit-proof)至Replicas。As mentioned above, after the collection node collects at least the first threshold signature share and recovers the first complete signature σ, it can broadcast the full-commit-proof containing the first complete signature σ to Replicas.
S340:所述接收到full-commit-proof消息的每一共识节点基于其中的完整签名得到随机数种子。S340: Each consensus node that receives the full-commit-proof message obtains a random number seed based on the complete signature therein.
随机数种子(random seed),是指在伪随机数生成器中用于生成伪随机数的初始数 值。对于一个伪随机数生成器,从相同的随机数种子出发,可以得到相同的随机数序列。对于单机来说,随机数种子可以由当前计算机的状态确定,如当前的时间。而对于分布式系统来说,要在各个节点上产生相同的随机数种子,以在系统合约/业务合约/区块链平台功能等中基于相同的随机数种子产生相同的随机数,且不应由任一节点以其可操控的、可预测的、可撤销的方式产生随机数。这就需要由参与共识的节点共同确定。而且,考虑到分布式网络往往是异步网络或半同步网络,从即时性出发,还需要在当前区块中的交易执行时即可以产生随机数并采用。Random number seed refers to the initial value used to generate pseudo-random numbers in a pseudo-random number generator. For a pseudo-random number generator, starting from the same random number seed, the same random number sequence can be obtained. For a single machine, the random number seed can be determined by the current status of the computer, such as the current time. For distributed systems, 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. Moreover, considering that 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.
经过上述S310-S330的步骤,正常情况下每个共识节点都可以得到相同的完整签名。当然,考虑到分布式系统的容错特性,在采用SBFT共识算法的区块链网络中至少应当有quorum数量的共识节点各自都可以分别得到相同的完整签名。After the above steps S310-S330, under normal circumstances each consensus node can obtain the same complete signature. Of course, considering the fault-tolerant nature of the distributed system, there should be at least a quorum of consensus nodes in a blockchain network using the SBFT consensus algorithm, each of which can obtain the same complete signature.
这样,基于完整签名,各共识节点可以采用相同的随机数种子生成算法生成随机数种子。一种较为简单的随机数种子生成算法例如是sha256算法。当然,也可以直接将完整签名作为随机数种子。In this way, based on the complete signature, each consensus node can use the same random number seed generation algorithm to generate random number seeds. A relatively simple random number seed generation algorithm is, for example, the sha256 algorithm. Of course, you can also directly use the complete signature as a random number seed.
在生成随机数种子前,各共识节点还可以采用所述门限签名算法产生私钥份额所对应的总公钥来验证完整签名的正确性。Before generating the random number seed, each consensus node can also use the threshold signature algorithm to generate the total public key corresponding to the private key share to verify the correctness of the complete signature.
经过上述过程,即可在区块链上产生随机数种子。After the above process, a random number seed can be generated on the blockchain.
上述图7的例子以SBFT为例说明本说明书实施例中链上产生随机数种子的方法,实际上也可以适用于SBFT的变种类共识算法。SBFT及其变种,可以统称为类SBFT的共识算法。类似的,基于PBFT改进而来的Hotstuff共识算法,也可以适用于申请实施例中链上产生随机数种子的方法。前述提到,PBFT中引入View-Change,是在网络的半同步假设下保持分布式系统的活性,典型的如主节点失效或作恶时触发更换主节点的视图切换过程。视图切换过程中,需要考虑各节点上的状态恢复,以使得分布式网络中各节点最终能够达到相同的区块状态,从而满足一致性的要求。如前所述,由于多对多消息交互模式的复杂性较大,PBFT难以适用于大规模的网络当中,即难于扩展。The above example in Figure 7 uses SBFT as an example to illustrate the method of generating random number seeds on the chain in the embodiment of this specification. In fact, it can also be applied to variant consensus algorithms of SBFT. SBFT and its variants can be collectively referred to as SBFT-like consensus algorithms. Similarly, the Hotstuff consensus algorithm improved based on PBFT can also be applied to the method of generating random number seeds on the chain in the application embodiment. As mentioned above, the introduction of View-Change in PBFT is to maintain the activity of the distributed system under the assumption of semi-synchronization of the network. Typically, the view switching process of replacing the master node is triggered when the master node fails or does evil. During the view switching process, the state recovery on each node needs to be considered, so that each node in the distributed network can eventually reach the same block state, thus meeting the consistency requirements. As mentioned before, due to the complexity of the many-to-many message interaction model, PBFT is difficult to apply to large-scale networks, that is, it is difficult to expand.
HotStuff的提出同样也解决了扩展性问题。其采用了门限签名、线性视图变更和共识状态树等技术。HotStuff的核心围绕着三轮共识投票展开,原论文中提出了三种形式:简易版HotStuff(Basic HotStuff),链状HotStuff(Chained HotStuff),事件驱动的HotStuff(Event-Driven HotStuff)。Basic HotStuff是后两种共识的基本过程。其中,视图以单调递增的方式不断切换。每个视图内都有一个唯一的主节点负责提案、收集和转发消息并生成QC。所述QC是Quorum Certificate的简写,意为证书,是主节点收到至少quorum个节点对用一个提案的投票消息(带签名)后,利用门限签名将其合成一个QC。这个QC可以理解为门限签名生成的完整签名,表示对该次提案达成一次共识。Basic HotStuff的整个过程可以如图8所示,包括:New-View:每一节点将上一轮的视图编号、区块hash以及自身的prepareQC通过New-View发送至Leader节点。New-View的消息可以包括上一轮的视图编号v-1,上一区块的hash值H(Block-1)。The introduction of HotStuff also solved the scalability problem. It uses technologies such as threshold signatures, linear view changes, and consensus state trees. The core of HotStuff revolves around three rounds of consensus voting. The original paper proposed three forms: simple HotStuff (Basic HotStuff), chained HotStuff (Chained HotStuff), and event-driven HotStuff (Event-Driven HotStuff). Basic HotStuff is the basic process of the latter two consensuses. Among them, the views are continuously switched in a monotonically increasing manner. There is a unique master node in each view that is responsible for proposing, collecting and forwarding messages, and generating QC. The QC is the abbreviation of Quorum Certificate, which means certificate. After the master node receives the voting message (with signature) of at least quorum nodes for a proposal, it uses the threshold signature to synthesize it into a QC. This QC can be understood as the complete signature generated by the threshold signature, indicating that a consensus has been reached on the proposal. The entire process of Basic HotStuff can be shown in Figure 8, including: New-View: Each node sends the previous round of view number, block hash and its own prepareQC to the Leader node through New-View. The New-View message may include the view number v-1 of the previous round and the hash value H (Block-1) of the previous block.
Leader节点(本说明书中也称为收集节点)根据收到的quorum条New-View消息中包含的各个节点发来的状态树中高度最高的prepareQC计算出高度最高的QC。Leader节点广播Prepare消息至其它共识节点。Prepare消息中可以包括视图编号v(正确的情况下应当是上一轮的视图编号+1),还可以包括Leader节点打包的有序交易集合。The Leader node (also called the collection node in this manual) calculates the highest QC based on the highest prepareQC in the status tree sent by each node included in the received quorum New-View message. The Leader node broadcasts Prepare messages to other consensus nodes. The Prepare message can include the view number v (correctly it should be the view number of the previous round + 1), and can also include the ordered transaction set packaged by the Leader node.
对Prepare投票阶段:各共识节点收到Prepare消息并验证通过后,发送针对当前提案的Prepare-Vote消息至Leader节点。其中,每一共识节点采用自身私钥份额做签名。各共识节点发送Prepare-Vote消息至Leader节点。Prepare-Vote消息可以包括Leader打包的有序交易集合的hash值(可以表示为H(block)),还可以包括共识节点采用自身私钥份额对包括(Prepare-Vote,v,H(block)的内容的第一签名份额(这里设为PartialSig1)。Prepare voting stage: After each consensus node receives the Prepare message and passes the verification, it sends a Prepare-Vote message for the current proposal to the Leader node. Among them, each consensus node uses its own private key share for signature. Each consensus node sends a Prepare-Vote message to the Leader node. The Prepare-Vote message can include the hash value of the ordered transaction set packaged by the Leader (can be expressed as H (block)), and can also include the consensus node using its own private key share pair including (Prepare-Vote, v, H (block) The first signature share of the content (here set to PartialSig1).
Leader主节点收到至少quorum个不同共识节点针对当前提案的Prepare-Vote消息时,通过聚合至少quorum个的PartialSig1得到第一完整签名,然后通过广播Precommit 消息至各共识节点。When the Leader master node receives Prepare-Vote messages for the current proposal from at least quorum different consensus nodes, it obtains the first complete signature by aggregating at least quorum PartialSig1, and then broadcasts the Precommit message to each consensus node.
对Precommit投票阶段:其它各共识节点收到Precommit消息并验证通过之后,发送Precommit-Vote消息至主节点。类似的,Precommit-Vote消息中包含共识节点采用自身私钥生成的第二签名份额(这里设为PartialSig2)。Precommit voting stage: After each other consensus node receives the Precommit message and passes the verification, it sends a Precommit-Vote message to the master node. Similarly, the Precommit-Vote message contains the second signature share (here set to PartialSig2) generated by the consensus node using its own private key.
Leader节点收集至少quorum个Precommit-vote消息,通过聚合至少quorum个PartialSig2得到第二完整签名,然后通过Commit消息广播至其它共识节点。主节点发送的Commit消息与PBFT中的COMMIT阶段类似。The Leader node collects at least quorum Precommit-vote messages, obtains the second complete signature by aggregating at least quorum PartialSig2, and then broadcasts it to other consensus nodes through Commit messages. The Commit message sent by the master node is similar to the COMMIT phase in PBFT.
对Commit投票阶段:其它各共识节点收到Commit消息并验证通过之后,发送Commit-Vote消息至主节点。类似的,Commit-Vote消息中包含共识节点采用自身私钥生成的第三签名份额(这里设为PartialSig3)。Commit voting stage: After each other consensus node receives the Commit message and passes the verification, it sends a Commit-Vote message to the master node. Similarly, the Commit-Vote message contains the third signature share generated by the consensus node using its own private key (here set to PartialSig3).
Leader节点收集到至少quorum个Commit-vote消息时,通过聚合至少quorum个PartialSig3得到第三完整签名,然后通过Decide消息广播至其它共识节点。When the Leader node collects at least quorum Commit-vote messages, it obtains the third complete signature by aggregating at least quorum PartialSig3, and then broadcasts it to other consensus nodes through Decide messages.
上述过程中,在对Precommit投票阶段,接收到所述广播消息的每一共识节点基于其中的完整签名得到随机数种子。该完整签名可以是Leader节点聚合至少quorum个PartialSig2后得到的完整签名。In the above process, during the Precommit voting stage, each consensus node that receives the broadcast message obtains a random number seed based on the complete signature therein. The complete signature can be a complete signature obtained by the Leader node after aggregating at least quorum PartialSig2.
上述过程中,类似的,也可以是在对Commit投票阶段,接收到所述广播消息的每一共识节点基于其中的完整签名得到随机数种子。该完整签名可以是Leader节点聚合至少quorum个PartialSig3后得到的完整签名。进而,接收到该广播消息的每一共识节点基于其中的完整签名得到随机数种子。In the above process, similarly, during the Commit voting stage, each consensus node that receives the broadcast message obtains a random number seed based on the complete signature therein. The complete signature can be a complete signature obtained by the Leader node after aggregating at least quorum PartialSig3. Furthermore, each consensus node that receives the broadcast message obtains a random number seed based on the complete signature therein.
上述PartialSig2或PartialSig3,可以是共识节点基于门限签名算法,采用自身私钥份额对包含本次共识中原始交易列表特有值的原始报文进行签名而生成的签名份额。The above-mentioned PartialSig2 or PartialSig3 can be a signature share generated by the consensus node using 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.
其中,所述原始交易列表的特有值可以包括:原始交易列表本身或者原始交易列表的hash值。The unique value of the original transaction list may include: the original transaction list itself or a hash value of the original transaction list.
其中,所述原始报文还包括上一区块中产生的随机数种子或区块hash。The original message also includes the random number seed or block hash generated in the previous block.
其中,所述收集节点收集齐至少门限数量的签名份额后,得到完整签名之前,还包括:采用对应的公钥份额对每一签名份额进行验证。Wherein, after the collection node collects at least a threshold number of signature shares and before obtaining a complete signature, it further includes: verifying each signature share using the corresponding public key share.
其中,所述得到完整签名之后,得到随机数种子之前,还包括:采用总公钥对所述完整签名进行验证。Wherein, after obtaining the complete signature and before obtaining the random number seed, the method further includes: verifying the complete signature using a total public key.
其中,所述门限签名算法的私钥份额/公钥份额的数量与共识节点的数量相等,所述门限签名算法的门限值与所述区块链所采用共识算法的quorum相等。The number of private key shares/public key shares of the threshold signature algorithm is equal to the number of consensus nodes, and the threshold value of the threshold signature algorithm is equal to the quorum of the consensus algorithm used by the blockchain.
上述方法基础上还可以包括:每一共识节点将得到的随机数种子放至在生成的当前区块的区块头中。Based on the above method, the method may also include: each consensus node puts the obtained random number seed into the block header of the current block generated.
上述方法基础上还可以包括:每一共识节点基于产生的随机数种子产生随机数。Based on the above method, the method may also include: each consensus node generates random numbers based on the generated random number seeds.
如前所述,在基于投票的共识算法中,往往有最后一轮投票,该投票可以是互相直接广播或者通过gossip协议广播,例如PBFT中的commit消息,Tendermint中的pre-commit消息,HoneyBadger中的用于门限解密的消息等。As mentioned before, in voting-based consensus algorithms, there is often a final round of voting, which can be broadcast directly to each other or through gossip protocols, such as commit messages in PBFT, pre-commit messages in Tendermint, and HoneyBadger. Messages used for threshold decryption, etc.
除了广播,最后一轮投票中的消息也可以是由某一节点收集、聚合后再广播给其他节点,例如Hotstuff中的commit消息等,SBFT中的Sign-share消息。本说明书提供的方案适用于此类执行交易前的共识算法中具有最后一轮投票的情形,以在对待执行的交易列表达成共识的同时达成一致的随机数种子,满足一致性、即时性、不可预测、不可操控和不可撤销。In addition to broadcasting, the messages in the last round of voting can also be collected by a node, aggregated and then broadcast to other nodes, such as the commit message in Hotstuff, and the Sign-share message in SBFT. The solution provided in this manual is applicable to the situation where there is a final round of voting in the consensus algorithm before executing the transaction, so as to reach a consensus on the transaction list to be executed and at the same time reach a consistent random number seed, which meets the requirements of consistency, immediacy, and impossibility. Predictable, uncontrollable and irrevocable.
本说明书提供一种区块链上产生随机数种子的方法,包括:在交易执行前的最后一轮投票阶段,每一共识节点基于门限签名算法,采用自身私钥份额对包含本次共识中投票值的原始报文进行签名,生成签名份额,并将该签名份额发送至至少一个收集节点;This specification provides a method for generating random number seeds on the blockchain, including: in the last round of voting before transaction execution, each consensus node uses its own private key share to include the votes in this consensus based on the threshold signature algorithm. Sign the original message with the value, generate a signature share, and send the signature share to at least one collection node;
所述收集节点将收集齐的至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复函数得到完整签名;所述收集节点广播该完整签名至共识节点; 所述接收到该完整签名的每一共识节点基于其中的完整签名得到随机数种子。The collection node passes the collected signature shares of at least a threshold number through the recovery function corresponding to the private key share generated by the threshold signature algorithm to obtain a complete signature; the collection node broadcasts the complete signature to the consensus node; the received Each consensus node of the complete signature obtains a random number seed based on the complete signature.
其中,所述投票值包括:原始交易列表本身或者原始交易列表的hash值。The voting value includes: the original transaction list itself or the hash value of the original transaction list.
其中,所述原始报文还包括区块号和/或时间戳。Wherein, the original message also includes a block number and/or a timestamp.
其中,所述原始报文还包括上一区块中产生的随机数种子或区块hash。The original message also includes the random number seed or block hash generated in the previous block.
其中,所述收集节点收集齐至少门限数量的签名份额后,得到完整签名之前,还包括:采用对应的公钥份额对每一签名份额进行验证。Wherein, after the collection node collects at least a threshold number of signature shares and before obtaining a complete signature, it further includes: verifying each signature share using the corresponding public key share.
其中,所述得到完整签名之后,得到随机数种子之前,还包括:采用总公钥对所述完整签名进行验证。Wherein, after obtaining the complete signature and before obtaining the random number seed, the method further includes: verifying the complete signature using a total public key.
其中,所述门限签名算法的私钥份额/公钥份额的数量与共识节点的数量相等,所述门限签名算法的门限值与所述区块链所采用共识算法的quorum相等。The number of private key shares/public key shares of the threshold signature algorithm is equal to the number of consensus nodes, and the threshold value of the threshold signature algorithm is equal to the quorum of the consensus algorithm used by the blockchain.
一种生成区块头的方法,在上述方法基础上还包括:每一共识节点将得到的随机数种子放至在生成的当前区块的区块头中。A method of generating a block header, based on the above method, also includes: each consensus node puts the obtained random number seed into the block header of the current block generated.
一种区块链上产生随机数的方法,在上述任一方法基础上还包括:每一共识节点基于产生的随机数种子产生随机数。A method of generating random numbers on the blockchain, based on any of the above methods, also includes: each consensus node generates random numbers based on the generated random number seeds.
根据门限签名算法的特性,通过上述方案,所有节点恢复出的签名必定一致,而且该签名具有不可操控和不可预测性,且必须要达到阈值的节点共同签名才能被成功恢复,因此符合链上随机数的要求。According to the characteristics of the threshold signature algorithm, through the above scheme, the signatures recovered by all nodes must be consistent, and the signature is uncontrollable and unpredictable, and it must be jointly signed by nodes that reach the threshold to be successfully recovered, so it is consistent with the randomness on the chain. number requirements.
本说明书实施例还提供一种区块链上产生随机数种子的方法,应用于包括若干共识节点和收集节点的系统,包括:在交易执行前的最后一轮投票阶段,每一共识节点基于门限签名算法,采用自身私钥份额对包含本次共识中投票值的原始报文进行签名,生成签名份额,并将该签名份额发送至至少一个收集节点;所述收集节点将收集齐的至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复函数得到完整签名;所述收集节点广播该完整签名至共识节点;所述接收到该完整签名的每一共识节点基于其中的完整签名得到随机数种子。Embodiments of this specification also provide a method for generating random number seeds on the blockchain, which is applied to a system including several consensus nodes and collection nodes, including: in the last round of voting before transaction execution, each consensus node generates a random number seed based on a threshold. Signature algorithm uses its own private key share to sign the original message containing the voting value in this consensus, generates a signature share, and sends the signature share to at least one collection node; the collection node will collect at least a threshold number The signature share is passed through the recovery function corresponding to the private key share generated by the threshold signature algorithm to obtain a complete signature; the collection node broadcasts the complete signature to the consensus node; each consensus node that receives the complete signature is based on the The complete signature gets the random number seed.
在20世纪90年代,对于一个技术的改进可以很明显地区分是硬件上的改进(例如,对二极管、晶体管、开关等电路结构的改进)还是软件上的改进(对于方法流程的改进)。然而,随着技术的发展,当今的很多方法流程的改进已经可以视为硬件电路结构的直接改进。设计人员几乎都通过将改进的方法流程编程到硬件电路中来得到相应的硬件电路结构。因此,不能说一个方法流程的改进就不能用硬件实体模块来实现。例如,可编程逻辑器件(Programmable Logic Device,PLD)(例如现场可编程门阵列(Field Programmable Gate Array,FPGA))就是这样一种集成电路,其逻辑功能由用户对器件编程来确定。由设计人员自行编程来把一个数字系统“集成”在一片PLD上,而不需要请芯片制造厂商来设计和制作专用的集成电路芯片。而且,如今,取代手工地制作集成电路芯片,这种编程也多半改用“逻辑编译器(logic compiler)”软件来实现,它与程序开发撰写时所用的软件编译器相类似,而要编译之前的原始代码也得用特定的编程语言来撰写,此称之为硬件描述语言(Hardware Description Language,HDL),而HDL也并非仅有一种,而是有许多种,如ABEL(Advanced Boolean Expression Language)、AHDL(Altera Hardware Description Language)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(Ruby Hardware Description Language)等,目前最普遍使用的是VHDL(Very-High-Speed Integrated Circuit Hardware Description Language)与Verilog。本领域技术人员也应该清楚,只需要将方法流程用上述几种硬件描述语言稍作逻辑编程并编程到集成电路中,就可以很容易得到实现该逻辑方法流程的硬件电路。In the 1990s, improvements in a technology could be clearly distinguished as hardware improvements (for example, improvements in circuit structures such as diodes, transistors, switches, etc.) or software improvements (improvements in method processes). However, with the development of technology, many improvements in today's method processes can be regarded as direct improvements in hardware circuit structures. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement of a method flow cannot be implemented using hardware entity modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic functions are determined by the user programming the device. Designers can program themselves to "integrate" a digital system on a PLD, instead of asking chip manufacturers to design and produce dedicated integrated circuit chips. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented using "logic compiler" software, which is similar to the software compiler used in program development and writing, and before compilation The original code must also be written in a specific programming language, which is called Hardware Description Language (HDL), and HDL is not just one kind, but there are many, such as ABEL (Advanced Boolean Expression Language) , AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc., are currently the most commonly used The two are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that by simply logically programming the method flow using the above-mentioned hardware description languages and programming it into the integrated circuit, the hardware circuit that implements the logical method flow can be easily obtained.
控制器可以按任何适当的方式实现,例如,控制器可以采取例如微处理器或处理器以及存储可由该(微)处理器执行的计算机可读程序代码(例如软件或固件)的计算机可读介质、逻辑门、开关、专用集成电路(Application Specific Integrated Circuit,ASIC)、 可编程逻辑控制器和嵌入微控制器的形式,控制器的例子包括但不限于以下微控制器:ARC 625D、Atmel AT91SAM、Microchip PIC18F26K20以及Silicone Labs C8051F320,存储器控制器还可以被实现为存储器的控制逻辑的一部分。本领域技术人员也知道,除了以纯计算机可读程序代码方式实现控制器以外,完全可以通过将方法步骤进行逻辑编程来使得控制器以逻辑门、开关、专用集成电路、可编程逻辑控制器和嵌入微控制器等的形式来实现相同功能。因此这种控制器可以被认为是一种硬件部件,而对其内包括的用于实现各种功能的装置也可以视为硬件部件内的结构。或者甚至,可以将用于实现各种功能的装置视为既可以是实现方法的软件模块又可以是硬件部件内的结构。The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer readable medium storing computer readable program code (eg, software or firmware) executable by the (micro)processor. , logic gates, switches, Application Specific Integrated Circuit (ASIC), programmable logic controllers and embedded microcontrollers. Examples of controllers include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, For Microchip PIC18F26K20 and Silicone Labs C8051F320, the memory controller can also be implemented as part of the memory's control logic. Those skilled in the art also know that in addition to implementing the controller in the form of pure computer-readable program code, the controller can be completely programmed with logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded logic by logically programming the method steps. Microcontroller, etc. to achieve the same function. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the means for implementing various functions can be considered as structures within hardware components as well as software modules implementing the methods.
上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为服务器系统。当然,本说明书不排除随着未来计算机技术的发展,实现上述实施例功能的计算机例如可以为个人计算机、膝上型计算机、车载人机交互设备、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任何设备的组合。The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a server system. Of course, this description does not rule out that with the development of computer technology in the future, the computer that implements the functions of the above embodiments may be, for example, a personal computer, a laptop computer, a vehicle-mounted human-computer interaction device, a cellular phone, a camera phone, a smart phone, or a personal digital assistant. , media player, navigation device, email device, game console, tablet, wearable device, or a combination of any of these devices.
虽然本说明书一个或多个实施例提供了如实施例或流程图所述的方法操作步骤,但基于常规或者无创造性的手段可以包括更多或者更少的操作步骤。实施例中列举的步骤顺序仅仅为众多步骤执行顺序中的一种方式,不代表唯一的执行顺序。在实际中的装置或终端产品执行时,可以按照实施例或者附图所示的方法顺序执行或者并行执行(例如并行处理器或者多线程处理的环境,甚至为分布式数据处理环境)。术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、产品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、产品或者设备所固有的要素。在没有更多限制的情况下,并不排除在包括所述要素的过程、方法、产品或者设备中还存在另外的相同或等同要素。例如若使用到第一,第二等词语用来表示名称,而并不表示任何特定的顺序。Although one or more embodiments of this specification provide method operation steps as described in the embodiments or flow charts, more or fewer operation steps may be included based on conventional or non-inventive means. The sequence of steps listed in the embodiment is only one way of executing the sequence of many steps, and does not represent the only execution sequence. When the actual device or terminal product is executed, it may be executed sequentially or in parallel according to the methods shown in the embodiments or figures (for example, a parallel processor or a multi-thread processing environment, or even a distributed data processing environment). The terms "comprises," "comprises" or any other variation thereof are intended to cover a non-exclusive inclusion such that a process, method, product or apparatus including a list of elements includes not only those elements but also others not expressly listed elements, or also elements inherent to the process, method, product or equipment. Without further limitation, it does not exclude the presence of additional identical or equivalent elements in a process, method, product or apparatus including the stated elements. For example, if the words "first" and "second" are used to express names, they do not indicate any specific order.
为了描述的方便,描述以上装置时以功能分为各种模块分别描述。当然,在实施本说明书一个或多个时可以把各模块的功能在同一个或多个软件和/或硬件中实现,也可以将实现同一功能的模块由多个子模块或子单元的组合实现等。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。For the convenience of description, when describing the above device, the functions are divided into various modules and described separately. Of course, when implementing one or more of this specification, the functions of each module can be implemented in the same or multiple software and/or hardware, or the modules that implement the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. . The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated. to another system, or some features can be ignored, or not implemented. On the other hand, the coupling or direct coupling or communication connection between each other shown or discussed may be through some interfaces, and the indirect coupling or communication connection of the devices or units may be in electrical, mechanical or other forms.
本说明书是参照根据本说明书实施例的方法、装置(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The specification is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the specification. It will be understood that each process and/or block in the flowchart illustrations and/or block diagrams, and combinations of processes and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine, such that the instructions executed by the processor of the computer or other programmable data processing device produce a use A device for realizing the functions specified in one process or multiple processes of the flowchart and/or one block or multiple blocks of the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。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.
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。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.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储、石墨烯存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。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. (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, Magnetic tape, magnetic tape storage, graphene storage or other magnetic storage devices or any other non-transmission medium can be used to store information that can be accessed by a computing device. As defined in this article, computer-readable media does not include transitory media, such as modulated data signals and carrier waves.
本领域技术人员应明白,本说明书一个或多个实施例可提供为方法、系统或计算机程序产品。因此,本说明书一个或多个实施例可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本说明书一个或多个实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。It should be understood by those skilled in the art that 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.
本说明书一个或多个实施例可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本本说明书一个或多个实施例,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。One or more embodiments of this specification may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. One or more embodiments of the present description may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including storage devices.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本说明书的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不必须针对的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任一个或多个实施例或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本领域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或示例的特征进行结合和组合。Each embodiment in this specification is described in a progressive manner. The same and similar parts between the various embodiments can be referred to each other. Each embodiment focuses on its differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple. For relevant details, please refer to the partial description of the method embodiment. In the description of this specification, reference to the terms "one embodiment," "some embodiments," "an example," "specific examples," or "some examples" or the like means that specific features are described in connection with the embodiment or example. , structures, materials or features are included in at least one embodiment or example of this specification. In this specification, the schematic expressions of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the specific features, structures, materials or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, those skilled in the art may combine and combine different embodiments or examples and features of different embodiments or examples described in this specification unless they are inconsistent with each other.
以上所述仅为本说明书一个或多个实施例的实施例而已,并不用于限制本本说明书一个或多个实施例。对于本领域技术人员来说,本说明书一个或多个实施例可以有各种更改和变化。凡在本说明书的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在权利要求范围之内。The above descriptions are only examples of one or more embodiments of this specification, and are not intended to limit one or more embodiments of this specification. To those skilled in the art, various modifications and changes may be made to one or more embodiments of this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this specification shall be included in the scope of the claims.

Claims (27)

  1. 一种区块链上产生随机数种子的方法,包括:A method of generating random number seeds on the blockchain, including:
    在类SBFT共识的Sign-share阶段,每一共识节点基于门限签名算法,采用自身私钥份额对包含本次共识中原始交易列表特有值的原始报文进行签名,生成签名份额,并将该签名份额加入到Sign-share消息中发送至至少一个收集节点;In the Sign-share phase of the SBFT-like consensus, each consensus 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 sends the signature The share is added to the Sign-share message and sent to at least one collection node;
    所述收集节点收集齐至少门限数量的Sign-share消息后将其中的至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复函数得到完整签名;After the collection node collects at least a threshold number of Sign-share messages, at least a threshold number of signature shares among them are passed through the recovery function corresponding to the private key share generated by the threshold signature algorithm to obtain a complete signature;
    所述收集节点广播包含该完整签名的full-commit-proof消息至共识节点;The collection node broadcasts the full-commit-proof message containing the complete signature to the consensus node;
    接收到full-commit-proof消息的每一共识节点基于其中的完整签名得到随机数种子。Each consensus node that receives the full-commit-proof message obtains a random number seed based on the complete signature in it.
  2. 如权利要求1所述的方法,所述原始交易列表的特有值包括:The method according to claim 1, the unique values of the original transaction list include:
    原始交易列表本身或者原始交易列表的hash值。The original transaction list itself or the hash value of the original transaction list.
  3. 如权利要求1所述的方法,所述原始报文还包括区块号和/或时间戳。The method of claim 1, wherein the original message further includes a block number and/or a timestamp.
  4. 如权利要求1所述的方法,所述原始报文还包括上一区块中产生的随机数种子或区块hash。The method of claim 1, wherein the original message further includes a random number seed or block hash generated in the previous block.
  5. 如权利要求1所述的方法,所述收集节点收集齐至少门限数量的Sign-share消息后,得到完整签名之前,还包括:The method according to claim 1, after the collection node collects at least a threshold number of Sign-share messages and before obtaining a complete signature, it also includes:
    采用对应的公钥份额对每一Sign-share消息中的签名份额进行验证。The signature share in each Sign-share message is verified using the corresponding public key share.
  6. 如权利要求1所述的方法,所述得到完整签名之后,得到随机数种子之前,还包括:The method according to claim 1, after obtaining the complete signature and before obtaining the random number seed, further comprising:
    采用总公钥对所述完整签名进行验证。The complete signature is verified using the total public key.
  7. 如权利要求1-6中任一项所述的方法,所述门限签名算法的私钥份额/公钥份额的数量与共识节点的数量相等,所述门限签名算法的门限值与所述区块链所采用共识算法的quorum相等。The method according to any one of claims 1 to 6, the number of private key shares/public key shares of the threshold signature algorithm is equal to the number of consensus nodes, and the threshold value of the threshold signature algorithm is equal to the number of consensus nodes. The quorum of the consensus algorithm used by the blockchain is equal.
  8. 一种生成区块头的方法,在上述1-7任一方法基础上还包括:A method of generating block headers, based on any of the above methods 1-7, also includes:
    每一共识节点将得到的随机数种子放至在生成的当前区块的区块头中。Each consensus node puts the obtained random number seed into the block header of the current block generated.
  9. 一种区块链上产生随机数的方法,在上述1-7任一方法基础上还包括:A method of generating random numbers on the blockchain, based on any of the above methods 1-7, also includes:
    每一共识节点基于产生的随机数种子产生随机数。Each consensus node generates random numbers based on the generated random number seeds.
  10. 一种区块链上产生随机数种子的方法,包括:A method of generating random number seeds on the blockchain, including:
    在类Hotstuff共识的对Pre-Commit/Commit投票阶段,每一共识节点基于门限签名算法,采用自身私钥份额对包含本次共识中原始交易列表特有值的原始报文进行签名,生成签名份额,并将该签名份额加入到广播的消息中发送至收集节点;In the Pre-Commit/Commit voting stage of the Hotstuff-like consensus, each consensus 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, and generates a signature share. And add the signature share to the broadcast message and send it to the collection node;
    所述收集节点收集齐至少门限数量的广播消息后将其中的至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复函数得到完整签名,广播包含该完整签名的消息至共识节点;After collecting at least a threshold number of broadcast messages, the collection node passes at least a threshold number of signature shares among them through the recovery function corresponding to the private key share generated by the threshold signature algorithm to obtain a complete signature, and broadcasts the message containing the complete signature to Consensus node;
    接收到所述广播消息的每一共识节点基于其中的完整签名得到随机数种子。Each consensus node that receives the broadcast message obtains a random number seed based on the complete signature therein.
  11. 如权利要求10所述的方法,所述原始交易列表的特有值包括:The method of claim 10, wherein the unique values of the original transaction list include:
    原始交易列表本身或者原始交易列表的hash值。The original transaction list itself or the hash value of the original transaction list.
  12. 如权利要求10所述的方法,所述原始报文还包括上一区块中产生的随机数种子或区块hash。The method of claim 10, wherein the original message further includes a random number seed or block hash generated in the previous block.
  13. 如权利要求10所述的方法,所述收集节点收集齐至少门限数量的Sign-share消息后,得到完整签名之前,还包括:The method according to claim 10, after the collection node collects at least a threshold number of Sign-share messages and before obtaining a complete signature, it further includes:
    采用对应的公钥份额对每一Sign-share消息中的签名份额进行验证。The signature share in each Sign-share message is verified using the corresponding public key share.
  14. 如权利要求10所述的方法,所述得到完整签名之后,得到随机数种子之前,还包括:The method according to claim 10, after obtaining the complete signature and before obtaining the random number seed, it further includes:
    采用总公钥对所述完整签名进行验证。The complete signature is verified using the total public key.
  15. 如权利要求10-14中任一项所述的方法,所述门限签名算法的私钥份额/公钥份 额的数量与共识节点的数量相等,所述门限签名算法的门限值与所述区块链所采用共识算法的quorum相等。The method according to any one of claims 10 to 14, the number of private key shares/public key shares of the threshold signature algorithm is equal to the number of consensus nodes, and the threshold value of the threshold signature algorithm is equal to the number of consensus nodes. The quorum of the consensus algorithm used by the blockchain is equal.
  16. 一种生成区块头的方法,在上述10-15任一方法基础上还包括:A method of generating block headers, based on any of the methods 10-15 above, also includes:
    每一共识节点将得到的随机数种子放至在生成的当前区块的区块头中。Each consensus node puts the obtained random number seed into the block header of the current block generated.
  17. 一种区块链上产生随机数的方法,在上述10-15任一方法基础上还包括:A method of generating random numbers on the blockchain, based on any of the methods 10-15 above, also includes:
    每一共识节点基于产生的随机数种子产生随机数。Each consensus node generates random numbers based on the generated random number seeds.
  18. 一种区块链上产生随机数种子的方法,应用于包括若干共识节点和收集节点的系统,包括:A method of generating random number seeds on the blockchain, applied to systems including several consensus nodes and collection nodes, including:
    在交易执行前的最后一轮投票阶段,每一共识节点基于门限签名算法,采用自身私钥份额对包含本次共识中投票值的原始报文进行签名,生成签名份额,并将该签名份额发送至至少一个收集节点;In the last round of voting before transaction execution, each consensus node uses its own private key share to sign the original message containing the voting value in this consensus based on the threshold signature algorithm, generates a signature share, and sends the signature share to at least one collection node;
    所述收集节点将收集齐的至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复函数得到完整签名;The collection node will collect at least a threshold number of signature shares through the recovery function corresponding to the private key share generated by the threshold signature algorithm to obtain a complete signature;
    所述收集节点广播该完整签名至共识节点;The collection node broadcasts the complete signature to the consensus node;
    接收到该完整签名的每一共识节点基于其中的完整签名得到随机数种子。Each consensus node that receives the complete signature obtains a random number seed based on the complete signature.
  19. 如权利要求18所述的方法,所述投票值包括:The method of claim 18, the voting value includes:
    原始交易列表本身或者原始交易列表的hash值。The original transaction list itself or the hash value of the original transaction list.
  20. 如权利要求18所述的方法,所述原始报文还包括区块号和/或时间戳。The method of claim 18, the original message further includes a block number and/or a timestamp.
  21. 如权利要求18所述的方法,所述原始报文还包括上一区块中产生的随机数种子或区块hash。The method of claim 18, wherein the original message further includes a random number seed or block hash generated in the previous block.
  22. 如权利要求18所述的方法,所述收集节点收集齐至少门限数量的签名份额后,得到完整签名之前,还包括:The method of claim 18, after the collection node collects at least a threshold number of signature shares and before obtaining a complete signature, it further includes:
    采用对应的公钥份额对每一签名份额进行验证。Each signature share is verified using the corresponding public key share.
  23. 如权利要求18所述的方法,所述得到完整签名之后,得到随机数种子之前,还包括:The method according to claim 18, after obtaining the complete signature and before obtaining the random number seed, further comprising:
    采用总公钥对所述完整签名进行验证。The complete signature is verified using the total public key.
  24. 如权利要求18-23中任一项所述的方法,所述门限签名算法的私钥份额/公钥份额的数量与共识节点的数量相等,所述门限签名算法的门限值与所述区块链所采用共识算法的quorum相等。The method according to any one of claims 18-23, the number of private key shares/public key shares of the threshold signature algorithm is equal to the number of consensus nodes, and the threshold value of the threshold signature algorithm is equal to the number of consensus nodes. The quorum of the consensus algorithm used by the blockchain is equal.
  25. 一种生成区块头的方法,在上述18-24任一方法基础上还包括:A method of generating block headers, based on any of the methods 18-24 above, also includes:
    每一共识节点将得到的随机数种子放至在生成的当前区块的区块头中。Each consensus node puts the obtained random number seed into the block header of the current block generated.
  26. 一种区块链上产生随机数的方法,在上述18-24任一方法基础上还包括:A method of generating random numbers on the blockchain, based on any of the above methods 18-24, also includes:
    每一共识节点基于产生的随机数种子产生随机数。Each consensus node generates random numbers based on the generated random number seeds.
  27. 一种区块链上产生随机数种子的方法,应用于包括若干共识节点和收集节点的系统,包括:A method of generating random number seeds on the blockchain, applied to systems including several consensus nodes and collection nodes, including:
    在交易执行前的最后一轮投票阶段,每一共识节点基于门限签名算法,采用自身私钥份额对包含本次共识中投票值的原始报文进行签名,生成签名份额,并将该签名份额发送至至少一个收集节点;In the last round of voting before transaction execution, each consensus node uses its own private key share to sign the original message containing the voting value in this consensus based on the threshold signature algorithm, generates a signature share, and sends the signature share to at least one collection node;
    所述收集节点将收集齐的至少门限数量的签名份额经过所述门限签名算法产生的私钥份额所对应的恢复函数得到完整签名;The collection node will collect at least a threshold number of signature shares through the recovery function corresponding to the private key share generated by the threshold signature algorithm to obtain a complete signature;
    所述收集节点广播该完整签名至共识节点;The collection node broadcasts the complete signature to the consensus node;
    接收到该完整签名的每一共识节点基于其中的完整签名得到随机数种子。Each consensus node that receives the complete signature obtains a random number seed based on the complete signature.
PCT/CN2022/135233 2022-03-29 2022-11-30 Method and system for generating random seed on blockchain, and consensus node WO2023185045A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210325831.0A CN114726517A (en) 2022-03-29 2022-03-29 Method, system and consensus node for generating random number seeds on block chain
CN202210325831.0 2022-03-29

Publications (1)

Publication Number Publication Date
WO2023185045A1 true WO2023185045A1 (en) 2023-10-05

Family

ID=82239300

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/135233 WO2023185045A1 (en) 2022-03-29 2022-11-30 Method and system for generating random seed on blockchain, and consensus node

Country Status (2)

Country Link
CN (1) CN114726517A (en)
WO (1) WO2023185045A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117408718A (en) * 2023-12-14 2024-01-16 南京邮电大学 PBFT optimization method for large-scale medicine traceability

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114726517A (en) * 2022-03-29 2022-07-08 蚂蚁区块链科技(上海)有限公司 Method, system and consensus node for generating random number seeds on block chain
CN115392912B (en) * 2022-10-26 2023-03-14 南方科技大学 Random number generation method, system, device and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111756823A (en) * 2020-06-12 2020-10-09 山西警察学院 Open permit chain applied to public security system based on simplified Byzantine fault-tolerant algorithm
CN112636905A (en) * 2020-12-11 2021-04-09 北京航空航天大学 System and method for extensible consensus mechanism based on multiple roles
US20210256011A1 (en) * 2020-02-14 2021-08-19 Vmware, Inc. Linear byzantine agreement
CN114726517A (en) * 2022-03-29 2022-07-08 蚂蚁区块链科技(上海)有限公司 Method, system and consensus node for generating random number seeds on block chain

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110825349B (en) * 2019-11-14 2023-03-28 深圳市迅雷网络技术有限公司 Random number generation method, block chain node, system and medium
CN113612604B (en) * 2021-07-30 2022-05-17 北京航空航天大学 Asynchronous network-oriented safe distributed random number generation method and device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20210256011A1 (en) * 2020-02-14 2021-08-19 Vmware, Inc. Linear byzantine agreement
CN111756823A (en) * 2020-06-12 2020-10-09 山西警察学院 Open permit chain applied to public security system based on simplified Byzantine fault-tolerant algorithm
CN112636905A (en) * 2020-12-11 2021-04-09 北京航空航天大学 System and method for extensible consensus mechanism based on multiple roles
CN114726517A (en) * 2022-03-29 2022-07-08 蚂蚁区块链科技(上海)有限公司 Method, system and consensus node for generating random number seeds on block chain

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117408718A (en) * 2023-12-14 2024-01-16 南京邮电大学 PBFT optimization method for large-scale medicine traceability
CN117408718B (en) * 2023-12-14 2024-03-08 南京邮电大学 PBFT optimization method for large-scale medicine traceability

Also Published As

Publication number Publication date
CN114726517A (en) 2022-07-08

Similar Documents

Publication Publication Date Title
WO2023185045A1 (en) Method and system for generating random seed on blockchain, and consensus node
US10791107B2 (en) Performing a change of primary node in a distributed system
EP3566392B1 (en) Achieving consensus among network nodes in a distributed system
US10649859B2 (en) Performing a recovery process for a network node in a distributed system
US11895248B2 (en) Method and apparatus for generating blockchain transaction
WO2023185051A1 (en) Method for generating random number seeds on blockchain, and system and consensus node
CN110689349B (en) Transaction hash value storage and searching method and device in blockchain
WO2023056974A1 (en) Consensus method, blockchain system and consensus nodes
WO2023056964A1 (en) Consensus method, blockchain system, and consensus node
WO2023056958A1 (en) Consensus method, blockchain system, and consensus node
WO2023056967A1 (en) Consensus method, blockchain system and consensus nodes
WO2023185046A1 (en) Method for rotating consensus nodes in blockchain system, and nodes and blockchain system
WO2023056966A1 (en) Consensus method, blockchain system, and consensus node
US11314564B2 (en) Blockchain event processing method and apparatus
CN114640451A (en) Method, system and consensus node for realizing distributed key generation on block chain
CN114640452B (en) Method and system for starting distributed key generation process on block chain
CN115865341A (en) Method, system and node for realizing distributed key generation on block chain
CN115174048A (en) Consensus method, system and consensus node
CN114650132A (en) Method, system and consensus node for realizing distributed key generation on block chain
CN115941163A (en) Method, system and node for realizing distributed key generation on block chain
CN115941164A (en) Method, system and node for realizing distributed key generation on block chain
CN116015621A (en) Method, system and node for realizing distributed key generation on blockchain
CN116032461A (en) Method and node for realizing distributed key generation on blockchain
CN114640450A (en) Method and system for realizing distributed key generation on block chain
CN115801780A (en) Consensus node rotation method and block link point

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: 22934863

Country of ref document: EP

Kind code of ref document: A1