Data processing method and device based on block chain, equipment and storage medium

By storing encrypted business contracts in the privacy contract factory and using key management services to decrypt, the problem that blockchain cannot protect business data and business algorithms at the same time is solved, and the dual protection of smart contracts is achieved, ensuring the data and algorithms Privacy.

CN119150368APending Publication Date: 2024-12-17TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310725457.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-16
Publication Date
2024-12-17

AI Technical Summary

Technical Problem

Existing blockchain privacy protection solutions cannot protect business data while also protecting business algorithms, especially the contract code of smart contracts.

Method used

By storing encrypted business contracts in the privacy contract factory and using the key provided by the key management service for decryption, the smart contract virtual machine is called to execute the contract code, thereby achieving dual protection of business data and business algorithms.

Benefits of technology

It realizes that without leaking the business contract key, accurately responds to client data processing requests, ensures the privacy of business data and business algorithms, and broadens the application scenarios of blockchain.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119150368A_ABST
    Figure CN119150368A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a block chain-based data processing method and device, equipment and a storage medium, which are at least applied to the field of block chains and the field of smart contracts, and the method comprises the following steps: in response to receiving a data processing request sent by a client, obtaining a calling parameter from the data processing request; if the smart contract corresponding to the data processing request is a service contract in a privacy contract factory, querying a target service contract corresponding to the data processing request from the privacy contract factory based on a calling parameter; querying a service contract key corresponding to the target service contract from a key management service; decrypting the target business contract by using the business contract key to obtain a contract code of the target business contract; and calling the intelligent contract virtual machine to execute the contract code to obtain a data processing result corresponding to the data processing request. According to the method and the device, the service algorithm can be protected while the service data is protected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of blockchain technology, and are related to but not limited to a blockchain-based data processing method, device, equipment, and storage medium. Background Art

[0002] The blockchain privacy protection schemes in related technologies mainly include: privacy protection schemes based on trusted execution environment (TEE), hardware such as cryptographic machines, and privacy protection schemes based on zero-knowledge proof.

[0003] However, the blockchain privacy protection scheme in the related technology cannot protect the business algorithm (ie, contract code) while protecting the business data (ie, contract data). Summary of the invention

[0004] The embodiments of the present application provide a blockchain-based data processing method, apparatus, device, and storage medium, which can be applied at least to the blockchain field and the smart contract field, and can protect business algorithms while protecting business data.

[0005] The technical solution of the embodiment of the present application is implemented as follows:

[0006] An embodiment of the present application provides a blockchain-based data processing method, the method comprising: in response to receiving a data processing request sent by a client, obtaining a calling parameter from the data processing request; if the smart contract corresponding to the data processing request is a business contract in a privacy contract factory, querying the target business contract corresponding to the data processing request from the privacy contract factory based on the calling parameter; the privacy contract factory stores multiple encrypted business contracts; querying the business contract key corresponding to the target business contract from the key management service; using the business contract key to decrypt the target business contract to obtain the contract code of the target business contract; calling the smart contract virtual machine to execute the contract code to obtain a data processing result corresponding to the data processing request.

[0007] An embodiment of the present application provides a blockchain-based data processing device, which includes: a parameter acquisition module, which is used to obtain call parameters from the data processing request in response to receiving a data processing request sent by a client; a business contract query module, which is used to query the target business contract corresponding to the data processing request from the privacy contract factory based on the call parameters if the smart contract corresponding to the data processing request is a business contract in a privacy contract factory; the privacy contract factory stores multiple encrypted business contracts; a key query module, which is used to query the business contract key corresponding to the target business contract from the key management service; a decryption module, which is used to decrypt the target business contract using the business contract key to obtain the contract code of the target business contract; and a code execution module, which is used to call the smart contract virtual machine to execute the contract code to obtain a data processing result corresponding to the data processing request.

[0008] In some embodiments, the data processing request includes client input parameters and signature information signed using the client's private key; the parameter acquisition module is also used to: in response to receiving the data processing request sent by the client, verify the signature information in the data processing request to obtain a signature verification result; in response to the signature verification result being verification passed, extract the call parameters from the client input parameters.

[0009] In some embodiments, the key management service corresponds to a key management contract, which is a system contract on the blockchain; the key management contract is used to store encrypted keys and address information of authorized users of each key; wherein the encrypted keys include the business contract keys; the key management contract includes at least one of the following functions: a method for generating each of the keys, a method for obtaining the keys, an encrypted data type, a decrypted data type, and authorization information for authorizing the use of the keys; by executing the contract code of the key management contract, the key management service can implement at least one of the functions.

[0010] In some embodiments, the device also includes: an acquisition module, used to obtain the contract code of the key management contract and the service key of the key management service; an encryption module, used to encrypt the contract code of the key management contract using the service key to obtain the encrypted contract code; a storage module, used to store the encrypted contract code in the target blockchain node of the blockchain; a calling module, used to start the target blockchain node when the business contract key corresponding to the target business contract is queried from the key management service, and when the target blockchain node is started, the target blockchain node calls the key management service to decrypt the encrypted contract code to obtain the decrypted contract code of the key management contract; the calling module is also used to call the smart contract virtual machine to execute the contract code of the key management contract to implement the functions in the key management contract.

[0011] In some embodiments, the privacy contract factory is a system contract on the blockchain; the privacy contract factory is used to store the contract code of the encrypted business contract, and to call the key management contract to decrypt the encrypted contract code and contract request parameters of the business contract to obtain the decrypted contract code and contract request parameters of the business contract; the business contract is a contract customized by the client of the business party.

[0012] In some embodiments, the device also includes: a privacy contract factory deployment module, which is used to deploy the privacy contract factory in the following manner: develop the source code of the privacy contract factory through a blockchain development node; deploy the source code of the privacy contract factory to the blockchain; develop the source code of the key management contract through the blockchain development node; use the master key of the key management service to encrypt the source code of the key management contract to obtain the encrypted source code; call the privacy contract factory on the blockchain and deploy the encrypted source code to the blockchain.

[0013] In some embodiments, the device also includes: a business contract deployment module, used to deploy the business contract in the following manner: obtaining the contract code of the business contract developed by the business development client; calling the key management contract to obtain the business contract key; using the business contract key to encrypt the contract code of the business contract to obtain the encrypted business contract code; calling the privacy contract factory to deploy the encrypted business contract code to the blockchain.

[0014] In some embodiments, the acquisition module is also used to obtain the chain key of the blockchain; the calling module is also used to call the root key of the key management service, encrypt the chain key, and obtain the encrypted chain key; the storage module is also used to store the encrypted chain key in the blockchain node of the blockchain; wherein, the chain key is used to generate the business contract key.

[0015] In some embodiments, the calling module is also used to call the key management service to decrypt the encrypted chain key and the encrypted key management contract to obtain the chain key and the key management contract; the device also includes: a reading module, used to read the encrypted system privacy contract code from the ledger of the blockchain; the decryption module is also used to use the chain key to decrypt the encrypted system privacy contract code to obtain the system privacy contract code; the system privacy contract code includes the key management contract and other system contracts whose source code cannot be made public; a loading module, used to load the system privacy contract code into the contract virtual machine of the blockchain to implement the code logic of the system privacy contract code.

[0016] In some embodiments, the key query module is also used to: obtain the business code hash value and the business user address of the target business contract; use the business code hash value and the business user address as keys to query the value corresponding to the key from the key management service; wherein the value corresponding to the key constitutes the business contract key corresponding to the target business contract.

[0017] In some embodiments, the acquisition module is also used to obtain the chain key of the blockchain; the acquisition module is also used to obtain the business code hash value, the business user address and the current block hash value of the blockchain for any business contract in the privacy contract factory; the device also includes: a business contract key generation module, which is used to generate the business contract key of the business contract based on the chain key, the business code hash value of the business contract, the business user address and the current block hash value of the blockchain; using the business code hash value of the business contract and the business user address as keys and the business contract key as a value to generate a key-value pair to be stored; the storage module is also used to store the key-value pair to be stored in the key management service.

[0018] In some embodiments, the acquisition module is also used to obtain the business public key corresponding to the target business contract if the data processing request is a transaction request; the encryption module is also used to encrypt the data processing result using the business public key to obtain a first encrypted data processing result; the storage module is also used to save the first encrypted data processing result to the ledger of the blockchain; the acquisition module is also used to obtain the business user public key corresponding to the target business contract if the data processing request is a query request; the encryption module is also used to encrypt the data processing result using the business user public key to obtain a second encrypted data processing result; the device also includes: a return module, used to return the second encrypted data processing result to the client.

[0019] An embodiment of the present application provides an electronic device, comprising: a memory for storing executable instructions; and a processor for implementing the above-mentioned blockchain-based data processing method when executing the executable instructions stored in the memory.

[0020] An embodiment of the present application provides a computer program product or a computer program, wherein the computer program product or the computer program includes executable instructions, and the executable instructions are stored in a computer-readable storage medium; when a processor of an electronic device reads the executable instructions from the computer-readable storage medium and executes the executable instructions, the above-mentioned blockchain-based data processing method is implemented.

[0021] An embodiment of the present application provides a computer-readable storage medium storing executable instructions for causing a processor to execute the executable instructions to implement the above-mentioned blockchain-based data processing method.

[0022] The embodiment of the present application has the following beneficial effects: if the smart contract corresponding to the data processing request sent by the client is a business contract in the privacy contract factory, then the target business contract corresponding to the data processing request is queried from the privacy contract factory based on the call parameters; wherein the privacy contract factory stores multiple encrypted business contracts; then, the business contract key corresponding to the target business contract is queried from the key management service; thereby the target business contract is decrypted using the business contract key to obtain the contract code of the target business contract; finally, the smart contract virtual machine is called to execute the contract code to obtain the data processing result corresponding to the data processing request, thereby completing the accurate response to the client's data processing request. In the embodiment of the present application, since the business contract is encrypted and stored in the privacy contract factory, the business contract key is stored in the key management service. In this way, through the privacy contract factory and the key management service, it is possible to protect the business data while also protecting the business algorithm. That is to say, the business contract key used to encrypt the business contract is stored through the key management service, so that not only the contract data of the business contract can be protected based on the business contract key, but also the contract code of the business contract can be protected. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 is a structural diagram of a data processing system provided in an embodiment of the present application;

[0024] Figure 2 This is an architecture diagram of the blockchain system provided by the embodiment of the present application;

