A blockchain-based data processing method, apparatus, device, and medium
Patent Information
- Application Number
- CN202110554624.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-20
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2041-05-20
AI Technical Summary
[0015]在本申请实施例中,可以获取客户端的交易数据,该交易数据可以携带客户端的身份标识,该身份标识可以是根据客户端的身份证书确定的,接着,可以根据该身份标识从智能合约中查询客户端的身份证书,如果从智能合约中查询到客户端的身份证书,且根据身份证书确定出客户端具备针对区块链执行交易数据所对应交易操作的权限,则可以针对区块链执行交易数据所对应的交易操作。通过上述实施方法,可以利用交易数据所携带的身份标识和智能合约中所记录的身份证书之间的映射关系,确定客户端对应的身份证书,并按照身份证书中指示的权限进行交易操作,从而提升区块链上数据处理的安全性。在交易数据中只携带身份标识,可以在保证能够获取到相应身份证书的情况下,相对于在交易数据中携带完整的身份证书,可以减少交易数据的数据量,有利于交易数据的快速传输。
Smart Images

Figure CN115375304B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of computer technology and blockchain technology, and in particular to a data processing method, apparatus, device and medium based on blockchain. Background Technology
[0002] With the development of computer technology, blockchain technology has also developed rapidly. Considering that the information stored on the blockchain cannot be forged or tampered with, more and more enterprises will store their business data on the blockchain. If users need to process the data on the blockchain in the form of transactions, they usually only need to verify the legality of the transaction signature. That is, any user can process the data on the blockchain. Therefore, how to improve the security of the current data processing process on the blockchain has become a hot research topic. Summary of the Invention
[0003] This application provides a blockchain-based data processing method, apparatus, device, and medium. It utilizes the mapping relationship between the identity identifier carried in transaction data and the identity certificate recorded in the smart contract to determine the client's corresponding identity certificate and perform transaction operations according to the permissions indicated in the identity certificate, thereby improving the security of data processing on the blockchain. Furthermore, by carrying only the identity identifier in the transaction data, compared to carrying the complete identity certificate, the amount of transaction data can be reduced, achieving a certain degree of data compression and facilitating rapid transmission of transaction data, while ensuring that the corresponding identity certificate can be obtained.
[0004] The first aspect of this application discloses a data processing method based on blockchain, the method comprising:
[0005] Obtain the client's transaction data, which carries the client's identity identifier, determined based on the client's identity certificate;
[0006] The client's identity certificate is retrieved from the smart contract based on the identity identifier;
[0007] If the client's identity certificate is found in the smart contract, and it is determined from the identity certificate that the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain, then the transaction operation corresponding to the transaction data is executed on the blockchain.
[0008] A second aspect of this application discloses a blockchain-based data processing apparatus, the apparatus comprising:
[0009] The acquisition unit is used to acquire transaction data from the client, the transaction data carrying the client's identity identifier, the identity identifier being determined based on the client's identity certificate;
[0010] The query unit is used to query the client's identity certificate from the smart contract based on the identity identifier;
[0011] An execution unit is configured to execute the transaction operation corresponding to the transaction data on the blockchain if the client's identity certificate is found in the smart contract and it is determined from the identity certificate that the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain.
[0012] A third aspect of this application discloses a data processing device, including a processor, a memory, and a network interface, wherein the processor, memory, and network interface are interconnected, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to invoke the program instructions to execute the method described in the first aspect.
[0013] A fourth aspect of this application discloses a computer-readable storage medium storing a computer program, the computer program including program instructions that, when executed by a processor, cause the processor to perform the method described in the first aspect.
[0014] A fifth aspect of this application discloses a computer program product or computer program, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a data processing device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, causing the data processing device to perform the method described in the first aspect.
[0015] In this embodiment, client transaction data can be obtained. This transaction data may carry the client's identity identifier, which can be determined based on the client's identity certificate. Then, the client's identity certificate can be queried from the smart contract based on this identity identifier. If the client's identity certificate is found in the smart contract, and the identity certificate determines that the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain, then the transaction operation corresponding to the transaction data can be executed on the blockchain. Through the above implementation method, the mapping relationship between the identity identifier carried in the transaction data and the identity certificate recorded in the smart contract can be used to determine the client's corresponding identity certificate, and the transaction operation can be performed according to the permissions indicated in the identity certificate, thereby improving the security of data processing on the blockchain. Carrying only the identity identifier in the transaction data, while ensuring that the corresponding identity certificate can be obtained, reduces the amount of transaction data compared to carrying the complete identity certificate, which is beneficial for the rapid transmission of transaction data. Attached Figure Description
[0016] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1a This is a schematic diagram of the architecture of a blockchain-based data processing system provided in an embodiment of this application;
[0018] Figure 1b This is a schematic diagram of a blockchain structure provided in an embodiment of this application;
[0019] Figure 1c This is a schematic diagram illustrating a process for generating a new block, provided in an embodiment of this application.
[0020] Figure 2 This is a flowchart illustrating a blockchain-based data processing method provided in an embodiment of this application;
[0021] Figure 3 This is a schematic diagram of the structure of an identity on a consortium blockchain provided in an embodiment of this application;
[0022] Figure 4 This is a flowchart illustrating a blockchain-based data processing method provided in an embodiment of this application;
[0023] Figure 5 This is a schematic diagram of the structure of a blockchain-based data processing device provided in an embodiment of this application;
[0024] Figure 6 This is a schematic diagram of the structure of a data processing device provided in an embodiment of this application. Detailed Implementation
[0025] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0026] Please see Figure 1a This is a schematic diagram of the architecture of a blockchain-based data processing system provided in an embodiment of this application. The blockchain-based data processing system includes a blockchain network 10 and a client 102, wherein:
[0027] Blockchain network 10 refers to a network used for data sharing between nodes. The blockchain network may include multiple nodes 101, among which consensus nodes may be included. Each node 101, in its normal operation, receives input information and maintains shared data (i.e., the blockchain) within the blockchain network based on the received input information. Each node in the blockchain network stores the same blockchain, which consists of a series of blocks sequentially generated in chronological order, such as... Figure 1a As shown in the diagram, blocks 1, M-1, etc., are blocks that, once added to the blockchain, will not be removed. Blocks record the data submitted by nodes in the blockchain network. To ensure information exchange within the blockchain network, each node can be connected to another node, enabling peer-to-peer (P2P) communication between any two nodes. This P2P communication can be conducted via wired or wireless communication links. For example, when any node in the blockchain network receives input information, other nodes retrieve this input information according to the consensus algorithm and store it as part of the shared data, ensuring consistency of data stored on all nodes in the blockchain network.
[0028] Client 102 can access the blockchain network and communicate with nodes in the blockchain network, such as sending transaction data to nodes. The terminal where client 102 is located can be a smartphone, tablet, laptop, desktop computer, in-vehicle smart terminal, etc., and this embodiment of the application does not limit the specific device.
[0029] It should be noted that, Figure 1aThe number of nodes shown is merely illustrative. Any number of nodes can be deployed as needed. A node can refer to any form of computing device connected to the network, such as a server or user terminal.
[0030] Each node in the blockchain network has a corresponding node identifier, and each node can also store the node identifiers of other nodes in the blockchain network. This allows for the subsequent broadcasting of generated blocks to other nodes in the blockchain network based on their node identifiers. Each node can maintain a node identifier list as shown in the table below, storing the node name and node identifier in this list. The node identifier can be an Internet Protocol (IP) address or any other information that can be used to identify the node; the table only uses IP addresses as an example.
[0031] Node 1 117.114.151.174 Node 2 117.116.189.145 … … Node N 119.123.789.258
[0032] In this blockchain network, each node stores an identical copy of the blockchain. A blockchain consists of multiple blocks; see [link to blockchain documentation]. Figure 1b A blockchain consists of multiple blocks. The genesis block includes a block header and a block body. The block header stores input information feature values, version number, timestamp, and difficulty value, while the block body stores the input information. The next block after the genesis block takes the genesis block as its parent block. The next block also includes a block header and a block body. The block header stores the input information feature values of the current block, the block header feature values of the parent block, version number, timestamp, and difficulty value, and so on. This ensures that the block data stored in each block is related to the block data stored in the parent block, guaranteeing the security of the input information in the blocks.
[0033] When generating the various blocks in the blockchain, see [link / reference]. Figure 1c When a node in the blockchain receives input information, it verifies the input information. After verification, it stores the input information in a memory pool and updates its hash tree used to record the input information. Then, it updates the timestamp to the time the input information was received and tries different random numbers multiple times to calculate the feature value, ensuring that the calculated feature value satisfies the following formula:
[0034] SHA256(SHA256(version+prev_hash+merkle_root+ntime+nbits+x)) <TARGET
[0035] Wherein, SHA256 is the feature value algorithm used to calculate the feature value; version (version number) is the version information of the relevant block protocol in the blockchain; prev_hash is the block header feature value of the parent block of the current block; merkle_root is the feature value of the input information; ntime is the update time of the update timestamp; nbits is the current difficulty, which is a fixed value for a period of time and is determined again after exceeding the fixed time period; x is a random number; TARGET is the feature value threshold, which can be determined based on nbits.
[0036] Thus, when a random number satisfying the above formula is calculated, the information can be stored accordingly, generating a block header and a block body to obtain the current block. Subsequently, the node containing the blockchain sends the newly generated block to other nodes in its blockchain network based on the node identifiers of other nodes in the blockchain network. The other nodes verify the newly generated block and, after verification, add the newly generated block to their stored blockchain.
[0037] In a blockchain network, smart contracts can run on nodes, enabling various transactions. A smart contract is an immutable, automatically executing computer program that runs on the blockchain. It's code that executes when certain conditions are met. Developers can define contract logic using programming languages, publish it to the blockchain (smart contract registration), and execute it based on the contract terms, triggered by keys or other events. The blockchain also provides functions for upgrading and deregistering smart contracts.
[0038] In some feasible implementations, any node 101 of the blockchain network can obtain transaction data from a client. This transaction data may carry the client's identity identifier, which can be determined based on the client's identity certificate. Node 101 can query the client's identity certificate from the smart contract based on the identity identifier. If the client's identity certificate is found in the smart contract, and the identity certificate determines that the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain, then node 101 can execute the transaction operation corresponding to the transaction data on the blockchain. By utilizing the mapping relationship between the identity identifier carried in the transaction data and the identity certificate recorded in the smart contract, the corresponding identity certificate of the client can be determined, and the transaction operation can be performed according to the permissions indicated in the identity certificate, thereby improving the security of data processing on the blockchain. Carrying only the identity identifier in the transaction data, while ensuring that the corresponding identity certificate can be obtained, can reduce the amount of transaction data compared to carrying the complete identity certificate in the transaction data, which is conducive to the rapid transmission of transaction data.
[0039] Typically, it is also necessary to generate transaction blocks for the transaction data and put the blocks on the blockchain (store the blocks on the blockchain). Since only the identity identifier is carried, the amount of transaction data can be reduced compared to carrying the complete identity certificate in the transaction data, while ensuring that the corresponding identity certificate can be obtained. This can achieve a certain degree of data compression, thereby reducing the consumption of blockchain storage resources.
[0040] The implementation details of the technical solutions in the embodiments of this application are described in detail below:
[0041] Please see Figure 2 , Figure 2 This is a flowchart illustrating a blockchain-based data processing method provided in an embodiment of this application. The data processing method in this embodiment is mainly described from the node side, such as... Figure 2 As shown, this blockchain-based data processing method may include:
[0042] S201: Obtain the client's transaction data, which carries the client's identity identifier.
[0043] In one implementation, when a client needs to perform a data operation on the blockchain, it can access the blockchain in the form of a transaction. For example, the data operation could be any one or more of adding, deleting, searching, or modifying data. The client can then send transaction data to the blockchain network, allowing the blockchain network to receive the transaction data and execute the corresponding transaction operation (which can be understood as a data operation) on the blockchain. After the client sends the transaction data to the blockchain network, a node in the blockchain network can retrieve it. This node can be any one of multiple nodes in the blockchain network; it can be a consensus node or other nodes (non-consensus nodes).
[0044] In one implementation, the transaction data may also carry the client's identity identifier. This identifier can be used to verify the client's identity and permissions for transactions initiated by the client, so that it can be used to determine whether the client has the authority to execute the transaction operations corresponding to the transaction data on the blockchain. For example, taking a consortium blockchain as an example, a consortium blockchain uses a permissioned access system, meaning that the client needs to obtain the permissions granted by an identity certificate from the consortium blockchain to access it. This identity certificate can be used to indicate the corresponding permissions possessed by the client. For consortium blockchains, the complete identity certificate can be carried in the transaction data to access the consortium blockchain and verify identity and permissions based on that identity certificate. However, considering that carrying the complete identity certificate in the transaction data may lead to a large storage overhead, the identity certificate can be compressed to reduce the large storage overhead caused by carrying the complete identity certificate in the transaction. For example, the identity certificate can be replaced with the identity identifier corresponding to the identity certificate, thus carrying the identity identifier in the transaction data instead of the complete identity certificate. As can be seen from the above, by only carrying an identity identifier and ensuring that the corresponding identity certificate can be obtained subsequently, the amount of transaction data can be reduced compared to carrying the complete identity certificate in the transaction data, thus achieving a certain degree of data compression. Therefore, identity and permissions can be verified based on the identity identifier carried in the transaction data. Specifically, identity and permissions verification can determine whether the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain based on the identity identifier. If the client has the authority, it can execute the transaction operation corresponding to the transaction data on the blockchain, thereby enhancing the security of data processing. This identity identifier can be determined based on the client's identity certificate. This identity identifier can be a hash value obtained by hashing the client's identity certificate, or it can be the corresponding numerical number, bit value, or other information of the identity certificate; this application does not limit this.
[0045] In one implementation, before sending transaction data to the blockchain, the client can record its identity certificate on a smart contract. This allows the client to subsequently obtain the permissions indicated in the identity certificate from the smart contract to process data on the blockchain. Assuming the identity identifier includes a hash value obtained by hashing the client's identity certificate, the smart contract can record one or more client identity certificates and their corresponding hash values. That is, each client can record its corresponding identity certificate on the smart contract before accessing the blockchain. The client's identity certificate can be obtained from the organization corresponding to the blockchain. The client can refer to a member of the organization or a member outside the organization; in this application, members of the organization or members outside the organization can be referred to as users. When the organization corresponding to the blockchain accesses the blockchain through a client, it also needs a corresponding identity certificate. The organization's identity certificate can be the identity certificate of the organization's administrator, which can be obtained from a Certificate Authority (CA). The organization administrator can also record its corresponding identity certificate on the smart contract so that the administrator can subsequently interact with the blockchain through the client. The identity certificate corresponding to the organization administrator can be understood as the identity certificate of the client used by the organization administrator. In subsequent descriptions of user identity certificates (or identity identifiers) and organization administrator identity certificates (or identity identifiers), these can be understood as the client used by the user and organization administrator, respectively.
[0046] In a specific implementation scenario, the following explanation uses a consortium blockchain as an example. On a consortium blockchain platform, all entities interacting with the blockchain, database, and configuration are assigned an identity; for example, this entity could be a client. Only when this identity possesses specific permissions can the corresponding interactive operation be successfully executed on the blockchain. Identity permissions can be managed through identity certificates. Identity certificates can be categorized into registration certificates, transaction certificates, and communication certificates. Registration certificates are issued to users or nodes that have provided registration credentials, representing their identity within the blockchain network. Transaction certificates are issued to users, controlling the permissions for each transaction; different transactions can have different permissions. Communication certificates control access to the network layer and can verify the identity of remote entities. For example... Figure 3As shown, identities on a consortium blockchain can include organization administrators, consensus nodes, other nodes, and users. Each identity on the consortium blockchain can be bound to an identity certificate. The consortium blockchain can be composed of one or more organizations. The organization administrator can be an administrator within that organization, and the organization administrator's identity certificate can be provided by the organization itself. The identity certificates of other members within the organization can be signed using the private key of the organization administrator's identity certificate, and the corresponding identity information of other members can be set in the corresponding fields of the organization administrator's identity certificate.
[0047] The process of recording the identity certificate of the organization administrator in the smart contract implementation may include the following steps:
[0048] s1: An organization can generate an asymmetric public and private key, and use the private key to sign its corresponding identity information to obtain signature information. After obtaining the signature information, it can send a certificate application request to a CA (Certificate Authority) to apply for an identity certificate corresponding to the organization, or in other words, an identity certificate for the organization's administrator. This certificate application request may include the public key, the organization's corresponding identity information, and the signature information.
[0049] S2: After receiving a certificate application request from an organization, the CA (Certificate Authority) can use the information included in the request to perform real-name authentication. Once authentication is successful, the CA can issue a corresponding identity certificate to the organization. After issuing the identity certificate, the CA needs to record it in a smart contract. The CA can then generate transaction data based on this identity certificate and send it to the blockchain network. This transaction data may include the identity certificate issued by the CA to the organization (the identity certificate corresponding to the organization's administrator).
[0050] S3: After receiving the transaction data, the blockchain network can verify its legitimacy. This can be done by any node in the blockchain network. The transaction data may also include signature data corresponding to the identity certificate, obtained by signing the identity certificate using the private key of the CA (Certificate Authority). Verifying the legitimacy of the transaction data can involve verifying this signature data. Specifically, this verification can be performed using the public key corresponding to the CA's private key to design the signature data, obtaining designed data. After obtaining the designed data, it can be checked whether it matches the identity certificate. If they match, the transaction data is considered legitimate. After successful verification, the virtual machine can be invoked to execute the transaction operation corresponding to the transaction data. Executing this transaction operation involves recording the organization administrator's identity certificate on a smart contract. The smart contract can run on this virtual machine.
[0051] S4: During execution, nodes in the blockchain network can invoke smart contracts to record identity certificates. For example, they can first determine the identity identifier corresponding to the identity certificate based on the certificate. This identity identifier can be a hash value obtained by hashing the identity certificate, and this hash calculation can be a digest hash calculation. After obtaining the hash value, the smart contract can be used to query whether the identity certificate corresponding to the hash value already exists. If the identity certificate corresponding to the hash value is found in the smart contract, an execution failure result can be returned to the CA (Certificate Authority). If the identity certificate corresponding to the hash value is not found in the smart contract, the hash value and the corresponding identity certificate can be recorded in the smart contract so that the corresponding identity certificate can be queried later based on the hash value. For example, the hash value and the corresponding identity certificate can be recorded in the smart contract in the form of key-value pairs, that is, the hash value can be used as the key and the corresponding identity certificate can be used as the value.
[0052] s5: Nodes in the blockchain network can also send the identity certificate of the organization administrator to the consensus node in the blockchain network for consensus, so that the consensus node in the blockchain network can reach a consensus on the hash value corresponding to the identity certificate. After the consensus is passed, the hash value and the identity certificate corresponding to the hash value can be recorded in the smart contract.
[0053] s6: After the identity certificate corresponding to the organization administrator is recorded in the smart contract, the nodes in the blockchain network can return the hash value corresponding to the identity certificate to the CA authority.
[0054] S7: The CA (Certificate Authority) can receive the hash value corresponding to the identity certificate of the organization administrator returned by the blockchain network, and return the identity certificate and its corresponding hash value to the organization. The organization can then store this identity certificate and its corresponding hash value so that, when interacting with the consortium blockchain later, it can verify identity and permissions based on the hash value.
[0055] In one implementation, when a user wants to join a consortium blockchain comprised of organizations—that is, when a user wants to interact with the blockchain through a client—identity verification is required, and the user's identity certificate needs to be recorded in the smart contract. The user's identity certificate can be obtained from the organization (or its administrator), and the specific implementation process of recording the user's identity certificate in the smart contract may include the following steps:
[0056] S1: Users can generate asymmetric public and private keys, and use the private key to sign their corresponding identity information to obtain signature information. After obtaining the signature information, they can send a certificate application request to an organization to apply for a certificate corresponding to their identity. This certificate application request may include the public key, the user's corresponding identity information, and the signature information.
[0057] S2: After receiving a certificate application request from a user, the organization can use the information included in the request to perform real-name authentication. Once authentication is successful, a corresponding identity certificate can be issued to the user. After issuing the identity certificate, the organization needs to record it in a smart contract. Then, the organization can generate transaction data based on this identity certificate and send it to the blockchain network. This transaction data may include the identity certificate issued by the organization to the user.
[0058] S3: After receiving the transaction data, the blockchain network can verify its legality. The verification process is described above and will not be repeated here. Once verified, the virtual machine can be invoked to execute the transaction operation corresponding to the transaction data. Executing this transaction operation involves recording the user's identity certificate on a smart contract.
[0059] S4: During execution, nodes in the blockchain network can invoke smart contracts to record identity certificates. For example, they can first determine the identity identifier corresponding to the identity certificate based on the certificate. This identity identifier can be a hash value obtained by hashing the identity certificate, and this hash calculation can be a digest hash calculation. After obtaining the hash value, the smart contract can be used to query whether the identity certificate corresponding to the hash value already exists. If the identity certificate corresponding to the hash value is found in the smart contract, an execution failure result can be returned to the organization. If the identity certificate corresponding to the hash value is not found in the smart contract, the hash value and the corresponding identity certificate can be recorded in the smart contract so that the corresponding identity certificate can be queried later based on the hash value. For example, the hash value and the corresponding identity certificate can be recorded in the smart contract in the form of key-value pairs, that is, the hash value can be used as the key and the corresponding identity certificate can be used as the value.
[0060] S5: Nodes in the blockchain network can also send the user's identity certificate to the consensus nodes in the blockchain network for consensus, so that the consensus nodes in the blockchain network can reach a consensus on the hash value corresponding to the identity certificate. After the consensus is passed, the hash value and the identity certificate corresponding to the hash value can be recorded in the smart contract.
[0061] S6: After the user's identity certificate is recorded in the smart contract, nodes in the blockchain network can return the hash value corresponding to the identity certificate to the organization.
[0062] S7: Organizations can receive the hash value corresponding to a user's identity certificate returned by the blockchain network and return the identity certificate and its corresponding hash value to the user. The user can then store this identity certificate and its corresponding hash value for subsequent data interaction with the consortium blockchain, where the hash value can be used to verify identity and permissions. Organizations may also choose to store the user's identity certificate and its corresponding hash value.
[0063] After both the organization's identity certificate and the user's identity certificate are recorded in the smart contract, the user can interact with the blockchain through the client.
[0064] In one implementation, after any node on the blockchain network receives transaction data from a client, it typically needs to generate a transaction block based on the transaction data and upload the block to the blockchain. For example, after a node in the blockchain network receives transaction data, it can store the transaction data in the block body, calculate the Merkle root of the transaction data, obtain the hash value of the last block in the blockchain stored by the node, and store the Merkle root of the transaction data, the hash value of the last block of the current blockchain, and the current timestamp in the block header. The node combines the block header and the block body containing the transaction data into a first block, adds the first block to the blockchain stored by the node, and broadcasts the first block to the other nodes in the blockchain network so that the other nodes add the first block to their own maintained blockchains, thereby synchronizing the blockchains maintained by all nodes. As can be seen from the above, by only carrying the identity identifier and ensuring that the corresponding identity certificate can be obtained later, compared with carrying the complete identity certificate in the transaction data, the amount of transaction data can be reduced, so as to achieve a certain degree of data compression. This can also reduce the consumption of blockchain storage resources.
[0065] S202: Query the client's identity certificate from the smart contract based on the identity identifier.
[0066] S203: If the client's identity certificate is found in the smart contract, and it is determined from the identity certificate that the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain, then execute the transaction operation corresponding to the transaction data on the blockchain.
[0067] In steps S202 and S203, the client's identity certificate can be queried from the smart contract based on the identity identifier to determine whether the client's identity certificate can be found in the smart contract. This allows the client to be determined to have the authority to execute the transaction operation corresponding to the transaction data on the blockchain. If the client's identity certificate is not found in the smart contract, it indicates that the client does not have the authority to execute the transaction operation corresponding to the transaction data on the blockchain, and a transaction execution failure result can be returned to the client. If the client's identity certificate can be found in the smart contract, it can be determined whether the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain based on the identity certificate. For example, it can be checked whether the identity certificate records the authority to execute the transaction operation corresponding to the transaction data on the blockchain. If the identity certificate records the authority to execute the transaction operation corresponding to the transaction data on the blockchain, it can be determined that the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain. If the identity certificate does not record the authority to execute the transaction operation corresponding to the transaction data on the blockchain, it can be determined that the client does not have the authority to execute the transaction operation corresponding to the transaction data on the blockchain. Therefore, if the identity certificate determines that the client does not have the authority to execute the transaction operation corresponding to the transaction data on the blockchain, then a transaction execution failure result can be returned to the client. Conversely, if the identity certificate determines that the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain, then the transaction operation corresponding to the transaction data can be executed.
[0068] In one implementation, the nodes described above can determine whether the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain based on the identity certificate. Alternatively, a consensus node can further determine whether the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain. For example, after a node (which can be a consensus node or a non-consensus node) determines that the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain based on the identity certificate, the consensus node can then reach a consensus to determine whether the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain based on the consensus data.
[0069] Optionally, the specific implementation method for the consensus node to determine whether a client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain can be described as follows. After the node determines that the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain based on the identity certificate, it can also send the client's identity identifier and transaction data to the consensus node in the blockchain network, so that the consensus node in the blockchain network can reach a consensus on whether the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain. The specific implementation method for the consensus node to determine whether the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain can refer to the above description of the node determining whether the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain, and will not be repeated here. After the consensus node determines whether the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain, it can return consensus data to the node. This consensus data can include consensus data determining that the client has the authority to execute the transaction operation on the blockchain, or consensus data determining that the client does not have the authority to execute the transaction operation on the blockchain.
[0070] Nodes can receive consensus data returned by consensus nodes in the blockchain network to determine whether a client has the authority to execute transactions on the blockchain. For example, if the consensus data indicates that more than a target proportion of consensus nodes in the blockchain network have the authority to execute transactions, then a consensus result indicating that the client has the authority to execute transactions is obtained. In other words, the number of consensus nodes corresponding to the consensus data that does not determine the client's authority to execute transactions can be detected first, and then the ratio between this number and the total number of consensus nodes in the blockchain network can be determined. If this ratio exceeds the target ratio, then a consensus result indicating that the client has the authority to execute transactions is obtained. The target ratio can be preset. For example, assuming the number of consensus nodes in the blockchain network is N (N can be greater than or equal to 2), the target ratio can be set to N / 2 or N*2 / 3, etc.
[0071] In one implementation, the transaction data may also include a designing key. Then, if the client's identity certificate is retrieved from the smart contract, the client's designing key can be obtained from the identity certificate to check if it matches the designing key included in the transaction data. If the designing key obtained from the identity certificate matches the designing key included in the transaction data, the client can be deemed to have the authority to execute the transaction operation corresponding to the transaction data on the blockchain, and the corresponding transaction operation can be executed. If the designing key obtained from the identity certificate does not match the designing key included in the transaction data, a transaction execution failure result can be returned to the client.
[0072] In one implementation, after a node executes the transaction operation corresponding to the transaction data on the blockchain, the execution result of the transaction operation can be encapsulated into a second block (or the transaction data and the execution result of the transaction operation can be encapsulated together into a second block) and stored in a block on the blockchain. When a node stores the second block on the blockchain, it can also broadcast the second block to other nodes, so that the other nodes can add the second block to their own maintained blockchains, thereby synchronizing the blockchains maintained by all nodes.
[0073] Optionally, when a node broadcasts the second block to the remaining nodes in the blockchain network, it can also broadcast the second block to the consensus nodes in the blockchain network. This allows the consensus nodes to verify the execution result of the transaction operation in the second block, confirming that the execution result is valid. After successful consensus verification, the second block can be added to its respective maintained blockchain, and the result indicating successful consensus verification can also be sent to the node that initiated the broadcast. For example, if the number of results indicating successful consensus verification received by the node that initiated the broadcast exceeds a specified proportion, then the consensus verification is considered successful, and the execution result of the transaction operation can be written into the blockchain. The specified proportion can be preset. For example, assuming the number of consensus nodes in the blockchain network is N (N can be greater than or equal to 2), the target proportion can be set to N / 2, N*2 / 3, or N*3 / 4, etc.
[0074] In this embodiment, the client's transaction data can be obtained. This transaction data can carry the client's identity identifier. The client's identity certificate can then be queried from the smart contract based on the identity identifier. If the client's identity certificate can be found in the smart contract, and the identity certificate confirms that the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain, then the transaction operation corresponding to the transaction data can be executed on the blockchain. By implementing the above method, the mapping relationship between the identity identifier carried in the transaction data and the identity certificate recorded in the smart contract can be used to determine the client's corresponding identity certificate and perform transaction operations according to the permissions indicated in the identity certificate, thereby improving the security of data processing on the blockchain. Furthermore, carrying only the identity identifier in the transaction data, while ensuring that the corresponding identity certificate can be obtained, reduces the amount of transaction data compared to carrying the complete identity certificate, achieving a certain degree of data compression. This facilitates faster transmission of transaction data and reduces the consumption of blockchain storage resources caused by carrying the complete identity certificate.
[0075] Please see Figure 4 , Figure 4 This is a flowchart illustrating a blockchain-based data processing method provided in an embodiment of this application. The data processing method in this embodiment is mainly described from the node side, such as... Figure 4 As shown, this blockchain-based data processing method may include:
[0076] S401: Obtain the client's transaction data, which carries the client's identity identifier.
[0077] In one implementation, the transaction may also include signature data, which can be obtained by signing the transaction data using the client's signature key. Therefore, after obtaining the client's transaction data, the signature data included in the transaction data needs to be verified. If the signature data verification passes, step S402 can be executed.
[0078] Optionally, the specific implementation method for verifying the signature data can be described as follows: The signature data can be designed using the designing key corresponding to the signature key to obtain the designed data. The designing key can be obtained from pre-stored data on the blockchain, the decryption key included in the transaction data, or other methods, which are not limited in this application. After obtaining the designed data, the signature verification result can be determined based on the designed data and the transaction data. This signature verification result can include indicating that the signature data verification passed or failed. For example, it can be determined whether the designed data and the transaction data are consistent. If they are consistent, the signature verification result indicates that the signature data verification passed; if they are inconsistent, the signature verification result indicates that the signature data verification failed. If the signature verification result indicates that the signature data verification passed, subsequent step S402 can be executed. If the signature verification result indicates that the signature data verification failed, a transaction execution failure result can be returned to the client.
[0079] For the specific implementation of step S401, please refer to the detailed description of step S201 in the above embodiment, which will not be repeated here.
[0080] S402: Query the client's identity certificate from the smart contract data stored in the cache based on the identity identifier.
[0081] In one implementation, to reduce storage overhead, this application can also utilize a caching mechanism to record the client's identity certificate on the smart contract. The client's identity certificate may be recorded in the smart contract data stored in the cache. Therefore, the existence of the client's identity certificate can be queried from the smart contract data stored in the cache based on the identity identifier. The smart contract data stored in the cache may include some client identity certificates. If the client's identity certificate can be found in the smart contract data stored in the cache, it can be determined whether the client has the permission to execute the transaction operation corresponding to the transaction data on the blockchain. For example, it can be checked whether the identity certificate records the permission to execute the transaction operation corresponding to the transaction data on the blockchain. If the identity certificate records the permission to execute the transaction operation corresponding to the transaction data on the blockchain, it can be determined that the client has the permission to execute the transaction operation corresponding to the transaction data on the blockchain, and the transaction operation corresponding to the transaction data on the blockchain can be executed. If the identity certificate does not record the permission to execute the transaction operation corresponding to the transaction data on the blockchain, it can be determined that the client does not have the permission to execute the transaction operation corresponding to the transaction data on the blockchain, and the transaction execution failure result can be returned to the client.
[0082] S403: If the client's identity certificate is not found in the smart contract data stored in the cache, then the client's identity certificate is retrieved from the smart contract stored in memory based on the identity identifier.
[0083] In one implementation, if the client's identity certificate cannot be found in the smart contract data stored in the cache, the client's identity certificate can be retrieved from the smart contract stored in memory based on the identity identifier.
[0084] As described above, the client's identity certificate can be queried from the cache first. If the certificate is not found in the cache, it can then be retrieved from memory. Therefore, the caching mechanism avoids reading data from memory every time it's necessary to determine if the client has the necessary permissions to execute transactions on the blockchain. This improves the speed of transaction permission verification, thereby increasing transaction execution speed and improving the overall throughput of the blockchain.
[0085] In one implementation, if the client's identity certificate is retrieved from a smart contract stored in memory, the client's identity certificate can be stored in a cache, thereby improving the speed of permission verification in subsequent transaction data initiated from the same client, and thus improving the speed of transaction execution.
[0086] S404: If the client's identity certificate is found in the smart contract stored in memory, and it is determined from the identity certificate that the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain, then execute the transaction operation corresponding to the transaction data on the blockchain.
[0087] The specific implementation of step S404 can be found in the detailed description of step S203 in the above embodiment, and will not be repeated here.
[0088] In this embodiment, the client's transaction data can be obtained. This transaction data may carry the client's identity identifier. The client's identity certificate can then be retrieved from the cached smart contract data based on the identity identifier. If the client's identity certificate is not found in the cached smart contract data, it can be retrieved from the smart contract stored in memory based on the identity identifier. If the client's identity certificate is found in the smart contract stored in memory, and the identity certificate indicates that the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain, then the transaction operation corresponding to the transaction data can be executed on the blockchain. By implementing the above method, the mapping relationship between the identity identifier carried in the transaction data and the identity certificate recorded in the smart contract can be used to determine the client's corresponding identity certificate and perform transaction operations according to the permissions indicated in the identity certificate, thereby improving the security of data processing on the blockchain. Furthermore, carrying only the identity identifier in the transaction data, compared to carrying the complete identity certificate, can reduce the amount of transaction data, achieving a certain degree of data compression, which is beneficial for the rapid transmission of transaction data and also reduces the consumption of blockchain storage resources caused by carrying the complete identity certificate. At the same time, by using a caching mechanism, that is, storing identity certificates in memory, it is not necessary to read data from memory every time, which can effectively improve the transaction execution speed.
[0089] Please see Figure 5 This is a schematic diagram of a blockchain-based data processing device provided in an embodiment of this application. The data processing device described in this embodiment includes:
[0090] The acquisition unit 501 is used to acquire transaction data from the client, the transaction data carrying the client's identity identifier, the identity identifier being determined based on the client's identity certificate;
[0091] Query unit 502 is used to query the client's identity certificate from the smart contract based on the identity identifier;
[0092] The execution unit 503 is configured to execute the transaction operation corresponding to the transaction data on the blockchain if the client's identity certificate is found in the smart contract and it is determined from the identity certificate that the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain.
[0093] In one implementation, the query unit 502 is specifically used for:
[0094] The client's identity certificate is retrieved from the smart contract data stored in the cache based on the identity identifier.
[0095] In one implementation, the query unit 502 is further configured to:
[0096] If the client's identity certificate is not found in the smart contract data stored in the cache, then the client's identity certificate is retrieved from the smart contract stored in memory based on the identity identifier.
[0097] In one implementation, the query unit 502 is further configured to:
[0098] If the client's identity certificate is found in the smart contract stored in the memory, then the client's identity certificate is stored in the cache.
[0099] In one implementation, the transaction data further includes signature data, which is obtained by signing the transaction data using the client's signature key; the acquisition unit 501 is further configured to:
[0100] Using the designing key corresponding to the signing key, the signature data is designed to obtain designed data;
[0101] The signature verification result of the signature data is determined based on the designed data and the transaction data;
[0102] If the signature verification result indicates that the signature data verification is successful, then the step of querying the client's identity certificate from the smart contract based on the identity identifier is executed.
[0103] In one implementation, the transaction data further includes the designing key; the execution unit 503 is specifically used for:
[0104] If the client's identity certificate is found in the smart contract, then the client's designing key is obtained from the identity certificate.
[0105] If the designing key obtained from the ID card matches the designing key included in the transaction data, and the client is determined to have the authority to execute the transaction operation corresponding to the transaction data on the blockchain based on the identity certificate, then the transaction operation corresponding to the transaction data is executed on the blockchain.
[0106] In one implementation, the execution unit 503 is further configured to:
[0107] The transaction data is sent to the consensus nodes in the blockchain network so that the consensus nodes in the blockchain network can reach a consensus on whether the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain.
[0108] Receive consensus data returned by consensus nodes in the blockchain network;
[0109] If, based on the consensus data, it is detected that more than a target proportion of consensus nodes in the blockchain network determine that the client has the authority to execute the transaction operation on the blockchain, then a consensus result is obtained indicating that the client has the authority to execute the transaction operation on the blockchain.
[0110] In one implementation, the identity identifier includes a hash value obtained by hashing the client's identity certificate; the smart contract records the identity certificates of one or more clients and the hash values corresponding to the identity certificates.
[0111] It is understood that the division of units in this embodiment is illustrative and merely a logical functional division; in actual implementation, there may be other division methods. The functional units in this embodiment can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated units can be implemented in hardware or as software functional units.
[0112] Please see Figure 6 This is a schematic diagram of the structure of a data processing device provided in an embodiment of this application. The data processing device described in this embodiment includes: a processor 601, a memory 602, and a network interface 603. The processor 601, the memory 602, and the network interface 603 can exchange data.
[0113] The processor 601 described above can be a Central Processing Unit (CPU), but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.
[0114] The aforementioned memory 602 may include read-only memory and random access memory, and provides program instructions and data to the processor 601. A portion of the memory 602 may also include non-volatile random access memory. The processor 601 executes the program instructions by calling them:
[0115] Obtain the client's transaction data, which carries the client's identity identifier, determined based on the client's identity certificate;
[0116] The client's identity certificate is retrieved from the smart contract based on the identity identifier;
[0117] If the client's identity certificate is found in the smart contract, and it is determined from the identity certificate that the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain, then the transaction operation corresponding to the transaction data is executed on the blockchain.
[0118] In one implementation, the processor 601 is specifically used for:
[0119] The client's identity certificate is retrieved from the smart contract data stored in the cache based on the identity identifier.
[0120] In one implementation, the processor 601 is further configured to:
[0121] If the client's identity certificate is not found in the smart contract data stored in the cache, then the client's identity certificate is retrieved from the smart contract stored in memory based on the identity identifier.
[0122] In one implementation, the processor 601 is further configured to:
[0123] If the client's identity certificate is found in the smart contract stored in the memory, then the client's identity certificate is stored in the cache.
[0124] In one implementation, the transaction data further includes signature data, which is obtained by signing the transaction data using the client's signature key; the processor 601 is further configured to:
[0125] Using the designing key corresponding to the signing key, the signature data is designed to obtain designed data;
[0126] The signature verification result of the signature data is determined based on the designed data and the transaction data;
[0127] If the signature verification result indicates that the signature data verification is successful, then the step of querying the client's identity certificate from the smart contract based on the identity identifier is executed.
[0128] In one implementation, the transaction data further includes the designing key; the processor 601 is specifically used for:
[0129] If the client's identity certificate is found in the smart contract, then the client's designing key is obtained from the identity certificate.
[0130] If the designing key obtained from the ID card matches the designing key included in the transaction data, and the client is determined to have the authority to execute the transaction operation corresponding to the transaction data on the blockchain based on the identity certificate, then the transaction operation corresponding to the transaction data is executed on the blockchain.
[0131] In one implementation, the processor 601 is further configured to:
[0132] The transaction data is sent to the consensus nodes in the blockchain network so that the consensus nodes in the blockchain network can reach a consensus on whether the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain.
[0133] Receive consensus data returned by consensus nodes in the blockchain network;
[0134] If, based on the consensus data, it is detected that more than a target proportion of consensus nodes in the blockchain network determine that the client has the authority to execute the transaction operation on the blockchain, then a consensus result is obtained indicating that the client has the authority to execute the transaction operation on the blockchain.
[0135] In one implementation, the identity identifier includes a hash value obtained by hashing the client's identity certificate; the smart contract records the identity certificates of one or more clients and the hash values corresponding to the identity certificates.
[0136] This application also provides a computer storage medium storing program instructions, which, when executed, may include, for example... Figure 2 or Figure 4 Some or all of the steps of the blockchain-based data processing method in the corresponding embodiments.
[0137] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0138] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc.
[0139] This application also provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. The server's processor reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the server to perform the steps described in the embodiments of the above methods.
[0140] The foregoing has provided a detailed description of a blockchain-based data processing method, apparatus, device, and medium. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A data processing method based on blockchain, characterized in that, The method includes: Obtain the client's transaction data, which carries the client's identity identifier, determined based on the client's identity certificate; Using the identity identifier as a key, the client's identity certificate is queried from the smart contract. The smart contract stores the client's identity identifier and identity certificate in key-value pairs. If the client's identity certificate is found in the smart contract, and the identity certificate records the permission to execute the transaction operation corresponding to the transaction data on the blockchain, then the transaction data is sent to the consensus node in the blockchain network so that the consensus node in the blockchain network can reach a consensus on whether the client has the permission to execute the transaction operation corresponding to the transaction data on the blockchain. Receive consensus data returned by consensus nodes in the blockchain network; If, based on the consensus data, it is detected that more than a target proportion of consensus nodes in the blockchain network determine that the client has the authority to execute the transaction operation on the blockchain, then a consensus result is obtained indicating that the client has the authority to execute the transaction operation on the blockchain, and the transaction operation corresponding to the transaction data is executed on the blockchain.
2. The method according to claim 1, characterized in that, The step of querying the client's identity certificate from the smart contract based on the identity identifier includes: The client's identity certificate is retrieved from the smart contract data stored in the cache based on the identity identifier.
3. The method according to claim 2, characterized in that, The method further includes: If the client's identity certificate is not found in the smart contract data stored in the cache, then the client's identity certificate is retrieved from the smart contract stored in memory based on the identity identifier.
4. The method according to claim 3, characterized in that, The method further includes: If the client's identity certificate is found in the smart contract stored in the memory, then the client's identity certificate is stored in the cache.
5. The method according to any one of claims 1-4, characterized in that, The transaction data also includes signature data, which is obtained by signing the transaction data using the client's signature key; the method further includes: Using the designing key corresponding to the signing key, the signature data is designed to obtain designed data; The signature verification result of the signature data is determined based on the designed data and the transaction data; If the signature verification result indicates that the signature data verification is successful, then the step of querying the client's identity certificate from the smart contract based on the identity identifier is executed.
6. The method according to claim 5, characterized in that, The transaction data also includes the designature key; if the client's identity certificate is found in the smart contract, and it is determined from the identity certificate that the client has the authority to execute the transaction operation corresponding to the transaction data on the blockchain, then executing the transaction operation corresponding to the transaction data on the blockchain includes: If the client's identity certificate is found in the smart contract, then the client's designing key is obtained from the identity certificate. If the designing key obtained from the ID card matches the designing key included in the transaction data, and the client is determined to have the authority to execute the transaction operation corresponding to the transaction data on the blockchain based on the identity certificate, then the transaction operation corresponding to the transaction data is executed on the blockchain.
7. The method according to claim 1, characterized in that, The identity identifier includes a hash value obtained by hashing the client's identity certificate; the smart contract records the identity certificates of one or more clients and the corresponding hash values of the identity certificates.
8. A data processing device based on blockchain, characterized in that, include: The acquisition unit is used to acquire transaction data from the client, the transaction data carrying the client's identity identifier, which is determined based on the client's identity certificate; The query unit is used to query the client's identity certificate from the smart contract using the identity identifier as a key. The smart contract stores the client's identity identifier and identity certificate in key-value pairs. An execution unit is configured to: if the client's identity certificate is found in the smart contract, and the identity certificate records the permission to execute the transaction operation corresponding to the transaction data on the blockchain, then send the transaction data to the consensus node in the blockchain network, so that the consensus node in the blockchain network can reach a consensus on whether the client has the permission to execute the transaction operation corresponding to the transaction data on the blockchain. Receive consensus data returned by consensus nodes in the blockchain network; if the consensus data detects that more than a target proportion of consensus nodes in the blockchain network determine that the client has the authority to execute the transaction operation on the blockchain, then obtain a consensus result indicating that the client has the authority to execute the transaction operation on the blockchain, and execute the transaction operation corresponding to the transaction data on the blockchain.
9. A data processing device, characterized in that, The device includes a processor, a memory, and a network interface, which are interconnected. The memory is used to store a computer program, which includes program instructions. The processor is configured to invoke the program instructions to execute the method as described in any one of claims 1-7.
10. A computer storage medium, characterized in that, The computer storage medium stores a computer program, the computer program including program instructions, which, when executed by a processor, cause a computer device having the processor to perform the method according to any one of claims 1-7.
11. A computer program product, characterized in that, The computer program product includes computer instructions stored in a computer-readable storage medium, a processor of a data processing device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the data processing device to perform the method according to any one of claims 1-7.
Citation Information
Patent Citations
Business processing method, device and system based on block chain
CN111311254A
Transaction verification method and device in block chain, node equipment and storage medium
CN111985929A