WO2021135757A1 - Method and apparatus for executing transaction correctness verification - Google Patents

Method and apparatus for executing transaction correctness verification Download PDF

Info

Publication number
WO2021135757A1
WO2021135757A1 PCT/CN2020/132060 CN2020132060W WO2021135757A1 WO 2021135757 A1 WO2021135757 A1 WO 2021135757A1 CN 2020132060 W CN2020132060 W CN 2020132060W WO 2021135757 A1 WO2021135757 A1 WO 2021135757A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
block
consensus
verified
correctness
Prior art date
Application number
PCT/CN2020/132060
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 WO2021135757A1 publication Critical patent/WO2021135757A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3825Use of electronic signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3829Payment protocols; Details thereof insuring higher security of transaction involving key management
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/04Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
    • H04L63/0428Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/08Network architectures or network communication protocols for network security for authentication of entities
    • H04L63/0876Network architectures or network communication protocols for network security for authentication of entities based on the identity of the terminal or configuration, e.g. MAC address, hardware or software configuration or device fingerprint
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/12Applying verification of the received information
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • H04L67/025Protocols based on web technology, e.g. hypertext transfer protocol [HTTP] for remote control or remote monitoring of applications
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]

Definitions

  • the embodiments of this specification relate to the field of blockchain technology, in particular, to methods and devices for performing transaction correctness verification.
  • the blockchain system includes full nodes and lightweight nodes.
  • the full amount of nodes maintains complete block chain information, while the lightweight nodes usually only need to maintain the block header information of each block chain.
  • SPV Simple Payment Verification
  • Lightweight nodes usually use SPV verification technology to verify transactions. If you want to prove that the transaction has been executed correctly, SPV verification needs to include existence verification and correctness verification.
  • SPV verification technology provides an existence verification method, but there are still many difficulties for lightweight nodes to prove that the transaction is executed by the correct consensus node in the correct consensus process. Therefore, there is an urgent need for effective and feasible means to verify the correctness of transactions.
  • the embodiments of this specification provide a method and device for performing transaction correctness verification.
  • a method for performing transaction correctness verification is executed by a lightweight node in a blockchain system, and the method includes: obtaining the to-be-verified node from the full amount of nodes.
  • Consensus proof information of the block includes a digital signature set, and the digital signature set is the first signature data corresponding to the block to be verified by each consensus node that has reached a consensus on the block to be verified
  • the original text is signed; based on the digital signature set and the public key set at the lightweight node to verify the correctness of the consensus proof information, the public key set includes at least part of the block system
  • the public key of the block chain node and based on the correctness verification result of the consensus certification information, the correctness of the transaction set in the block to be verified is determined.
  • the method may further include: from the full node Obtaining the block body information of the block to be verified at any location; based on the block body information, verifying the correctness of the block header of the block to be verified at the lightweight node.
  • determining the correctness of the transaction set in the block to be verified includes: the correctness verification result based on the block header and the correctness verification result of the block proof information To determine the correctness of the transaction set in the block to be verified.
  • verifying the correctness of the consensus certification information based on the digital signature set and the public key set at the lightweight node may include: using each consensus node to sign the original text of the first signature data
  • the encryption algorithm used restores the public key of each consensus node from the set of digital signatures; and verifies the public key of each consensus node based on the restored public key of each consensus node and the set of public keys at the lightweight node.
  • the stated consensus proves the correctness of the information.
  • verifying the correctness of the transaction in the block to be verified may include: When at least part of the restored public keys are included in the public key set and the number of public keys included in the public key set meets the consensus rule, it is determined that the consensus certification information is correct.
  • the set of public keys may include the public keys of all blockchain nodes participating in the consensus in the blockchain system, or the set of public keys may include The public key of all consensus nodes that conduct consensus at the trust anchor point at the location, and the trust anchor point indicates the trust block that has been verified as correct.
  • the method may further include: receiving a transaction correctness verification request for a specified transaction in the transaction set.
  • Obtaining the consensus proof information of the block to be verified from the full number of nodes may include: obtaining the consensus proof information of the block to be verified from the full number of nodes when the transaction correctness verification request is received.
  • the method may further include: verifying whether the specified transaction exists in the transaction set; and based on the correctness verification result of the transaction set and the existence verification result of the specified transaction in the to-be-verified block To determine the correctness of the specified transaction.
  • the method may further include: monitoring whether there is a block to be verified that includes the specified transaction.
  • Obtaining the consensus certification information of the block to be verified from the full number of nodes includes: when the block to be verified including the specified transaction is monitored, obtaining the consensus certification information of the block to be verified that is monitored from the full number of nodes.
  • the method may further include: receiving a transaction correctness verification request for a designated transaction in the transaction set; verifying whether the designated transaction exists in the transaction set; and The correctness verification result of the transaction set and the existence verification result of the designated transaction in the to-be-verified block determine the correctness of the designated transaction.
  • the blockchain system may be a consortium chain system.
  • a device for performing transaction correctness verification is used for a lightweight node in a blockchain system.
  • the device includes: a consensus certification information acquisition unit, The node obtains the consensus proof information of the block to be verified.
  • the consensus proof information includes a set of digital signatures.
  • the set of digital signatures corresponds to each consensus node that has reached a consensus on the block to be verified.
  • the first signature data is obtained by signing the original text; the consensus certification information verification unit verifies the correctness of the consensus certification information based on the digital signature set and the public key set at the lightweight node, the public key set It includes the public keys of at least part of the blockchain nodes in the block system; and a transaction set verification unit, which determines the correctness of the transaction set in the block to be verified based on the verification result of the correctness of the consensus certification information .
  • the device may further include: a block body information obtaining unit, which determines the correctness of the transaction set in the block to be verified based on the correctness verification result of the consensus proof information Previously, the block body information of the block to be verified was obtained from the full node; the block header verification unit, based on the block body information, verifies the area of the block to be verified at the lightweight node The correctness of the bulk.
  • the consensus proof information verification unit may determine the correctness of the transaction set in the block to be verified based on the correctness verification result of the block header and the correctness verification result of the block proof information.
  • the transaction set verification unit may include: a public key restoration module, which uses the encryption algorithm used by each consensus node to sign the original text of the first signature data to restore from the digital signature set The public key of each consensus node; and the consensus certification information verification module verify the correctness of the consensus certification information based on the restored public key of each consensus node and the public key set at the lightweight node.
  • a public key restoration module which uses the encryption algorithm used by each consensus node to sign the original text of the first signature data to restore from the digital signature set The public key of each consensus node
  • the consensus certification information verification module verify the correctness of the consensus certification information based on the restored public key of each consensus node and the public key set at the lightweight node.
  • the consensus certification information verification module may include at least part of the restored public key in the public key set and the public key included in the public key set When the quantity satisfies the consensus rule, it is determined that the consensus certification information is correct.
  • the set of public keys includes the public keys of all blockchain nodes participating in the consensus in the blockchain system, or the set of public keys includes the
  • the trust anchor is the public key of all consensus nodes that perform consensus, and the trust anchor indicates the trust block that has been verified as correct.
  • the device may further include: a verification request receiving unit, which receives that the transaction for the specified transaction in the transaction set is correct sexual verification request.
  • the consensus proof information obtaining unit obtains the consensus proof information of the block to be verified from all nodes when receiving the transaction correctness verification request.
  • the device may further include: an existence verification unit that verifies whether the specified transaction exists in the transaction set; and a specified transaction correctness determination unit based on the correctness verification result of the transaction set and the specified transaction The existence verification result in the to-be-verified block determines the correctness of the specified transaction.
  • the device may further include: a block to be verified monitoring unit, which monitors whether there is a block to be verified that includes the specified transaction before obtaining the consensus proof information of the block to be verified from the full number of nodes .
  • the consensus proof information obtaining unit may obtain the monitored consensus proof information of the block to be verified from the full number of nodes when it monitors that there is a block to be verified that includes the designated transaction.
  • the device may further include: a verification request receiving unit to receive a transaction correctness verification request for a specified transaction in the transaction set; an existence verification unit to verify whether the specified transaction exists In the transaction set; and a designated transaction correctness determination unit, based on the correctness verification result of the transaction set and the existence verification result of the designated transaction in the to-be-verified block, determine the designated transaction Correctness.
  • a verification request receiving unit to receive a transaction correctness verification request for a specified transaction in the transaction set
  • an existence verification unit to verify whether the specified transaction exists In the transaction set
  • a designated transaction correctness determination unit based on the correctness verification result of the transaction set and the existence verification result of the designated transaction in the to-be-verified block, determine the designated transaction Correctness.
  • a computing device including: at least one processor; and a memory, the memory stores instructions, and when the instructions are executed by the at least one processor, the At least one processor executes the method as described above.
  • a non-transitory machine-readable storage medium which stores executable instructions, which when executed cause the machine to execute the method as described above.
  • the correctness of the transaction set on the block to be proven can be verified by verifying the consensus proof information of the block to be verified, so that the lightweight node can be used without accessing multiple full nodes. Verify the correctness of the transaction.
  • FIG. 1 shows a schematic diagram of an example of an environment that can be used to execute a method for performing transaction correctness verification according to an embodiment of the present specification
  • FIG. 2 shows a schematic diagram of an example of a system architecture for executing the method for performing transaction correctness verification according to an embodiment of the present specification
  • Figure 3 shows a flowchart of an example of a consensus process applicable to a blockchain system
  • FIG. 4 shows a schematic diagram of an example of a blockchain system to which the method for performing transaction correctness verification according to an embodiment of the present specification is applicable;
  • Fig. 5 is a flowchart of a method for performing transaction correctness verification according to an embodiment of the present specification
  • Fig. 6 is a flowchart of an example of a consensus proof information verification process in a method for performing transaction correctness verification according to an embodiment of the present specification
  • Fig. 7 is a flowchart of a method for performing transaction correctness verification according to another embodiment of the present specification.
  • Fig. 8 is a flowchart of a method for performing transaction correctness verification according to another embodiment of the present specification.
  • FIG. 9 is a schematic diagram for explaining the transaction existence verification process in the method for performing transaction correctness verification according to an embodiment of the present specification.
  • Fig. 10 is a flowchart of a method for performing transaction correctness verification according to another embodiment of the present specification.
  • FIG. 11 is a structural block diagram of a device for performing transaction correctness verification according to an embodiment of the present specification.
  • FIG. 12 is a structural block diagram of the consensus proof verification process in the device for performing transaction correctness verification shown in FIG. 11;
  • Fig. 13 is a structural block diagram of a computing device for implementing a method for verifying the correctness of a transaction according to an embodiment of the present specification.
  • the term “including” and its variations mean open terms, meaning “including but not limited to”.
  • the term “based on” means “based at least in part on.”
  • the terms “one embodiment” and “an embodiment” mean “at least one embodiment.”
  • the term “another embodiment” means “at least one other embodiment.”
  • the terms “first”, “second”, etc. may refer to different or the same objects. Other definitions can be included below, whether explicit or implicit. Unless clearly indicated in the context, the definition of a term is consistent throughout the specification.
  • connection refers to direct mechanical connection, communication or electrical connection between two components, or indirect mechanical connection, communication or electrical connection through intermediate components.
  • electrically connected refers to the possibility of electrical communication between two components for data/information exchange.
  • the electrical connection may refer to a direct electrical connection between two components, or an indirect electrical connection through an intermediate component.
  • the electrical connection can be implemented in a wired manner or a wireless manner.
  • Blockchain is a chain data structure that connects and combines data blocks sequentially in chronological order, and cryptographically ensures that the data blocks cannot be tampered with or forged.
  • the blockchain includes one or more blocks. Each block in the blockchain is linked to the previous block by including the cryptographic hash of the immediately preceding block in the blockchain. Each block also includes a timestamp, a cryptographic hash of the block, and one or more transactions.
  • the transaction that has been verified by the blockchain node is hashed and a Merkle tree is formed. In the Merkle tree, the data at the leaf nodes is hashed, and for each branch of the Merkle tree, all the hash values of the branch are concatenated at the root of the branch.
  • the above processing is performed on the Merkle tree until the root node of the entire Merkle tree.
  • the root node of the Merkle tree stores hash values representing all data in the Merkle tree.
  • Blockchain is a data structure used to store transactions.
  • the blockchain network is a network of computing nodes used to manage, update and maintain one or more blockchain structures.
  • the blockchain network can include a public blockchain network, a private blockchain network, or a consortium blockchain network.
  • the consensus process is controlled by the nodes of the consensus network.
  • the public blockchain network can be considered as a public network of participating entities.
  • most entities nodes must sign each block in sequence, and add the signed block to the blockchain of the blockchain network.
  • Examples of public blockchain networks may include specific peer-to-peer payment networks.
  • blockchain does not specifically refer to any particular blockchain.
  • the public blockchain network supports public transactions. Public transactions are shared among all nodes in the public blockchain network and stored in the global blockchain.
  • a global blockchain refers to a blockchain that is replicated across all nodes.
  • consensus protocols include but are not limited to: proof-of-work (POW), proof-of-stake (POS), and proof-of-authority (POA).
  • POW is used as a non-limiting example.
  • Private blockchain networks are provided for specific entities.
  • the read and write permissions of each node in the private blockchain network are strictly controlled. Therefore, a private blockchain network is usually also called a permissioned network, which restricts who is allowed to participate in the network and the level of network participation (for example, only in certain transaction situations).
  • a private blockchain network various types of access control mechanisms can be used (for example, existing participants vote to add new entities, regulatory agencies control permissions, etc.).
  • the alliance blockchain network is private among participating entities.
  • the consensus process is controlled by authorized nodes.
  • a consortium composed of several (for example, 10) entities (for example, financial institutions, insurance companies) can operate a consortium blockchain network, and each entity operates at least one node in the consortium blockchain network. Therefore, the consortium blockchain network can be considered as a private network of participating entities.
  • each participating entity node
  • each block may be signed by a subset of participating entities (nodes) (for example, at least 7 entities), and the block may be added to the blockchain.
  • Blockchain is a tamper-proof shared digital ledger that records transactions in a public or private peer-to-peer network.
  • the ledger is distributed to all member nodes in the network, and the history of asset transactions that occurred in the network is permanently recorded in the block.
  • the consensus mechanism ensures that all blockchain nodes in the distributed blockchain network execute transactions in the same order and then write to the same ledger.
  • FIG. 1 shows a schematic diagram of an example of an environment 100 that can be used to execute a method for performing transaction correctness verification according to an embodiment of the present disclosure.
  • the environment 100 enables entities to participate in the blockchain network 102.
  • the environment 100 includes a network 104, and computing devices/systems 106, 108.
  • the network 104 may include a local area network (LAN), a wide area network (WAN), the Internet, or a combination thereof, and connect a website, a user device (eg, a computing device), and a back-end system.
  • the network 104 may be accessed through a wired and/or wireless communication link.
  • the computing devices/systems 106 and 108 communicate with each other through the network 104, and communicate with the blockchain network 102 through the network 104, and the nodes (or node devices) in the blockchain network 102 pass through The network 104 communicates.
  • the network 104 represents one or more communication networks.
  • the computing devices/systems 106, 108 may be nodes of a cloud computing system (not shown), or each computing device/system 106, 108 may be a separate cloud computing system, including interconnection through the network 104 Multiple computers and used as a distributed processing system.
  • each of the computing devices/systems 106, 108 may include any suitable computing system capable of participating as a node in the blockchain network 102.
  • Examples of computing devices/systems include, but are not limited to, servers, desktop computers, notebook computers, tablet devices, smart phones, etc.
  • one or more computer-implemented services for interacting with the blockchain network 102 may be installed on the computing device/system 106, 108.
  • the computing device/system 106 may be installed with the services of the first entity (for example, user A), for example, the first entity is used to manage transactions with one or more other entities (for example, other users). Management system.
  • the computing device/system 108 may be installed with services of a second entity (for example, user B), for example, a transaction management system used by the second entity to manage transactions with one or more other entities (for example, other users) .
  • a second entity for example, user B
  • a transaction management system used by the second entity to manage transactions with one or more other entities (for example, other users) .
  • the blockchain network 102 is represented as a peer-to-peer network of nodes, and the computing devices/systems 106, 108 serve as the nodes of the first entity and the second entity participating in the blockchain network 102, respectively.
  • FIG. 2 shows a schematic diagram of an example of a system architecture 200 that executes the method for performing transaction correctness verification according to an embodiment of the present disclosure.
  • An example of the system architecture 200 includes the participant systems 202, 204, and 206 corresponding to the participant A, the participant B, and the participant C, respectively.
  • Each participant eg, user, enterprise
  • the blockchain network 212 includes a plurality of nodes 214, wherein at least some of the nodes 214 record information in the blockchain 216, and the recorded information cannot be changed.
  • a single blockchain 216 is schematically shown within the blockchain network 212, multiple copies of the blockchain 216 may be provided, and multiple copies are maintained in the blockchain network 212, as described in detail later of.
  • each participant system 202, 204, 206 is provided by participant A, participant B, and participant C, or provided as participant A, participant B, and participant C, respectively. And it serves as the corresponding node 214 in the blockchain network 212.
  • a node generally refers to a single system (for example, a computer, a server) connected to the blockchain network 212 and enables corresponding participants to participate in the blockchain network.
  • the participant corresponds to each node 214.
  • one participant can operate multiple nodes 214 within the blockchain network 212, and/or multiple participants can share a single node 214.
  • the participant systems 202, 204, 206 use protocols (e.g., Hypertext Transfer Protocol Security (HTTPS)) and/or use remote procedure calls (RPC) to communicate with the blockchain network 212, or through the blockchain
  • HTTPS Hypertext Transfer Protocol Security
  • RPC remote procedure calls
  • the degree of participation of the node 214 in the blockchain network 212 may vary. For example, some nodes 214 may participate in the consensus process (eg, as miner nodes that add blocks to the blockchain 216), while other nodes 214 do not participate in the consensus process. As another example, some nodes 214 store a complete copy of the blockchain 216, while other nodes 214 only store a partial copy of the blockchain 216. In the example of Figure 2, the participant systems 202, 204, 206 each store a complete copy of the blockchain 216 216', 216", 216"'.
  • a blockchain (for example, the blockchain 216 in FIG. 2) is composed of a series of blocks, and each block stores data.
  • Examples of data may include transaction data representing transactions between two or more participants.
  • transactions are used as a non-limiting example, and it is expected that any appropriate data can be stored in the blockchain (e.g., documents, images, videos, audios).
  • Examples of transactions may include, but are not limited to, the exchange of valuable things (eg, assets, products, services, currency, etc.).
  • Transaction data is stored immutably in the blockchain.
  • hash Before storing in the block, hash the transaction data. Hashing is the process of converting transaction data (provided as string data) into a fixed-length hash value (also provided as string data). After the transaction data is hashed, even a slight change in the transaction data will result in a completely different hash value.
  • the hash value is usually generated by hashing transaction data using a hash function. Examples of hash functions include, but are not limited to, Secure Hash Algorithm (SHA)-256, which outputs a 256-bit hash value.
  • SHA Secure Hash Algorithm
  • the transaction data of multiple transactions can be stored in the block after being hashed. For example, two transaction data are hashed to obtain two hash values, and then the two obtained hash values are hashed again to obtain another hash value. This process is repeated until a single hash value is obtained for all transactions to be stored in the block.
  • This hash value is called the Merkle root hash and is stored at the head of the block. Any change in the transaction will cause its hash value to change, and eventually the Merkle root hash value will change.
  • the block is added to the blockchain through a consensus protocol.
  • Multiple nodes in the blockchain network participate in the consensus protocol, and after competition, blocks are added to the blockchain.
  • Such nodes are called miner nodes (or accounting nodes).
  • the POW introduced above serves as a non-limiting example.
  • Miner nodes perform a consensus process to add transactions (corresponding blocks) to the blockchain. Although multiple miner nodes participate in the consensus process, only one miner node can write a block to the blockchain. In other words, miner nodes compete in the consensus process to add their blocks to the blockchain. In more detail, the miner node periodically collects pending transactions from the transaction pool (for example, until a predetermined limit on the number of transactions that can be included in the block is reached, if any). The transaction pool includes transaction messages from participants in the blockchain network. Miner nodes create blocks and add transactions to the blocks. Before adding the transaction to the block, the miner node checks whether there is a transaction in the block of the blockchain among the transactions to be added. If the transaction has been added to another block, the transaction will be discarded.
  • the miner node generates a block header, hashes all transactions in the block, and combines the hash values in pairs to generate further hash values until a single hash value (Merkle root) is obtained for all transactions in the block. Hash). Then, add the Merkle root hash to the block header.
  • the miner also determines the hash value of the latest block in the blockchain (ie, the last block added to the blockchain). Miner nodes can also add random values (noune values) and timestamps to the block header.
  • the miner node tries to find a hash value that meets the required parameters. The miner node keeps changing the nonce value until it finds a hash value that meets the required parameters.
  • Every miner in the blockchain network tries to find a hash value that meets the required parameters and competes with each other in this way.
  • a miner node finds a hash value that meets the required parameters and advertises the hash value to all other miner nodes in the blockchain network.
  • Other miner nodes verify the hash value, and if it is determined to be correct, verify each transaction in the block, accept the block, and attach the block to their copy of the blockchain. In this way, the global state of the blockchain is agreed upon on all miner nodes within the blockchain network.
  • the above process is a POW consensus protocol.
  • participant A wants to send a certain amount of funds to participant B.
  • Participant A generates a transaction message and sends the transaction message to the blockchain network, and the transaction message is added to the transaction pool.
  • Each miner node in the blockchain network creates a block, obtains transactions from the transaction pool, and adds the transaction to the block. In this way, the transaction issued by participant A is added to the block of the miner node.
  • cryptography is implemented to maintain the privacy of transactions. For example, if two nodes want to maintain the privacy of the transaction so that other nodes in the blockchain network cannot learn the details of the transaction, the node can encrypt the transaction data.
  • encryption methods include, but are not limited to, symmetric encryption and asymmetric encryption.
  • Symmetric encryption refers to the encryption process that uses a single key to encrypt (generate ciphertext based on plaintext) and decrypt (generate plaintext based on ciphertext).
  • symmetric encryption multiple nodes can use the same key, so each node can encrypt/decrypt transaction data.
  • a key pair is used for encryption and decryption, and each key pair includes a different private key and public key.
  • the private key in its asymmetric encryption key pair needs to be stored confidentially; the public key can be made public for other nodes to obtain.
  • the data is encrypted with a public key, only the corresponding private key can be used to decrypt it.
  • Participant A can use the public key of participant B to encrypt data, and send the encrypted data to participant B.
  • Participant B can use its private key to decrypt the encrypted data (ciphertext) sent from participant A and decrypt the original data (plaintext). Messages encrypted with the public key of the node can only be decrypted with the corresponding private key in the paired secret key.
  • Asymmetric encryption can also be used to provide digital signatures, which enable participants in a transaction to confirm other participants in the transaction and the validity of the transaction.
  • participant A can digitally sign the message, and another participant B can confirm that the message was sent by the participant A according to the digital signature of the participant A.
  • Digital signatures can also be used to ensure that messages are not tampered with during transmission. For example, refer to Figure 1 again.
  • Participant A will send a message to participant B.
  • Participant A generates a hash value of the message, and then uses its private key to encrypt the hash value to generate a digital signature.
  • Participant A attaches the digital signature to the message, and sends the message with the digital signature to participant B.
  • Participant B uses the public key of participant A to decrypt the digital signature, thereby decrypting the corresponding hash value. Participant B hashes the received message to obtain another hash value, and then compares the two hash values. If the hash value is the same, participant B can confirm that the message is indeed from participant A and has not been tampered with.
  • the blockchain node can be any participant in FIG. 1 or FIG. 2.
  • FIG. 3 shows a schematic diagram of an example of a consensus process 300 applicable to a blockchain system.
  • C represents the client (ie, lightweight node)
  • R 0 is the master node of the current consensus process of the blockchain system
  • R 1 , R 2 and R 3 are backup nodes.
  • the client C can send a transaction request (Request) to the master node R 0.
  • the client C can also send to other nodes in the blockchain system (for example, R 1 , R 2 and R 3 ) The transaction request (not shown in FIG. 3), and then the other node forwards the received transaction request to the master node R 0 .
  • the master node R 0 and the backup nodes R 1 , R 2 and R 3 After receiving the transaction request (Request), the master node R 0 and the backup nodes R 1 , R 2 and R 3 perform consensus processing.
  • the process of consensus processing includes: a pre-prepare phase (pre-prepare) 320, a preparation phase (prepare) 330, and a confirmation phase (commit) 340.
  • the master node R 0 sorts and packages the received transactions into a message m, and then generates a pre-prepare message (Pre-prepare), and in a given time interval Inside, the pre-prepare message (Pre-prepare) is sent (for example, broadcast) to the backup nodes R 1 , R 2 and R 3 .
  • the pre-prepare message (Pre-prepare) indicates that the master node R 0 is starting the consensus process.
  • the master node R0 sends a Pre-prepare message to other blockchain nodes R1, R2, and R3 in the blockchain network.
  • the consensus process 300 is shown as including 4 blockchain nodes R0, R1, R2, and R3 for illustration purposes only, and the consensus process 300 may also include any suitable number of blockchain nodes.
  • the pre-preparation message can be stored in the local log and generated for In response to the preparation message Prepare of the pre-preparation message, the generated preparation message Prepare is broadcast to other nodes.
  • the preparation message Prepare indicates that the backup node has received the pre-prepare message Pre-prepare from the master node, and is sending a response in response to the pre-prepare message Pre-prepare.
  • each backup node will also receive pre-preparation messages sent by other backup nodes.
  • the backup nodes R 1 as an example, then the backup nodes R 1 R 0 master node receives the message transmitted from a prepared, ready to broadcast a message will be generated to the master node R 0, R 2 and backup node R 3.
  • the backup node R 1 will also receive the preparation messages sent by the master node R 0 and the backup nodes R 2 and R 3.
  • the blockchain node determines that a consensus has been reached. For example, if the master node R0 or the backup node R1, R2 or R3 receives a quorum (for example, 2f+1, where f represents multiple failed blockchain nodes) to prepare the message Prepare, it is determined to be in the blockchain A consensus is reached between nodes. Then, the master node R0 or the backup nodes R1, R2, or R3 will broadcast a confirmation message Commit to other nodes.
  • a quorum for example, 2f+1, where f represents multiple failed blockchain nodes
  • each of all nodes participating in the consensus sequentially executes a set of ordered requests in the message m of the pre-prepare message in the local state machine, and returns a response Message reply to client C.
  • FIG. 3 is only an example of the consensus process, and the blockchain system in the embodiment of this specification can adopt any suitable common adaptation process to perform consensus processing.
  • FIG. 4 shows a schematic diagram of an example of a blockchain system to which the method for performing transaction correctness verification according to an embodiment of the present specification is applicable.
  • the blockchain system 400 includes light nodes and full nodes.
  • the full nodes include blockchain nodes 401, 402, etc., and the light nodes are connected to one or more full nodes.
  • the blockchain nodes 401a, 401b, and 401c which are lightweight nodes, are connected to the full node 401
  • the blockchain nodes 402a, 402b, and 402c are connected to the full node 402.
  • Each full node in the blockchain system 400 is connected to each other, and each full node can be used as a bookkeeping node (that is, a consensus node) to jointly maintain a ledger of all transactions in the blockchain system based on the blockchain technology.
  • the accounting node can perform accounting operations such as transaction verification, transaction consensus, and block generation.
  • Full nodes usually maintain all the data of the blockchain locally, including the block body and block header of each block in the blockchain.
  • Lightweight nodes can only store the block headers of each block in the blockchain locally for simple verification operations (for example, SPV verification). Lightweight nodes can always be connected to the same full number of nodes, and can also replace all connected nodes based on connection rules to reduce trust risks.
  • Transactions initiated by each blockchain node can be broadcast to the blockchain network for consensus processing.
  • the transaction initiated by the full node can be broadcast to each other full node, and after each full node receives the transaction, it can be broadcast to the lightweight node it is connected to.
  • the transaction initiated by the light-weight node can be sent to all nodes connected to the light-weight node, so as to be broadcast by the all-weight node to other full-weight nodes or light-weight nodes.
  • Lightweight nodes can download block headers from the full number of nodes connected to it to maintain the local blockchain (blockchain that only includes block headers), and can also obtain the block body from the full number of nodes according to the needs of their own operations Various information.
  • Lightweight nodes can connect to one or more clients (not shown in the figure).
  • the transaction initiated by the client can be sent to the blockchain system via the lightweight node and all nodes connected to the lightweight node to perform accounting processing on the transaction.
  • the method for performing cross correctness verification in the embodiment of this specification is executed by a lightweight node.
  • Fig. 5 is a flowchart of a method for performing transaction correctness verification according to an embodiment of the present specification.
  • the consensus proof information of the block to be verified is obtained from all nodes.
  • Consensus proof information can be included in the block body of the block to be verified.
  • Lightweight nodes can obtain the consensus proof information of the block to be verified from any full node connected to it. Lightweight nodes can send consensus proof information acquisition requests to all nodes, so that all nodes can send the consensus proof information to the light nodes.
  • the lightweight node may obtain consensus proof information from the block body after downloading the block body of the block to be verified.
  • the consensus proof information includes a collection of digital signatures. The digital signature set is obtained by signing the original text of the first signature data corresponding to the block to be verified by each consensus node that has reached a consensus on the block to be verified.
  • the consensus node can be any full node in the blockchain system. According to different consensus algorithms, the information in the original text of the first signature data can also be different.
  • the original text of the first signature data may include proof summary information, and the proof summary information is generated at each consensus node based on the first proof basis information.
  • Consensus proof information is used to prove that the corresponding block has been executed by the correct consensus node in the correct consensus process. For example, in the PBFT-based consensus algorithm, it can be proved that the corresponding block has been confirmed by no less than a quorum of consensus nodes.
  • Each consensus node can generate a digital signature when reaching a consensus on the corresponding block, and when the block is added to the blockchain, the digital signature of each consensus node can be assembled into a digital signature set to generate consensus proof information.
  • each consensus node when each consensus node receives a preparation message of no less than a statutory number in the confirmation phase 340, it can generate proof summary information based on the first proof basis information obtained locally, and then use each The private key to sign the certificate summary information to generate their respective digital signatures. After the digital signature is generated, each consensus node can include the digital signature in the confirmation message and broadcast it to other consensus nodes. After each consensus node receives a sufficient number (not less than f+1) of confirmation messages, it can assemble and generate consensus proof information based on the digital signatures of each consensus node confirming the block, and include the consensus proof information In the block body of the corresponding block.
  • the proof basis information used to generate the proof summary information may include the public key set identification information generated based on the public key set of the corresponding block, the number of public keys in the public key set, the parent hash of the block to be verified, and the The root hash of the transaction tree of the verification block and the timestamp of the block to be verified.
  • the public key set includes the public keys of all consensus nodes participating in the consensus process of the corresponding block. When the corresponding block reaches a consensus, the public key of each consensus node that agrees on the block can be obtained to generate a public key set corresponding to the block, and then it can be generated based on each public key in the public key set Public key collection identification information and the number of public keys.
  • the Merkel tree can be generated based on each public key, and the root hash of the Merkel tree can be used as the public key set identification information.
  • a hash operation may be performed on the public key set, and the obtained hash value may be used as the public key set identifier.
  • the parent hash of each block (the hash value of the parent block), the root hash of the transaction tree, and the timestamp can be obtained from the block header information of the locally maintained blockchain.
  • the proof basis information obtained locally by each consensus node when generating the signature data is described as the first proof basis information
  • the proof basis information acquired locally by the lightweight node when verifying the correctness of the transaction is described as The second proof is based on information, but the categories of information included in the first and second proof based information are the same.
  • the consensus node may use a digest algorithm to perform a digest operation on the first proof basis information used to generate the proof summary information to obtain the proof summary information.
  • the proof digest algorithm can be a hash operation or any other digest algorithm, which is not limited in this specification.
  • the consensus node can generate the first original signature text information based on the proof summary information.
  • the proof summary information can be used as the first original signature text information, and the proof summary information can be further subjected to a predetermined calculation process (for example, a hash operation) to generate the first original signature text information.
  • a predetermined calculation process for example, a hash operation
  • the proof basis information may also include the serial number of the block to be verified in the blockchain.
  • the proof basis information can also include other information.
  • the proof basis information may also include the consensus era (View) identification of the block to be verified.
  • the consensus era refers to the corresponding time period in which a certain consensus node acts as the master node in the blockchain system. Whenever the master node cannot normally perform the operations that the master node should perform, the blockchain system can trigger the master node replacement process. After the master node is replaced, the blockchain system enters another consensus era.
  • the consensus node can hash the proof basis information, use the obtained hash value as the original text of the first signature data, and then use the respective private keys to encrypt the original text of the first signature data to generate the corresponding digital signature.
  • the lightweight node After the lightweight node obtains the consensus certification information of the block to be verified, in block 540, the correctness of the consensus certification information is verified based on the digital signature set and the public key set at the lightweight node.
  • the lightweight node can store a set of public keys locally.
  • the public key set at the lightweight node may include the public keys of all nodes participating in the consensus in the blockchain system, and may also include the public keys of each consensus node that agrees on the trust anchor.
  • the trust anchor can indicate a trust block that has been verified as correct.
  • the trust anchor can be the genesis block, and the set of public keys corresponding to the genesis block can be the public keys of all consensus nodes in the blockchain system when the genesis block is generated.
  • the trust block can be verified using the transaction correctness verification method in the embodiment of this specification.
  • the transaction set in the block to be verified is verified as correct, the block to be verified can be updated as a new trust anchor point, and the public key of each consensus node that agrees on the block to be verified can be updated to trust The anchor's public key collection.
  • Fig. 6 is a flowchart of an example of a consensus proof information verification process in a method for performing transaction correctness verification according to an embodiment of the present specification.
  • the encryption algorithm used by each consensus node to sign the original text of the first signature data is used to restore the public key of each consensus node from the digital signature set.
  • the public key is generated based on the private key. Therefore, the corresponding public key can be restored based on the digital signature.
  • the digital signature can include information used to restore the public key. Taking the SM2 elliptic curve algorithm as an example, the digital signature can include the coordinates (x, y) of the elliptic curve point and the judgment identifier, which is used to judge the parity of the coordinate y of the elliptic curve point.
  • Lightweight nodes can recover the public key of the corresponding consensus node based on the coordinates of the elliptic curve point and the judgment identifier.
  • the consensus proof information may also include the original text of the first signature data, and the coordinates of the elliptic curve point and the judgment identifier may be included in the original text of the first signature data.
  • the public key can be further recovered based on the original text of the first signature data.
  • Lightweight nodes can verify the correctness of the consensus proof information based on the consensus rules corresponding to the block to be verified. For example, for certain consensus algorithms, it can be determined that the consensus certification information is correct when each restored public key is included in the public key set. If the restored public key is included in the public key set, it indicates that the block to be verified has passed the consensus of the correct consensus node. If the restored public key is not included in the public key set, or part of it is not included in the public key set, it indicates that the block to be verified is not in the correct consensus node consensus.
  • the restored public key is not completely included in the public key set, if at least part of the restored public key is included in the public key set, and is included in the public key set
  • the number of public keys meets the consensus rules of the consensus algorithm for reaching a consensus, and it can also be determined that the block to be verified has been correctly agreed. For example, for a consensus algorithm based on PDFT, if the number of public keys included in the public key set reaches a quorum, it can also prove that the block to be verified has been correctly agreed. Therefore, it can be determined that the consensus certification information is correct when the number of restored public keys included in the public key set reaches a quorum.
  • Lightweight nodes can determine the verification rules of the consensus proof information based on the consensus rules corresponding to the consensus algorithm. For example, if the consensus algorithm is the PBFT algorithm, it is necessary to confirm that the consensus certification information is correct when the restored public key is included in the public key set and the number of restored public keys reaches a quorum.
  • the consensus algorithm may be known to lightweight nodes. In another example, the consensus algorithm can be included in the consensus proof information, so that the lightweight node can learn the verification rules from the consensus proof information.
  • the lightweight node can also verify the original text of the first signature data in the consensus proof information.
  • the light-weight node may locally obtain the second proof basis information used to generate the original text of the signature data, and generate the second original signature data text based on the second proof basis information and the generation rules of the first signature data original text.
  • the public key can be recovered from the digital signature.
  • the correctness of the transaction set in the block to be verified is determined.
  • the consensus proof information is verified as correct, it indicates that the transactions in the block to be verified have gone through the correct consensus process. Therefore, it can be determined that the block body of the block to be verified is correct, and then each of the block bodies can be considered The transactions are all correct.
  • the lightweight node does not need to visit multiple full nodes to verify the correctness of the transaction set on the block to be verified.
  • the lightweight node needs to visit multiple full nodes to determine whether the block to be verified is quorum correct The nodes agree correctly.
  • Fig. 7 is a flowchart of a method for performing transaction correctness verification according to another embodiment of the present specification.
  • the correctness of the consensus certification information is verified.
  • the verification process of the consensus certification information described in this manual can be used to verify the correctness of the consensus certification information.
  • the consensus proves that the information is correct, it can be determined that the block body is correct.
  • block 706 the block body information of the block to be verified is obtained from all nodes. Then, in block 708, based on the block body information, the correctness of the block header of the block to be verified at the lightweight node is verified. And in block 710, it is determined whether the block header is correct.
  • All block body information can be downloaded from all nodes, and then the transaction tree information can be extracted from the block body information. It is also possible to obtain transaction tree information only from all nodes.
  • the transaction root in the block header can be verified based on the transaction tree information.
  • the transaction tree may be generated based on a Merkle tree, for example.
  • the leaf nodes store transaction data of each transaction in the block to be verified.
  • the upper node of the binary fork can be calculated layer by layer based on each leaf node, until the Merkle root is calculated. Then you can compare whether the calculated merkle root is consistent with the transaction root in the block header. When the two are consistent, it can be determined that the block header is correct.
  • the block header also includes the receipt root and the state root.
  • the receipt tree and the state tree can also be generated based on the Merkle tree.
  • the Merkle roots of the receipt tree and the state tree can be calculated based on the obtained receipt tree information and state tree information, and the Merkle roots obtained by the two can be compared with the zone respectively.
  • the receipt root in the block header is consistent with the state root. When the calculated Merkle root is consistent with the receipt root and state root, it can be determined that the receipt root and state root are correct. In the case where the block body also includes the receipt tree and the state tree, the receipt root and the state root may not be verified.
  • the block header and block body of the block to be verified are verified as correct, it can be determined that the block to be verified is correct, and then all transactions in the block body can be considered correct. Therefore, at block 712, it is determined that the set of transactions on the block to be verified is correct. If the verification result of the block header or the consensus proof information is incorrect, then in block 714, it is determined that the transaction set on the block to be verified is incorrect. In order to save storage space at the lightweight node, after verifying the transaction set on the block to be verified, the obtained block body information can be deleted. When the transaction set on the block to be verified is verified as correct, the block to be verified can be updated as a trust anchor.
  • FIG. 7 shows that the block header verification process is performed after the consensus certification information is verified as correct, there is no restriction on the execution sequence of the consensus certification information verification process and the block header verification process.
  • the two can be executed in parallel, and the consensus proof information verification process can also be executed after the block header information is verified as correct.
  • Fig. 8 is a flowchart of a method for performing transaction correctness verification according to another embodiment of the present specification.
  • a transaction correctness verification request for a specified transaction in the transaction set is received.
  • the transaction correctness verification request may be issued by a client connected to a lightweight node.
  • the client can send a transaction correctness verification request to the lightweight node for the transaction initiated by it.
  • the transaction correctness verification request may include the transaction hash of the designated transaction and the block number of the designated transaction in the block.
  • the transaction hash and block number can be notified to the client through the lightweight node after the full node has packaged the specified transaction on the chain.
  • the block number is used to determine the block in which the specified exchange is located, and the transaction hash can be used to verify the existence of the specified transaction.
  • the transaction correctness verification request may not include the block number.
  • the lightweight node can query the full node based on the transaction hash for the block in which the specified transaction is located, and the full node can send the block number to the lightweight node. node. After determining the block in which the designated exchange is located, the lightweight node determines the block as a block to be verified.
  • the consensus proof information of the block to be verified is obtained from all nodes. Then, in block 806, the correctness of the transaction set in the block body of the block to be verified is determined based on the consensus proof information.
  • the existence of the specified transaction in the block to be verified is verified.
  • the correctness of the designated transaction is determined based on the correctness verification result of the transaction set and the existence verification result of the designated transaction. It can be determined that the specified transaction is correct when the transaction set and the existence verification result are correct, that is, the specified transaction has been executed correctly.
  • the execution sequence of the correctness verification process and the existence verification process of the transaction set on the block to be verified is not particularly limited, and the two may also be parallel.
  • FIG. 9 is a schematic diagram for explaining the transaction existence verification process in the method for performing transaction correctness verification according to the embodiment of the present specification.
  • Fig. 9 shows an example of a transaction tree generated based on a Merkle tree.
  • the block including the transaction tree includes transactions A to P.
  • Leaf node is stored in each transaction to transaction hash H A H P.
  • Lightweight nodes can obtain transaction tree information from the downloaded block body information, and then obtain each leaf node data in the query path of the specified transaction from the transaction tree. Without downloading block body information, lightweight nodes can send transaction tree path query requests for specified transactions to all nodes. The full node can send the leaf node data included in the transaction query path of the specified transaction in the transaction tree to the light node.
  • the leaf node data in the transaction query path from the leaf node where the transaction hash H K of transaction K is located to the transaction root H ABCDEFGHIJKLMNOP includes H L , H IJ , H MNOP , and H ABCDEFGH.
  • binary calculations can be performed layer by layer to determine whether the obtained transaction root is consistent with the transaction root in the block header of the block to be verified.
  • the transaction hash H K of the designated transaction K is known.
  • H KL H K H L is calculated based on, then can be H IJKL H KL and H IJ calculated based on the acquired and can be H IJKLMNOP H IJKL and H MNOP calculated based on the acquired and then, based H IJKLMNOP H ABCDEFGH calculated and acquired obtained H aBCDEFGHIJKLMNOP. Then you can compare whether H ABCDEFGHIJKLMNOP is consistent with the transaction root in the block header. When the two are consistent, it can be determined that the transaction H K of the specified transaction K exists in the transaction tree, which indicates that the transaction K exists in the transaction set of the block to be verified. When the two are inconsistent, it indicates that transaction K is not in the transaction set of the block to be verified.
  • the verification of the transaction set may be performed before receiving the transaction correctness verification request for the specified transaction.
  • Lightweight nodes can download block headers from all nodes according to their own conditions to update local blockchain data. For example, lightweight nodes can download block headers from full nodes periodically and quantitatively. Lightweight nodes can verify the correctness of the transaction set of the block in the process of updating the local blockchain. For example, the correctness of the transaction set can be verified one by one for the blocks added to the local blockchain. In order to reduce the burden of lightweight nodes, lightweight nodes can only verify the associated blocks.
  • the associated block is a block related to the lightweight node.
  • it may include a transaction initiated by a client connected to the lightweight node, and may also include a transaction concerned by the client connected to the lightweight node.
  • a transaction correctness verification request for a specified transaction After verifying the transaction set, if a transaction correctness verification request for a specified transaction is received, the existence of the specified transaction can be further verified to verify the correctness of the specified transaction. This example will be described below with reference to FIG. 10.
  • Fig. 10 is a flowchart of a method for performing transaction correctness verification according to another embodiment of the present specification.
  • the block header may include transaction receipt identification information, and the transaction receipt identification information may be generated based on the transaction address information in the transaction receipt, for example.
  • the transaction receipt identification information may be generated based on a Bloom filter, for example.
  • the consensus node will write the transaction record into the transaction receipt.
  • the transaction receipt includes information related to the transaction.
  • Lightweight nodes can monitor whether there are blocks that include specified transactions based on Bloom filters.
  • the listening rules can be set by the client. The client can set up and monitor information related to the transaction initiated by the lightweight node.
  • the consensus proof information of the block to be verified is obtained from all nodes. Then, in block 1008, the correctness of the transaction set in the block body of the block to be verified is determined based on the consensus proof information. After verifying the correctness of the transaction set on the block to be verified, if the client requests verification of a specific transaction on the block to be verified, it does not need to perform the correctness verification process of the transaction set again, but can only verify whether the specified transaction Exist in the block to be verified for verification.
  • the lightweight node can verify the transaction correctness request sent by the monitoring client, and in block 1010, determine whether the transaction correctness verification request for the specified transaction has been received. If a transaction correctness verification request is received, in block 1012, the existence of the specified transaction is verified.
  • the existence verification process can be performed using the method described in the above example.
  • the correctness of the designated transaction is determined based on the correctness verification result of the transaction set and the existence verification result of the designated transaction.
  • the set of transactions on the block to be verified is verified as correct, and the specified transaction exists on the block to be verified, it can be determined that the specified transaction is correct.
  • the lightweight node After receiving the transaction correctness request, the lightweight node can first determine whether the block in which the designated exchange is located has been subjected to the transaction set correctness verification process. If the block where the designated exchange is located has not performed the transaction set correctness verification process, the example shown in Figure 8 can be used to verify the transaction correctness.
  • Fig. 11 is a structural block diagram of an apparatus for performing transaction correctness verification according to an embodiment of the present specification.
  • the transaction correctness verification execution device 1100 includes a consensus certification information acquisition unit 1110, a consensus certification information verification unit 1120, a transaction set verification unit 1130, a block body information acquisition unit 1140, a block header verification unit 1150, and a verification unit to be verified.
  • the consensus proof information obtaining unit 1110 obtains the consensus proof information of the block to be verified from all nodes.
  • the consensus proof information includes a set of digital signatures, which are obtained by signing the original text of the first signature data corresponding to the block to be verified by each consensus node that has reached a consensus on the block to be verified.
  • the consensus certification information verification unit 1120 verifies the correctness of the consensus certification information based on the digital signature set and the public key set at the lightweight node.
  • the public key set includes the public keys of at least part of the blockchain nodes in the block system.
  • the set of public keys may include the public keys of all blockchain nodes participating in the consensus in the blockchain system.
  • the set of public keys may include the public keys of all consensus nodes that agree on the trust anchors at the lightweight nodes, and the trust anchors indicate the trust blocks that are verified as correct.
  • the transaction set verification unit 1130 determines the correctness of the transaction set in the block to be verified based on the verification result of the correctness of the consensus certification information.
  • the block body information obtaining unit 1140 obtains the block body information of the block to be verified from all nodes before determining the correctness of the transaction set in the block to be verified based on the correctness verification result of the consensus proof information.
  • the block header verification unit 1150 verifies the correctness of the transaction root of the block to be verified at the lightweight node based on the block body information.
  • the transaction set verification unit 1130 may determine the correctness of the transaction set in the block to be verified based on the correctness verification result of the transaction root and the correctness verification result of the block proof information.
  • the to-be-verified block monitoring unit 1160 monitors whether there is a to-be-verified block that includes the specified transaction before obtaining the consensus proof information of the to-be-verified block from all nodes.
  • the consensus proof information obtaining unit 1110 can obtain the monitored consensus proof information of the block to be verified from all nodes when it monitors that there is a block to be verified that includes the specified transaction.
  • the verification request receiving unit 1170 receives a transaction correctness verification request for a specified transaction in the transaction set.
  • the existence verification unit 1180 verifies whether the specified transaction exists in the transaction set.
  • the designated transaction correctness determination unit 1190 determines the correctness of the designated transaction based on the correctness verification result of the transaction set and the existence verification result of the designated transaction in the block to be verified.
  • the verification request receiving unit 1170 may also receive a transaction correctness verification request for a specified transaction in the transaction set before obtaining the consensus proof information of the block to be verified from the full number of nodes.
  • the consensus proof information obtaining unit 1110 may obtain the consensus proof information of the block to be verified from all nodes when receiving the transaction correctness verification request.
  • the units in FIG. 11 are not all necessary, and the transaction correctness verification execution device may not include some of the units.
  • the block monitoring unit to be verified may not be included, the verification request receiving unit, the existence verification unit, the specified transaction correctness determination unit, etc. may not be included, and the block body information acquisition unit and Block header verification unit.
  • Fig. 12 is a structural block diagram of the consensus proof verification process in the device for performing transaction correctness verification shown in Fig. 11.
  • the consensus certification information verification unit 1120 includes a public key restoration module 1121 and a consensus certification information verification module 1122.
  • the public key restoration module 1121 uses the encryption algorithm used by each consensus node to sign the original text of the first signature data to restore the public key of each consensus node from the digital signature set.
  • the consensus certification information verification module 1122 verifies the correctness of the consensus certification information based on the restored public key of each consensus node and the public key set at the lightweight node.
  • the consensus proof information verification module 1122 may be included when at least part of the restored public keys are included in the public key set and the number of public keys included in the public key set meets the consensus rules , To confirm that the consensus proof information is correct.
  • the device for performing transaction correctness verification in the embodiments of this specification can be implemented by hardware, or by software or a combination of hardware and software.
  • the various embodiments in this specification are described in a progressive manner, and the same or similar parts among the various embodiments are referred to each other.
  • the device for performing transaction correctness verification in the embodiments of this specification can be implemented by hardware, or by software or a combination of hardware and software. Taking software implementation as an example, as a logical device, it is formed by reading the corresponding computer program instructions in the memory into the memory through the processor of the device where it is located. In the embodiment of this specification, the means for performing transaction correctness verification can be implemented by using a computing device, for example.
  • Fig. 13 is a structural block diagram of a computing device for implementing a method for verifying the correctness of a transaction according to an embodiment of the present specification.
  • the computing device 1300 includes a processor 1313, a memory 1320, a memory 1330, a communication interface 1340, and an internal bus 1350, and a processor 1213, a memory (for example, a non-volatile memory) 1320, a memory 1330, and a communication interface 1340 is connected together via a bus 1350.
  • the computing device 1300 may include at least one processor 1313 that executes at least one computer readable instruction (ie, the aforementioned Elements implemented in software).
  • computer-executable instructions are stored in the memory 1320, which, when executed, cause at least one processor 1313 to: obtain consensus proof information of the block to be verified from all nodes, the consensus proof information including a set of digital signatures
  • the digital signature set is obtained by signing the original text of the first signature data corresponding to the block to be verified by each consensus node that reached a consensus on the block to be verified; based on the digital signature set and the
  • the public key set at the lightweight node verifies the correctness of the consensus proof information, the public key set includes the public keys of at least part of the blockchain nodes in the block system; and the correctness of the proof information based on the consensus
  • the result of the sexual verification determines the correctness of the transaction set in the block to be verified.
  • a program product such as a non-transitory machine-readable medium.
  • the non-transitory machine-readable medium may have instructions (ie, the above-mentioned elements implemented in the form of software), which when executed by a machine, cause the machine to execute the above described in conjunction with FIGS. 1-12 in the various embodiments of the embodiments of this specification.
  • instructions ie, the above-mentioned elements implemented in the form of software
  • a system or device equipped with a readable storage medium may be provided, and the software program code for realizing the function of any one of the above-mentioned embodiments is stored on the readable storage medium, and the computer or device of the system or device The processor reads and executes the instructions stored in the readable storage medium.
  • the program code itself read from the readable medium can realize the function of any one of the above embodiments, so the machine readable code and the readable storage medium storing the machine readable code constitute the present invention a part of.
  • Examples of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), magnetic tape, Volatile memory card and ROM.
  • the program code can be downloaded from a server computer or cloud via a communication network.
  • the device structure described in the foregoing embodiments may be a physical structure or a logical structure, that is, some units may be implemented by the same physical entity, or some units may be implemented by multiple physical entities, or may be implemented by multiple physical entities. Some components in independent devices are implemented together.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Business, Economics & Management (AREA)
  • Signal Processing (AREA)
  • Accounting & Taxation (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Finance (AREA)
  • Strategic Management (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Power Engineering (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

A method for executing transaction correctness verification. The method is executed by a lightweight node in a blockchain system. The method comprises: acquiring, from a full node, consensus proof information of a block to be verified (520), wherein the consensus proof information comprises a digital signature set, and the digital signature set is obtained by means of all consensus nodes that achieve a consensus with regard to the block to be verified signing a first signature data original text corresponding to the block to be verified; on the basis of the digital signature set and a public key set at a lightweight node, verifying the correctness of the consensus proof information (540), wherein the public key set comprises public keys of at least some blockchain nodes in a block system; and on the basis of a correctness verification result of the consensus proof information, determining the correctness of a transaction set in the block to be verified (560).

Description

用于执行交易正确性验证的方法及装置Method and device for performing transaction correctness verification 技术领域Technical field
本说明书实施例涉及区块链技术领域,具体地,涉及用于执行交易正确性验证的方法及装置。The embodiments of this specification relate to the field of blockchain technology, in particular, to methods and devices for performing transaction correctness verification.
背景技术Background technique
区块链系统中包括全量节点和轻量节点,全量节点处维护有完整的区块链信息,而轻量节点处通常只需维护各个区块链的区块头信息。SPV(简单支付验证)是由轻量节点基于本地维护的区块头信息进行的支付验证技术。轻量节点通常利用SPV验证技术对交易进行验证。如果要证明交易已被正确地执行,SPV验证需要包括存在性验证和正确性验证。SPV验证技术提供了存在性验证方法,然而轻量节点想要证明交易被正确的共识节点执行了正确的共识过程,还存在许多困难。因此,亟需有效可行的交易正确性验证手段。The blockchain system includes full nodes and lightweight nodes. The full amount of nodes maintains complete block chain information, while the lightweight nodes usually only need to maintain the block header information of each block chain. SPV (Simple Payment Verification) is a payment verification technology performed by lightweight nodes based on locally maintained block header information. Lightweight nodes usually use SPV verification technology to verify transactions. If you want to prove that the transaction has been executed correctly, SPV verification needs to include existence verification and correctness verification. SPV verification technology provides an existence verification method, but there are still many difficulties for lightweight nodes to prove that the transaction is executed by the correct consensus node in the correct consensus process. Therefore, there is an urgent need for effective and feasible means to verify the correctness of transactions.
发明内容Summary of the invention
鉴于上述,本说明书实施例提供了一种用于执行交易正确性验证的方法及装置。In view of the foregoing, the embodiments of this specification provide a method and device for performing transaction correctness verification.
根据本说明书实施例的一个方面,提供了一种用于执行交易正确性验证的方法,所述方法由区块链系统中的轻量节点执行,所述方法包括:从全量节点处获取待验证区块的共识证明信息,所述共识证明信息包括数字签名集合,所述数字签名集合是对所述待验证区块达成共识的各个共识节点对所述待验证区块所对应的第一签名数据原文进行签名而得到的;基于所述数字签名集合和所述轻量节点处的公钥集合验证所述共识证明信息的正确性,所述公钥集合包括所述区块系统中的至少部分区块链节点的公钥;以及基于所述共识证明信息的正确性验证结果,确定所述待验证区块中的交易集合的正确性。According to one aspect of the embodiments of the present specification, there is provided a method for performing transaction correctness verification. The method is executed by a lightweight node in a blockchain system, and the method includes: obtaining the to-be-verified node from the full amount of nodes. Consensus proof information of the block, the consensus proof information includes a digital signature set, and the digital signature set is the first signature data corresponding to the block to be verified by each consensus node that has reached a consensus on the block to be verified The original text is signed; based on the digital signature set and the public key set at the lightweight node to verify the correctness of the consensus proof information, the public key set includes at least part of the block system The public key of the block chain node; and based on the correctness verification result of the consensus certification information, the correctness of the transaction set in the block to be verified is determined.
可选的,在一个示例中,在基于所述共识证明信息的正确性验证结果,确定所述待验证区块中的交易集合的正确性之前,所述方法还可以包括:从所述全量节点处获取所述待验证区块的区块体信息;基于所述区块体信息,验证所述轻量节点处的所述待验证区块的区块头的正确性。基于所述共识证明信息的正确性验证结果,确定所述待验证区块中的交易集合的正确性包括:基于所述区块头的正确性验证结果和所述区块证明信 息的正确性验证结果,确定所述待验证区块中的交易集合的正确性。Optionally, in an example, before determining the correctness of the transaction set in the block to be verified based on the verification result of the correctness of the consensus proof information, the method may further include: from the full node Obtaining the block body information of the block to be verified at any location; based on the block body information, verifying the correctness of the block header of the block to be verified at the lightweight node. Based on the verification result of the correctness of the consensus proof information, determining the correctness of the transaction set in the block to be verified includes: the correctness verification result based on the block header and the correctness verification result of the block proof information To determine the correctness of the transaction set in the block to be verified.
可选的,在一个示例中,基于所述数字签名集合和所述轻量节点处的公钥集合验证所述共识证明信息的正确性可以包括:利用各个共识节点对第一签名数据原文进行签名所使用的加密算法,从所述数字签名集合中还原出所述各个共识节点的公钥;以及基于所还原出的各个共识节点的公钥和所述轻量节点处的公钥集合,验证所述共识证明信息的正确性。Optionally, in an example, verifying the correctness of the consensus certification information based on the digital signature set and the public key set at the lightweight node may include: using each consensus node to sign the original text of the first signature data The encryption algorithm used restores the public key of each consensus node from the set of digital signatures; and verifies the public key of each consensus node based on the restored public key of each consensus node and the set of public keys at the lightweight node. The stated consensus proves the correctness of the information.
可选的,在一个示例中,基于所还原出的各个共识节点的公钥和所述轻量节点处的公钥集合,验证所述待验证区块中的交易的正确性可以包括:在所还原出的公钥中的至少部分被包括在所述公钥集合中并且被包括在所述公钥集合中的公钥数量满足共识规则时,确定所述共识证明信息是正确的。Optionally, in an example, based on the restored public key of each consensus node and the public key set at the lightweight node, verifying the correctness of the transaction in the block to be verified may include: When at least part of the restored public keys are included in the public key set and the number of public keys included in the public key set meets the consensus rule, it is determined that the consensus certification information is correct.
可选的,在一个示例中,所述公钥集合可以包括所述区块链系统中的所有参与共识的区块链节点的公钥,或所述公钥集合可以包括对所述轻量节点处的信任锚点进行共识的所有共识节点的公钥,所述信任锚点指示被验证为正确的信任区块。Optionally, in an example, the set of public keys may include the public keys of all blockchain nodes participating in the consensus in the blockchain system, or the set of public keys may include The public key of all consensus nodes that conduct consensus at the trust anchor point at the location, and the trust anchor point indicates the trust block that has been verified as correct.
可选的,在一个示例中,在从全量节点处获取待验证区块的共识证明信息之前,所述方法还可以包括:接收针对所述交易集合中的指定交易的交易正确性验证请求。从全量节点处获取待验证区块的共识证明信息可以包括:在接收到所述交易正确性验证请求时,从全量节点处获取待验证区块的共识证明信息。所述方法还可以包括:验证所述指定交易是否存在于所述交易集合中;以及基于所述交易集合的正确性验证结果和所述指定交易在所述待验证区块中的存在性验证结果,确定所述指定交易的正确性。Optionally, in an example, before obtaining the consensus proof information of the block to be verified from the full number of nodes, the method may further include: receiving a transaction correctness verification request for a specified transaction in the transaction set. Obtaining the consensus proof information of the block to be verified from the full number of nodes may include: obtaining the consensus proof information of the block to be verified from the full number of nodes when the transaction correctness verification request is received. The method may further include: verifying whether the specified transaction exists in the transaction set; and based on the correctness verification result of the transaction set and the existence verification result of the specified transaction in the to-be-verified block To determine the correctness of the specified transaction.
可选的,在一个示例中,在从全量节点处获取待验证区块的共识证明信息之前,所述方法还可以包括:监听是否存在包括指定交易的待验证区块。从全量节点处获取待验证区块的共识证明信息包括:在监听到存在包括所述指定交易的待验证区块时,从全量节点处获取所监听到的待验证区块的共识证明信息。Optionally, in an example, before obtaining the consensus proof information of the block to be verified from the full number of nodes, the method may further include: monitoring whether there is a block to be verified that includes the specified transaction. Obtaining the consensus certification information of the block to be verified from the full number of nodes includes: when the block to be verified including the specified transaction is monitored, obtaining the consensus certification information of the block to be verified that is monitored from the full number of nodes.
可选的,在一个示例中,所述方法还可以包括:接收针对所述交易集合中的指定交易的交易正确性验证请求;验证所述指定交易是否存在于所述交易集合中;以及基于所述交易集合的正确性验证结果和所述指定交易在所述待验证区块中的存在性验证结果,确定所述指定交易的正确性。Optionally, in an example, the method may further include: receiving a transaction correctness verification request for a designated transaction in the transaction set; verifying whether the designated transaction exists in the transaction set; and The correctness verification result of the transaction set and the existence verification result of the designated transaction in the to-be-verified block determine the correctness of the designated transaction.
可选的,在一个示例中,所述区块链系统可以为联盟链系统。Optionally, in an example, the blockchain system may be a consortium chain system.
根据本说明书实施例的另一方面,一种用于执行交易正确性验证的装置,所述装置用于区块链系统中的轻量节点,所述装置包括:共识证明信息获取单元,从全量节点处获取待验证区块的共识证明信息,所述共识证明信息包括数字签名集合,所述数字签 名集合是对所述待验证区块达成共识的各个共识节点对所述待验证区块所对应的第一签名数据原文进行签名而得到的;共识证明信息验证单元,基于所述数字签名集合和所述轻量节点处的公钥集合验证所述共识证明信息的正确性,所述公钥集合包括所述区块系统中的至少部分区块链节点的公钥;以及交易集合验证单元,基于所述共识证明信息的正确性验证结果,确定所述待验证区块中的交易集合的正确性。According to another aspect of the embodiments of this specification, a device for performing transaction correctness verification is used for a lightweight node in a blockchain system. The device includes: a consensus certification information acquisition unit, The node obtains the consensus proof information of the block to be verified. The consensus proof information includes a set of digital signatures. The set of digital signatures corresponds to each consensus node that has reached a consensus on the block to be verified. The first signature data is obtained by signing the original text; the consensus certification information verification unit verifies the correctness of the consensus certification information based on the digital signature set and the public key set at the lightweight node, the public key set It includes the public keys of at least part of the blockchain nodes in the block system; and a transaction set verification unit, which determines the correctness of the transaction set in the block to be verified based on the verification result of the correctness of the consensus certification information .
可选的,在一个示例中,所述装置还可以包括:区块体信息获取单元,在基于所述共识证明信息的正确性验证结果,确定所述待验证区块中的交易集合的正确性之前,从所述全量节点处获取所述待验证区块的区块体信息;区块头验证单元,基于所述区块体信息,验证所述轻量节点处的所述待验证区块的区块头的正确性。共识证明信息验证单元可以基于所述区块头的正确性验证结果和所述区块证明信息的正确性验证结果,确定所述待验证区块中的交易集合的正确性。Optionally, in an example, the device may further include: a block body information obtaining unit, which determines the correctness of the transaction set in the block to be verified based on the correctness verification result of the consensus proof information Previously, the block body information of the block to be verified was obtained from the full node; the block header verification unit, based on the block body information, verifies the area of the block to be verified at the lightweight node The correctness of the bulk. The consensus proof information verification unit may determine the correctness of the transaction set in the block to be verified based on the correctness verification result of the block header and the correctness verification result of the block proof information.
可选的,在一个示例中,所述交易集合验证单元可以包括:公钥还原模块,利用各个共识节点对第一签名数据原文进行签名所使用的加密算法,从所述数字签名集合中还原出所述各个共识节点的公钥;以及共识证明信息验证模块,基于所还原出的各个共识节点的公钥和所述轻量节点处的公钥集合,验证所述共识证明信息的正确性。Optionally, in an example, the transaction set verification unit may include: a public key restoration module, which uses the encryption algorithm used by each consensus node to sign the original text of the first signature data to restore from the digital signature set The public key of each consensus node; and the consensus certification information verification module verify the correctness of the consensus certification information based on the restored public key of each consensus node and the public key set at the lightweight node.
可选的,在一个示例中,所述共识证明信息验证模块可以在所还原出的公钥中的至少部分被包括在所述公钥集合中并且被包括在所述公钥集合中的公钥数量满足共识规则时,确定所述共识证明信息是正确的。Optionally, in an example, the consensus certification information verification module may include at least part of the restored public key in the public key set and the public key included in the public key set When the quantity satisfies the consensus rule, it is determined that the consensus certification information is correct.
可选的,在一个示例中,所述公钥集合包括所述区块链系统中的所有参与共识的区块链节点的公钥,或所述公钥集合包括对所述轻量节点处的信任锚点进行共识的所有共识节点的公钥,所述信任锚点指示被验证为正确的信任区块。Optionally, in an example, the set of public keys includes the public keys of all blockchain nodes participating in the consensus in the blockchain system, or the set of public keys includes the The trust anchor is the public key of all consensus nodes that perform consensus, and the trust anchor indicates the trust block that has been verified as correct.
可选的,在一个示例中,在从全量节点处获取待验证区块的共识证明信息之前,所述装置还可以包括:验证请求接收单元,接收针对所述交易集合中的指定交易的交易正确性验证请求。所述共识证明信息获取单元在接收到所述交易正确性验证请求时,从全量节点处获取待验证区块的共识证明信息。所述装置还可以包括:存在性验证单元,验证所述指定交易是否存在于所述交易集合中;以及指定交易正确性确定单元,基于所述交易集合的正确性验证结果和所述指定交易在所述待验证区块中的存在性验证结果,确定所述指定交易的正确性。Optionally, in an example, before obtaining the consensus proof information of the block to be verified from the full number of nodes, the device may further include: a verification request receiving unit, which receives that the transaction for the specified transaction in the transaction set is correct Sexual verification request. The consensus proof information obtaining unit obtains the consensus proof information of the block to be verified from all nodes when receiving the transaction correctness verification request. The device may further include: an existence verification unit that verifies whether the specified transaction exists in the transaction set; and a specified transaction correctness determination unit based on the correctness verification result of the transaction set and the specified transaction The existence verification result in the to-be-verified block determines the correctness of the specified transaction.
可选的,在一个示例中,所述装置还可以包括:待验证区块监听单元,在从全量节点处获取待验证区块的共识证明信息之前,监听是否存在包括指定交易的待验证区块。所述共识证明信息获取单元可以在监听到存在包括所述指定交易的待验证区块时,从全 量节点处获取所监听到的待验证区块的共识证明信息。Optionally, in an example, the device may further include: a block to be verified monitoring unit, which monitors whether there is a block to be verified that includes the specified transaction before obtaining the consensus proof information of the block to be verified from the full number of nodes . The consensus proof information obtaining unit may obtain the monitored consensus proof information of the block to be verified from the full number of nodes when it monitors that there is a block to be verified that includes the designated transaction.
可选的,在一个示例中,所述装置还可以包括:验证请求接收单元,接收针对所述交易集合中的指定交易的交易正确性验证请求;存在性验证单元,验证所述指定交易是否存在于所述交易集合中;以及指定交易正确性确定单元,基于所述交易集合的正确性验证结果和所述指定交易在所述待验证区块中的存在性验证结果,确定所述指定交易的正确性。Optionally, in an example, the device may further include: a verification request receiving unit to receive a transaction correctness verification request for a specified transaction in the transaction set; an existence verification unit to verify whether the specified transaction exists In the transaction set; and a designated transaction correctness determination unit, based on the correctness verification result of the transaction set and the existence verification result of the designated transaction in the to-be-verified block, determine the designated transaction Correctness.
根据本说明书实施例的另一方面,还提供一种计算设备,包括:至少一个处理器;以及存储器,所述存储器存储指令,当所述指令被所述至少一个处理器执行时,使得所述至少一个处理器执行如上所述的方法。According to another aspect of the embodiments of this specification, there is also provided a computing device, including: at least one processor; and a memory, the memory stores instructions, and when the instructions are executed by the at least one processor, the At least one processor executes the method as described above.
根据本说明书实施例的另一方面,还提供一种非暂时性机器可读存储介质,其存储有可执行指令,所述指令当被执行时使得所述机器执行如上所述的方法。According to another aspect of the embodiments of the present specification, there is also provided a non-transitory machine-readable storage medium, which stores executable instructions, which when executed cause the machine to execute the method as described above.
利用本说明书实施例的方法和装置,可以通过对待验证区块的共识证明信息进行验证来验证待证明区块上的交易集合的正确性,从而轻量节点可以在不用访问多个全量节点的情况下对交易执行正确性验证。Using the method and device of the embodiments of the present specification, the correctness of the transaction set on the block to be proven can be verified by verifying the consensus proof information of the block to be verified, so that the lightweight node can be used without accessing multiple full nodes. Verify the correctness of the transaction.
附图说明Description of the drawings
通过参照下面的附图,可以实现对于本说明书实施例内容的本质和优点的进一步理解。在附图中,类似组件或特征可以具有相同的附图标记。附图是用来提供对本发明实施例的进一步理解,并且构成说明书的一部分,与下面的具体实施方式一起用于解释本说明书实施例的实施例,但并不构成对本说明书实施例的实施例的限制。By referring to the following drawings, a further understanding of the nature and advantages of the contents of the embodiments of this specification can be achieved. In the drawings, similar components or features may have the same reference signs. The accompanying drawings are used to provide a further understanding of the embodiments of the present invention, and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the embodiments of the specification, but do not constitute an example of the embodiments of the specification. limit.
图1示出了可用于执行根据本说明书实施例的用于执行交易正确性验证的方法的环境的示例的示意图;FIG. 1 shows a schematic diagram of an example of an environment that can be used to execute a method for performing transaction correctness verification according to an embodiment of the present specification;
图2示出了执行根据本说明书实施例的用于执行交易正确性验证的方法的系统架构的示例的示意图;FIG. 2 shows a schematic diagram of an example of a system architecture for executing the method for performing transaction correctness verification according to an embodiment of the present specification;
图3示出了适用于区块链系统的共识过程的一个示例的流程图;Figure 3 shows a flowchart of an example of a consensus process applicable to a blockchain system;
图4示出了根据本说明书实施例的用于执行交易正确性验证的方法所适用的区块链系统的一个示例的示意图;FIG. 4 shows a schematic diagram of an example of a blockchain system to which the method for performing transaction correctness verification according to an embodiment of the present specification is applicable;
图5是根据本说明书的一个实施例的用于执行交易正确性验证的方法的流程图;Fig. 5 is a flowchart of a method for performing transaction correctness verification according to an embodiment of the present specification;
图6是根据本说明书的一个实施例的用于执行交易正确性验证的方法中的共识证明信息验证过程的示例的流程图;Fig. 6 is a flowchart of an example of a consensus proof information verification process in a method for performing transaction correctness verification according to an embodiment of the present specification;
图7是根据本说明书的另一实施例的用于执行交易正确性验证的方法的流程图;Fig. 7 is a flowchart of a method for performing transaction correctness verification according to another embodiment of the present specification;
图8是根据本说明书的另一实施例的用于执行交易正确性验证的方法的流程图;Fig. 8 is a flowchart of a method for performing transaction correctness verification according to another embodiment of the present specification;
图9是用于说明本说明书实施例的用于执行交易正确性验证的方法中的交易存在性验证过程的示意图;FIG. 9 is a schematic diagram for explaining the transaction existence verification process in the method for performing transaction correctness verification according to an embodiment of the present specification;
图10是根据本说明书的另一实施例的用于执行交易正确性验证的方法的流程图;Fig. 10 is a flowchart of a method for performing transaction correctness verification according to another embodiment of the present specification;
图11是根据本说明书的一个实施例的用于执行交易正确性验证的装置的结构框图;FIG. 11 is a structural block diagram of a device for performing transaction correctness verification according to an embodiment of the present specification;
图12是图11所示的用于执行交易正确性验证的装置中的共识证明验证过程的结构框图;以及FIG. 12 is a structural block diagram of the consensus proof verification process in the device for performing transaction correctness verification shown in FIG. 11; and
图13是根据本说明书的一个实施例的用于实现用执行交易正确性验证的方法的计算设备的结构框图。Fig. 13 is a structural block diagram of a computing device for implementing a method for verifying the correctness of a transaction according to an embodiment of the present specification.
具体实施方式Detailed ways
以下将参考示例实施方式讨论本文描述的主题。应该理解,讨论这些实施方式只是为了使得本领域技术人员能够更好地理解从而实现本文描述的主题,并非是对权利要求书中所阐述的保护范围、适用性或者示例的限制。可以在不脱离本说明书实施例内容的保护范围的情况下,对所讨论的元素的功能和排列进行改变。各个示例可以根据需要,省略、替代或者添加各种过程或组件。另外,相对一些示例所描述的特征在其它例子中也可以进行组合。The subject described herein will be discussed below with reference to example embodiments. It should be understood that the discussion of these embodiments is only to enable those skilled in the art to better understand and realize the subject described herein, and is not to limit the scope of protection, applicability, or examples set forth in the claims. The function and arrangement of the discussed elements can be changed without departing from the protection scope of the content of the embodiments of this specification. Various examples can omit, substitute, or add various procedures or components as needed. In addition, features described with respect to some examples can also be combined in other examples.
如本文中使用的,术语“包括”及其变型表示开放的术语,含义是“包括但不限于”。术语“基于”表示“至少部分地基于”。术语“一个实施例”和“一实施例”表示“至少一个实施例”。术语“另一个实施例”表示“至少一个其他实施例”。术语“第一”、“第二”等可以指代不同的或相同的对象。下面可以包括其他的定义,无论是明确的还是隐含的。除非上下文中明确地指明,否则一个术语的定义在整个说明书中是一致的。As used herein, the term "including" and its variations mean open terms, meaning "including but not limited to". The term "based on" means "based at least in part on." The terms "one embodiment" and "an embodiment" mean "at least one embodiment." The term "another embodiment" means "at least one other embodiment." The terms "first", "second", etc. may refer to different or the same objects. Other definitions can be included below, whether explicit or implicit. Unless clearly indicated in the context, the definition of a term is consistent throughout the specification.
在本文中,术语“相连”是指两个组件之间直接机械连接、连通或电连接,或者通过中间组件来间接机械连接、连通或电连接。术语“电连接”是指两个组件之间可以进行电通信以进行数据/信息交换。同样,所述电连接可以指两个组件之间直接电连接,或者通过中间组件来间接电连接。所述电连接可以采用有线方式或无线方式来实现。In this document, the term "connected" refers to direct mechanical connection, communication or electrical connection between two components, or indirect mechanical connection, communication or electrical connection through intermediate components. The term "electrically connected" refers to the possibility of electrical communication between two components for data/information exchange. Similarly, the electrical connection may refer to a direct electrical connection between two components, or an indirect electrical connection through an intermediate component. The electrical connection can be implemented in a wired manner or a wireless manner.
现在结合附图来描述本说明书实施例的用于执行交易正确性验证的方法及装置。The method and device for performing transaction correctness verification according to the embodiments of this specification will now be described with reference to the accompanying drawings.
区块链是一种按照时间顺序来将数据区块顺序相连组合而成的链式数据结构,并且以密码学方式保证数据区块不可篡改和不可伪造。区块链包括一个或多个区块。区块链中的每个区块通过包括该区块链中紧接其之前的前一个区块的加密哈希而链接到该 前一个区块。每个区块还包括时间戳、该区块的加密哈希以及一个或多个交易(transaction)。对已经被区块链节点验证的交易进行哈希处理并形成Merkle树。在Merkle树中,对叶节点处的数据进行哈希处理,并且针对Merkle树的每个分支,在该分支的根处级联该分支的所有哈希值。针对Merkle树执行上述处理,直到整个Merkle树的根节点。Merkle树的根节点存储代表该Merkle树中的所有数据的哈希值。当一个哈希值声称是Merkle树中存储的交易时,可以通过判断该哈希值是否与Merkle树的结构一致来进行快速验证。Blockchain is a chain data structure that connects and combines data blocks sequentially in chronological order, and cryptographically ensures that the data blocks cannot be tampered with or forged. The blockchain includes one or more blocks. Each block in the blockchain is linked to the previous block by including the cryptographic hash of the immediately preceding block in the blockchain. Each block also includes a timestamp, a cryptographic hash of the block, and one or more transactions. The transaction that has been verified by the blockchain node is hashed and a Merkle tree is formed. In the Merkle tree, the data at the leaf nodes is hashed, and for each branch of the Merkle tree, all the hash values of the branch are concatenated at the root of the branch. The above processing is performed on the Merkle tree until the root node of the entire Merkle tree. The root node of the Merkle tree stores hash values representing all data in the Merkle tree. When a hash value claims to be a transaction stored in the Merkle tree, it can be quickly verified by judging whether the hash value is consistent with the structure of the Merkle tree.
区块链是用于存储交易的数据结构。区块链网络是用于管理、更新和维护一个或多个区块链结构的计算节点网络。如上所述,区块链网络可以包括公有区块链网络、私有区块链网络或联盟区块链网络。Blockchain is a data structure used to store transactions. The blockchain network is a network of computing nodes used to manage, update and maintain one or more blockchain structures. As mentioned above, the blockchain network can include a public blockchain network, a private blockchain network, or a consortium blockchain network.
在公有区块链网络中,共识过程由共识网络的节点控制。例如,在公有区块链网络中可以存在成千上万个实体协作处理,每个实体操作该公有区块链网络中的至少一个节点。因此,公有区块链网络可以被认为是参与实体的公有网络。在一些示例中,大多数实体(节点)必须按序对每个区块进行签名,并且将签名后的区块添加到区块链网络的区块链中。公有区块链网络的示例可以包括特定对等支付网络。此外,术语“区块链”不特别指代任何特定的区块链。In the public blockchain network, the consensus process is controlled by the nodes of the consensus network. For example, there may be thousands of entities in a public blockchain network for collaborative processing, and each entity operates at least one node in the public blockchain network. Therefore, the public blockchain network can be considered as a public network of participating entities. In some examples, most entities (nodes) must sign each block in sequence, and add the signed block to the blockchain of the blockchain network. Examples of public blockchain networks may include specific peer-to-peer payment networks. In addition, the term "blockchain" does not specifically refer to any particular blockchain.
公有区块链网络支持公有交易。公有交易在公有区块链网络内的所有节点之间共享,并且存储在全局区块链中。全局区块链是指跨所有节点复制的区块链。为了达成共识(例如,同意向区块链添加区块),在公有区块链网络内实现共识协议。共识协议的示例包括但不限于:工作量证明(POW,proof-of-work),权益证明(POS,proof-of-stake)和权威证明(POA,proof-of-authority)。在本说明书实施例中,采用POW作为非限制性示例。The public blockchain network supports public transactions. Public transactions are shared among all nodes in the public blockchain network and stored in the global blockchain. A global blockchain refers to a blockchain that is replicated across all nodes. In order to reach a consensus (for example, agree to add a block to the blockchain), a consensus agreement is implemented in the public blockchain network. Examples of consensus protocols include but are not limited to: proof-of-work (POW), proof-of-stake (POS), and proof-of-authority (POA). In the embodiments of this specification, POW is used as a non-limiting example.
私有区块链网络被提供来用于特定实体。私有区块链网络中的各个节点的读写权限被严格控制。因此,私有区块链网络通常也称为许可网络,其对允许谁参与网络以及网络参与水平(例如,仅在某些交易情形下)进行限制。在私有区块链网络中,可以使用各种类型的访问控制机制(例如,现有参与方对添加新实体进行投票,监管机构控制许可等)。Private blockchain networks are provided for specific entities. The read and write permissions of each node in the private blockchain network are strictly controlled. Therefore, a private blockchain network is usually also called a permissioned network, which restricts who is allowed to participate in the network and the level of network participation (for example, only in certain transaction situations). In a private blockchain network, various types of access control mechanisms can be used (for example, existing participants vote to add new entities, regulatory agencies control permissions, etc.).
联盟区块链网络在参与实体之间是私有的。在联盟区块链网络中,共识过程由授权节点控制。例如,由若干个(例如,10个)实体(例如,金融机构,保险公司)组成的联盟可以操作联盟区块链网络,每个实体操作该联盟区块链网络中的至少一个节点。因此,联盟区块链网络可以被认为是参与实体的私有网络。在一些示例中,每个参与实体(节点)必须按序对每个区块进行签名,并将该区块添加到区块链。在一些示例中, 可以由参与实体(节点)的子集(例如,至少7个实体)来对每个区块进行签名,并将该区块添加到区块链。The alliance blockchain network is private among participating entities. In the alliance blockchain network, the consensus process is controlled by authorized nodes. For example, a consortium composed of several (for example, 10) entities (for example, financial institutions, insurance companies) can operate a consortium blockchain network, and each entity operates at least one node in the consortium blockchain network. Therefore, the consortium blockchain network can be considered as a private network of participating entities. In some examples, each participating entity (node) must sign each block in sequence and add the block to the blockchain. In some examples, each block may be signed by a subset of participating entities (nodes) (for example, at least 7 entities), and the block may be added to the blockchain.
区块链是防篡改的共享数字分类账,其在公有或私有对等网络中记录交易。分类账被分发到网络中的所有成员节点,并且网络中发生的资产交易历史记录被永久记录在区块中。Blockchain is a tamper-proof shared digital ledger that records transactions in a public or private peer-to-peer network. The ledger is distributed to all member nodes in the network, and the history of asset transactions that occurred in the network is permanently recorded in the block.
共识机制确保分布式区块链网络中的所有区块链节点按照相同的顺序执行交易,并且随后写入相同的分类账。The consensus mechanism ensures that all blockchain nodes in the distributed blockchain network execute transactions in the same order and then write to the same ledger.
图1示出了可用于执行根据本公开的实施例的用于执行交易正确性验证的方法的环境100的示例的示意图。在一些示例中,环境100使得实体能够参与区块链网络102。如图1所示,环境100包括网络104、和计算设备/系统106、108。在一些示例中,网络104可以包括局域网(LAN)、广域网(WAN)、因特网或其组合,并且连接网站、用户设备(例如,计算设备)和后端系统。在一些示例中,可以通过有线和/或无线通信链路来访问网络104。在一些示例中,计算设备/系统106、108通过网络104相互通信,以及通过网络104实现与区块链网络102之间的通信,以及区块链网络102中的节点(或,节点设备)通过网络104来进行通信。通常,网络104表示一个或多个通信网络。在一些情况下,计算设备/系统106、108可以是云计算系统(未示出)的节点,或者每个计算设备/系统106、108可以是单独的云计算系统,其包括通过网络104互连的多个计算机并且用作分布式处理系统。FIG. 1 shows a schematic diagram of an example of an environment 100 that can be used to execute a method for performing transaction correctness verification according to an embodiment of the present disclosure. In some examples, the environment 100 enables entities to participate in the blockchain network 102. As shown in FIG. 1, the environment 100 includes a network 104, and computing devices/ systems 106, 108. In some examples, the network 104 may include a local area network (LAN), a wide area network (WAN), the Internet, or a combination thereof, and connect a website, a user device (eg, a computing device), and a back-end system. In some examples, the network 104 may be accessed through a wired and/or wireless communication link. In some examples, the computing devices/ systems 106 and 108 communicate with each other through the network 104, and communicate with the blockchain network 102 through the network 104, and the nodes (or node devices) in the blockchain network 102 pass through The network 104 communicates. Generally, the network 104 represents one or more communication networks. In some cases, the computing devices/ systems 106, 108 may be nodes of a cloud computing system (not shown), or each computing device/ system 106, 108 may be a separate cloud computing system, including interconnection through the network 104 Multiple computers and used as a distributed processing system.
在所说明的示例中,计算设备/系统106、108中的每个可以包括能够参与作为区块链网络102中的节点的任何合适的计算系统。计算设备/系统的示例包括但不限于,服务器、台式计算机、笔记本电脑、平板电脑设备和智能手机等。在一些示例中,计算设备/系统106、108上可以安装有用于与区块链网络102交互的一个或多个计算机实现的服务。例如,计算设备/系统106可以上可以安装有第一实体(例如,用户A)的服务,比如,第一实体用于管理其与一个或多个其他实体(例如,其他用户)的交易的交易管理系统。计算设备/系统108可以上可以安装有第二实体(例如,用户B)的服务,比如,第二实体用于管理其与一个或多个其他实体(例如,其他用户)的交易的交易管理系统。在图1的示例中,区块链网络102被表示为节点的对等网络,并且计算设备/系统106、108分别作为参与区块链网络102的第一实体和第二实体的节点。In the illustrated example, each of the computing devices/ systems 106, 108 may include any suitable computing system capable of participating as a node in the blockchain network 102. Examples of computing devices/systems include, but are not limited to, servers, desktop computers, notebook computers, tablet devices, smart phones, etc. In some examples, one or more computer-implemented services for interacting with the blockchain network 102 may be installed on the computing device/ system 106, 108. For example, the computing device/system 106 may be installed with the services of the first entity (for example, user A), for example, the first entity is used to manage transactions with one or more other entities (for example, other users). Management system. The computing device/system 108 may be installed with services of a second entity (for example, user B), for example, a transaction management system used by the second entity to manage transactions with one or more other entities (for example, other users) . In the example of FIG. 1, the blockchain network 102 is represented as a peer-to-peer network of nodes, and the computing devices/ systems 106, 108 serve as the nodes of the first entity and the second entity participating in the blockchain network 102, respectively.
图2示出了执行根据本公开的实施例的用于执行交易正确性验证的方法的系统架构200的示例的示意图。系统架构200的示例包括分别与参与方A,参与方B和参与方C对应的参与方系统202、204、206。每个参与方(例如,用户,企业)参与被提供来作为对等网络的区块链网络212。区块链网络212包括多个节点214,其中,节点214 中的至少一些节点在区块链216中记录信息,并且所记录的信息不可更改。尽管在区块链网络212内示意性地示出了单个区块链216,但是可以提供区块链216的多个副本,并且在区块链网络212中维护多个副本,如稍后详细描述的。FIG. 2 shows a schematic diagram of an example of a system architecture 200 that executes the method for performing transaction correctness verification according to an embodiment of the present disclosure. An example of the system architecture 200 includes the participant systems 202, 204, and 206 corresponding to the participant A, the participant B, and the participant C, respectively. Each participant (eg, user, enterprise) participates in the blockchain network 212 provided as a peer-to-peer network. The blockchain network 212 includes a plurality of nodes 214, wherein at least some of the nodes 214 record information in the blockchain 216, and the recorded information cannot be changed. Although a single blockchain 216 is schematically shown within the blockchain network 212, multiple copies of the blockchain 216 may be provided, and multiple copies are maintained in the blockchain network 212, as described in detail later of.
在所示出的示例中,每个参与方系统202、204、206分别由参与方A,参与方B和参与方C提供,或者被提供来作为参与方A、参与方B和参与方C,并且充当区块链网络212内的对应节点214。如这里所使用的,节点通常是指连接到区块链网络212的单个系统(例如,计算机、服务器),并且使得相应的参与方能够参与区块链网络。在图2示出的示例中,参与方对应于每个节点214。然而,一个参与方可以操作区块链网络212内的多个节点214,和/或多个参与方可以共享单个节点214。在一些示例中,参与方系统202、204、206使用协议(例如,超文本传输协议安全(HTTPS))和/或使用远程过程调用(RPC)来与区块链网络212通信,或者通过区块链网络212进行通信。In the example shown, each participant system 202, 204, 206 is provided by participant A, participant B, and participant C, or provided as participant A, participant B, and participant C, respectively. And it serves as the corresponding node 214 in the blockchain network 212. As used herein, a node generally refers to a single system (for example, a computer, a server) connected to the blockchain network 212 and enables corresponding participants to participate in the blockchain network. In the example shown in FIG. 2, the participant corresponds to each node 214. However, one participant can operate multiple nodes 214 within the blockchain network 212, and/or multiple participants can share a single node 214. In some examples, the participant systems 202, 204, 206 use protocols (e.g., Hypertext Transfer Protocol Security (HTTPS)) and/or use remote procedure calls (RPC) to communicate with the blockchain network 212, or through the blockchain The chain network 212 communicates.
节点214在区块链网络212的参与度可以不同。例如,一些节点214可以参与共识过程(例如,作为将区块添加到区块链216的矿工节点),而其他节点214不参与共识过程。作为另一示例,一些节点214存储区块链216的完整副本,而其他节点214仅存储区块链216的部分副本。在图2的示例中,参与方系统202、204、206各自存储区块链216的完整副本216'、216”、216”'。The degree of participation of the node 214 in the blockchain network 212 may vary. For example, some nodes 214 may participate in the consensus process (eg, as miner nodes that add blocks to the blockchain 216), while other nodes 214 do not participate in the consensus process. As another example, some nodes 214 store a complete copy of the blockchain 216, while other nodes 214 only store a partial copy of the blockchain 216. In the example of Figure 2, the participant systems 202, 204, 206 each store a complete copy of the blockchain 216 216', 216", 216"'.
区块链(例如,图2中的区块链216)由一连串的区块组成,每个区块存储数据。数据的示例可以包括表示两个或更多参与方之间的交易的交易数据。在本公开中,交易被使用来作为非限制性示例,可以预期的是,任何适当的数据都可以存储在区块链中(例如,文档、图像、视频、音频)。交易的示例可以包括但不限于交换有价值的东西(例如,资产、产品、服务和货币等)。交易数据被不可更改地存储在区块链中。A blockchain (for example, the blockchain 216 in FIG. 2) is composed of a series of blocks, and each block stores data. Examples of data may include transaction data representing transactions between two or more participants. In this disclosure, transactions are used as a non-limiting example, and it is expected that any appropriate data can be stored in the blockchain (e.g., documents, images, videos, audios). Examples of transactions may include, but are not limited to, the exchange of valuable things (eg, assets, products, services, currency, etc.). Transaction data is stored immutably in the blockchain.
在存储在区块中之前,对交易数据进行哈希处理。哈希处理是将(作为字符串数据提供的)交易数据转换为固定长度的哈希值(也被作为字符串数据提供)的过程。通过对交易数据进行哈希处理后,即使交易数据出现轻微更改,也会导致得到完全不同的哈希值。哈希值通常是通过使用哈希函数来对交易数据进行哈希处理而生成的。哈希函数的示例包括但不限于安全散列算法(SHA)-256,其输出256比特的哈希值。Before storing in the block, hash the transaction data. Hashing is the process of converting transaction data (provided as string data) into a fixed-length hash value (also provided as string data). After the transaction data is hashed, even a slight change in the transaction data will result in a completely different hash value. The hash value is usually generated by hashing transaction data using a hash function. Examples of hash functions include, but are not limited to, Secure Hash Algorithm (SHA)-256, which outputs a 256-bit hash value.
多个交易的交易数据可以在被哈希化之后存储在区块中。例如,对两个交易数据进行哈希处理得到两个哈希值,然后,对所得到的两个哈希值再次进行哈希处理以得到另一哈希值。重复该过程,直到对于要存储在区块中的所有交易,得到单个哈希值。该哈希值被称为Merkle根哈希,并且被存储在区块的头部。任何交易的更改都会导致其哈希值发生变化,最终导致Merkle根哈希值发生变化。The transaction data of multiple transactions can be stored in the block after being hashed. For example, two transaction data are hashed to obtain two hash values, and then the two obtained hash values are hashed again to obtain another hash value. This process is repeated until a single hash value is obtained for all transactions to be stored in the block. This hash value is called the Merkle root hash and is stored at the head of the block. Any change in the transaction will cause its hash value to change, and eventually the Merkle root hash value will change.
通过共识协议来将区块添加到区块链中。区块链网络中的多个节点参与共识协议, 并且经过竞争之后将区块添加到区块链中。这样的节点被称为矿工节点(或记账节点)。以上介绍的POW用作非限制性示例。The block is added to the blockchain through a consensus protocol. Multiple nodes in the blockchain network participate in the consensus protocol, and after competition, blocks are added to the blockchain. Such nodes are called miner nodes (or accounting nodes). The POW introduced above serves as a non-limiting example.
矿工节点执行共识过程来将交易(所对应的区块)添加到区块链。虽然多个矿工节点参与共识过程,但只有一个矿工节点可以将区块写入区块链。也就是说,矿工节点在共识过程中竞争以将其区块添加到区块链中。更详细地,矿工节点周期性地从交易池中收集待处理的交易(例如,直到达到在区块中可以包括的交易数量的预定限制,如果有的话)。交易池包括来自区块链网络中的参与方的交易消息。矿工节点创建区块,并将交易添加到区块中。在将交易添加到区块之前,矿工节点检查待添加的交易中是否存在区块链的区块中具有的交易。如果该交易已被添加到另一个区块中,则该交易将被丢弃。Miner nodes perform a consensus process to add transactions (corresponding blocks) to the blockchain. Although multiple miner nodes participate in the consensus process, only one miner node can write a block to the blockchain. In other words, miner nodes compete in the consensus process to add their blocks to the blockchain. In more detail, the miner node periodically collects pending transactions from the transaction pool (for example, until a predetermined limit on the number of transactions that can be included in the block is reached, if any). The transaction pool includes transaction messages from participants in the blockchain network. Miner nodes create blocks and add transactions to the blocks. Before adding the transaction to the block, the miner node checks whether there is a transaction in the block of the blockchain among the transactions to be added. If the transaction has been added to another block, the transaction will be discarded.
矿工节点生成区块头,对区块中的所有交易进行哈希处理,并且成对地组合哈希值以生成进一步的哈希值,直到针对区块中的所有交易得到单个哈希值(Merkle根哈希)。然后,将Merkle根哈希添加到区块头中。矿工还确定区块链中的最新区块(即,添加到区块链的最后一个区块)的哈希值。矿工节点还可以在区块头中添加随机数值(noune值)和时间戳。在挖掘过程中,矿工节点尝试找到满足所需参数的哈希值。矿工节点不断更改nonce值,直到找到满足所需参数的哈希值。The miner node generates a block header, hashes all transactions in the block, and combines the hash values in pairs to generate further hash values until a single hash value (Merkle root) is obtained for all transactions in the block. Hash). Then, add the Merkle root hash to the block header. The miner also determines the hash value of the latest block in the blockchain (ie, the last block added to the blockchain). Miner nodes can also add random values (noune values) and timestamps to the block header. During the mining process, the miner node tries to find a hash value that meets the required parameters. The miner node keeps changing the nonce value until it finds a hash value that meets the required parameters.
区块链网络中的每个矿工都试图找到满足所需参数的哈希值,并且以这种方式彼此竞争。最终,一个矿工节点找到满足所需参数的哈希值,并将该哈希值通告给区块链网络中的所有其他矿工节点。其他矿工节点验证哈希值,如果确定为正确,则验证区块中的每个交易,接受该区块,并将该区块附加到它们的区块链副本中。以这种方式,区块链的全局状态在区块链网络内的所有矿工节点上达成一致。上述过程是POW共识协议。Every miner in the blockchain network tries to find a hash value that meets the required parameters and competes with each other in this way. Finally, a miner node finds a hash value that meets the required parameters and advertises the hash value to all other miner nodes in the blockchain network. Other miner nodes verify the hash value, and if it is determined to be correct, verify each transaction in the block, accept the block, and attach the block to their copy of the blockchain. In this way, the global state of the blockchain is agreed upon on all miner nodes within the blockchain network. The above process is a POW consensus protocol.
在图2所提供的示例中,参与方A想要向参与方B发送一定数量的资金。参与方A生成交易消息,并将交易消息发送到区块链网络,该交易消息被增加到交易池中。区块链网络中的每个矿工节点创建区块,并从交易池中获取交易,并将交易添加到区块。按照这种方式,参与方A所发布的交易被添加到矿工节点的区块中。In the example provided in Figure 2, participant A wants to send a certain amount of funds to participant B. Participant A generates a transaction message and sends the transaction message to the blockchain network, and the transaction message is added to the transaction pool. Each miner node in the blockchain network creates a block, obtains transactions from the transaction pool, and adds the transaction to the block. In this way, the transaction issued by participant A is added to the block of the miner node.
在一些区块链网络中,实施密码技术来维护交易的隐私性。例如,如果两个节点想要保持交易私密性,使得区块链网络中的其他节点不能获悉交易细节,则节点可以对交易数据进行加密处理。加密方法的示例包括但不限于对称加密和非对称加密。对称加密是指使用单个密钥进行加密(根据明文生成密文)和解密(根据密文生成明文)的加密过程。在对称加密中,多个节点可以使用相同的密钥,因此每个节点都可以对交易数据进行加密/解密。In some blockchain networks, cryptography is implemented to maintain the privacy of transactions. For example, if two nodes want to maintain the privacy of the transaction so that other nodes in the blockchain network cannot learn the details of the transaction, the node can encrypt the transaction data. Examples of encryption methods include, but are not limited to, symmetric encryption and asymmetric encryption. Symmetric encryption refers to the encryption process that uses a single key to encrypt (generate ciphertext based on plaintext) and decrypt (generate plaintext based on ciphertext). In symmetric encryption, multiple nodes can use the same key, so each node can encrypt/decrypt transaction data.
非对称加密中使用密钥对来进行加密和解密,且每个密钥对包括的私钥和公钥不同。对于一个节点来说,其具有的非对称加密的密钥对中的私钥需要保密存储;公钥可以公开出去,让其它节点获得。如果用公钥对数据进行加密,只有用对应的私钥才能解密。例如,再次参考图1。参与方A可以使用参与方B的公钥来加密数据,并将加密后的数据发送至参与方B。参与方B可以使用其私钥来解密从参与方A发来的加密数据(密文)并解密得到原始数据(明文)。使用节点的公钥加密的消息,只能使用成对秘钥中对应的私钥解密。In asymmetric encryption, a key pair is used for encryption and decryption, and each key pair includes a different private key and public key. For a node, the private key in its asymmetric encryption key pair needs to be stored confidentially; the public key can be made public for other nodes to obtain. If the data is encrypted with a public key, only the corresponding private key can be used to decrypt it. For example, refer to Figure 1 again. Participant A can use the public key of participant B to encrypt data, and send the encrypted data to participant B. Participant B can use its private key to decrypt the encrypted data (ciphertext) sent from participant A and decrypt the original data (plaintext). Messages encrypted with the public key of the node can only be decrypted with the corresponding private key in the paired secret key.
非对称加密还可以用于提供数字签名,这使得交易中的参与方能够确认交易中的其他参与方以及交易的有效性。例如,参与方A可以对消息进行数字签名,而另一个参与方B可以根据参与方A的数字签名确认消息是由该参与方A发送的。数字签名还可以用于确保消息在传输过程中不被篡改。例如,再次参考图1。参与方A将向参与方B发送消息。参与方A生成消息的哈希值,然后使用其私钥对哈希值进行加密来生成数字签名。参与方A将该数字签名附加到消息,并将具有数字签名的消息发送给参与方B。参与方B使用参与方A的公钥解密数字签名,从而解密出对应的哈希值。参与方B对所接收的消息进行哈希处理以得到另一哈希值,然后比较两个哈希值。如果哈希值相同,则参与方B可以确认该消息确实来自参与方A,并且未被篡改。Asymmetric encryption can also be used to provide digital signatures, which enable participants in a transaction to confirm other participants in the transaction and the validity of the transaction. For example, participant A can digitally sign the message, and another participant B can confirm that the message was sent by the participant A according to the digital signature of the participant A. Digital signatures can also be used to ensure that messages are not tampered with during transmission. For example, refer to Figure 1 again. Participant A will send a message to participant B. Participant A generates a hash value of the message, and then uses its private key to encrypt the hash value to generate a digital signature. Participant A attaches the digital signature to the message, and sends the message with the digital signature to participant B. Participant B uses the public key of participant A to decrypt the digital signature, thereby decrypting the corresponding hash value. Participant B hashes the received message to obtain another hash value, and then compares the two hash values. If the hash value is the same, participant B can confirm that the message is indeed from participant A and has not been tampered with.
在本说明书实施例中,区块链节点可以是图1或图2中的任意参与方。In the embodiment of this specification, the blockchain node can be any participant in FIG. 1 or FIG. 2.
图3示出了适用于区块链系统的共识过程300的一个示例的示意图。如图3所示,C表示客户端(即轻量节点),R 0为区块链系统的当前共识过程的主节点,以及R 1、R 2和R 3为备份节点。 FIG. 3 shows a schematic diagram of an example of a consensus process 300 applicable to a blockchain system. As shown in Figure 3, C represents the client (ie, lightweight node), R 0 is the master node of the current consensus process of the blockchain system, and R 1 , R 2 and R 3 are backup nodes.
在请求阶段310,客户端C可以向主节点R 0发送交易请求(Request),另外,客户端C也可以向区块链系统中的其他节点(例如,R 1、R 2和R 3)发送该交易请求(图3中未示出),然后,该其他节点将所接收的交易请求转发给主节点R 0In the request phase 310, the client C can send a transaction request (Request) to the master node R 0. In addition, the client C can also send to other nodes in the blockchain system (for example, R 1 , R 2 and R 3 ) The transaction request (not shown in FIG. 3), and then the other node forwards the received transaction request to the master node R 0 .
在接收到交易请求(Request)之后,主节点R 0与备份节点R 1、R 2以及R 3进行共识处理。共识处理的过程包括:预准备阶段(pre-prepare)320、准备阶段(prepare)330以及确认阶段(commit)340。 After receiving the transaction request (Request), the master node R 0 and the backup nodes R 1 , R 2 and R 3 perform consensus processing. The process of consensus processing includes: a pre-prepare phase (pre-prepare) 320, a preparation phase (prepare) 330, and a confirmation phase (commit) 340.
在预准备阶段320,在接收到一定数量的交易请求后,主节点R 0对所接收的交易排序并打包为消息m,然后生成预准备消息(Pre-prepare),并且在给定的时间间隔内,将预准备消息(Pre-prepare)发送(例如,广播)给备份节点R 1、R 2和R 3。预准备消息(Pre-prepare)表明主节点R 0正在启动共识过程。 In the pre-preparation stage 320, after receiving a certain number of transaction requests, the master node R 0 sorts and packages the received transactions into a message m, and then generates a pre-prepare message (Pre-prepare), and in a given time interval Inside, the pre-prepare message (Pre-prepare) is sent (for example, broadcast) to the backup nodes R 1 , R 2 and R 3 . The pre-prepare message (Pre-prepare) indicates that the master node R 0 is starting the consensus process.
如图3所示,主节点R0向区块链网络中的其他区块链节点R1、R2和R3发送Pre-prepare消息。注意,共识过程300被示为包括4个区块链节点R0、R1、R2和R3 仅用于说明目的,共识过程300也可以包括任何合适数量的区块链节点。As shown in Figure 3, the master node R0 sends a Pre-prepare message to other blockchain nodes R1, R2, and R3 in the blockchain network. Note that the consensus process 300 is shown as including 4 blockchain nodes R0, R1, R2, and R3 for illustration purposes only, and the consensus process 300 may also include any suitable number of blockchain nodes.
在准备阶段330,对于每个备份节点(R 1、R 2或R 3),在接收到预准备消息并验证预准备消息合法后,可以将预准备消息存储在本地日志中,并生成用于响应预准备消息的准备消息Prepare,再将所生成的准备消息Prepare广播至其他节点。准备消息Prepare指示备份节点已从主节点接收到预准备消息Pre-prepare,并且正在响应预准备消息Pre-prepare发送应答。 In the preparation phase 330, for each backup node (R 1 , R 2 or R 3 ), after receiving the pre-preparation message and verifying that the pre-preparation message is legal, the pre-preparation message can be stored in the local log and generated for In response to the preparation message Prepare of the pre-preparation message, the generated preparation message Prepare is broadcast to other nodes. The preparation message Prepare indicates that the backup node has received the pre-prepare message Pre-prepare from the master node, and is sending a response in response to the pre-prepare message Pre-prepare.
相应地,每个备份节点也会接收到其他备份节点发送的预准备消息。以备份节点R 1为例,备份节点R 1接收到主节点R 0发送的预准备消息之后,会将生成的准备消息广播至主节点R 0、备份节点R 2和R 3。相应地,备份节点R 1也会接收到主节点R 0、备份节点R 2和R 3发送的准备消息。 Correspondingly, each backup node will also receive pre-preparation messages sent by other backup nodes. In the backup nodes R 1 as an example, then the backup nodes R 1 R 0 master node receives the message transmitted from a prepared, ready to broadcast a message will be generated to the master node R 0, R 2 and backup node R 3. Correspondingly, the backup node R 1 will also receive the preparation messages sent by the master node R 0 and the backup nodes R 2 and R 3.
在确认阶段340,当区块链节点从其他区块链节点接收到足够数量的准备消息Prepare时,该区块链节点确定已经达成共识。例如,如果主节点R0或备份节点R1,R2或R3接收到法定数量(Quorum)的(例如,2f+1,其中f表示多个故障区块链节点)准备消息Prepare,则确定在区块链节点之间达成共识。然后,主节点R0或备份节点R1、R2或R3会向其他节点广播确认消息Commit。In the confirmation stage 340, when the blockchain node receives a sufficient number of prepare messages from other blockchain nodes, the blockchain node determines that a consensus has been reached. For example, if the master node R0 or the backup node R1, R2 or R3 receives a quorum (for example, 2f+1, where f represents multiple failed blockchain nodes) to prepare the message Prepare, it is determined to be in the blockchain A consensus is reached between nodes. Then, the master node R0 or the backup nodes R1, R2, or R3 will broadcast a confirmation message Commit to other nodes.
在应答阶段350,在针对发起的提议达成共识后,所有参与共识的节点中的每一个在本地状态机中顺序执行预准备消息pre-prepare的消息m中的一组有序requests,并返回应答消息reply给客户端C。In the response stage 350, after reaching a consensus on the initiated proposal, each of all nodes participating in the consensus sequentially executes a set of ordered requests in the message m of the pre-prepare message in the local state machine, and returns a response Message reply to client C.
图3中各个阶段所发送的消息数据格式可以参照本领域的公知常识。此外,图3仅仅是共识过程的一种示例,本说明书实施例中的区块链系统可以采用任意合适的共适过程来进行共识处理。The format of the message data sent at each stage in FIG. 3 can refer to common knowledge in the art. In addition, FIG. 3 is only an example of the consensus process, and the blockchain system in the embodiment of this specification can adopt any suitable common adaptation process to perform consensus processing.
图4示出了根据本说明书实施例的用于执行交易正确性验证的方法所适用的区块链系统的一个示例的示意图。FIG. 4 shows a schematic diagram of an example of a blockchain system to which the method for performing transaction correctness verification according to an embodiment of the present specification is applicable.
如图4所示,区块链系统400中包括轻量节点和全量节点,全量节点包括区块链节点401、402等,轻量节点连接至一个或多个全量节点。例如,作为轻量节点的区块链节点401a、401b、401c与全量节点401连接,区块链节点402a、402b、402c与全量节点402连接。区块链系统400中的各个全量节点互相连接,各个全量节点可以作为记账节点(即共识节点)来基于区块链技术共同维护区块链系统中的所有交易的账本。记账节点可以执行交易验证、交易共识、区块生成等记账操作。全量节点通常会在本地维护区块链的所有数据,包括区块链中各个区块的区块体和区块头。轻量节点可以仅在本地存储区块链中各个区块的块头,以用于简单的验证操作(例如SPV验证)。轻量节点可以始终连接至相同的全量节点,还可以基于连接规则更换其所连接的全量节点,以 降低信任风险。As shown in FIG. 4, the blockchain system 400 includes light nodes and full nodes. The full nodes include blockchain nodes 401, 402, etc., and the light nodes are connected to one or more full nodes. For example, the blockchain nodes 401a, 401b, and 401c, which are lightweight nodes, are connected to the full node 401, and the blockchain nodes 402a, 402b, and 402c are connected to the full node 402. Each full node in the blockchain system 400 is connected to each other, and each full node can be used as a bookkeeping node (that is, a consensus node) to jointly maintain a ledger of all transactions in the blockchain system based on the blockchain technology. The accounting node can perform accounting operations such as transaction verification, transaction consensus, and block generation. Full nodes usually maintain all the data of the blockchain locally, including the block body and block header of each block in the blockchain. Lightweight nodes can only store the block headers of each block in the blockchain locally for simple verification operations (for example, SPV verification). Lightweight nodes can always be connected to the same full number of nodes, and can also replace all connected nodes based on connection rules to reduce trust risks.
各个区块链节点所发起的交易可以广播至区块链网络中,以进行共识处理。全量节点所发起的交易可以广播给各个其它全量节点,各个全量节点在接收到交易后可以广播给其所连接的轻量节点。轻量节点所发起的交易可以发送给该轻量节点所连接的全量节点,以由该全量节点广播至其它全量节点或轻量节点。轻量节点可以从与其连接的全量节点处下载区块头,以维护本地的区块链(只包括区块头的区块链),还可以根据自身操作的需要从该全量节点处获取区块体中的各个信息。轻量节点可以连接一个或多个客户端(附图中未示出)。客户端发起的交易可以经由轻量节点和轻量节点所连接的全量节点发送到区块链系统中,以对该交易进行记账处理。Transactions initiated by each blockchain node can be broadcast to the blockchain network for consensus processing. The transaction initiated by the full node can be broadcast to each other full node, and after each full node receives the transaction, it can be broadcast to the lightweight node it is connected to. The transaction initiated by the light-weight node can be sent to all nodes connected to the light-weight node, so as to be broadcast by the all-weight node to other full-weight nodes or light-weight nodes. Lightweight nodes can download block headers from the full number of nodes connected to it to maintain the local blockchain (blockchain that only includes block headers), and can also obtain the block body from the full number of nodes according to the needs of their own operations Various information. Lightweight nodes can connect to one or more clients (not shown in the figure). The transaction initiated by the client can be sent to the blockchain system via the lightweight node and all nodes connected to the lightweight node to perform accounting processing on the transaction.
本说明书实施例中的用于执行交正确性验证的方法由轻量节点执行。The method for performing cross correctness verification in the embodiment of this specification is executed by a lightweight node.
图5是根据本说明书的一个实施例的用于执行交易正确性验证的方法的流程图。Fig. 5 is a flowchart of a method for performing transaction correctness verification according to an embodiment of the present specification.
如图5所示,在块520,从全量节点处获取待验证区块的共识证明信息。共识证明信息可以被包括在待验证区块的区块体中。轻量节点可以从与其连接的任意全量节点处获取待验证区块的共识证明信息。轻量节点可以向全量节点发送共识证明信息获取请求,以由全量节点将共识证明信息发送给轻量节点。在另一示例中,轻量节点可以在下载待验证区块的区块体之后,从区块体中获取共识证明信息。共识证明信息包括数字签名集合。数字签名集合是由对待验证区块达成共识的各个共识节点对待验证区块所对应的第一签名数据原文进行签名而得到的。共识节点可以是区块链系统中的任意全量节点。根据共识算法的不同,第一签名数据原文中的信息也可以不同。在一个示例中,第一签名数据原文可以包括证明摘要信息,证明摘要信息是在各个共识节点处基于第一证明依据信息生成的。As shown in FIG. 5, at block 520, the consensus proof information of the block to be verified is obtained from all nodes. Consensus proof information can be included in the block body of the block to be verified. Lightweight nodes can obtain the consensus proof information of the block to be verified from any full node connected to it. Lightweight nodes can send consensus proof information acquisition requests to all nodes, so that all nodes can send the consensus proof information to the light nodes. In another example, the lightweight node may obtain consensus proof information from the block body after downloading the block body of the block to be verified. The consensus proof information includes a collection of digital signatures. The digital signature set is obtained by signing the original text of the first signature data corresponding to the block to be verified by each consensus node that has reached a consensus on the block to be verified. The consensus node can be any full node in the blockchain system. According to different consensus algorithms, the information in the original text of the first signature data can also be different. In an example, the original text of the first signature data may include proof summary information, and the proof summary information is generated at each consensus node based on the first proof basis information.
共识证明信息用于证明相应区块已被正确的共识节点执行了正确的共识过程,例如在基于PBFT的共识算法中,可以证明相应区块得到了不低于法定数量的共识节点的确认。各个共识节点可以在对相应区块达成共识时生成数字签名,并在将区块加入区块链时将各个共识节点的数字签名组装成数字签名集合,以生成共识证明信息。Consensus proof information is used to prove that the corresponding block has been executed by the correct consensus node in the correct consensus process. For example, in the PBFT-based consensus algorithm, it can be proved that the corresponding block has been confirmed by no less than a quorum of consensus nodes. Each consensus node can generate a digital signature when reaching a consensus on the corresponding block, and when the block is added to the blockchain, the digital signature of each consensus node can be assembled into a digital signature set to generate consensus proof information.
以图3所示的共识过程为例,各个共识节点在确认阶段340收到不低于法定数量的准备消息时,可以基于在各自本地获取的第一证明依据信息生成证明摘要信息,然后利用各自的私钥对证明摘要信息进行签名以生成各自的数字签名。在生成数字签名之后,各个共识节点可以将数字签名包括在确认消息中广播给其他共识节点。各个共识节点在接收到足够数量(不低于f+1个)的确认消息之后,可以基于对该区块进行确认的各个共识节点的数字签名来组装生成共识证明信息,并将共识证明信息包括在相应区块的区块体中。Taking the consensus process shown in Figure 3 as an example, when each consensus node receives a preparation message of no less than a statutory number in the confirmation phase 340, it can generate proof summary information based on the first proof basis information obtained locally, and then use each The private key to sign the certificate summary information to generate their respective digital signatures. After the digital signature is generated, each consensus node can include the digital signature in the confirmation message and broadcast it to other consensus nodes. After each consensus node receives a sufficient number (not less than f+1) of confirmation messages, it can assemble and generate consensus proof information based on the digital signatures of each consensus node confirming the block, and include the consensus proof information In the block body of the corresponding block.
作为示例,用于生成证明摘要信息的证明依据信息可以包括基于相应区块的公钥集合生成的公钥集合标识信息、公钥集合中的公钥数量、待验证区块的父哈希、待验证区块的交易树根哈希、以及待验证区块的时间戳。公钥集合包括参与相应区块的共识过程的所有共识节点的公钥。当相应区块达成共识时,可以获取到对该区块进行共识的各个共识节点的公钥,以生成对应于该区块的公钥集合,然后可以基于该公钥集合中的各个公钥生成公钥集合标识信息和公钥数量。在一个示例中,可以基于各个公钥来生成默克尔树,该默克尔树的根哈希可以作为公钥集合标识信息。在另一示例中,可以对公钥集合进行哈希运算,并将所得的哈希值作为公钥集合标识。各个区块的父哈希(父区块的哈希值)、交易树根哈希以及时间戳可以从本地所维护的区块链的区块头信息中获取。为了进行区分,本说明书中将各个共识节点在生成签名数据时本地获取的证明依据信息描述为第一证明依据信息,并将轻量节点在进行交易正确性验证时本地获取的证明依据信息描述为第二证明依据信息,但第一和第二证明依据信息所包括的信息的类别是相同的。As an example, the proof basis information used to generate the proof summary information may include the public key set identification information generated based on the public key set of the corresponding block, the number of public keys in the public key set, the parent hash of the block to be verified, and the The root hash of the transaction tree of the verification block and the timestamp of the block to be verified. The public key set includes the public keys of all consensus nodes participating in the consensus process of the corresponding block. When the corresponding block reaches a consensus, the public key of each consensus node that agrees on the block can be obtained to generate a public key set corresponding to the block, and then it can be generated based on each public key in the public key set Public key collection identification information and the number of public keys. In an example, the Merkel tree can be generated based on each public key, and the root hash of the Merkel tree can be used as the public key set identification information. In another example, a hash operation may be performed on the public key set, and the obtained hash value may be used as the public key set identifier. The parent hash of each block (the hash value of the parent block), the root hash of the transaction tree, and the timestamp can be obtained from the block header information of the locally maintained blockchain. In order to distinguish, in this specification, the proof basis information obtained locally by each consensus node when generating the signature data is described as the first proof basis information, and the proof basis information acquired locally by the lightweight node when verifying the correctness of the transaction is described as The second proof is based on information, but the categories of information included in the first and second proof based information are the same.
在一个示例中,共识节点可以利用摘要算法对用于生成证明摘要信息的第一证明依据信息进行摘要运算以得到证明摘要信息。证明摘要算法可以是哈希运算或其它任意摘要算法,本说明书对此没有限制。在得到证明摘要信息之后,共识节点可以基于证明摘要信息生成第一签名原文信息。例如,可以将证明摘要信息作为第一签名原文信息,还可以进一步地对证明摘要信息进行规定的运算处理(例如哈希运算)之后生成第一签名原文信息。然后可以利用各自的私钥对第一签名原文信息进行签名以得到数字签名。In an example, the consensus node may use a digest algorithm to perform a digest operation on the first proof basis information used to generate the proof summary information to obtain the proof summary information. The proof digest algorithm can be a hash operation or any other digest algorithm, which is not limited in this specification. After obtaining the proof summary information, the consensus node can generate the first original signature text information based on the proof summary information. For example, the proof summary information can be used as the first original signature text information, and the proof summary information can be further subjected to a predetermined calculation process (for example, a hash operation) to generate the first original signature text information. Then, the respective private keys can be used to sign the first signed original text information to obtain a digital signature.
证明依据信息还可以包括待验证区块在区块链中的序号。根据区块链系统中所使用的共识算法的不同,证明依据信息还可以包括其它信息。例如,在联盟链中,对于诸如PBFT之类的存在主节点和节点更换的共识算法,证明依据信息还可以包括待验证区块所处的共识时代(View)标识。共识时代是指在区块链系统中,某一共识节点作为主节点的对应时间段。每当主节点不能正常执行主节点应执行的操作时,区块链系统可以触发主节点更换过程,在更换主节点之后,区块链系统进入另一个共识时代。共识节点可以对证明依据信息进行哈希运算后,将所得到的哈希值作为第一签名数据原文,然后利用各自的私钥对第一签名数据原文进行加密后生成对应的数字签名。The proof basis information may also include the serial number of the block to be verified in the blockchain. Depending on the consensus algorithm used in the blockchain system, the proof basis information can also include other information. For example, in a consortium chain, for a consensus algorithm such as PBFT that has a master node and node replacement, the proof basis information may also include the consensus era (View) identification of the block to be verified. The consensus era refers to the corresponding time period in which a certain consensus node acts as the master node in the blockchain system. Whenever the master node cannot normally perform the operations that the master node should perform, the blockchain system can trigger the master node replacement process. After the master node is replaced, the blockchain system enters another consensus era. The consensus node can hash the proof basis information, use the obtained hash value as the original text of the first signature data, and then use the respective private keys to encrypt the original text of the first signature data to generate the corresponding digital signature.
轻量节点在获取到待验证区块的共识证明信息之后,在块540,基于数字签名集合和轻量节点处的公钥集合验证共识证明信息的正确性。轻量节点本地可以存储有公钥集合。轻量节点处的公钥集合可以包括区块链系统中的所有参与共识的节点的公钥,还可以包括对信任锚点进行共识的各个共识节点的公钥。信任锚点可以指示已被验证为正确的信任区块。信任锚点可以是创世区块,创世区块所对应的公钥集合可以是在生成创世 区块时区块链系统中所有共识节点的公钥。当信任区块不是创世区块时,信任区块可以是利用本说明书实施例中的交易正确性验证方法来进行验证的。在待验证区块中的交易集合被验证为正确时,可以将该待验证区块更新为新的信任锚点,并将对该待验证区块进行共识的各个共识节点的公钥更新为信任锚点的公钥集合。After the lightweight node obtains the consensus certification information of the block to be verified, in block 540, the correctness of the consensus certification information is verified based on the digital signature set and the public key set at the lightweight node. The lightweight node can store a set of public keys locally. The public key set at the lightweight node may include the public keys of all nodes participating in the consensus in the blockchain system, and may also include the public keys of each consensus node that agrees on the trust anchor. The trust anchor can indicate a trust block that has been verified as correct. The trust anchor can be the genesis block, and the set of public keys corresponding to the genesis block can be the public keys of all consensus nodes in the blockchain system when the genesis block is generated. When the trust block is not the genesis block, the trust block can be verified using the transaction correctness verification method in the embodiment of this specification. When the transaction set in the block to be verified is verified as correct, the block to be verified can be updated as a new trust anchor point, and the public key of each consensus node that agrees on the block to be verified can be updated to trust The anchor's public key collection.
图6是根据本说明书的一个实施例的用于执行交易正确性验证的方法中的共识证明信息验证过程的一个示例的流程图。Fig. 6 is a flowchart of an example of a consensus proof information verification process in a method for performing transaction correctness verification according to an embodiment of the present specification.
如图6所示,在块602,基于数字签名集合,利用各个共识节点对第一签名数据原文进行签名所使用的加密算法,从数字签名集合中还原出各个共识节点的公钥。在利用诸如椭圆曲线算法生成公私钥对的情形中,公钥是基于私钥生成的。因而,可以基于数字签名来还原出对应的公钥。数字签名中可以包括用于还原出公钥的信息。以SM2椭圆曲线算法为例,可以在数字签名中包括椭圆曲线点的坐标(x,y)和判断标识,判断标识用于判断椭圆曲线点的坐标y的奇偶性。轻量节点可以基于椭圆曲线点坐标和判断标识来恢复出相应共识节点的公钥。共识证明信息还可以包括第一签名数据原文,椭圆曲线点的坐标和判断标识可以被包括在第一签名数据原文中。还可以进一步基于第一签名数据原文来恢复出公钥。As shown in FIG. 6, in block 602, based on the digital signature set, the encryption algorithm used by each consensus node to sign the original text of the first signature data is used to restore the public key of each consensus node from the digital signature set. In the case of generating a public-private key pair using, for example, an elliptic curve algorithm, the public key is generated based on the private key. Therefore, the corresponding public key can be restored based on the digital signature. The digital signature can include information used to restore the public key. Taking the SM2 elliptic curve algorithm as an example, the digital signature can include the coordinates (x, y) of the elliptic curve point and the judgment identifier, which is used to judge the parity of the coordinate y of the elliptic curve point. Lightweight nodes can recover the public key of the corresponding consensus node based on the coordinates of the elliptic curve point and the judgment identifier. The consensus proof information may also include the original text of the first signature data, and the coordinates of the elliptic curve point and the judgment identifier may be included in the original text of the first signature data. The public key can be further recovered based on the original text of the first signature data.
在还原出各个公钥之后,在块604,基于所还原出的各个共识节点的公钥和轻量节点处的公钥集合,验证共识证明信息的正确性。轻量节点可以基于对应于待验证区块的共识规则来验证共识证明信息的正确性。例如,对于某些共识算法,可以在所还原出的各个公钥被包括在公钥集合中时,确定共识证明信息是正确的。如果所还原出的公钥被包括在公钥集合中,表明待验证区块已经过了正确的共识节点的共识。如果的还原出的公钥没有被包括在公钥集合中,或者部分未被包括在公钥集合中,表明待验证区块未被正确的共识节点共识。在诸如基于PDFT的共识算法中,可以在确定共识证明信息中的数字签名数量不低于法定数量时,从数字签名中还原出公钥。还可以进一步确定所还出原的公钥数量是否达到了法定数量。然后可以在所还原出的各个公钥均被包括在公钥集合中并且公钥数量达到法定数量时确定共识证明信息是正确的。After each public key is restored, in block 604, based on the restored public key of each consensus node and the public key set at the lightweight node, the correctness of the consensus certification information is verified. Lightweight nodes can verify the correctness of the consensus proof information based on the consensus rules corresponding to the block to be verified. For example, for certain consensus algorithms, it can be determined that the consensus certification information is correct when each restored public key is included in the public key set. If the restored public key is included in the public key set, it indicates that the block to be verified has passed the consensus of the correct consensus node. If the restored public key is not included in the public key set, or part of it is not included in the public key set, it indicates that the block to be verified is not in the correct consensus node consensus. In a consensus algorithm such as PDFT, it is possible to restore the public key from the digital signature when it is determined that the number of digital signatures in the consensus certification information is not less than the legal number. It can also be further determined whether the number of original public keys returned has reached a quorum. Then, it can be determined that the consensus certification information is correct when each of the restored public keys is included in the public key set and the number of public keys reaches a quorum.
在一个示例中,即使被还原出的公钥不完全被包括在公钥集合中,如果所还原出的公钥中的至少部分被包括在公钥集合中,并且被包括在公钥集合中的公钥数量满足共识算法对于达成共识的共识规则,也可以确定待验证区块已被正确地共识。例如,对于基于PDFT的共识算法,如果包括在公钥集合中的公钥数量达到了法定数量,也能够证明待验证区块已被正确地共识。因而,可以在被包括在公钥集合中的被还原出的公钥数量达到法定数量时,确定共识证明信息是正确的。In one example, even if the restored public key is not completely included in the public key set, if at least part of the restored public key is included in the public key set, and is included in the public key set The number of public keys meets the consensus rules of the consensus algorithm for reaching a consensus, and it can also be determined that the block to be verified has been correctly agreed. For example, for a consensus algorithm based on PDFT, if the number of public keys included in the public key set reaches a quorum, it can also prove that the block to be verified has been correctly agreed. Therefore, it can be determined that the consensus certification information is correct when the number of restored public keys included in the public key set reaches a quorum.
轻量节点可以基于共识算法所对应的共识规则来确定共识证明信息的验证规则。 例如,如果共识算法是PBFT算法,则需要在所还原出的公钥被包括在公钥集合中并且所还原出的公钥数量达到法定数量时,确定共识证明信息是正确的。共识算法可以是轻量节点已知的。在另一示例中,可以将共识算法包括在共识证明信息中,从而轻量节点可以从共识证明信息中获知验证规则。Lightweight nodes can determine the verification rules of the consensus proof information based on the consensus rules corresponding to the consensus algorithm. For example, if the consensus algorithm is the PBFT algorithm, it is necessary to confirm that the consensus certification information is correct when the restored public key is included in the public key set and the number of restored public keys reaches a quorum. The consensus algorithm may be known to lightweight nodes. In another example, the consensus algorithm can be included in the consensus proof information, so that the lightweight node can learn the verification rules from the consensus proof information.
此外,在共识证明信息包括第一签名数据原文时,轻量节点还可以对共识证明信息中的第一签名数据原文进行验证。轻量节点可以在本地获取用于生成签名数据原文的第二证明依据信息,并基于第二证明依据信息以及第一签名数据原文的生成规则来生成第二签名数据原文。然可以基于第一签名数据原文和第二签名数据原文之间的一致性来确定第一签名数据原文是否正确。当二者一致时,可以确定第一签名数据原文是正确的。在一个示例中,可以在第一签名数据原文被验证为正确时,从数字签名中恢复出公钥。In addition, when the consensus proof information includes the original text of the first signature data, the lightweight node can also verify the original text of the first signature data in the consensus proof information. The light-weight node may locally obtain the second proof basis information used to generate the original text of the signature data, and generate the second original signature data text based on the second proof basis information and the generation rules of the first signature data original text. However, it can be determined whether the original text of the first signature data is correct based on the consistency between the original text of the first signature data and the original text of the second signature data. When the two are consistent, it can be determined that the original text of the first signature data is correct. In an example, when the original text of the first signature data is verified as correct, the public key can be recovered from the digital signature.
在对共识证明信息进行验证之后,在块560,基于共识证明信息的正确性验证结果,确定待验证区块中的交易集合的正确性。在共识证明信息被验证为正确时,表明待验证区块中的交易都经过了正确的共识过程,因而可以确定待验证区块的区块体是正确的,进而可以认为区块体中的各个交易都是正确的。After verifying the consensus proof information, in block 560, based on the correctness verification result of the consensus proof information, the correctness of the transaction set in the block to be verified is determined. When the consensus proof information is verified as correct, it indicates that the transactions in the block to be verified have gone through the correct consensus process. Therefore, it can be determined that the block body of the block to be verified is correct, and then each of the block bodies can be considered The transactions are all correct.
通过上述实施例,轻量节点不需要访问多个全量节点即可对待验证区块上的交易集合进行正确性验证。例如,在采用诸如基于PBFT的共识算法的区块链系统中,如果不采用本说明书中的正确性验证方法,轻量节点需要访问多个全量节点才能确定待验证区块是否被法定数量的正确节点正确地共识。然而在实践中,轻量节点难以连接到多个全量节点,因而难以顺利完成正确性验证。Through the above embodiments, the lightweight node does not need to visit multiple full nodes to verify the correctness of the transaction set on the block to be verified. For example, in a blockchain system that uses a consensus algorithm such as PBFT, if the correctness verification method in this manual is not used, the lightweight node needs to visit multiple full nodes to determine whether the block to be verified is quorum correct The nodes agree correctly. However, in practice, it is difficult for a lightweight node to connect to multiple full nodes, so it is difficult to successfully complete the correctness verification.
在另一示例中,还可以对待验证区块的区块头进行验证,并在区块头和区块体中的交易集合都被验证为正确时确定待验证区块中的各个交易是正确的。以下将参照图7来说明该示例。图7是根据本说明书的另一实施例的用于执行交易正确性验证的方法的流程图。In another example, the block header of the block to be verified can also be verified, and it is determined that each transaction in the block to be verified is correct when both the block header and the transaction set in the block body are verified as correct. This example will be explained below with reference to FIG. 7. Fig. 7 is a flowchart of a method for performing transaction correctness verification according to another embodiment of the present specification.
如图7所示,在块702和704,验证共识证明信息的正确性。可以利用本说明书中描述的共识证明信息验证过程来验证共识证明信息的正确性。共识证明信息为正确时,可以确定区块体是正确的。As shown in FIG. 7, in blocks 702 and 704, the correctness of the consensus certification information is verified. The verification process of the consensus certification information described in this manual can be used to verify the correctness of the consensus certification information. When the consensus proves that the information is correct, it can be determined that the block body is correct.
如果共识证明信息的验证结果是正确的,则在块706,从全量节点处获取待验证区块的区块体信息。然后,在块708,基于区块体信息,验证轻量节点处的待验证区块的区块头的正确性。并在块710,确定区块头是否正确。If the verification result of the consensus proof information is correct, then in block 706, the block body information of the block to be verified is obtained from all nodes. Then, in block 708, based on the block body information, the correctness of the block header of the block to be verified at the lightweight node is verified. And in block 710, it is determined whether the block header is correct.
可以从全量节点处下载全部区块体信息,然后可以从区块体信息中提取出交易树信息。还可以仅从全量节点处获取交易树信息。在获取到交易树信息之后,可以基于交易树信息来验证区块头中的交易根是否正确。交易树例如可以是基于默克尔(Merkle) 树生成的。在Merkle树中,叶子节点中存储有待验证区块中的各个交易的交易数据。可以基于各个叶子节点逐层向上计算二叉的上层节点,只到计算出Merkle根为止。然后可以比较计算所得的merkle根是否与区块头中的交易根一致。当二者一致时,可以确定区块头是正确的。此外,对于区块体还包括收据树和状态树的情形,区块头中还包括收据根和状态根。在该示例中,还可以在获取收据树信息、状态树信息之后,对区块头中的收据根和状态根进行验证,并在交易根、收据根和状态根均被验证为正确时,确定区块头是正确的。收据树和状态树也可以是基于Merkle树生成的,可以基于所获得的收据树信息和状态树信息计算出收据树和状态树的Merkle根,并分别比较二者所得到的Merkle根是否与区块头中的收据根和状态根一致。当计算得到的Merkle根与收据根和状态根一致时,可以确定收据根和状态根是正确的。在区块体还包括收据树和状态树的情形中,也可以不对收据根和状态根进行验证。All block body information can be downloaded from all nodes, and then the transaction tree information can be extracted from the block body information. It is also possible to obtain transaction tree information only from all nodes. After obtaining the transaction tree information, the transaction root in the block header can be verified based on the transaction tree information. The transaction tree may be generated based on a Merkle tree, for example. In the Merkle tree, the leaf nodes store transaction data of each transaction in the block to be verified. The upper node of the binary fork can be calculated layer by layer based on each leaf node, until the Merkle root is calculated. Then you can compare whether the calculated merkle root is consistent with the transaction root in the block header. When the two are consistent, it can be determined that the block header is correct. In addition, for the case where the block body also includes the receipt tree and the state tree, the block header also includes the receipt root and the state root. In this example, you can also verify the receipt root and state root in the block header after obtaining the receipt tree information and state tree information, and when the transaction root, receipt root, and state root are all verified as correct, determine the area The bulk is correct. The receipt tree and the state tree can also be generated based on the Merkle tree. The Merkle roots of the receipt tree and the state tree can be calculated based on the obtained receipt tree information and state tree information, and the Merkle roots obtained by the two can be compared with the zone respectively. The receipt root in the block header is consistent with the state root. When the calculated Merkle root is consistent with the receipt root and state root, it can be determined that the receipt root and state root are correct. In the case where the block body also includes the receipt tree and the state tree, the receipt root and the state root may not be verified.
在待验证区块的区块头和区块体被验证为正确时,可以确定待验证区块是正确的,进而可以认为区块体中的所有交易都是正确的。因此,在块712,确定待验证区块上的交易集合是正确的。如果区块头或共识证明信息的验证结果是不正确的,则在块714,确定待验证区块上的交易集合是不正确的。为了节省轻量节点处的存储空间,在对待验证区块上的交易集合进行验证之后,可以删除所获得的区块体信息。在待验证区块上的交易集合被验证为正确时,可以将该待验证区块更新为信任锚点。When the block header and block body of the block to be verified are verified as correct, it can be determined that the block to be verified is correct, and then all transactions in the block body can be considered correct. Therefore, at block 712, it is determined that the set of transactions on the block to be verified is correct. If the verification result of the block header or the consensus proof information is incorrect, then in block 714, it is determined that the transaction set on the block to be verified is incorrect. In order to save storage space at the lightweight node, after verifying the transaction set on the block to be verified, the obtained block body information can be deleted. When the transaction set on the block to be verified is verified as correct, the block to be verified can be updated as a trust anchor.
虽然图7示出的是在共识证明信息被验证为正确之后执行区块头验证过程,但是共识证明信息验证过程和区块头验证过程的执行顺序并没有限制。在另一示例中,二者可以并行执行,还可以在区块头信息验证为正确之后执行共识证明信息验证过程。Although FIG. 7 shows that the block header verification process is performed after the consensus certification information is verified as correct, there is no restriction on the execution sequence of the consensus certification information verification process and the block header verification process. In another example, the two can be executed in parallel, and the consensus proof information verification process can also be executed after the block header information is verified as correct.
当待验证区块中的交易集合被验证为正确时,如果想要验证该待验证区块中的指定交易的正确性,可以验证该指定交易是否存在于待验证区块中。如果指定交易存在于待验证区块中(即对指定交易进行存在性验证),由于待验证区块中的所有交易都已被确定为正确的,则可以确定该指定交易也是正确的。以下,参照图8至图10来描述对指定交易的正确性验证过程。When the set of transactions in the block to be verified is verified as correct, if you want to verify the correctness of the specified transaction in the block to be verified, you can verify whether the specified transaction exists in the block to be verified. If the designated transaction exists in the block to be verified (that is, the existence of the designated transaction is verified), since all transactions in the block to be verified have been determined to be correct, it can be determined that the designated transaction is also correct. Hereinafter, the process of verifying the correctness of the specified transaction will be described with reference to FIGS. 8 to 10.
图8是根据本说明书的另一实施例的用于执行交易正确性验证的方法的流程图。Fig. 8 is a flowchart of a method for performing transaction correctness verification according to another embodiment of the present specification.
如图8所示,在块802,接收针对交易集合中的指定交易的交易正确性验证请求。交易正确性验证请求可以是与轻量节点连接的客户端所发出的。客户端可以针对其所发起的交易向轻量节点发送交易正确性验证请求。交易正确性验证请求中可以包括指定交易的交易哈希,和该指定交易所在区块的区块号。交易哈希和区块号可以是全量节点在将指定交易打包上链之后通过轻量节点通知给客户端的。区块号用于确定指定交易所在的区块,交易哈希可以用于对指定交易进行存在性验证。在另一示例中,交易正确性验 证请求可以不包括区块号,轻量节点可以基于交易哈希向全量节点查询该指定交易所在的区块,全量节点可以将区块号发送给轻量节点。在确定指定交易所在的区块之后,轻量节点将该区块确定为待验证区块。As shown in FIG. 8, at block 802, a transaction correctness verification request for a specified transaction in the transaction set is received. The transaction correctness verification request may be issued by a client connected to a lightweight node. The client can send a transaction correctness verification request to the lightweight node for the transaction initiated by it. The transaction correctness verification request may include the transaction hash of the designated transaction and the block number of the designated transaction in the block. The transaction hash and block number can be notified to the client through the lightweight node after the full node has packaged the specified transaction on the chain. The block number is used to determine the block in which the specified exchange is located, and the transaction hash can be used to verify the existence of the specified transaction. In another example, the transaction correctness verification request may not include the block number. The lightweight node can query the full node based on the transaction hash for the block in which the specified transaction is located, and the full node can send the block number to the lightweight node. node. After determining the block in which the designated exchange is located, the lightweight node determines the block as a block to be verified.
在接收到交易正确性验证请求之后,在块804,从全量节点处获取待验证区块的共识证明信息。然后,在块806,基于共识证明信息确定待验证区块的区块体中的交易集合的正确性。After receiving the transaction correctness verification request, in block 804, the consensus proof information of the block to be verified is obtained from all nodes. Then, in block 806, the correctness of the transaction set in the block body of the block to be verified is determined based on the consensus proof information.
接下来,在块808,对指定交易在待验证区块中的存在性进行验证。在得到交易集合验证结果和存在性验证结果之后,在块810,基于交易集合的正确性验证结果和指定交易的存在性验证结果,确定指定交易的正确性。可以在交易集合和存在性验证结果均为正确时,确定指定交易是正确的,即指定交易已被正确执行。待验证区块上的交易集合的正确性验证过程和存在性验证过程的执行顺序没有特别限制,二者也可以是并行的。Next, at block 808, the existence of the specified transaction in the block to be verified is verified. After the transaction set verification result and the existence verification result are obtained, in block 810, the correctness of the designated transaction is determined based on the correctness verification result of the transaction set and the existence verification result of the designated transaction. It can be determined that the specified transaction is correct when the transaction set and the existence verification result are correct, that is, the specified transaction has been executed correctly. The execution sequence of the correctness verification process and the existence verification process of the transaction set on the block to be verified is not particularly limited, and the two may also be parallel.
存在性验证(也可称为存在性证明)可以采取现有技术中的任意存在性验证方法来执行。以下参照图9对存在性验证的一个示例进行说明。Existence verification (also referred to as existence proof) can be performed by adopting any existence verification methods in the prior art. An example of existence verification will be described below with reference to FIG. 9.
图9是用于说明本说明书实施例的用于执行交易正确性验证的方法中的交易存在性验证过程的示意图。FIG. 9 is a schematic diagram for explaining the transaction existence verification process in the method for performing transaction correctness verification according to the embodiment of the present specification.
图9示出了基于Merkle树生成的交易树的一个示例。包括该交易树的区块中包括交易A至P。叶子节点中存储有各个交易的交易哈希H A至H P。轻量节点可以从所下载的区块体信息中获取交易树信息,然后从交易树中获取指定交易的查询路径中的各个叶子节点数据。在没有下载区块体信息的情况下,轻量节点可以向全量节点发送针对指定交易的交易树路径查询请求。全量节点可以将指定交易在交易树中的交易查询路径包括的叶子节点数据发送给轻量节点。 Fig. 9 shows an example of a transaction tree generated based on a Merkle tree. The block including the transaction tree includes transactions A to P. Leaf node is stored in each transaction to transaction hash H A H P. Lightweight nodes can obtain transaction tree information from the downloaded block body information, and then obtain each leaf node data in the query path of the specified transaction from the transaction tree. Without downloading block body information, lightweight nodes can send transaction tree path query requests for specified transactions to all nodes. The full node can send the leaf node data included in the transaction query path of the specified transaction in the transaction tree to the light node.
以图9中的交易K为例,从交易K的交易哈希H K所在的叶子节点至交易根H ABCDEFGHIJKLMNOP的交易查询路径中的叶子节点数据包括H L、H IJ、H MNOP、H ABCDEFGH。在获取这些叶子节点数据之后可以逐层进行二叉计算,以确定所得到的交易根是否与待验证区块的区块头中的交易根一致。具体地,指定交易K的交易哈希H K是已知的。因而,可以基于H K和H L计算得到H KL,然后可以基于H KL和所获取的H IJ计算得到H IJKL,然后可以基于H IJKL和所获取的H MNOP计算得到H IJKLMNOP,然后基于H IJKLMNOP和所获取的H ABCDEFGH计算得到H ABCDEFGHIJKLMNOP。然后可以比较H ABCDEFGHIJKLMNOP与区块头中的交易根是否一致。当二者一致时,可以确定指定交易K的交易合希H K存在于交易树中,这表明交易K存在于待验证区块的交易集合中。当二者不一致时,表明交易K不在待验证区块的交易集合中。 Taking transaction K in Figure 9 as an example, the leaf node data in the transaction query path from the leaf node where the transaction hash H K of transaction K is located to the transaction root H ABCDEFGHIJKLMNOP includes H L , H IJ , H MNOP , and H ABCDEFGH. After obtaining the leaf node data, binary calculations can be performed layer by layer to determine whether the obtained transaction root is consistent with the transaction root in the block header of the block to be verified. Specifically, the transaction hash H K of the designated transaction K is known. Accordingly, it is possible to obtain H KL H K H L is calculated based on, then can be H IJKL H KL and H IJ calculated based on the acquired and can be H IJKLMNOP H IJKL and H MNOP calculated based on the acquired and then, based H IJKLMNOP H ABCDEFGH calculated and acquired obtained H aBCDEFGHIJKLMNOP. Then you can compare whether H ABCDEFGHIJKLMNOP is consistent with the transaction root in the block header. When the two are consistent, it can be determined that the transaction H K of the specified transaction K exists in the transaction tree, which indicates that the transaction K exists in the transaction set of the block to be verified. When the two are inconsistent, it indicates that transaction K is not in the transaction set of the block to be verified.
交易集合的验证可以是在接收到针对指定交易的交易正确性验证请求之前执行的。 随着区块链系统所处理的交易的增加,区块链上会不断生成新的区块,轻量节点可以根据自身情况来从全量节点处下载区块头,以更新本地的区块链数据。例如,轻量节点可以定期定量地从全量节点处下载区块头。轻量节点可以在更新本地区块链的过程中对区块进行交易集合的正确性验证。例如可以对加入到本地区块链中的区块逐一地进行交易集合的正确性验证。为了减轻轻量节点的负担,轻量节点可以仅对关联区块进行验证。关联区块是与该轻量节点有关的区块,例如可以是包括与该轻量节点连接的客户端所发起的交易的区块,还可以包括与其连接的客户端所关注的交易。在对交易集合进行验证之后,如果接收到了针对指定交易的交易正确性验证请求,可以进一步对指定交易进行存在性验证,以验证指定交易的正确性。以下参考图10对该示例进行说明。The verification of the transaction set may be performed before receiving the transaction correctness verification request for the specified transaction. As the transactions processed by the blockchain system increase, new blocks will be continuously generated on the blockchain. Lightweight nodes can download block headers from all nodes according to their own conditions to update local blockchain data. For example, lightweight nodes can download block headers from full nodes periodically and quantitatively. Lightweight nodes can verify the correctness of the transaction set of the block in the process of updating the local blockchain. For example, the correctness of the transaction set can be verified one by one for the blocks added to the local blockchain. In order to reduce the burden of lightweight nodes, lightweight nodes can only verify the associated blocks. The associated block is a block related to the lightweight node. For example, it may include a transaction initiated by a client connected to the lightweight node, and may also include a transaction concerned by the client connected to the lightweight node. After verifying the transaction set, if a transaction correctness verification request for a specified transaction is received, the existence of the specified transaction can be further verified to verify the correctness of the specified transaction. This example will be described below with reference to FIG. 10.
图10是根据本说明书的另一实施例的用于执行交易正确性验证的方法的流程图。Fig. 10 is a flowchart of a method for performing transaction correctness verification according to another embodiment of the present specification.
如图10所示,在块1002,监听是否存在包括指定交易的待验证区块。并在块1004,确定是否监听到了包括指定交易的待验证区块。区块头可以包括交易收据标识信息,交易收据标识信息例如可以基于交易收据中的交易地址信息生成。交易收据标识信息例如可以是基于布隆过滤器生成的。交易在被执行之后,共识节点会将交易记录写入交易收据中。交易收据中包括与交易相关的信息。轻量节点可以基于布隆过滤器来监听与是否存在包括指定交易的区块。监听规则可以由客户端来设置。客户端可以在轻量节点处设置监听与其所发起的交易有关的信息。例如,可以监听交易发起方地址对应于客户端的账户地址的交易。还可以监听具体的某笔交易,例如,如果客户发起了一起交易是由账户地址A转账至账户地址B,则可以设置为监听交易发起方地址为A且交易对象地址为B的交易。轻量节点还可以监听与其连接的所有客户端有关的交易,例如可以监听交易发起方地址对应于其所连接的客户端的账户地址的交易。当监听规则是基于交易信息中的其它信息生成的时,可以基于交易收据信息中的对应信息来生成交易收据标识。As shown in FIG. 10, at block 1002, it is monitored whether there is a block to be verified that includes a specified transaction. And at block 1004, it is determined whether a block to be verified including the specified transaction is monitored. The block header may include transaction receipt identification information, and the transaction receipt identification information may be generated based on the transaction address information in the transaction receipt, for example. The transaction receipt identification information may be generated based on a Bloom filter, for example. After the transaction is executed, the consensus node will write the transaction record into the transaction receipt. The transaction receipt includes information related to the transaction. Lightweight nodes can monitor whether there are blocks that include specified transactions based on Bloom filters. The listening rules can be set by the client. The client can set up and monitor information related to the transaction initiated by the lightweight node. For example, you can monitor transactions where the address of the transaction initiator corresponds to the account address of the client. It is also possible to monitor a specific transaction. For example, if a customer initiates a transaction that transfers money from account address A to account address B, it can be set to monitor the transaction where the transaction initiator address is A and the transaction object address is B. Lightweight nodes can also monitor transactions related to all clients connected to it, for example, can monitor transactions where the address of the transaction initiator corresponds to the account address of the client connected to it. When the monitoring rule is generated based on other information in the transaction information, the transaction receipt identifier can be generated based on the corresponding information in the transaction receipt information.
在监听到包括指定交易的待验证区块时,在块1006,从全量节点处获取待验证区块的共识证明信息。然后,在块1008,基于共识证明信息确定待验证区块的区块体中的交易集合的正确性。在对待验证区块上的交易集合的正确性进行验证之后,如果客户端请求对待验证区块上的特定交易进行验证,则不必再次执行交易集合的正确性验证过程,而可以只对指定交易是否存在于待验证区块进行验证。When the block to be verified including the specified transaction is monitored, at block 1006, the consensus proof information of the block to be verified is obtained from all nodes. Then, in block 1008, the correctness of the transaction set in the block body of the block to be verified is determined based on the consensus proof information. After verifying the correctness of the transaction set on the block to be verified, if the client requests verification of a specific transaction on the block to be verified, it does not need to perform the correctness verification process of the transaction set again, but can only verify whether the specified transaction Exist in the block to be verified for verification.
轻量节点可以对监听客户端发送的交易正确性验证请求,并在块1010,判断是否接收到了针对指定交易的交易正确性验证请求。如果接收到交易正确性验证请求,在块1012,对指定交易进行存在性验证。存在性验证过程可以采用如上示例中描述的方法来执行。The lightweight node can verify the transaction correctness request sent by the monitoring client, and in block 1010, determine whether the transaction correctness verification request for the specified transaction has been received. If a transaction correctness verification request is received, in block 1012, the existence of the specified transaction is verified. The existence verification process can be performed using the method described in the above example.
在获得存在性验证结果和交易集合的正确性验证结果之后,在块1014,基于交易 集合的正确性验证结果和指定交易的存在性验证结果,确定指定交易的正确性。当待验证区块上的交易集合被验证为正确,并且指定交易存在于待验征区块上时,可以确定指定交易是正确的。After obtaining the existence verification result and the correctness verification result of the transaction set, in block 1014, the correctness of the designated transaction is determined based on the correctness verification result of the transaction set and the existence verification result of the designated transaction. When the set of transactions on the block to be verified is verified as correct, and the specified transaction exists on the block to be verified, it can be determined that the specified transaction is correct.
轻量节点在接收到交易正确性请求之后,可首先确定该指定交易所在的区块是否已被执行过交易集合正确性验证过程。如果指定交易所在的区块没有执行过交易集合正确性验证过程,则可以采用图8所示的示例来进行交易正确性验证。After receiving the transaction correctness request, the lightweight node can first determine whether the block in which the designated exchange is located has been subjected to the transaction set correctness verification process. If the block where the designated exchange is located has not performed the transaction set correctness verification process, the example shown in Figure 8 can be used to verify the transaction correctness.
图11是根据本说明书的一个实施例的用于执行交易正确性验证的装置的结构框图。如图11所示,交易正确性验证执行装置1100包括共识证明信息获取单元1110、共识证明信息验证单元1120、交易集合验证单元1130、区块体信息获取单元1140、区块头验证单元1150、待验证区块监听单元1160、验证请求接收单元1170、存在性验证单元1180和指定交易正确性确定单元1190。Fig. 11 is a structural block diagram of an apparatus for performing transaction correctness verification according to an embodiment of the present specification. As shown in FIG. 11, the transaction correctness verification execution device 1100 includes a consensus certification information acquisition unit 1110, a consensus certification information verification unit 1120, a transaction set verification unit 1130, a block body information acquisition unit 1140, a block header verification unit 1150, and a verification unit to be verified. The block monitoring unit 1160, the verification request receiving unit 1170, the existence verification unit 1180, and the designated transaction correctness determining unit 1190.
共识证明信息获取单元1110从全量节点处获取待验证区块的共识证明信息。共识证明信息包括数字签名集合,数字签名集合是对待验证区块达成共识的各个共识节点对待验证区块所对应的第一签名数据原文进行签名而得到的。共识证明信息验证单元1120基于数字签名集合和轻量节点处的公钥集合验证共识证明信息的正确性,公钥集合包括区块系统中的至少部分区块链节点的公钥。在一个示例中,公钥集合可以包括区块链系统中的所有参与共识的区块链节点的公钥。在另一示例中,公钥集合可以包括对轻量节点处的信任锚点进行共识的所有共识节点的公钥,信任锚点指示被验证为正确的信任区块。交易集合验证单元1130基于共识证明信息的正确性验证结果,确定待验证区块中的交易集合的正确性。The consensus proof information obtaining unit 1110 obtains the consensus proof information of the block to be verified from all nodes. The consensus proof information includes a set of digital signatures, which are obtained by signing the original text of the first signature data corresponding to the block to be verified by each consensus node that has reached a consensus on the block to be verified. The consensus certification information verification unit 1120 verifies the correctness of the consensus certification information based on the digital signature set and the public key set at the lightweight node. The public key set includes the public keys of at least part of the blockchain nodes in the block system. In an example, the set of public keys may include the public keys of all blockchain nodes participating in the consensus in the blockchain system. In another example, the set of public keys may include the public keys of all consensus nodes that agree on the trust anchors at the lightweight nodes, and the trust anchors indicate the trust blocks that are verified as correct. The transaction set verification unit 1130 determines the correctness of the transaction set in the block to be verified based on the verification result of the correctness of the consensus certification information.
可区块体信息获取单元1140在基于共识证明信息的正确性验证结果,确定待验证区块中的交易集合的正确性之前,从全量节点处获取待验证区块的区块体信息。区块头验证单元1150基于区块体信息,验证轻量节点处的待验证区块的交易根的正确性。交易集合验证单元1130可以基于交易根的正确性验证结果和区块证明信息的正确性验证结果,确定待验证区块中的交易集合的正确性。The block body information obtaining unit 1140 obtains the block body information of the block to be verified from all nodes before determining the correctness of the transaction set in the block to be verified based on the correctness verification result of the consensus proof information. The block header verification unit 1150 verifies the correctness of the transaction root of the block to be verified at the lightweight node based on the block body information. The transaction set verification unit 1130 may determine the correctness of the transaction set in the block to be verified based on the correctness verification result of the transaction root and the correctness verification result of the block proof information.
待验证区块监听单元1160在从全量节点处获取待验证区块的共识证明信息之前,监听是否存在包括指定交易的待验证区块。共识证明信息获取单元1110可以在监听到存在包括指定交易的待验证区块时,从全量节点处获取所监听到的待验证区块的共识证明信息。The to-be-verified block monitoring unit 1160 monitors whether there is a to-be-verified block that includes the specified transaction before obtaining the consensus proof information of the to-be-verified block from all nodes. The consensus proof information obtaining unit 1110 can obtain the monitored consensus proof information of the block to be verified from all nodes when it monitors that there is a block to be verified that includes the specified transaction.
验证请求接收单元1170接收针对交易集合中的指定交易的交易正确性验证请求。存在性验证单元1180验证指定交易是否存在于交易集合中。指定交易正确性确定单元1190基于交易集合的正确性验证结果和指定交易在待验证区块中的存在性验证结果,确 定指定交易的正确性。The verification request receiving unit 1170 receives a transaction correctness verification request for a specified transaction in the transaction set. The existence verification unit 1180 verifies whether the specified transaction exists in the transaction set. The designated transaction correctness determination unit 1190 determines the correctness of the designated transaction based on the correctness verification result of the transaction set and the existence verification result of the designated transaction in the block to be verified.
验证请求接收单元1170还可以在从全量节点处获取待验证区块的共识证明信息之前,接收针对交易集合中的指定交易的交易正确性验证请求。在该示例中,共识证明信息获取单元1110可以在接收到所述交易正确性验证请求时,从全量节点处获取待验证区块的共识证明信息。The verification request receiving unit 1170 may also receive a transaction correctness verification request for a specified transaction in the transaction set before obtaining the consensus proof information of the block to be verified from the full number of nodes. In this example, the consensus proof information obtaining unit 1110 may obtain the consensus proof information of the block to be verified from all nodes when receiving the transaction correctness verification request.
图11中的各个单元并不都是必要的,交易正确性验证执行装置可以不包括其中的部分单元。例如,在一个示例中,可以不包括待验证区块监听单元,还可以不包括验证请求接收单元、存在性验证单元、指定交易正确性确定单元等,还可以不包括区块体信息获取单元和区块头验证单元。The units in FIG. 11 are not all necessary, and the transaction correctness verification execution device may not include some of the units. For example, in an example, the block monitoring unit to be verified may not be included, the verification request receiving unit, the existence verification unit, the specified transaction correctness determination unit, etc. may not be included, and the block body information acquisition unit and Block header verification unit.
图12是图11所示的用于执行交易正确性验证的装置中的共识证明验证过程的结构框图。如图12所示,共识证明信息验证单元1120包括公钥还原模块1121和共识证明信息验证模块1122。Fig. 12 is a structural block diagram of the consensus proof verification process in the device for performing transaction correctness verification shown in Fig. 11. As shown in FIG. 12, the consensus certification information verification unit 1120 includes a public key restoration module 1121 and a consensus certification information verification module 1122.
公钥还原模块1121利用各个共识节点对第一签名数据原文进行签名所使用的加密算法,从数字签名集合中还原出各个共识节点的公钥。共识证明信息验证模块1122基于所还原出的各个共识节点的公钥和轻量节点处的公钥集合,验证共识证明信息的正确性。在一个示例中,共识证明信息验证模块1122可以在所还原出的公钥中的至少部分被包括在所述公钥集合中并且被包括在所述公钥集合中的公钥数量满足共识规则时,确定所述共识证明信息是正确的。The public key restoration module 1121 uses the encryption algorithm used by each consensus node to sign the original text of the first signature data to restore the public key of each consensus node from the digital signature set. The consensus certification information verification module 1122 verifies the correctness of the consensus certification information based on the restored public key of each consensus node and the public key set at the lightweight node. In an example, the consensus proof information verification module 1122 may be included when at least part of the restored public keys are included in the public key set and the number of public keys included in the public key set meets the consensus rules , To confirm that the consensus proof information is correct.
以上参照图1到图12,对根据本说明书实施例的用于执行交易正确性验证的方法及装置的实施例进行了描述。在以上对方法实施例的描述中所提及的细节,同样适用于本说明书实施例的装置的实施例。The embodiments of the method and device for performing transaction correctness verification according to the embodiments of the present specification are described above with reference to FIGS. 1 to 12. The details mentioned in the above description of the method embodiment are also applicable to the embodiment of the device in the embodiment of this specification.
本说明书实施例的用于执行交易正确性验证的装置可以采用硬件实现,也可以采用软件或者硬件和软件的组合来实现。本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见。The device for performing transaction correctness verification in the embodiments of this specification can be implemented by hardware, or by software or a combination of hardware and software. The various embodiments in this specification are described in a progressive manner, and the same or similar parts among the various embodiments are referred to each other.
本说明书实施例的用于执行交易正确性验证的装置可以采用硬件实现,也可以采用软件或者硬件和软件的组合来实现。以软件实现为例,作为一个逻辑意义上的装置,是通过其所在设备的处理器将存储器中对应的计算机程序指令读取到内存中运行形成的。在本说明书实施例中,用于执行交易正确性验证的装置例如可以利用计算设备实现。The device for performing transaction correctness verification in the embodiments of this specification can be implemented by hardware, or by software or a combination of hardware and software. Taking software implementation as an example, as a logical device, it is formed by reading the corresponding computer program instructions in the memory into the memory through the processor of the device where it is located. In the embodiment of this specification, the means for performing transaction correctness verification can be implemented by using a computing device, for example.
图13是根据本说明书的一个实施例的用于实现用执行交易正确性验证的方法的计算设备的结构框图。如图13所示,计算设备1300包括处理器1313、存储器1320、内存1330、通信接口1340和内部总线1350,并且处理器1213、存储器(例如,非易失性存储器)1320、内存1330、通信接口1340经由总线1350连接在一起。根据一个实施例, 计算设备1300可以包括至少一个处理器1313,该至少一个处理器1313执行在计算机可读存储介质(即,存储器1320)中存储或编码的至少一个计算机可读指令(即,上述以软件形式实现的元素)。Fig. 13 is a structural block diagram of a computing device for implementing a method for verifying the correctness of a transaction according to an embodiment of the present specification. As shown in FIG. 13, the computing device 1300 includes a processor 1313, a memory 1320, a memory 1330, a communication interface 1340, and an internal bus 1350, and a processor 1213, a memory (for example, a non-volatile memory) 1320, a memory 1330, and a communication interface 1340 is connected together via a bus 1350. According to an embodiment, the computing device 1300 may include at least one processor 1313 that executes at least one computer readable instruction (ie, the aforementioned Elements implemented in software).
在一个实施例中,在存储器1320中存储计算机可执行指令,其当执行时使得至少一个处理器1313:从全量节点处获取待验证区块的共识证明信息,所述共识证明信息包括数字签名集合,所述数字签名集合是对所述待验证区块达成共识的各个共识节点对所述待验证区块所对应的第一签名数据原文进行签名而得到的;基于所述数字签名集合和所述轻量节点处的公钥集合验证所述共识证明信息的正确性,所述公钥集合包括所述区块系统中的至少部分区块链节点的公钥;以及基于所述共识证明信息的正确性验证结果,确定所述待验证区块中的交易集合的正确性。。In one embodiment, computer-executable instructions are stored in the memory 1320, which, when executed, cause at least one processor 1313 to: obtain consensus proof information of the block to be verified from all nodes, the consensus proof information including a set of digital signatures The digital signature set is obtained by signing the original text of the first signature data corresponding to the block to be verified by each consensus node that reached a consensus on the block to be verified; based on the digital signature set and the The public key set at the lightweight node verifies the correctness of the consensus proof information, the public key set includes the public keys of at least part of the blockchain nodes in the block system; and the correctness of the proof information based on the consensus The result of the sexual verification determines the correctness of the transaction set in the block to be verified. .
应该理解,在存储器1320中存储的计算机可执行指令当执行时使得至少一个处理器1313进行本说明书实施例的各个实施例中以上结合图1-12描述的各种操作和功能。It should be understood that the computer-executable instructions stored in the memory 1320, when executed, cause at least one processor 1313 to perform the various operations and functions described above in conjunction with FIGS. 1-12 in the various embodiments of the embodiments of this specification.
根据一个实施例,提供了一种例如非暂时性机器可读介质的程序产品。非暂时性机器可读介质可以具有指令(即,上述以软件形式实现的元素),该指令当被机器执行时,使得机器执行本说明书实施例的各个实施例中以上结合图1-12描述的各种操作和功能。According to one embodiment, a program product such as a non-transitory machine-readable medium is provided. The non-transitory machine-readable medium may have instructions (ie, the above-mentioned elements implemented in the form of software), which when executed by a machine, cause the machine to execute the above described in conjunction with FIGS. 1-12 in the various embodiments of the embodiments of this specification. Various operations and functions.
具体地,可以提供配有可读存储介质的系统或者装置,在该可读存储介质上存储着实现上述实施例中任一实施例的功能的软件程序代码,且使该系统或者装置的计算机或处理器读出并执行存储在该可读存储介质中的指令。Specifically, a system or device equipped with a readable storage medium may be provided, and the software program code for realizing the function of any one of the above-mentioned embodiments is stored on the readable storage medium, and the computer or device of the system or device The processor reads and executes the instructions stored in the readable storage medium.
在这种情况下,从可读介质读取的程序代码本身可实现上述实施例中任何一项实施例的功能,因此机器可读代码和存储机器可读代码的可读存储介质构成了本发明的一部分。In this case, the program code itself read from the readable medium can realize the function of any one of the above embodiments, so the machine readable code and the readable storage medium storing the machine readable code constitute the present invention a part of.
可读存储介质的实施例包括软盘、硬盘、磁光盘、光盘(如CD-ROM、CD-R、CD-RW、DVD-ROM、DVD-RAM、DVD-RW、DVD-RW)、磁带、非易失性存储卡和ROM。可选择地,可以由通信网络从服务器计算机上或云上下载程序代码。Examples of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), magnetic tape, Volatile memory card and ROM. Alternatively, the program code can be downloaded from a server computer or cloud via a communication network.
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。The foregoing describes specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims may be performed in a different order than in the embodiments and still achieve desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or sequential order shown in order to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
上述各流程和各系统结构图中不是所有的步骤和单元都是必须的,可以根据实际的需要忽略某些步骤或单元。各步骤的执行顺序不是固定的,可以根据需要进行确定。 上述各实施例中描述的装置结构可以是物理结构,也可以是逻辑结构,即,有些单元可能由同一物理实体实现,或者,有些单元可能分由多个物理实体实现,或者,可以由多个独立设备中的某些部件共同实现。Not all steps and units in the above processes and system structure diagrams are necessary, and some steps or units can be omitted according to actual needs. The order of execution of each step is not fixed and can be determined as needed. The device structure described in the foregoing embodiments may be a physical structure or a logical structure, that is, some units may be implemented by the same physical entity, or some units may be implemented by multiple physical entities, or may be implemented by multiple physical entities. Some components in independent devices are implemented together.
在整个本说明书中使用的术语“示例性”意味着“用作示例、实例或例示”,并不意味着比其它实施例“优选”或“具有优势”。出于提供对所描述技术的理解的目的,具体实施方式包括具体细节。然而,可以在没有这些具体细节的情况下实施这些技术。在一些实例中,为了避免对所描述的实施例的概念造成难以理解,公知的结构和装置以框图形式示出。The term "exemplary" used throughout this specification means "serving as an example, instance, or illustration", and does not mean "preferred" or "advantageous" over other embodiments. The detailed description includes specific details for the purpose of providing an understanding of the described technology. However, these techniques can be implemented without these specific details. In some instances, in order to avoid incomprehensibility to the concepts of the described embodiments, well-known structures and devices are shown in the form of block diagrams.
以上结合附图详细描述了本说明书实施例的实施例的可选实施方式,但是,本说明书实施例的实施例并不限于上述实施方式中的具体细节,在本说明书实施例的实施例的技术构思范围内,可以对本说明书实施例的实施例的技术方案进行多种简单变型,这些简单变型均属于本说明书实施例的实施例的保护范围。The above describes in detail the optional implementation manners of the embodiments of the embodiments of this specification with reference to the accompanying drawings. However, the embodiments of the embodiments of this specification are not limited to the specific details in the above-mentioned embodiments. Within the scope of the conception, a variety of simple modifications can be made to the technical solutions of the embodiments of the embodiments of the present specification, and these simple modifications all belong to the protection scope of the embodiments of the embodiments of the present specification.
本说明书实施例内容的上述描述被提供来使得本领域任何普通技术人员能够实现或者使用本说明书实施例内容。对于本领域普通技术人员来说,对本说明书实施例内容进行的各种修改是显而易见的,并且,也可以在不脱离本说明书实施例内容的保护范围的情况下,将本文所定义的一般性原理应用于其它变型。因此,本说明书实施例内容并不限于本文所描述的示例和设计,而是与符合本文公开的原理和新颖性特征的最广范围相一致。The foregoing description of the content of the embodiments of this specification is provided to enable any person of ordinary skill in the art to implement or use the content of the embodiments of this specification. It is obvious to a person of ordinary skill in the art that various modifications made to the content of the embodiments of this specification are obvious, and the general principles defined herein can also be used without departing from the scope of protection of the content of the embodiments of this specification. Apply to other variants. Therefore, the contents of the embodiments of this specification are not limited to the examples and designs described herein, but are consistent with the widest scope that conforms to the principles and novel features disclosed herein.

Claims (19)

  1. 一种用于执行交易正确性验证的方法,所述方法由区块链系统中的轻量节点执行,所述方法包括:A method for performing transaction correctness verification, the method is executed by a lightweight node in a blockchain system, and the method includes:
    从全量节点处获取待验证区块的共识证明信息,所述共识证明信息包括数字签名集合,所述数字签名集合是对所述待验证区块达成共识的各个共识节点对所述待验证区块所对应的第一签名数据原文进行签名而得到的;Obtain the consensus proof information of the block to be verified from the full number of nodes. The consensus proof information includes a set of digital signatures. The corresponding first signature data is obtained by signing the original text;
    基于所述数字签名集合和所述轻量节点处的公钥集合验证所述共识证明信息的正确性,所述公钥集合包括所述区块系统中的至少部分区块链节点的公钥;以及Verifying the correctness of the consensus proof information based on the digital signature set and the public key set at the lightweight node, the public key set including the public keys of at least part of the blockchain nodes in the block system; as well as
    基于所述共识证明信息的正确性验证结果,确定所述待验证区块中的交易集合的正确性。Based on the verification result of the correctness of the consensus proof information, the correctness of the transaction set in the block to be verified is determined.
  2. 如权利要求1所述的方法,其中,在基于所述共识证明信息的正确性验证结果,确定所述待验证区块中的交易集合的正确性之前,所述方法还包括:The method according to claim 1, wherein, before determining the correctness of the transaction set in the block to be verified based on the correctness verification result of the consensus proof information, the method further comprises:
    从所述全量节点处获取所述待验证区块的区块体信息;Obtain the block body information of the block to be verified from the full number of nodes;
    基于所述区块体信息,验证所述轻量节点处的所述待验证区块的交易根的正确性,Based on the block body information, verify the correctness of the transaction root of the block to be verified at the lightweight node,
    基于所述共识证明信息的正确性验证结果,确定所述待验证区块中的交易集合的正确性包括:Based on the verification result of the correctness of the consensus proof information, determining the correctness of the transaction set in the block to be verified includes:
    基于所述交易根的正确性验证结果和所述区块证明信息的正确性验证结果,确定所述待验证区块中的交易集合的正确性。Based on the correctness verification result of the transaction root and the correctness verification result of the block proof information, the correctness of the transaction set in the block to be verified is determined.
  3. 如权利要求1所述的方法,其中,基于所述数字签名集合和所述轻量节点处的公钥集合验证所述共识证明信息的正确性包括:The method of claim 1, wherein verifying the correctness of the consensus proof information based on the digital signature set and the public key set at the lightweight node comprises:
    利用各个共识节点对第一签名数据原文进行签名所使用的加密算法,从所述数字签名集合中还原出所述各个共识节点的公钥;以及Using the encryption algorithm used by each consensus node to sign the original text of the first signature data, restore the public key of each consensus node from the digital signature set; and
    基于所还原出的各个共识节点的公钥和所述轻量节点处的公钥集合,验证所述共识证明信息的正确性。Based on the restored public key of each consensus node and the public key set at the lightweight node, the correctness of the consensus certification information is verified.
  4. 如权利要求3所述的方法,其中,基于所还原出的各个共识节点的公钥和所述轻量节点处的公钥集合,验证所述待验证区块中的交易的正确性包括:The method of claim 3, wherein, based on the restored public key of each consensus node and the public key set at the lightweight node, verifying the correctness of the transaction in the block to be verified comprises:
    在所还原出的公钥中的至少部分被包括在所述公钥集合中并且被包括在所述公钥集合中的公钥数量满足共识规则时,确定所述共识证明信息是正确的。When at least part of the restored public keys is included in the public key set and the number of public keys included in the public key set meets the consensus rule, it is determined that the consensus certification information is correct.
  5. 如权利要求1-4中任一所述的方法,其中,所述公钥集合包括所述区块链系统中的所有参与共识的区块链节点的公钥,或The method according to any one of claims 1-4, wherein the set of public keys includes the public keys of all blockchain nodes participating in the consensus in the blockchain system, or
    所述公钥集合包括对所述轻量节点处的信任锚点进行共识的所有共识节点的公钥, 所述信任锚点指示被验证为正确的信任区块。The set of public keys includes the public keys of all consensus nodes that agree on the trust anchors at the lightweight nodes, and the trust anchors indicate the trust blocks that are verified as correct.
  6. 如权利要求1-4中任一所述的方法,其中,在从全量节点处获取待验证区块的共识证明信息之前,所述方法还包括:The method according to any one of claims 1-4, wherein, before obtaining the consensus proof information of the block to be verified from the full number of nodes, the method further comprises:
    接收针对所述交易集合中的指定交易的交易正确性验证请求,Receiving a transaction correctness verification request for a specified transaction in the transaction set,
    从全量节点处获取待验证区块的共识证明信息包括:Obtaining the consensus proof information of the block to be verified from all nodes includes:
    在接收到所述交易正确性验证请求时,从全量节点处获取待验证区块的共识证明信息,Upon receiving the transaction correctness verification request, obtain the consensus proof information of the block to be verified from the full number of nodes,
    所述方法还包括:The method also includes:
    验证所述指定交易是否存在于所述交易集合中;以及Verify whether the specified transaction exists in the transaction set; and
    基于所述交易集合的正确性验证结果和所述指定交易在所述待验证区块中的存在性验证结果,确定所述指定交易的正确性。Based on the correctness verification result of the transaction set and the existence verification result of the designated transaction in the to-be-verified block, the correctness of the designated transaction is determined.
  7. 如权利要求1-4中任一所述的方法,其中,在从全量节点处获取待验证区块的共识证明信息之前,所述方法还包括:The method according to any one of claims 1-4, wherein, before obtaining the consensus proof information of the block to be verified from the full number of nodes, the method further comprises:
    监听是否存在包括指定交易的待验证区块;Monitor whether there is a block to be verified including the specified transaction;
    从全量节点处获取待验证区块的共识证明信息包括:Obtaining the consensus proof information of the block to be verified from all nodes includes:
    在监听到存在包括所述指定交易的待验证区块时,从全量节点处获取所监听到的待验证区块的共识证明信息。When it is monitored that there is a block to be verified that includes the specified transaction, the consensus proof information of the block to be verified that is monitored is obtained from all nodes.
  8. 如权利要求7所述的方法,还包括:The method of claim 7, further comprising:
    接收针对所述交易集合中的指定交易的交易正确性验证请求;Receiving a transaction correctness verification request for a specified transaction in the transaction set;
    验证所述指定交易是否存在于所述交易集合中;Verify whether the specified transaction exists in the transaction set;
    基于所述交易集合的正确性验证结果和所述指定交易在所述待验证区块中的存在性验证结果,确定所述指定交易的正确性。Based on the correctness verification result of the transaction set and the existence verification result of the designated transaction in the to-be-verified block, the correctness of the designated transaction is determined.
  9. 如权利要求1-4任一所述的方法,其中,所述区块链系统为联盟链系统。The method according to any one of claims 1 to 4, wherein the blockchain system is a consortium chain system.
  10. 一种用于执行交易正确性验证的装置,所述装置用于区块链系统中的轻量节点,所述装置包括:A device for performing transaction correctness verification. The device is used for a lightweight node in a blockchain system. The device includes:
    共识证明信息获取单元,从全量节点处获取待验证区块的共识证明信息,所述共识证明信息包括数字签名集合,所述数字签名集合是对所述待验证区块达成共识的各个共识节点对所述待验证区块所对应的第一签名数据原文进行签名而得到的;The consensus proof information obtaining unit obtains consensus proof information of the block to be verified from all nodes, the consensus proof information includes a digital signature set, and the digital signature set is a pair of consensus nodes that reach a consensus on the block to be verified Obtained by signing the original text of the first signature data corresponding to the block to be verified;
    共识证明信息验证单元,基于所述数字签名集合和所述轻量节点处的公钥集合验证所述共识证明信息的正确性,所述公钥集合包括所述区块系统中的至少部分区块链节点的公钥;以及The consensus certification information verification unit verifies the correctness of the consensus certification information based on the digital signature set and the public key set at the lightweight node, and the public key set includes at least part of the blocks in the block system The public key of the chain node; and
    交易集合验证单元,基于所述共识证明信息的正确性验证结果,确定所述待验证区块中的交易集合的正确性。The transaction set verification unit determines the correctness of the transaction set in the block to be verified based on the verification result of the correctness of the consensus certification information.
  11. 如权利要求10所述的装置,还包括:The device of claim 10, further comprising:
    区块体信息获取单元,在基于所述共识证明信息的正确性验证结果,确定所述待验证区块中的交易集合的正确性之前,从所述全量节点处获取所述待验证区块的区块体信息;The block body information acquisition unit, before determining the correctness of the transaction set in the block to be verified based on the correctness verification result of the consensus proof information, obtains the information of the block to be verified from the full amount of nodes Block body information;
    区块头验证单元,基于所述区块体信息,验证所述轻量节点处的所述待验证区块的区块头的正确性,The block header verification unit verifies the correctness of the block header of the block to be verified at the lightweight node based on the block body information,
    共识证明信息验证单元基于所述区块头的正确性验证结果和所述区块证明信息的正确性验证结果,确定所述待验证区块中的交易集合的正确性。The consensus proof information verification unit determines the correctness of the transaction set in the block to be verified based on the correctness verification result of the block header and the correctness verification result of the block proof information.
  12. 如权利要求10所述的装置,其中,所述交易集合验证单元包括:The apparatus of claim 10, wherein the transaction set verification unit comprises:
    公钥还原模块,利用各个共识节点对第一签名数据原文进行签名所使用的加密算法,从所述数字签名集合中还原出所述各个共识节点的公钥;以及The public key restoration module uses the encryption algorithm used by each consensus node to sign the original text of the first signature data to restore the public key of each consensus node from the digital signature set; and
    共识证明信息验证模块,基于所还原出的各个共识节点的公钥和所述轻量节点处的公钥集合,验证所述共识证明信息的正确性。The consensus certification information verification module verifies the correctness of the consensus certification information based on the restored public key of each consensus node and the public key set at the lightweight node.
  13. 如权利要求12所述的装置,其中,所述共识证明信息验证模块在所还原出的公钥中的至少部分被包括在所述公钥集合中并且被包括在所述公钥集合中的公钥数量满足共识规则时,确定所述共识证明信息是正确的。The apparatus according to claim 12, wherein at least part of the public key recovered by the consensus certification information verification module is included in the public key set and the public key included in the public key set When the number of keys meets the consensus rule, it is determined that the consensus certification information is correct.
  14. 如权利要求10-13中任一所述的装置,其中,所述公钥集合包括所述区块链系统中的所有参与共识的区块链节点的公钥,或The device according to any one of claims 10-13, wherein the set of public keys includes the public keys of all blockchain nodes participating in consensus in the blockchain system, or
    所述公钥集合包括对所述轻量节点处的信任锚点进行共识的所有共识节点的公钥,所述信任锚点指示被验证为正确的信任区块。The set of public keys includes the public keys of all consensus nodes that agree on the trust anchors at the lightweight nodes, and the trust anchors indicate the trust blocks that are verified as correct.
  15. 如权利要求10-13中任一所述的装置,其中,在从全量节点处获取待验证区块的共识证明信息之前,所述装置还包括:The device according to any one of claims 10-13, wherein, before obtaining the consensus proof information of the block to be verified from all nodes, the device further comprises:
    验证请求接收单元,接收针对所述交易集合中的指定交易的交易正确性验证请求,The verification request receiving unit receives a transaction correctness verification request for a specified transaction in the transaction set,
    所述共识证明信息获取单元在接收到所述交易正确性验证请求时,从全量节点处获取待验证区块的共识证明信息,The consensus proof information obtaining unit obtains the consensus proof information of the block to be verified from the full number of nodes when receiving the transaction correctness verification request,
    所述装置还包括:The device also includes:
    存在性验证单元,验证所述指定交易是否存在于所述交易集合中;以及An existence verification unit to verify whether the specified transaction exists in the transaction set; and
    指定交易正确性确定单元,基于所述交易集合的正确性验证结果和所述指定交易在所述待验证区块中的存在性验证结果,确定所述指定交易的正确性。The designated transaction correctness determining unit determines the correctness of the designated transaction based on the correctness verification result of the transaction set and the existence verification result of the designated transaction in the block to be verified.
  16. 如权利要求10-13中任一所述的装置,其中,所述装置还包括:The device according to any one of claims 10-13, wherein the device further comprises:
    待验证区块监听单元,在从全量节点处获取待验证区块的共识证明信息之前,监听是否存在包括指定交易的待验证区块;The block to be verified monitoring unit monitors whether there is a block to be verified that includes the specified transaction before obtaining the consensus proof information of the block to be verified from the full number of nodes;
    所述共识证明信息获取单元在监听到存在包括所述指定交易的待验证区块时,从全量节点处获取所监听到的待验证区块的共识证明信息。When the consensus proof information acquisition unit monitors that there is a block to be verified that includes the designated transaction, it acquires the monitored consensus proof information of the block to be verified from all nodes.
  17. 如权利要求16所述的装置,还包括:The device of claim 16, further comprising:
    验证请求接收单元,接收针对所述交易集合中的指定交易的交易正确性验证请求;A verification request receiving unit, which receives a transaction correctness verification request for a specified transaction in the transaction set;
    存在性验证单元,验证所述指定交易是否存在于所述交易集合中;以及An existence verification unit to verify whether the specified transaction exists in the transaction set; and
    指定交易正确性确定单元,基于所述交易集合的正确性验证结果和所述指定交易在所述待验证区块中的存在性验证结果,确定所述指定交易的正确性。The designated transaction correctness determining unit determines the correctness of the designated transaction based on the correctness verification result of the transaction set and the existence verification result of the designated transaction in the block to be verified.
  18. 一种计算设备,包括:A computing device including:
    至少一个处理器;以及At least one processor; and
    存储器,所述存储器存储指令,当所述指令被所述至少一个处理器执行时,使得所述至少一个处理器执行如权利要求1到9中任一所述的方法。A memory, where the memory stores instructions, and when the instructions are executed by the at least one processor, the at least one processor executes the method according to any one of claims 1 to 9.
  19. 一种机器可读存储介质,其存储有可执行指令,所述指令当被执行时使得所述机器执行如权利要求1到9中任一所述的方法。A machine-readable storage medium storing executable instructions, which when executed, cause the machine to execute the method according to any one of claims 1-9.
PCT/CN2020/132060 2020-01-02 2020-11-27 Method and apparatus for executing transaction correctness verification WO2021135757A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010002500.4A CN111242617B (en) 2020-01-02 2020-01-02 Method and apparatus for performing transaction correctness verification
CN202010002500.4 2020-01-02

Publications (1)

Publication Number Publication Date
WO2021135757A1 true WO2021135757A1 (en) 2021-07-08

Family

ID=70879599

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/132060 WO2021135757A1 (en) 2020-01-02 2020-11-27 Method and apparatus for executing transaction correctness verification

Country Status (2)

Country Link
CN (1) CN111242617B (en)
WO (1) WO2021135757A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113378144A (en) * 2021-07-14 2021-09-10 湖北央中巨石信息技术有限公司 Image file consensus method, system, device and medium based on block chain
WO2023168993A1 (en) * 2022-03-07 2023-09-14 腾讯科技(深圳)有限公司 Blockchain-based data processing method, apparatus, and device, medium, and product

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111242617B (en) * 2020-01-02 2022-05-10 支付宝(杭州)信息技术有限公司 Method and apparatus for performing transaction correctness verification
CN111881486B (en) * 2020-07-23 2024-06-14 中国工商银行股份有限公司 Multi-party data backup method, device and system based on block chain
CN111833062B (en) * 2020-09-21 2020-12-01 江苏傲为控股有限公司 Credibility verification system for digital asset data packet
CN112085504B (en) * 2020-11-16 2021-02-09 腾讯科技(深圳)有限公司 Data processing method and device, computer equipment and storage medium
CN112883117B (en) * 2020-12-24 2022-03-15 腾讯科技(深圳)有限公司 Data synchronization method, equipment and computer readable storage medium
CN112766971A (en) * 2021-03-30 2021-05-07 支付宝(杭州)信息技术有限公司 Method and apparatus for transmitting transactions and executing transactions in blockchain
CN112967065B (en) * 2021-05-18 2021-07-13 腾讯科技(深圳)有限公司 Transaction verification method, device, equipment and storage medium
CN113746638B (en) * 2021-09-03 2023-04-07 杭州复杂美科技有限公司 NFT storage method, NFT restoration method, computer device, and storage medium
CN114172689B (en) * 2021-11-11 2023-11-28 卓尔智联(武汉)研究院有限公司 Information processing method and equipment
CN114449003A (en) * 2022-01-28 2022-05-06 浪潮云信息技术股份公司 Alliance chain data processing method and alliance chain
CN115225639B (en) * 2022-09-15 2022-12-27 杭州趣链科技有限公司 Changing method and device for consensus trusted cluster, computer equipment and medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019001139A1 (en) * 2017-06-26 2019-01-03 华为技术有限公司 Method and device for running chaincode
CN109981279A (en) * 2017-12-28 2019-07-05 航天信息股份有限公司 A kind of block catenary system, communication means, device, equipment and medium
CN109995536A (en) * 2019-03-15 2019-07-09 广州杰赛科技股份有限公司 A kind of block chain common recognition method, apparatus and readable storage medium storing program for executing
CN110113388A (en) * 2019-04-17 2019-08-09 四川大学 A kind of method and apparatus of the block catenary system common recognition based on improved clustering algorithm
CN110458560A (en) * 2019-07-12 2019-11-15 阿里巴巴集团控股有限公司 For carrying out the method and device of transaction verification
CN110597839A (en) * 2019-09-20 2019-12-20 腾讯科技(深圳)有限公司 Transaction data processing method, device, equipment and storage medium
CN111242617A (en) * 2020-01-02 2020-06-05 支付宝(杭州)信息技术有限公司 Method and apparatus for performing transaction correctness verification

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190303932A1 (en) * 2018-03-28 2019-10-03 NEC Laboratories Europe GmbH Method and system for verifying policy compliance of transactions in a blockchain executing smart contracts
CN108711052B (en) * 2018-05-18 2021-04-30 电子科技大学 Information verification system based on block chain
CN108964982B (en) * 2018-06-13 2021-07-09 众安信息技术服务有限公司 Method, apparatus and storage medium for enabling deployment of multiple nodes of a blockchain
CN108681900A (en) * 2018-07-18 2018-10-19 众安信息技术服务有限公司 The method of light node verification transaction
CN109241778A (en) * 2018-08-13 2019-01-18 阿里巴巴集团控股有限公司 A kind of public transport data processing method and device based on block chain
CN108964926B (en) * 2018-08-28 2021-02-02 成都信息工程大学 User trust negotiation establishing method, user behavior data storage method and medium
CN109102308A (en) * 2018-09-05 2018-12-28 深圳正品创想科技有限公司 Merchandise news maintaining method, block chain node and its system based on block chain
CN109242500B (en) * 2018-09-20 2021-07-02 百度在线网络技术(北京)有限公司 Block chain transaction validity verification method and device and storage medium
CN109863521A (en) * 2018-12-13 2019-06-07 阿里巴巴集团控股有限公司 Data isolation in block chain network
CN110601816B (en) * 2019-09-18 2021-09-28 腾讯科技(深圳)有限公司 Lightweight node control method and device in block chain system
CN110598456B (en) * 2019-09-24 2021-04-30 腾讯科技(深圳)有限公司 Data storage method and device, electronic equipment and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019001139A1 (en) * 2017-06-26 2019-01-03 华为技术有限公司 Method and device for running chaincode
CN109981279A (en) * 2017-12-28 2019-07-05 航天信息股份有限公司 A kind of block catenary system, communication means, device, equipment and medium
CN109995536A (en) * 2019-03-15 2019-07-09 广州杰赛科技股份有限公司 A kind of block chain common recognition method, apparatus and readable storage medium storing program for executing
CN110113388A (en) * 2019-04-17 2019-08-09 四川大学 A kind of method and apparatus of the block catenary system common recognition based on improved clustering algorithm
CN110458560A (en) * 2019-07-12 2019-11-15 阿里巴巴集团控股有限公司 For carrying out the method and device of transaction verification
CN110597839A (en) * 2019-09-20 2019-12-20 腾讯科技(深圳)有限公司 Transaction data processing method, device, equipment and storage medium
CN111242617A (en) * 2020-01-02 2020-06-05 支付宝(杭州)信息技术有限公司 Method and apparatus for performing transaction correctness verification

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113378144A (en) * 2021-07-14 2021-09-10 湖北央中巨石信息技术有限公司 Image file consensus method, system, device and medium based on block chain
CN113378144B (en) * 2021-07-14 2022-09-02 湖北央中巨石信息技术有限公司 Image file consensus method, system, device and medium based on block chain
WO2023168993A1 (en) * 2022-03-07 2023-09-14 腾讯科技(深圳)有限公司 Blockchain-based data processing method, apparatus, and device, medium, and product

Also Published As

Publication number Publication date
CN111242617B (en) 2022-05-10
CN111242617A (en) 2020-06-05

Similar Documents

Publication Publication Date Title
WO2021135757A1 (en) Method and apparatus for executing transaction correctness verification
CN111062716B (en) Method and device for generating block chain signature data and block chain transaction initiating system
US11698840B2 (en) Transaction consensus processing method and apparatus for blockchain and electronic device
US11614994B2 (en) Method, apparatus and electronic device for blockchain-based transaction consensus processing
US11050549B2 (en) Blockchain-based transaction method and apparatus, and remitter device
US11032077B2 (en) Blockchain-based transaction method and apparatus, and remitter device
WO2021184885A1 (en) Method and device for use in updating public key set at blockchain node
US11128522B2 (en) Changing a master node in a blockchain system
EP3673446B1 (en) Managing blockchain-based centralized ledger systems
WO2021135857A1 (en) Method and device for updating trusted node information
WO2021008117A1 (en) Method and apparatus for performing transaction verification
US11240041B2 (en) Blockchain-based transaction verification
EP3808030B1 (en) Managing blockchain-based centralized ledger systems
EP3889869A1 (en) Managing blockchain-based centralized ledger systems
CN111241593A (en) Data synchronization method and device for block chain nodes
WO2021143364A1 (en) Method and apparatus for acquiring transaction processing state in decentralized application cluster
WO2021135755A1 (en) Method and apparatus for sending response message for data request, and blockchain system
CN111144894B (en) UTXO processing method and device
CN111143381B (en) Method and device for updating trust points in multi-layer block chain structure
CN110827034B (en) Method and apparatus for initiating a blockchain transaction
CN111159286B (en) Method and apparatus for generating multi-layer block chain structure
CN111162970B (en) Method and device for testing decentralized application server in block chain system

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

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20910948

Country of ref document: EP

Kind code of ref document: A1