[0025] Figure 3 This is an optional structural diagram of a distributed system provided in an embodiment of the present application;

[0026] Figure 4 It is an optional schematic diagram of a block structure provided in an embodiment of the present application;

[0027] Figure 5 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0028] Figure 6 This is an optional flowchart of a blockchain-based data processing method provided in an embodiment of the present application;

[0029] Figure 7 This is another optional flowchart of the blockchain-based data processing method provided in the embodiment of the present application;

[0030] Figure 8 It is a schematic diagram of the implementation process of the deployment method of the privacy contract factory provided in the embodiment of the present application;

[0031] Fig. 9It is a schematic diagram of the implementation process of the deployment method of the business contract provided in the embodiment of the present application;

[0032] Fig.10 It is a schematic diagram of the implementation process of the business contract key generation method provided in the embodiment of the present application;

[0033] Fig.11 is a system architecture diagram of a data processing system provided in an embodiment of the present application;

[0034] Fig.12 is a schematic diagram of a privacy contract factory provided in an embodiment of the present application;

[0035] Fig.13 is a schematic diagram of a key management contract provided in an embodiment of the present application;

[0036] Fig.14 is a schematic diagram of a business contract provided in an embodiment of the present application;

[0037] Fig.15 This is a use case diagram of a privacy contract factory and a key contract provided in an embodiment of the present application;

[0038] Fig.16 It is a business program development use case diagram provided by an embodiment of the present application;

[0039] Fig.17 It is a business privacy contract use case diagram provided in an embodiment of the present application;

[0040] Fig.18 It is a flow chart of the chain root key generation method provided in an embodiment of the present application;

[0041] Fig.19 This is a schematic diagram of the system privacy contract loading process provided by an embodiment of the present application;

[0042] Fig. 20 This is a schematic diagram of the new business contract key generation process provided by the embodiment of the present application;

[0043] Fig.21 It is a schematic diagram of the deployment process of a new business contract provided in an embodiment of the present application;

[0044] Fig. 22 This is a schematic diagram of the business contract calling process provided by the embodiment of the present application;

[0045] Fig.23 It is a flowchart of setting a service authorization access party provided in an embodiment of the present application;

[0046] Fig.24 It is a flow chart of the business authorization party calling a business contract provided by an embodiment of the present application. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.

[0048] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict. Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meaning as those commonly understood by those skilled in the art of the technical field of the embodiments of the present application. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.

[0049] Before explaining the blockchain-based data processing method in the embodiment of the present application, the professional terms involved in the embodiment of the present application are first explained.

[0050] (1) P2P peer-to-peer communication: Peer-to-peer communication is a communication mode in which two nodes communicate directly, sending and receiving messages to each other without going through an intermediate node or proxy. In peer-to-peer communication, the sender sends a message to the receiver, and the receiver directly receives and processes the message. Peer-to-peer communication is usually associated with a client-server architecture, in which the client node sends a request to the server node, and the server node responds to the request and sends the response result back to the client node. This communication mode is widely used in many applications, for example, a web browser sends a Hyper Text Transfer Protocol (HTTP) request to a web server, and an email client sends a Simple Mail Transfer Protocol (SMTP) request to a mail server.

[0051] Peer-to-peer communication is usually a real-time communication mode because two nodes can exchange messages directly without the help of intermediate nodes or agents. This communication mode can provide low latency and high bandwidth, so it is widely used in many real-time applications, such as real-time video and audio communication, online games, and financial trading systems.

[0052] (2) Blockchain privacy protection: refers to taking measures to protect the privacy of data and transactions on the blockchain to prevent unauthorized access or leakage. These measures include the use of encryption technology, anonymization technology, scalability solutions and smart contracts. Among them, encryption technology is the most commonly used way to protect privacy. Encryption technology can encrypt data and transaction information so that only authorized people can access it. Anonymization technology protects privacy by hiding the identities of transaction participants, while smart contracts can help ensure the legitimacy of transactions and protect privacy.

[0053] (3) Digital signature: It is a technology used to ensure the authenticity, integrity and non-repudiation of digital documents (such as e-mails, electronic contracts, software, etc.). The digital signature process includes the following steps: First, create a message digest: the original data is used to generate a message digest using a hash function to ensure the integrity of the data. Then, perform private key encryption: the creator uses his own private key to encrypt the message digest to generate a digital signature. Then, verify through the public key: the recipient uses the creator's public key to decrypt the digital signature and obtain the message digest. Finally, verify the digest: the recipient uses the same hash function on the original data to generate a message digest, and compares it with the decrypted digest to verify the integrity of the data.

[0054] If the digital signature is verified, the recipient can trust the authenticity and integrity of the original data, and the creator cannot deny the source and content of the data. Digital signature technology is widely used in e-commerce, digital certificates, digital copyright and other fields.

[0055] (4) Key Encryption Key (KEK): Also known as the key exchange algorithm, it refers to the algorithm used to securely exchange keys between communicating parties. The communicating parties use asymmetric encryption algorithms to encrypt and decrypt data, but the performance of asymmetric encryption algorithms is slow, so they cannot be directly used to encrypt large amounts of data during communication. Therefore, the communicating parties need to use a secure method to exchange the keys used in the symmetric encryption algorithm. This process is called the Key Encryption Key.

[0056] In the key encryption key algorithm, the two communicating parties first negotiate a symmetric key for encrypting the data during the communication process. This key can be generated using a random number generator. Then, the two communicating parties use the other party's public key to encrypt the symmetric key. The encrypted symmetric key can only be decrypted using the corresponding private key. In this way, the two communicating parties have safely exchanged symmetric keys and can use symmetric encryption algorithms to encrypt data during the communication process.

[0057] KEK is usually a longer and more secure key used to encrypt and protect the Data Encryption Key (DEK). DEK is a symmetric key used to encrypt and decrypt actual data. In encrypted communications, KEK is usually used to encrypt DEK, and then DEK is used to encrypt and decrypt actual data in the communication. This method can improve the security of communications because DEK can be changed frequently while KEK can remain unchanged. If DEK is exposed or leaked, the communicating parties only need to change DEK without changing KEK, which can reduce the number of times the key is renegotiated between the communicating parties.

[0058] (5) Symmetric encryption: It is a type of encryption, also known as key encryption. In symmetric encryption, the sender and receiver use the same key to encrypt and decrypt data. The advantage of symmetric encryption is that it is fast and suitable for encryption and decryption of large amounts of data. But its disadvantage is that the key needs to be shared between the sender and the receiver, so the security of the key needs to be ensured. If the key is leaked, the confidentiality of the encrypted data will be destroyed. Common symmetric encryption algorithms include DES, 3DES, AES, etc. Among them, AES is one of the most commonly used symmetric encryption algorithms. It has the advantages of high strength, high speed and versatility, and is widely used in protecting data security.

[0059] (6) Asymmetric encryption: It is a type of encrypted communication, also known as public key encryption. In this method, different keys are used for encryption and decryption, namely public key and private key respectively. The sender uses the public key of the receiver to encrypt the data, and the receiver uses his own private key to decrypt the data. The advantage of asymmetric encryption is that it can ensure the security of the key, because the private key is only known to the receiver and the sender cannot obtain the private key. This method is suitable for encryption and decryption of small amounts of data, such as passwords, digital signatures, and secure identity authentication. At the same time, the disadvantage of asymmetric encryption is that it has high computational complexity and slow speed, and is not suitable for encryption and decryption of large amounts of data. Therefore, in practical applications, asymmetric encryption is usually used in combination with symmetric encryption to balance security and efficiency.

[0060] (7) Factory pattern: It is a creational design pattern that provides a way to create objects without exposing the object creation logic. The factory pattern usually includes a factory class and one or more product classes. The factory class is responsible for creating and returning instances of the product class, while the product class is responsible for implementing specific functions. The factory pattern can separate the code for creating and using objects, thereby improving the maintainability and scalability of the code. Common factory patterns include the simple factory pattern, the factory method pattern, and the abstract factory pattern.

[0061] (8) Key Management Service (KMS): It is a key management service provided by cloud computing service providers. KMS can help users create, store, manage and protect encryption keys to protect the security of applications and data on the cloud. KMS usually provides a series of application programming interfaces (APIs) so that applications can safely use the keys stored in KMS for encryption and decryption operations. KMS supports a variety of encryption algorithms and key lengths, which can be configured according to user needs and security requirements.

[0062] Based on at least one problem existing in the related art, the embodiment of the present application expands the function of the blockchain virtual machine, so that the blockchain virtual machine can encrypt and decrypt smart contracts and contract data, so that the algorithms and business data of the protected business are all subject to enhanced privacy protection. The blockchain has both openness, transparency and privacy protection functions, which greatly broadens the application scenarios of the blockchain. In addition, the blockchain virtual machine also provides a method for generating, storing, using and authorizing the use of on-chain business contract keys, so that business algorithms and data can interact smoothly under encryption.

[0063] The following is a description of the blockchain-based data processing method provided in an embodiment of the present application.

[0064] The data processing method based on blockchain provided by the embodiment of the present application, after receiving the data processing request sent by the client, first, in response to the data processing request, obtains the call parameters from the data processing request; then, if the smart contract corresponding to the data processing request is a business contract in the privacy contract factory, then based on the call parameters, the target business contract corresponding to the data processing request is queried from the privacy contract factory; the privacy contract factory stores multiple encrypted business contracts; and the business contract key corresponding to the target business contract is queried from the key management service; then, the target business contract is decrypted using the business contract key to obtain the contract code of the target business contract; finally, the smart contract virtual machine is called to execute the contract code to obtain the data processing result corresponding to the data processing request. In this way, since the business contract is encrypted and stored in the privacy contract factory, the business contract key is stored in the key management service. In this way, through the privacy contract factory and the key management service, it is possible to protect the business data while protecting the business algorithm. That is to say, the business contract key used to encrypt the business contract is stored through the key management service, so that not only the contract data of the business contract can be protected based on the business contract key, but also the contract code of the business contract can be protected.

[0065] Before explaining the blockchain-based data processing method of the embodiment of the present application, the data processing system provided by the embodiment of the present application is first described.

[0066] The present application embodiment provides a data processing system. Figure 1 is a schematic diagram of the structure of the data processing system provided in the embodiment of the present application, such as Figure 1 As shown, the data processing system 10 includes a client 101 and a blockchain system 102. The client 101 can be a client of any application, such as an instant messaging application, an information recommendation application, a shopping application, etc.; the client 101 is installed on a terminal 100, and the terminal 100 can be a laptop, a tablet computer, a desktop computer, a mobile phone, a portable music player, a personal digital assistant, a dedicated messaging device, a portable gaming device, an intelligent robot, a smart home appliance, a smart car-mounted device, and any other terminal that can install an application and has data transmission and processing functions.

[0067] The blockchain system 102 includes multiple blockchain nodes 1021, wherein a privacy contract factory is deployed on any blockchain node, and a key management service is deployed on another blockchain node. The blockchain node 1021 can receive a data processing request sent by the client 101, and adopt the blockchain-based data processing method provided in the embodiment of the present application to respond to the data processing request of the client 101 to obtain the final data processing result. It should be noted that the multiple blockchain nodes in the blockchain system 102 form the blockchain in the embodiment of the present application.

[0068] When the data processing method based on blockchain of the embodiment of the present application is implemented by the above data processing system, the client 101 sends a data processing request to the blockchain node in the blockchain system 102. The blockchain node obtains the call parameters from the data processing request in response to receiving the data processing request sent by the client; then the smart contract corresponding to the data processing request is judged. If it is judged that the smart contract corresponding to the data processing request is a business contract in the privacy contract factory, the target business contract corresponding to the data processing request is queried from the privacy contract factory based on the call parameters; the privacy contract factory stores multiple encrypted business contracts; the business contract key corresponding to the target business contract is queried from the key management service; then, the target business contract is decrypted using the business contract key to obtain the contract code of the target business contract; finally, the smart contract virtual machine is called to execute the contract code to obtain the data processing result corresponding to the data processing request. After obtaining the data processing result, the blockchain node can feed back the data processing result to the client 101.

[0069] Figure 2 This is an architecture diagram of the blockchain system provided by the embodiment of the present application, such as Figure 2 As shown, the blockchain system 20 consists of a data layer 13, a network layer 14, a consensus layer 15, an incentive layer 16, a contract layer 17 and an application layer 18.

[0070] The data layer 13 encapsulates the chain structure of the underlying data blocks, as well as related asymmetric public and private key data encryption technology and timestamp technology. Among them, the data layer 13 not only encapsulates the chain structure of the identity data blocks of the client and each blockchain node (the identity data block here refers to the data block formed by different types of identity data such as personal identity data, application identity data, device identity data and institutional identity data), but also encapsulates the chain structure of the data blocks of the privacy contract factory and key management service. The data layer 13 is the lowest data structure in the entire blockchain system. The network layer 14 includes distributed networking mechanisms, data dissemination mechanisms and data verification mechanisms. Since a completely P2P networking technology is adopted, it means that the blockchain has an automatic networking function. The consensus layer 15 mainly encapsulates various consensus mechanism algorithms of each node in the blockchain system. The consensus mechanism algorithm is the core technology of blockchain technology, because it determines who will do the bookkeeping, and the bookkeeper's selection method will affect the security and reliability of the entire system. The incentive layer 16 integrates economic factors into the blockchain technology system, mainly including the issuance mechanism and distribution mechanism of economic incentives. The incentive mechanism is often also a game mechanism, which makes more rule-abiding nodes willing to keep accounts. The contract layer 17 mainly encapsulates various scripts, algorithms and smart contracts, and is the basis of the programmable characteristics of the blockchain. The application layer 18 encapsulates various application scenarios and cases of the blockchain. Among them, the data layer, network layer and consensus layer are necessary factors for building blockchain applications, otherwise it cannot be called a real blockchain. The incentive layer, contract layer and application layer are not necessary factors for every blockchain application. Some blockchain applications do not fully contain these three layers.

[0071] In some embodiments, the above blockchain system may also be a distributed system 201 of the blockchain system, see Figure 3 , Figure 3 This is an optional structural diagram of a distributed system 201 provided in an embodiment of the present application, wherein the distributed system 201 may be a distributed node formed by multiple nodes 202 (any form of computing devices in the access network, such as servers, user terminals) and clients 203, and a P2P network is formed between the nodes. The P2P protocol is an application layer protocol running on the Transmission Control Protocol (TCP) protocol. In a distributed system, any machine such as a server or a terminal can join and become a node, and the node includes a hardware layer, an intermediate layer, an operating system layer, and an application layer.

[0072] It should be noted that the node 202 in the distributed system 201 can be a blockchain node that deploys a privacy contract factory, a blockchain node that deploys a key management service, or a blockchain node that executes a data processing method. When the node 202 is a blockchain node that executes a data processing method, the node 202 can be used to receive a data processing request sent by a client, and query the target business contract corresponding to the data processing request from the privacy contract factory based on the call parameters; it can also be used to query the business contract key corresponding to the target business contract from the key management service; and, use the business contract key to decrypt the target business contract to obtain the contract code of the target business contract. When the node 202 is a blockchain node that deploys a privacy contract factory, the node 202 can be used to store the contract code of the encrypted business contract, and to call the key management contract to decrypt the contract code and contract request parameters of the encrypted business contract to obtain the contract code and contract request parameters of the decrypted business contract. When the node 202 is a blockchain node that deploys a key management service, the node 202 can be used to save the encrypted key and the address information of the authorized user of each key.

[0073] See also Figure 3 The functions of each node in the blockchain system shown in the figure are introduced in detail below: 1) Routing, the basic function of the node, used to support communication between nodes. In addition to the routing function, the node can also have the following functions: 2) Application, used to be deployed in the blockchain, to implement specific services according to actual business needs, to record the data related to the implementation of the function to form record data, to carry a digital signature in the record data to indicate the source of the task data, and to send the record data to other nodes in the blockchain system for other nodes to add the record data to the temporary block when they successfully verify the source and integrity of the record data.

[0074] See also Figure 4 , Figure 4 It is an optional schematic diagram of the block structure (Block Structure) provided in an embodiment of the present application. Each block includes the hash value of the transaction record stored in this block (the hash value of this block) and the hash value of the previous block. Each block is connected by the hash value to form a blockchain. In addition, the block may also include information such as the timestamp when the block was generated. Blockchain (Blockchain), essentially a decentralized database, is a string of data blocks generated by cryptographic methods. Each data block contains relevant information for verifying the validity of its information (anti-counterfeiting) and generating the next block. In some embodiments, each block may also include a block header.

[0075] The following describes an exemplary application of a blockchain-based data processing device according to an embodiment of the present application, which is an electronic device for implementing a blockchain-based data processing method. In one implementation, the blockchain-based data processing device (i.e., electronic device) provided in the embodiment of the present application can be implemented as a blockchain node (i.e., the above-mentioned node 202) in a blockchain system, wherein the blockchain node can be a laptop, tablet computer, desktop computer, mobile phone, portable music player, personal digital assistant, dedicated messaging device, portable game device, intelligent robot, smart home appliance, and smart vehicle-mounted device, etc., any terminal with data transmission and processing functions; in another implementation, the blockchain-based data processing device provided in the embodiment of the present application can also be implemented as a server, wherein the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDN, Content Delivery Network), and big data and artificial intelligence platforms. The terminal and the server can be directly or indirectly connected by wired or wireless communication, which is not limited in the embodiment of the present application. Below, an exemplary application in which a blockchain-based data processing device is implemented as a blockchain node and the blockchain node is implemented as a server will be described.

[0076] See also Figure 5 , Figure 5 is a schematic diagram of the structure of an electronic device (ie, an observer node) provided in an embodiment of the present application, Figure 5 The electronic device shown may be a blockchain-based data processing device, which includes: at least one processor 310, a memory 350, at least one network interface 320, and a user interface 330. The various components in the blockchain-based data processing device are coupled together via a bus system 340. It is understood that the bus system 340 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 340 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, in Figure 5 Various buses are labeled as bus system 340 .

[0077] The processor 310 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.

[0078] The user interface 330 includes one or more output devices 331 that enable presentation of media content, and one or more input devices 332 .

[0079] The memory 350 may be removable, non-removable or a combination thereof. Exemplary hardware devices include solid-state memory, hard disk drive, optical disk drive, etc. The memory 350 may optionally include one or more storage devices physically away from the processor 310. The memory 350 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memory. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 350 described in the embodiment of the present application is intended to include any suitable type of memory. In some embodiments, the memory 350 can store data to support various operations, and examples of these data include programs, modules, and data structures or subsets or supersets thereof, as exemplarily described below.

[0080] An operating system 351 includes system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic businesses and processing hardware-based tasks; a network communication module 352 is used to reach other computing devices via one or more (wired or wireless) network interfaces 320. Exemplary network interfaces 320 include: Bluetooth, wireless compatibility certification (WiFi), and Universal Serial Bus (USB), etc.; an input processing module 353 is used to detect one or more user inputs or interactions from one of the one or more input devices 332 and translate the detected inputs or interactions.

[0081] In some embodiments, the device provided in the embodiments of the present application can be implemented in software. Figure 5 A data processing device 354 based on blockchain stored in a memory 350 is shown. The data processing device 354 based on blockchain can be a data processing device based on blockchain in an electronic device, which can be software in the form of programs and plug-ins, including the following software modules: parameter acquisition module 3541, business contract query module 3542, key query module 3543, decryption module 3544 and code execution module 3545. These modules are logical, so they can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be explained below.

[0082] In some embodiments, the device provided in the embodiments of the present application can be implemented in hardware. As an example, the device provided in the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the blockchain-based data processing method provided in the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can adopt one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field programmable gate arrays (FPGAs) or other electronic components.

[0083] This application can also use cloud technology to implement a data processing method based on blockchain, where cloud technology (Cloudtech nology) refers to a hosting technology that unifies a series of resources such as hardware, software, and network in a wide area network or local area network to realize data calculation, storage, processing, and sharing. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model application. It can form a resource pool, which is used on demand, flexible and convenient. Cloud computing technology will become an important support. The background service of the technical network system requires a large amount of computing and storage resources, such as video websites, picture websites, and more portal websites. With the high development and application of the Internet industry, each item may have its own identification mark in the future, and all need to be transmitted to the background system for logical processing. Data of different levels will be processed separately, and all kinds of industry data need strong system backing support, which can only be achieved through cloud computing.

[0084] In some embodiments, data processing results and other information can also be stored. In the process of storing data processing results, cloud storage technology can be used, where cloud storage is a new concept extended and developed from the concept of cloud computing. A distributed cloud storage system refers to a storage system that uses cluster applications, grid technology, and distributed storage file systems to bring together a large number of different types of storage devices (storage devices are also called storage nodes) in the network through application software or application interfaces to work together and provide external data storage and business access functions.

[0085] In other embodiments, data query can be performed on the data processing results. The solution for data query on the data processing results can be implemented by using a database in cloud technology, wherein the database can be regarded as an electronic file cabinet, that is, a place for storing electronic files, and users can add, query, update, etc. the data in the files. The so-called "database" is a collection of data that is stored together in a certain way, can be shared with multiple users, has as little redundancy as possible, and is independent of the application.

[0086] The following will be combined with the exemplary application and implementation of the node 202 and the data processing system 10 provided in the embodiment of the present application to illustrate the data processing method based on blockchain provided in the embodiment of the present application. The data processing method based on blockchain provided in each embodiment of the present application can be executed by a blockchain node in the data processing system, wherein the blockchain node can be implemented as a server or as a terminal, that is, the data processing method based on blockchain in each embodiment of the present application can be executed by a server, can be executed by a terminal, or can be executed by interaction between a server and a terminal.

[0087] Figure 6 This is an optional flowchart of the data processing method based on blockchain provided in the embodiment of the present application. Figure 6 The steps shown are explained as Figure 6 As shown, the method includes the following steps S101 to S105:

[0088] Step S101, in response to receiving a data processing request sent by a client, obtaining a call parameter from the data processing request.

[0089] In the embodiment of the present application, the blockchain node can receive a data processing request sent by a client, and the data processing request can be a processing request for any business in the application on the terminal. Among them, on the terminal, a client of the application is installed, and the user can trigger a processing request for a business in the application through the client. The business requested to be processed by the data processing request has a business contract in the blockchain, and the business contract is a smart contract. A smart contract is an automated contract based on blockchain technology that can automatically execute and verify the terms of the contract without third-party intervention.

[0090] Here, the blockchain node can use P2P point-to-point communication to receive the data processing request sent by the client.

[0091] In some embodiments, when the contract code of the smart contract corresponding to the data processing request is executed, it can implement the processing process corresponding to the data processing request, thereby obtaining the final data processing result. In the embodiment of the present application, the smart contract corresponding to the data processing request can be a business contract in the privacy contract factory or a general smart contract. The difference between the general smart contract and the business contract in the privacy contract factory will be explained below.

[0092] In some embodiments, the data processing request may include client input parameters, which are parameters corresponding to the current data processing request input by the user through the client. The client input parameters may include call parameters of the business contract, through which the business contract corresponding to the data processing request can be accurately called.

[0093] For example, the calling parameters include but are not limited to at least one of the following: the name of the processing method corresponding to the data processing request (ie, the method name), and a parameter list, wherein the parameter list includes the values ​​of various parameters required in the process of executing the data processing request.

[0094] Here, the application is an instant messaging application and the data processing request is a red envelope request. User A can enter a red envelope request in the client of the instant messaging application to request to send a red envelope to friend B. The call parameters can be entered in the client, and the call parameters include but are not limited to: the address of the user receiving the red envelope (i.e., the ID of friend B), the amount of the red envelope, the method of receiving the red envelope, the red envelope blessing and other parameters. After receiving these call parameters, the client of the instant messaging application encapsulates the call parameters into the red envelope request, and sends the red envelope request to the blockchain node, so as to perform a safe and reliable processing of the red envelope sending process based on the blockchain technology. It should be noted that after receiving the red envelope request, the blockchain node can parse the call parameters and determine that the business corresponding to the red envelope request is a red envelope business based on the call parameters. Therefore, the business contract of the red envelope business can be obtained, and then the business contract is executed based on the call parameters to complete the red envelope request of user A.

[0095] In some embodiments, before sending a data processing request to a blockchain node, the client may also use the client's private key to sign the data processing request to obtain a signed data processing request. The signed data processing request may include the client's signature information. After receiving the data processing request, the blockchain node may first verify the signature of the data processing request, and execute the data processing flow of the embodiment of the present application after the signature verification is passed.

[0096] Here, the private key of the client is the private key of the user corresponding to the client. For each user, the blockchain system can assign a unique private key for information encryption. In the embodiment of the present application, the client can use a private key encryption algorithm to implement the information encryption process, where the private key encryption algorithm uses a single private key to encrypt and decrypt data.

[0097] Since a client with the key can use it to decrypt data, the key must be protected from unauthorized agents. Private key encryption is also called symmetric encryption because the same key is used for both encryption and decryption. Private key encryption algorithms are very fast (compared to public key algorithms) and are particularly suitable for performing cryptographic transformations on larger data streams. Typically, private key algorithms (called block ciphers) are used to encrypt data one block at a time. A block cipher converts an input block of n bytes into an output block of encrypted bytes by encrypting. If you want to encrypt or decrypt a sequence of bytes, you must do it block by block. Since n is small, data values ​​greater than n must be encrypted one block at a time.

[0098] In some embodiments, the data processing request is signed using the client's private key to obtain a signed data processing request. In this way, after receiving the signed data processing request, the blockchain node can verify the signature to ensure that the data processing request comes from a legitimate client, so that further response can be made to the data processing request.

[0099] Step S102: If the smart contract corresponding to the data processing request is a business contract in the privacy contract factory, the target business contract corresponding to the data processing request is queried from the privacy contract factory based on the calling parameters.

[0100] In some embodiments, after a blockchain node receives a data processing request, it can determine the smart contract corresponding to the data processing request based on the call parameters of the data processing request value, and determine whether the smart contract is a business contract in the privacy contract factory. If the smart contract is a business contract in the privacy contract factory, the target business contract corresponding to the data processing request is queried from the privacy contract factory based on the call parameters; if the smart contract is not a business contract in the privacy contract factory, the data processing request is responded to according to the processing flow of the smart contract corresponding to the data processing request, that is, a general smart contract is used to respond to the data processing request.

[0101] It should be noted here that the smart contract corresponding to the data processing request can be a business contract in the privacy contract factory or a general smart contract.

[0102] The privacy contract factory stores multiple encrypted business contracts. The privacy contract factory is a system contract on the blockchain. The privacy contract factory is used to store the contract code of the encrypted business contract, and to call the key management contract to decrypt the encrypted business contract contract code and contract request parameters to obtain the decrypted business contract contract code and contract request parameters. The business contract is a contract customized by the client of the business party. In other words, the business contracts stored in the privacy contract factory are all encrypted business contracts, and when encrypting the business contract, the key management contract is called to encrypt the business contract through the business contract key in the key management contract.

[0103] In the embodiments of the present application, the privacy contract factory can be deployed on any blockchain node in the blockchain system, and the key management contract can also be deployed in any blockchain node in the blockchain system. The description of calling the privacy contract factory and calling the key management contract (or key management service) mentioned in the embodiments of the present application is actually calling the blockchain node storing the privacy contract factory and calling the blockchain node storing the key management contract. Alternatively, the description of performing certain processing and operations through the privacy contract factory and performing certain processing and operations through the key management contract (or key management service) mentioned in the embodiments of the present application is actually performing these processing and operations through the blockchain node storing the privacy contract factory and performing these processing and operations through the blockchain node storing the key management contract.

[0104] A general smart contract is an unencrypted business contract, that is, any business contract that is not encrypted using the business contract key in the key management contract provided in the embodiment of the present application is a general smart contract. A general smart contract is a smart contract that does not belong to the privacy contract factory.

[0105] In an embodiment of the present application, in order to enhance the privacy protection function of the blockchain, all business contracts can be encrypted and stored in a privacy contract factory. In this way, the privacy of both business data and business algorithms (i.e., contract codes) can be guaranteed.

[0106] In some embodiments, the privacy contract factory stores multiple encrypted business contracts. After obtaining the call parameters, the target business contract can be queried based on the name of the processing method corresponding to the data processing request in the call parameters (i.e., the method name), that is, the encrypted business contract is stored in the privacy contract factory in the form of a key-value pair, where the key in the key-value pair can be the method name, and the value in the key-value pair can be the business code hash value of the business contract. The business code hash value can be queried through the method name, and the business code hash value is the encrypted data, so the encrypted data needs to be further decrypted.

[0107] Step S103: query the business contract key corresponding to the target business contract from the key management service.

[0108] In an embodiment of the present application, a key management service is deployed in any blockchain node in a blockchain system. The key management service corresponds to a key management contract, which is a system contract on the blockchain. The key management contract is used to store encrypted keys and address information of the authorized user of each key. That is, the key management service is used to store encrypted keys and address information of the authorized user of each key, wherein the encrypted keys include business contract keys.

[0109] In an embodiment of the present application, the key management contract may include at least one of the following functions: a method for generating each key, a method for obtaining a key, an encryption data type, a decryption data type, and authorization information for authorizing the use of the key; by executing the contract code of the key management contract, the key management service can implement at least one of the functions.

[0110] In some embodiments, the business code hash value and business user address of the target business contract can be obtained; wherein the business user address can be obtained from the call parameters, for example, for a red envelope request, the business user address can be the ID of the user receiving the red envelope. Then, using the business code hash value and the business user address as keys, the value corresponding to the key is queried from the key management service, and the queried value is the business contract key corresponding to the target business contract.

[0111] Step S104: Decrypt the target business contract using the business contract key to obtain the contract code of the target business contract.

[0112] In the embodiment of the present application, after the business contract key is obtained, the encrypted target business contract is decrypted using the business contract key to obtain the contract code of the target business contract.

[0113] Step S105, calling the smart contract virtual machine to execute the contract code and obtain the data processing result corresponding to the data processing request.

[0114] Here, the smart contract virtual machine is the operating environment of the business contract. The smart contract virtual machine is similar to an operating system, because the virtual resource contract is essentially a piece of contract code. The contract code must be run in the program, so the smart contract virtual machine provides a running environment for the business contract.

[0115] It should be noted that the smart contract virtual machine is actually a program. The program of the smart contract virtual machine provides an operating environment. The smart contract virtual machine can be deployed on any blockchain node in the blockchain system; it can also be separated from the blockchain system, that is, the smart contract virtual machine can be the operating environment of the blockchain node that has been separated from the blockchain system. The smart contract virtual machine can be a data communication bridge between the client and the blockchain system, which can enable the blockchain node in the blockchain system to obtain the contract code of the target business contract and execute the contract code of the target business contract, thereby completing the response process of the client data processing request.

[0116] In the data processing method based on blockchain provided in the embodiment of the present application, if the smart contract corresponding to the data processing request sent by the client is a business contract in the privacy contract factory, the target business contract corresponding to the data processing request is queried from the privacy contract factory based on the call parameters; wherein the privacy contract factory stores multiple encrypted business contracts; then, the business contract key corresponding to the target business contract is queried from the key management service; thereby the target business contract is decrypted using the business contract key to obtain the contract code of the target business contract; finally, the smart contract virtual machine is called to execute the contract code to obtain the data processing result corresponding to the data processing request, thereby completing the accurate response to the data processing request of the client. In the embodiment of the present application, since the business contract is encrypted and stored in the privacy contract factory, the business contract key is stored in the key management service. In this way, the privacy contract factory and the key management service can protect the business data while protecting the business algorithm. That is to say, the business contract key used to encrypt the business contract is stored through the key management service, so that not only the contract data of the business contract can be protected based on the business contract key, but also the contract code of the business contract can be protected.

[0117] In some embodiments, the data processing method based on blockchain can be applied to a data processing system, which includes a client and a blockchain system, and the blockchain system includes at least multiple blockchain nodes, for example, a blockchain node that deploys a privacy contract factory, a blockchain node that deploys a key management service, and a blockchain node for implementing the data processing method of the embodiment of the present application. The embodiment of the present application takes the blockchain node used to implement the data processing method of the embodiment of the present application as a first blockchain node, the blockchain node that deploys a privacy contract factory as a second blockchain node, and the blockchain node that deploys a key management service as a third blockchain node as an example to illustrate the data processing method of the embodiment of the present application.

[0118] Figure 7 is another optional flow chart of the blockchain-based data processing method provided in the embodiment of the present application, such as Figure 7As shown, the method includes the following steps S201 to S217:

[0119] Step S201: The client receives an input operation from a user.

[0120] Here, the input operation is used to input client input parameters, that is, the client input parameters are parameters corresponding to the current data processing request input by the user through the client. The client input parameters may include call parameters of the business contract, through which the business contract corresponding to the data processing request can be accurately called.

[0121] Step S202: The client generates a data processing request based on the input operation.

[0122] The input operation is used to input the client input parameters and the signature information signed with the client's private key.

[0123] In an embodiment of the present application, the data processing request may be a processing request for any service in an application on the terminal. After receiving the client input parameters entered by the user, the client input parameters may be encapsulated into the data processing request, and the signature information may also be encapsulated into the data processing request.

[0124] Step S203: The client signs the data processing request using its private key to obtain signature information, and adds the signature information to the data processing request.

[0125] Step S204: The client sends a data processing request to the first blockchain node.

[0126] Step S205: In response to receiving the data processing request sent by the client, the first blockchain node verifies the signature information in the data processing request and obtains a signature verification result.

[0127] Step S206: In response to the signature verification result being a passed verification, the first blockchain node extracts a call parameter from the client input parameter.

[0128] In an embodiment of the present application, if the signature verification result is that the verification is passed, the call parameters are extracted from the client input parameters, and the subsequent data processing flow is further executed; if the signature verification result is that the verification is not passed, the entire data processing flow is terminated.

[0129] Step S207: The first blockchain node determines whether the smart contract corresponding to the data processing request is a business contract in the privacy contract factory.

[0130] If the judgment result is yes, execute step S208; if the judgment result is no, respond to the data processing request according to the processing flow of the smart contract corresponding to the data processing request.

[0131] In some embodiments, after a blockchain node receives a data processing request, it can determine the smart contract corresponding to the data processing request based on the call parameters of the data processing request value, and determine whether the smart contract is a business contract in the privacy contract factory. If the smart contract is a business contract in the privacy contract factory, the target business contract corresponding to the data processing request is queried from the privacy contract factory based on the call parameters; if the smart contract is not a business contract in the privacy contract factory, the data processing request is responded to according to the processing flow of the smart contract corresponding to the data processing request, that is, a general smart contract is used to respond to the data processing request.

[0132] It should be noted here that the smart contract corresponding to the data processing request can be a business contract in the privacy contract factory or a general smart contract.

[0133] Step S208, the first blockchain node queries the target business contract corresponding to the data processing request from the privacy contract factory based on the calling parameters; the privacy contract factory stores multiple encrypted business contracts.

[0134] In some embodiments, the privacy contract factory is a system contract on the blockchain; the privacy contract factory is used to store the contract code of the encrypted business contract, and to call the key management contract to decrypt the encrypted contract code and contract request parameters of the business contract to obtain the decrypted contract code and contract request parameters of the business contract; wherein the business contract is a contract customized by the client of the business party.

[0135] In some embodiments, a method for deploying a privacy contract factory is provided, and the method for deploying the privacy contract factory can be implemented by any blockchain node in the blockchain system. Figure 8 As shown, it is a schematic diagram of the implementation process of the deployment method of the privacy contract factory provided in the embodiment of the present application, including the following steps S301 to S305:

[0136] Step S301, develop the source code of the privacy contract factory through the blockchain development node.

[0137] Here, the blockchain development node can be realized by any blockchain node in the blockchain system, that is, the blockchain development node is any blockchain node in the blockchain system.

[0138] Step S302, deploy the source code of the privacy contract factory to the blockchain.

[0139] Here, the source code of the privacy contract factory can be stored on the blockchain.

[0140] Step S303, developing the source code of the key management contract through the blockchain development node.

[0141] Step S304: Use the master key of the key management service to encrypt the source code of the key management contract to obtain the encrypted source code.

[0142] Step S305, calling the privacy contract factory on the blockchain and deploying the encrypted source code to the blockchain.

[0143] Here, since the privacy contract factory is a system contract on the blockchain, the privacy contract factory is used to store the contract code of the encrypted business contract. Therefore, the blockchain node where the privacy contract factory is located can be called to deploy the encrypted source code to the blockchain node in the blockchain system to realize the on-chain storage of the source code of the key management contract.

[0144] In some embodiments, a method for deploying a business contract is provided, and the method for deploying a business contract can be implemented by any blockchain node in the blockchain system. Fig. 9 FIG. 4 is a schematic diagram of an implementation flow of a method for deploying a business contract provided in an embodiment of the present application, including the following steps S401 to S404:

[0145] Step S401, obtaining the contract code of the business contract developed by the business development client.

[0146] Step S402: call the key management contract to obtain the business contract key.

[0147] In some embodiments, the business contract key can be derived from the chain key of the blockchain. When obtaining the business contract key, it can be achieved in the following way: first, obtain the chain key of the blockchain; then, call the root key of the key management service, encrypt the chain key, and obtain the encrypted chain key; finally, store the encrypted chain key in the blockchain node of the blockchain; wherein, the chain key is used to generate the business contract key.

[0148] The chain key can be called the chain master key or the chain root key. The chain key is the key related to the entire blockchain. The business contract keys of all business contracts can be encrypted using the chain key. The chain key can be encrypted using the service key of the key management service (i.e., the KMS key) to obtain the encrypted chain key, and then the encrypted chain key can also be saved in the blockchain node. When the blockchain node is started, the encrypted chain key can be obtained, and the encrypted chain key can be used to decrypt the business contract key in the key management service. After decryption, the business contract key is stored in the memory. In this way, the business contract key can be obtained from the memory and the business contract key can be used to decrypt other keys.

[0149] Step S403: Use the business contract key to encrypt the contract code of the business contract to obtain the encrypted business contract code.

[0150] Step S404, calling the privacy contract factory to deploy the encrypted business contract code to the blockchain.

[0151] Step S209: The first blockchain node queries the business contract key corresponding to the target business contract from the key management service.

[0152] In an embodiment of the present application, querying the business contract key corresponding to the target business contract from the key management service can be achieved in the following way: first, obtain the business code hash value and the business user address of the target business contract; then, using the business code hash value and the business user address as keys, query the value corresponding to the key from the key management service; wherein the value corresponding to the key constitutes the business contract key corresponding to the target business contract.

[0153] Accordingly, for a new business contract, the present application embodiment further provides a business contract key generation method for a new business contract, and the business contract key generation method can be implemented by any blockchain node in the blockchain system. Fig.10 FIG. 5 is a schematic diagram of an implementation flow of a method for generating a business contract key provided in an embodiment of the present application, including the following steps S501 to S505:

[0154] Step S501, obtaining the chain key of the blockchain.

[0155] Step S502, for any business contract in the privacy contract factory, obtain the business code hash value, business user address and current block hash value of the blockchain of the business contract.

[0156] Step S503, generating a business contract key for the business contract based on the chain key, the business code hash value of the business contract, the business user address and the current block hash value of the blockchain.

[0157] Here, the business contract key of the business contract is generated based on the chain key, the business code hash value of the business contract, the business user address and the current block hash value of the blockchain.

[0158] Step S504, using the business code hash value and the business user address of the business contract as the key and the business contract key as the value, a key-value pair to be stored is generated.

[0159] Step S505: store the key-value pair to be stored in the key management service.

[0160] In some embodiments, the key management service corresponds to a key management contract, which is a system contract on the blockchain; the key management contract is used to store encrypted keys and address information of authorized users of each key; wherein the encrypted keys include the business contract keys.

[0161] The key management contract includes at least one of the following functions: the method of generating each key, the method of obtaining the key, the type of encryption data, the type of decryption data, and the authorization information for authorizing the use of the key; by executing the contract code of the key management contract, the key management service can realize at least one of the above functions.

[0162] In some embodiments, the key management contract is stored in a third blockchain node (i.e., the target blockchain node). Before querying the business contract key corresponding to the target business contract from the third blockchain node, the method may further include the following steps:

[0163] Step S210: The third blockchain node obtains the contract code of the key management contract and the service key of the key management service.

[0164] Here, the service key is the key of the key management service, which can be expressed as a KMS key; the service key is used to encrypt the contract code of the key management contract corresponding to the key management service.

[0165] Step S211: The third blockchain node uses the service key to encrypt the contract code of the key management contract to obtain the encrypted contract code.

[0166] In step S212, the third blockchain node stores the encrypted contract code in the target blockchain node (i.e., the third blockchain node) of the blockchain.

[0167] At this time, the encrypted contract code of the key management contract is stored in the third blockchain node. Therefore, when the business contract key corresponding to the target business contract is queried from the key management service, the third blockchain node is started; and when the third blockchain node is started, the third blockchain node can call the key management service to decrypt the encrypted contract code and obtain the decrypted contract code of the key management contract; and call the smart contract virtual machine to execute the contract code of the key management contract to implement the functions in the key management contract.

[0168] In some embodiments, a system privacy contract loading process can also be provided based on the key management service, wherein the system privacy contract can be a key management contract and any other system contract whose source code cannot be made public. The system privacy contract loading process includes the following steps: first, call the key management service to decrypt the encrypted chain key and the encrypted key management contract to obtain the chain key and the key management contract; and read the encrypted system privacy contract code from the blockchain ledger; then, use the chain key to decrypt the encrypted system privacy contract code to obtain the system privacy contract code; the system privacy contract code includes the key management contract and other system contracts whose source code cannot be made public; finally, load the system privacy contract code into the contract virtual machine of the blockchain to implement the code logic of the system privacy contract code.

[0169] Step S213: The first blockchain node uses the business contract key to decrypt the target business contract to obtain the contract code of the target business contract.

[0170] Step S214: The first blockchain node calls the smart contract virtual machine to execute the contract code and obtains a data processing result corresponding to the data processing request.

[0171] In one implementation, if the data processing request in the embodiment of the present application is a transaction request, the business public key corresponding to the target business contract can be obtained; the data processing result is encrypted using the business public key to obtain a first encrypted data processing result; and the first encrypted data processing result is saved in the ledger of the blockchain.

[0172] In another implementation method, if the data processing request in the embodiment of the present application is a query request, the public key of the business user corresponding to the target business contract can be obtained; the data processing result is encrypted using the public key of the business user to obtain a second encrypted data processing result; and the second encrypted data processing result is returned to the client.

[0173] Here we take the data processing request as a query request as an example. Please continue to refer to Figure 7 The method may further include the following steps:

[0174] Step S215: The first blockchain node returns the second encrypted data processing result to the client.

[0175] Step S216: The client uses the client private key to decrypt the second encrypted data processing result to obtain a decrypted data processing result.

[0176] Step S217: the client displays the decrypted data processing result on the current interface.

[0177] The blockchain-based data processing method provided in the embodiment of the present application, since the business contract is encrypted and stored in the privacy contract factory, and the business contract key is stored in the key management service, thus, through the privacy contract factory and the key management service, it is possible to protect the business data while also protecting the business algorithm. That is to say, the business contract key used to encrypt the business contract is stored through the key management service, so that not only the contract data of the business contract can be protected based on the business contract key, but also the contract code of the business contract can be protected.

[0178] The following is an explanation of an exemplary application of the embodiments of the present application in a practical application scenario.

[0179] Privacy computing is a technical system that integrates many fields such as cryptography and security hardware. It is based on protecting the privacy and security of data throughout its entire life cycle, and enables calculation and analysis of data in an encrypted or non-transparent state, thereby promoting the circulation and integration of data elements and realizing the "available but invisible" function of data from multiple parties.

[0180] However, the authenticity of data, data sources, data rights confirmation, and whether the data transfer process is safe and compliant are the difficulties faced by privacy computing technology. At the same time, due to the uneven quality of data from multiple parties, data owners lack a credible incentive mechanism, contribution assessment, and benefit distribution process, which makes privacy computing technology face problems such as difficulty in mutual trust and collaboration.

[0181] Blockchain has technical features such as data traceability, difficulty in tampering, openness and transparency, and automatic execution of smart contracts. It is a powerful tool to solve the problems of multi-party collaboration and trust. Through the consensus mechanism, a trust foundation is established between the participants to achieve point-to-point value transfer. Through smart contracts, the authenticity of data on the chain is verified and audited. Through the establishment and consensus of collaborative mechanisms and incentive mechanisms, data openness, sharing and value collaboration are promoted.

[0182] The organic combination of blockchain and privacy computing can greatly expand the circulation channels of data requirements, eliminate the privacy protection concerns of data holders, and make some processes and data open and transparent, making data more credible and supervision more convenient.

[0183] Based on this, the embodiment of the present application expands the functions of the blockchain virtual machine (which can be deployed on the blockchain node) so that the blockchain virtual machine can encrypt and decrypt smart contracts and contract data, thereby protecting the algorithms and business data of the business, and enhancing privacy protection. The blockchain has both openness, transparency and privacy protection functions, which greatly broadens the application scenarios of the blockchain. In addition, the embodiment of the present application also provides a method for generating, storing, using, and authorizing the use of business contract keys on the chain, so that business algorithms and data can interact smoothly under encryption. The embodiment of the present application realizes an enhanced blockchain privacy protection scheme that protects both business algorithms and business data.

[0184] Fig.11 is a system architecture diagram of a data processing system provided in an embodiment of the present application, such as Fig.11 As shown, the data processing system consists of a business application 1101, a blockchain network 1102 (i.e., a blockchain system) and a KMS 1103.

[0185] Among them, the business application 1101 provides users with a simple and easy-to-use graphical interface, uses the business contract key to encrypt part of the user input, and assembles the user input into a blockchain transaction or query request (corresponding to the above-mentioned data processing method), and then uses the user's private key to sign the transaction or query request, and finally sends the transaction or query request and its signature to the blockchain.

[0186] After receiving the transaction or query request, the blockchain node in the blockchain network 1102 verifies the signature in the transaction or query request and calls the smart contract virtual machine to execute the transaction or query request. If the smart contract requested by the transaction or query request is a business contract in the privacy contract factory, the target privacy business contract (i.e. the above-mentioned target business contract) is found according to the call parameters in the transaction or query request, the user authority is identified, the business contract key is found from the key management service KMS, the business contract key is used to decrypt the content of the transaction or query request, the contract code of the business contract is decrypted, the contract code is loaded into the smart contract virtual machine, and the method of the privacy contract is called based on the user transaction or query request.

[0187] Use KMS 1103 for key management to generate chain keys, and use KMS to encrypt chain keys. Chain key ciphertext is stored on the blockchain node. In order to protect the security of the algorithm, the KMS master key is used to encrypt the code of the "key contract" and store the code ciphertext on the blockchain; at the same time, the chain key is also used to derive other business contract keys and encrypt the derived keys so that there are no plaintext keys on the chain, but these keys can be used. When the blockchain node is started, the code ciphertext can be used as a parameter to call the KMS master key for decryption.

[0188] The following is a description of the smart contract involved in the embodiments of the present application.

[0189] Fig.12 is a schematic diagram of a privacy contract factory provided in an embodiment of the present application, such as Fig.12 As shown, the privacy contract factory is a system contract that is used to store encrypted business contract code. It is responsible for calling the key management contract to decrypt the contract code and contract request parameters, loading the contract code into the smart contract virtual machine, and executing contract deployment, query, and call functions.

[0190] Fig.13 is a schematic diagram of a key management contract provided in an embodiment of the present application, such as Fig.13 As shown in the figure, the key management contract is a system contract used to save encrypted keys and the addresses of key authorized users. It includes functions such as key generation, key acquisition, data encryption, data decryption, and key authorization. The code of the key management contract is not public. It exists on the blockchain after being encrypted with the KMS key. When the blockchain node is started, it will call KMS to decrypt the contract and load its code into the smart contract virtual machine. It should be noted that the key management contract function is not available in the native blockchain node, and the blockchain needs to expand its capabilities to support this function.

[0191] Fig.14 is a schematic diagram of a business contract provided in an embodiment of the present application, such as Fig.14 As shown, the business contract is a contract customized by the business party, and the contract code will be saved in the blockchain in the form of ciphertext.

[0192] Fig.15 This is a use case diagram of the privacy contract factory and key contract provided in the embodiment of the present application, such as Fig.15 As shown, blockchain developers develop and deploy a privacy contract factory; develop a key management contract and use the KMS master key to encrypt the contract code; and finally call the privacy contract factory to deploy the encrypted contract code to the blockchain.

[0193] Fig.16 is a business program development use case diagram provided by the embodiment of the present application, such as Fig.16 As shown, business developers develop privacy business contracts. First, they call the key factory contract to obtain the business contract key, then use the business contract key to encrypt the privacy business contract code, and finally call the privacy factory contract to deploy the encrypted privacy business contract. At the same time, business developers develop business applications to provide users with a business function user interface for saving business contract keys and user keys, encrypting request parameters with business contract keys, assembling blockchain transactions or query requests, signing transactions with user keys, and decrypting return results with business contract keys.

[0194] Fig.17 This is a business privacy contract use case diagram provided by the embodiment of the present application, such as Fig.17 As shown, business personnel use business applications to initiate queries or transaction requests to the blockchain.

[0195] The following describes the various system workflows of the data processing system provided in the embodiments of the present application.

[0196] Fig.18 is a flow chart of the chain root key generation method provided in the embodiment of the present application, such as Fig.18 As shown, the steps S181 to S183 are included:

[0197] Step S181, the chain developer calls KMS and the chain root key.

[0198] Step S182, call the KMS root key to encrypt the chain root key and obtain the encrypted chain root key.

[0199] Step S183, save the encrypted chain root key to the blockchain node.

[0200] Fig.19 This is a schematic diagram of the system privacy contract loading process provided by the embodiment of the present application, such as Fig.19 As shown, the steps include steps S191 to S194:

[0201] Step S191, after the system is started, call KMS to decrypt the chain root key and key management contract.

[0202] Step S192, read the encrypted system privacy contract code from the blockchain ledger.

[0203] Step S193, use the chain root key to decrypt other system privacy contract codes.

[0204] Step S194, load the system privacy contract code into the contract virtual machine and cache the chain root key.

[0205] In the embodiment of the present application, the system privacy contract includes a key management contract and other system contracts whose source codes cannot be made public.

[0206] Fig. 20 : is a schematic diagram of the new business contract key generation process provided by the embodiment of the present application, such as Fig. 20 As shown, the process includes the following steps S2001 and S2007:

[0207] Step S2001: A business developer generates a new business contract key request.

[0208] Step S2002: The business user signs the new business contract key request using a private key.

[0209] In step S2003, the developer packages the new business contract key request and signature into a transaction and sends it to the blockchain node in the blockchain.

[0210] Step S2004: The transaction pool in the blockchain executes the transaction and verifies the signature.

[0211] Step S2005, when the signature verification passes, the key management contract derives the business contract key based on the chain root key, business code hash value, business user address, current block hash value of the blockchain and other information.

[0212] Step S2006: The key management contract uses the chain root key to encrypt the business contract key and save the business contract key. Here, the saving is implemented in the form of a key-value pair, where the key in the key-value pair is the business user address and the business code hash value, and the value in the key-value pair is the business contract key encrypted with the chain root key.

[0213] Step S2007: Use the public key of the business user to encrypt the business contract key, and return the encrypted business contract key.

[0214] In an embodiment of the present application, the business contract key is used to encrypt the code and business data of the business contract, thereby ensuring that there are no plaintext business algorithms and data on the blockchain.

[0215] Fig.21 is a schematic diagram of the deployment process of a new business contract provided in an embodiment of the present application, such as Fig.21 As shown, the following steps S2101 to S2108 are included:

[0216] Step S2101, obtaining the business contract key of the new business contract.

[0217] Step S2102: Use the developer's private key to decrypt the business contract key to obtain the plaintext key of the new business contract.

[0218] Step S2103: The developer uses the business contract key to encrypt the business contract code.

[0219] Step S2104, generate the following transaction: call the privacy contract factory to deploy the business contract.

[0220] Step S2105: The business party signs the transaction.

[0221] Step S2106, the developer uploads the transaction to the blockchain node.

[0222] Step S2107: The blockchain node verifies the signature in the transaction.

[0223] Step S2108, save the business contract to the privacy contract factory, where the business contract is saved in the form of a key-value pair, the key in the key-value pair is the code hash value of the business contract, and the value in the key-value pair is the encrypted contract code.

[0224] Fig. 22 is a schematic diagram of the business contract calling process provided by the embodiment of the present application, such as Fig. 22 As shown, the steps include the following steps S2201 to S2207:

[0225] Step S2201: The business user uses the business application to select the business and method parameters to be called and fill in the calling parameters.

[0226] In step S2202, the business application uses the business contract key to encrypt the calling method and calling parameters; the business code hash value and the encrypted user input are used as transaction parameters to generate a transaction, the transaction is signed with the private key of the business user, and the transaction is sent to the blockchain node.

[0227] Step S2203: The blockchain node queries and verifies the transaction.

[0228] In step S2204, the privacy contract factory calls the key management service. The key management service obtains the business code hash value from the transaction parameters based on the caller address obtained from the transaction signature, and obtains the encrypted business contract key based on the caller address and the business code hash value, and uses the business contract key to decrypt the transaction.

[0229] Step S2205, the privacy contract factory searches for the encrypted business code based on the business code hash value, decrypts the business contract code using the business contract key, and loads the encrypted business contract code into the smart contract virtual machine.

[0230] Step S2206: Based on the decrypted transaction calling method and calling parameters, the corresponding business contract is called, and the data read from the account book during the contract execution process is decrypted using the business contract key.

[0231] Step S2207: If the business corresponding to the business contract is a transaction business, the execution result is encrypted using the business public key of the transaction business and the execution result is saved in the account book; if the business corresponding to the business contract is a query business, the execution result is encrypted using the public key of the business user and the execution result is returned to the client.

[0232] Fig.23 is a flow chart of setting a service authorization access party provided in an embodiment of the present application. When a service party needs to authorize another party to access data, such as Fig.23 As shown, the following steps S2301 to S2304 are included:

[0233] Step S2301: The business personnel fills in the address of the business authorizer through the client of the business application program.

[0234] Step S2302: The business application generates an "authorized use key of the key contract" transaction based on the business code hash value and the business authorizer address, signs the transaction, and sends the signed transaction to the blockchain node.

[0235] Step S2303: The blockchain node performs transaction verification through the transaction pool.

[0236] Step S2304, the key management contract uses the user address and business code hash value based on the business personnel to find the business contract key. If the business contract key exists, it indicates that the caller is determined to be a business personnel, and then the authorization method is called to save the authorizer information. The information is saved in the form of a key-value pair, the key in the key-value pair is the business authorizer address and the encrypted business code hash value, and the value in the key-value pair is the business party address.

[0237] In some embodiments, the business party may also revoke the previous authorization, such as Fig.24 As shown, it is a schematic diagram of the process of the business authorization party calling the business contract provided by the embodiment of the present application, such as Fig.24 As shown, the following steps S2401 to S2407 are included:

[0238] Step S2401: The service authorizer uses the service application to select the service and method to be called and fill in the calling parameters.

[0239] Step S2402, the business application uses the business contract key to encrypt the calling method and calling parameters; uses the encrypted business code hash value and the encrypted user input as transaction parameters to generate a transaction, uses the business user's private key to sign the transaction, and sends the signed transaction to the blockchain node.

[0240] Step S2403: The blockchain node queries and verifies the transaction.

[0241] In step S2404, the privacy contract factory calls the key management service. The key management service obtains the business code hash value from the transaction parameters based on the caller address obtained from the transaction signature, and detects whether the user is an authorized access party based on the caller address and the business code hash value. If so, it obtains the business party address, and then obtains the encrypted business contract key based on the business party address and the business code hash value, and uses the chain root key to decrypt the business contract key; the business contract key is used to decrypt the transaction.

[0242] Step S2405, the privacy contract factory searches for the encrypted business code based on the business code hash value, decrypts the business contract code using the business contract key, and loads the encrypted business contract code into the smart contract virtual machine.

[0243] Step S2406: Based on the decrypted transaction calling method and calling parameters, the corresponding business contract is called, and the data read from the account book during the contract execution process is decrypted using the business contract key.

[0244] Step S2407: If the business corresponding to the business contract is a transaction business, the execution result is encrypted using the business public key of the transaction business and the execution result is saved in the account book; if the business corresponding to the business contract is a query business, the execution result is encrypted using the public key of the business user and the execution result is returned to the client.

[0245] Based on the above content, the data processing method based on blockchain provided by the embodiment of the present application expands the function of the blockchain virtual machine (blockchain node), so that the blockchain virtual machine can encrypt and decrypt smart contracts and contract data, thereby protecting the algorithms and business data of the business, and enhancing privacy protection. The blockchain has both openness, transparency and privacy protection functions, which greatly broadens the application scenarios of the blockchain. In addition, a method for generating, storing, using and authorizing the use of business contract keys on the chain is also provided, so that business algorithms and data can interact smoothly under encryption.

[0246] It can be understood that in the embodiments of the present application, the content involving user information, such as the call parameters entered by the user through the client, the user's signature information, etc., if it involves data related to user information or corporate information, when the embodiments of the present application are applied to specific products or technologies, it is necessary to obtain user permission or consent, or to blur this information to eliminate the correspondence between this information and the user; and the relevant data collection and processing should be strictly in accordance with the requirements of relevant national laws and regulations when applied in examples, obtain the informed consent or separate consent of the subject of personal information, and carry out subsequent data use and processing within the scope of authorization of laws and regulations and the subject of personal information.

[0247] The following is an exemplary structure of a blockchain-based data processing device 354 implemented as a software module provided in an embodiment of the present application. In some embodiments, Figure 5As shown, the blockchain-based data processing device 354 includes: a parameter acquisition module 3541, which is used to obtain call parameters from the data processing request in response to receiving a data processing request sent by the client; a business contract query module 3542, which is used to query the target business contract corresponding to the data processing request from the privacy contract factory based on the call parameters if the smart contract corresponding to the data processing request is a business contract in the privacy contract factory; the privacy contract factory stores multiple encrypted business contracts; a key query module 3543, which is used to query the business contract key corresponding to the target business contract from the key management service; a decryption module 3544, which is used to use the business contract key to decrypt the target business contract to obtain the contract code of the target business contract; a code execution module 3545, which is used to call the smart contract virtual machine to execute the contract code to obtain the data processing result corresponding to the data processing request.

[0248] In some embodiments, the data processing request includes client input parameters and signature information signed using the client's private key; the parameter acquisition module is also used to: in response to receiving the data processing request sent by the client, verify the signature information in the data processing request to obtain a signature verification result; in response to the signature verification result being verification passed, extract the call parameters from the client input parameters.

[0249] In some embodiments, the key management service corresponds to a key management contract, which is a system contract on the blockchain; the key management contract is used to store encrypted keys and address information of authorized users of each key; wherein the encrypted keys include the business contract keys; the key management contract includes at least one of the following functions: a method for generating each of the keys, a method for obtaining the keys, an encrypted data type, a decrypted data type, and authorization information for authorizing the use of the keys; by executing the contract code of the key management contract, the key management service can implement at least one of the functions.

[0250] In some embodiments, the device also includes: an acquisition module, used to obtain the contract code of the key management contract and the service key of the key management service; an encryption module, used to encrypt the contract code of the key management contract using the service key to obtain the encrypted contract code; a storage module, used to store the encrypted contract code in the target blockchain node of the blockchain; a calling module, used to start the target blockchain node when the business contract key corresponding to the target business contract is queried from the key management service, and when the target blockchain node is started, the target blockchain node calls the key management service to decrypt the encrypted contract code to obtain the decrypted contract code of the key management contract; the calling module is also used to call the smart contract virtual machine to execute the contract code of the key management contract to implement the functions in the key management contract.

[0251] In some embodiments, the privacy contract factory is a system contract on the blockchain; the privacy contract factory is used to store the contract code of the encrypted business contract, and to call the key management contract to decrypt the encrypted contract code and contract request parameters of the business contract to obtain the decrypted contract code and contract request parameters of the business contract; the business contract is a contract customized by the client of the business party.

[0252] In some embodiments, the device also includes: a privacy contract factory deployment module, which is used to deploy the privacy contract factory in the following manner: develop the source code of the privacy contract factory through a blockchain development node; deploy the source code of the privacy contract factory to the blockchain; develop the source code of the key management contract through the blockchain development node; use the master key of the key management service to encrypt the source code of the key management contract to obtain the encrypted source code; call the privacy contract factory on the blockchain and deploy the encrypted source code to the blockchain.

[0253] In some embodiments, the device also includes: a business contract deployment module, used to deploy the business contract in the following manner: obtaining the contract code of the business contract developed by the business development client; calling the key management contract to obtain the business contract key; using the business contract key to encrypt the contract code of the business contract to obtain the encrypted business contract code; calling the privacy contract factory to deploy the encrypted business contract code to the blockchain.

[0254] In some embodiments, the acquisition module is also used to obtain the chain key of the blockchain; the calling module is also used to call the root key of the key management service, encrypt the chain key, and obtain the encrypted chain key; the storage module is also used to store the encrypted chain key in the blockchain node of the blockchain; wherein, the chain key is used to generate the business contract key.

[0255] In some embodiments, the calling module is also used to call the key management service to decrypt the encrypted chain key and the encrypted key management contract to obtain the chain key and the key management contract; the device also includes: a reading module, used to read the encrypted system privacy contract code from the ledger of the blockchain; the decryption module is also used to use the chain key to decrypt the encrypted system privacy contract code to obtain the system privacy contract code; the system privacy contract code includes the key management contract and other system contracts whose source code cannot be made public; a loading module, used to load the system privacy contract code into the contract virtual machine of the blockchain to implement the code logic of the system privacy contract code.

[0256] In some embodiments, the key query module is also used to: obtain the business code hash value and the business user address of the target business contract; use the business code hash value and the business user address as keys to query the value corresponding to the key from the key management service; wherein the value corresponding to the key constitutes the business contract key corresponding to the target business contract.

[0257] In some embodiments, the acquisition module is also used to obtain the chain key of the blockchain; the acquisition module is also used to obtain the business code hash value, the business user address and the current block hash value of the blockchain for any business contract in the privacy contract factory; the device also includes: a business contract key generation module, which is used to generate the business contract key of the business contract based on the chain key, the business code hash value of the business contract, the business user address and the current block hash value of the blockchain; using the business code hash value of the business contract and the business user address as keys and the business contract key as a value to generate a key-value pair to be stored; the storage module is also used to store the key-value pair to be stored in the key management service.

[0258] In some embodiments, the acquisition module is also used to obtain the business public key corresponding to the target business contract if the data processing request is a transaction request; the encryption module is also used to encrypt the data processing result using the business public key to obtain a first encrypted data processing result; the storage module is also used to save the first encrypted data processing result to the ledger of the blockchain; the acquisition module is also used to obtain the business user public key corresponding to the target business contract if the data processing request is a query request; the encryption module is also used to encrypt the data processing result using the business user public key to obtain a second encrypted data processing result; the device also includes: a return module, used to return the second encrypted data processing result to the client.

[0259] It should be noted that the description of the device of the embodiment of the present application is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment, so it is not repeated. For technical details not disclosed in the embodiment of the device, please refer to the description of the method embodiment of the present application for understanding.

[0260] The embodiment of the present application provides a computer program product, which includes an executable instruction, which is a computer instruction; the executable instruction is stored in a computer-readable storage medium. When a processor of an electronic device reads the executable instruction from the computer-readable storage medium and the processor executes the executable instruction, the electronic device executes the method described in the embodiment of the present application.

[0261] The present application embodiment provides a storage medium storing executable instructions, wherein the executable instructions are stored. When the executable instructions are executed by a processor, the processor will execute the method provided by the present application embodiment, for example, Figure 6 The method shown.

[0262] In some embodiments, the storage medium can be a computer-readable storage medium, for example, a ferroelectric random access memory (FRAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPR OM), a flash memory, a magnetic surface memory, an optical disk, or a compact disk read-only memory (CD-ROM), etc.; it can also be various devices including one or any combination of the above memories.

[0263] In some embodiments, executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.

[0264] As an example, executable instructions may, but need not correspond to, a file in a file system, may be stored as part of a file storing other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions). As an example, executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one location, or on multiple electronic devices distributed at multiple locations and interconnected by a communication network.

[0265] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.

Claims

1. A data processing method based on blockchain, It is characterized in that The method comprises: In response to receiving a data processing request sent by a client, obtaining a call parameter from the data processing request; If the smart contract corresponding to the data processing request is a business contract in a privacy contract factory, querying the target business contract corresponding to the data processing request from the privacy contract factory based on the call parameters; the privacy contract factory stores multiple encrypted business contracts; Querying a business contract key corresponding to the target business contract from a key management service; Decrypting the target business contract using the business contract key to obtain a contract code of the target business contract; Call the smart contract virtual machine to execute the contract code and obtain a data processing result corresponding to the data processing request.

2. The method according to claim 1, It is characterized in that The data processing request includes client input parameters and signature information signed by the client's private key; The step of obtaining a call parameter from the data processing request in response to receiving the data processing request sent by the client includes: In response to receiving a data processing request sent by a client, verifying the signature information in the data processing request to obtain a signature verification result; In response to the signature verification result being a passed verification, the call parameter is extracted from the client input parameter.

3. The method according to claim 1, It is characterized in that The key management service corresponds to a key management contract, and the key management contract is a system contract on the blockchain; The key management contract is used to store encrypted keys and address information of authorized users of each key; wherein the encrypted keys include the business contract keys; The key management contract includes at least one of the following functions: the generation method of each key, the key acquisition method, the encryption data type, the decryption data type and the authorization information for authorizing the use of the key; By executing the contract code of the key management contract, the key management service can implement at least one of the functions.

4. The method according to claim 3, It is characterized in that The method further comprises: Obtaining the contract code of the key management contract and the service key of the key management service; Encrypting the contract code of the key management contract using the service key to obtain the encrypted contract code; Storing the encrypted contract code in a target blockchain node of the blockchain; When a business contract key corresponding to the target business contract is queried from a key management service, the target blockchain node is started; When the target blockchain node is started, the target blockchain node calls the key management service to decrypt the encrypted contract code to obtain the decrypted contract code of the key management contract; The smart contract virtual machine is called to execute the contract code of the key management contract to implement the functions in the key management contract.

5. The method according to claim 3, It is characterized in that The privacy contract factory is a system contract on the blockchain; The privacy contract factory is used to store the encrypted contract code of the business contract, and to call the key management contract to decrypt the encrypted contract code and contract request parameters of the business contract to obtain the decrypted contract code and contract request parameters of the business contract; The business contract is a contract customized by the client of the business party.

6. The method according to claim 5, It is characterized in that The method further includes: deploying the privacy contract factory in the following manner: Develop the source code of the privacy contract factory through the blockchain development node; Deploy the source code of the privacy contract factory to the blockchain; Developing the source code of the key management contract through the blockchain development node; Using the master key of the key management service, encrypt the source code of the key management contract to obtain the encrypted source code; Call the privacy contract factory on the blockchain to deploy the encrypted source code to the blockchain.

7. The method according to claim 5, It is characterized in that The method further includes: deploying the business contract in the following manner: Get the contract code of the business contract developed by the business development client; Calling the key management contract to obtain the business contract key; Encrypting the contract code of the business contract using the business contract key to obtain an encrypted business contract code; Call the privacy contract factory to deploy the encrypted business contract code to the blockchain.

8. The method according to claim 7, It is characterized in that The method further comprises: Obtaining a chain key of the blockchain; Calling the root key of the key management service to encrypt the chain key to obtain the encrypted chain key; Storing the encrypted chain key in a blockchain node of the blockchain; The chain key is used to generate the business contract key.

9. The method according to claim 8, It is characterized in that The method further comprises: Calling the key management service to decrypt the encrypted chain key and the encrypted key management contract to obtain the chain key and the key management contract; Reading the encrypted system privacy contract code from the ledger of the blockchain; Decrypting the encrypted system privacy contract code using the chain key to obtain the system privacy contract code; the system privacy contract code includes the key management contract and other system contracts whose source codes cannot be made public; The system privacy contract code is loaded into the contract virtual machine of the blockchain to implement the code logic of the system privacy contract code.

10. The method according to any one of claims 1 to 9, It is characterized in that The querying the business contract key corresponding to the target business contract from the key management service includes: Obtain the business code hash value and business user address of the target business contract; Using the service code hash value and the service user address as keys, querying the value corresponding to the key from the key management service; The value corresponding to the key constitutes the business contract key corresponding to the target business contract.

11. The method according to claim 10, It is characterized in that The method further comprises: Obtaining a chain key of the blockchain; For any business contract in the privacy contract factory, obtain the business code hash value, business user address and current block hash value of the blockchain of the business contract; Generate a business contract key for the business contract based on the chain key, the business code hash value of the business contract, the business user address, and the current block hash value of the blockchain; Generate a key-value pair to be stored using the business code hash value of the business contract and the business user address as a key and the business contract key as a value; The key-value pair to be stored is stored in the key management service.

12. The method according to any one of claims 1 to 9, It is characterized in that The method further comprises: If the data processing request is a transaction request, obtaining a business public key corresponding to the target business contract; Encrypting the data processing result using the business public key to obtain a first encrypted data processing result; Saving the first encrypted data processing result in the ledger of the blockchain; If the data processing request is a query request, obtaining a business user public key corresponding to the target business contract; Encrypting the data processing result using the service user's public key to obtain a second encrypted data processing result; The second encrypted data processing result is returned to the client.

13. A data processing device based on blockchain, It is characterized in that The device comprises: A parameter acquisition module, configured to acquire a call parameter from a data processing request in response to receiving the data processing request sent by the client; A business contract query module, for querying a target business contract corresponding to the data processing request from the privacy contract factory based on the call parameters if the smart contract corresponding to the data processing request is a business contract in a privacy contract factory; the privacy contract factory stores a plurality of encrypted business contracts; A key query module, used to query a business contract key corresponding to the target business contract from a key management service; A decryption module, used to decrypt the target business contract using the business contract key to obtain a contract code of the target business contract; The code execution module is used to call the smart contract virtual machine to execute the contract code and obtain the data processing result corresponding to the data processing request.

14. An electronic device, It is characterized in that include: A memory for storing executable instructions; The processor is used to implement the blockchain-based data processing method described in any one of claims 1 to 12 when executing the executable instructions stored in the memory.

15. A computer-readable storage medium, It is characterized in that Executable instructions are stored, which are used to cause the processor to execute the executable instructions to implement the blockchain-based data processing method described in any one of claims 1 to 12.

16. A computer program product or a computer program, the computer program product or the computer program comprising executable instructions stored in a computer readable storage medium; When the processor of the electronic device reads the executable instructions from the computer-readable storage medium and executes the executable instructions, the blockchain-based data processing method described in any one of claims 1 to 12 is implemented.