Blockchain privacy protection method, electronic device and computer-readable storage medium
By adopting non-consensus contracts and zero-knowledge proof protocols in the alliance blockchain, local execution and verification of nodes are achieved, which solves the problem of data privacy leakage during the blockchain calculation process, ensures privacy and reliability, and is suitable for complex applications. business scenario.
Patent Information
- Application Number
- CN202111661728.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-30
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2041-12-30
AI Technical Summary
When the alliance blockchain executes smart contracts, there may be defects in data privacy leakage between nodes participating in the consensus. It is difficult for existing technology to effectively protect the privacy of the computing process.
Using non-consensus contracts and zero-knowledge proof protocols, non-consensus contracts are executed locally to generate results and proofs, and are verified among blockchain nodes through consensus transaction proposals to ensure the privacy and reliability of the calculation process.
Through local execution of non-consensus contracts and verification results, the privacy and security of data and calculation processes between participating computing nodes are guaranteed, while the reliability of node execution is improved, which is suitable for the universal needs of complex business scenarios.
Smart Images

Figure CN114374554B
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer application technology, and in particular, relates to a blockchain privacy protection method, an electronic device, and a computer-readable storage medium. Background Art
[0002] The alliance blockchain is designed based on the Byzantine consensus algorithm theory. When executing smart contracts, the nodes participating in the consensus will synchronize the data input, calculation process and output to each consensus node. Under the existing consensus algorithm and smart contract virtual machine architecture, the data between the nodes participating in the business calculation may have the defect of privacy leakage. Summary of the invention
[0003] The embodiments of the present application provide a blockchain privacy protection method, an electronic device, and a computer-readable storage medium, which can protect the privacy security of the data and the computing process on the chain between the nodes participating in the computing in the blockchain.
[0004] In a first aspect, the present application provides a blockchain privacy protection method, which may include:
[0005] According to the call request sent by the client for the non-consensus contract, the non-consensus contract is executed locally to generate results and proofs;
[0006] Obtaining a consensus transaction proposal based on the result and the proof, and broadcasting the consensus transaction proposal;
[0007] The consensus transaction proposal is used to instruct the nodes in the blockchain to verify the proof based on the result and execute the consensus algorithm during the execution of the smart contract.
[0008] In a possible implementation of the first aspect, the non-consensus contract includes a zero-knowledge proof protocol, and the zero-knowledge proof protocol is used to generate the proof when executing the non-consensus contract.
[0009] In a possible implementation manner of the first aspect, locally executing the non-consensus contract and generating a result and a proof includes:
[0010] Compile the non-consensus contract through a non-consensus contract virtual machine to obtain an arithmetic circuit and constraints;
[0011] The arithmetic circuit and the constraint are executed to obtain the proof and the result.
[0012] In a possible implementation manner of the first aspect, after obtaining and generating a consensus transaction proposal based on the result and the proof, the method further includes:
[0013] The consensus transaction proposal is sent to a master node in the blockchain, where the consensus transaction proposal is used to instruct the master node to broadcast the consensus transaction proposal.
[0014] In a possible implementation manner of the first aspect, before broadcasting the consensus transaction proposal, the method further includes:
[0015] Sending the result and the proof to the client; the result and the proof are used to instruct the client to generate the consensus transaction proposal by combining the result and the proof with input parameters;
[0016] Receive the consensus transaction proposal sent by the client.
[0017] In a possible implementation manner of the first aspect, the method further includes:
[0018] If the nodes in the blockchain verify the proof and pass the consensus algorithm, the state database is modified after the execution of the smart contract is completed based on the results.
[0019] In a possible implementation manner of the first aspect, the method further includes:
[0020] If the nodes in the blockchain fail to verify the proof and the execution of the consensus algorithm passes, the execution of the smart contract is stopped.
[0021] In a possible implementation manner of the first aspect, the method further includes:
[0022] If the verification results of the nodes in the blockchain for the proof verification are inconsistent, the nodes corresponding to the abnormal verification results in the inconsistent verification results will be eliminated during the execution of the consensus algorithm.
[0023] In a second aspect, an embodiment of the present application provides a blockchain privacy protection device, which may include:
[0024] A local execution unit, used to execute the non-consensus contract locally according to the call request sent by the client for the non-consensus contract, and generate results and proofs;
[0025] A consensus execution unit is used to obtain a consensus transaction proposal generated based on the result and the proof, and broadcast the consensus transaction proposal; wherein the consensus transaction proposal is used to instruct the nodes in the blockchain to verify the proof based on the result and execute the consensus algorithm during the execution of the smart contract.
[0026] In a third aspect, the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the first aspect when executing the computer program.
[0027] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect is implemented.
[0028] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute the method described in the first aspect above.
[0029] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect and will not be repeated here.
[0030] Compared with the prior art, the present application has the following beneficial effects: through the present application, the nodes participating in the calculation in the blockchain execute the non-consensus contract locally according to the call request sent by the client for the non-consensus contract, generate results and proofs; obtain a consensus transaction proposal generated based on the results and the proof, and broadcast the consensus transaction proposal; wherein the consensus transaction proposal is used to instruct the nodes in the blockchain to verify the proof based on the results and execute the consensus algorithm during the execution of the smart contract; the nodes of the present application execute the non-consensus contract locally, and verify the generated results and proofs in the consensus stage of the blockchain node execution of the smart contract, which can ensure the privacy security of the data and the calculation process participating in the calculation between the nodes participating in the calculation, and at the same time, through the verification of the results and proofs, the reliability of the node's local execution of the non-consensus contract can also be guaranteed; it has strong ease of use and practicality. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0032] Figure 1 It is a schematic diagram of the system architecture application scenario provided by the embodiment of the present application;
[0033] Figure 2 It is a flowchart of the blockchain privacy protection method provided by the embodiment of the present application;
[0034] Figure 3This is a schematic diagram of the architecture of blockchain privacy protection provided by an embodiment of the present application;
[0035] Figure 4 This is a schematic diagram of the architecture of blockchain privacy protection provided by another embodiment of the present application;
[0036] Figure 5 It is a structural diagram of a blockchain privacy protection device provided in an embodiment of the present application;
[0037] Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0038] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0039] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0040] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0041] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0042] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0043] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0044] As a public ledger, blockchain solves the trust problem among all parties through the established consensus mechanism. However, at the same time, all transaction information uploaded by users will be synchronized to the consensus nodes in the blockchain. If the transaction information is maliciously mined or used, it will pose a serious threat to user privacy.
[0045] Exemplarily, methods for protecting blockchain privacy may include signature consensus and hash consensus on transactions, or on-chain homomorphic encryption calculations.
[0046] For example, a privacy transfer design is performed for the built-in transfer or evidence transaction of the blockchain platform. When initiating a privacy transaction through a call from the client, the participating nodes of the privacy transaction are specified. The participating nodes of the privacy transaction execute the privacy transaction locally, and after completing the signature consensus within these participating nodes, the hash of the privacy transaction is broadcast within the chain. The privacy transaction completes the hash consensus among all consensus nodes. This method is limited to non-complex smart contract transactions and does not meet the universality of business needs.
[0047] For another example, the blockchain platform provides the function of homomorphic encryption on the chain. While the built-in homomorphic encryption algorithm is used, the homomorphic encryption calculation method is open to the smart contract. The private data is encrypted before the participating nodes are on the chain, and synchronized after homomorphic processing on the chain. This method is mainly due to the low performance of the current homomorphic encryption algorithm engineering implementation in the industry, and the speed of the full homomorphic encryption scheme is almost unusable, which leads to many limitations of the scheme in actual business scenarios.
[0048] The embodiment of the present application provides a blockchain privacy protection method, which adds a non-consensus contract on the basis of the smart contract of the blockchain consensus node, and the non-consensus contract is only executed locally on the node of the business participant. At the same time, the non-consensus contract is deployed with a zero-knowledge proof zk-SNARK (zero-knowledge Succinct Non-Interactive Arguments of Knowledge, zero-knowledge, succinct, non-interactive knowledge argument, referred to as zero-knowledge proof) protocol, which can ensure the reliability of the results of the local execution of the non-consensus contract by the business participant node. When the consensus node in the blockchain executes the smart contract, the results and proofs generated by the execution of the non-consensus contract are verified, ensuring the privacy and security of local computing.
[0049] The following is an example of an implementation of the calculation process of blockchain privacy protection in this application. The execution subject of the method steps in the embodiments of this application can be an electronic device, which can be a computing device such as a desktop computer, a notebook, a PDA, and a cloud server; it should be understood that the electronic device can be a node participating in business calculations in the blockchain, and the node is deployed with a non-consensus contract.
[0050] See also Figure 1 , Figure 1 Schematic diagram of the system architecture application scenario provided by the embodiment of the present application. Figure 1 As shown, the blockchain system architecture may include multiple consensus nodes; for example, node A, node B, node C and node D.
[0051] For example, if there is business logic to be processed between node A and node B, node C and node D do not participate; node A mainly performs the calculation of business logic, then the corresponding non-consensus contract is deployed on node A based on the business logic. Node B can issue the parameters required for processing business logic through broadcasting; based on the call of the blockchain software development kit (SDK), node A executes the non-consensus contract locally after receiving the parameters to obtain the results and proofs; node A, as the execution subject, can package the results and proofs into a new consensus transaction proposal through the blockchain SDK, and send the consensus transaction proposal to one or more nodes in the blockchain, and the master node of the one or more nodes broadcasts the consensus transaction proposal, and then executes the smart contract through the consensus node in the blockchain, each consensus node verifies the proof in the consensus transaction proposal, and each node of the blockchain executes the on-chain consensus process. Since other nodes in the blockchain (such as node B, node C, and node D) cannot know the calculation process of node A and the data that node A participates in the local calculation, node B only knows that node A can perform business logic calculations (negotiated in advance based on the business type), thereby ensuring the privacy and security of node A's local calculations.
[0052] For example, after node B broadcasts the parameters required for processing business logic, although nodes C and D receive the parameters, they will not process the parameters because they are not involved in the business logic. The blockchain SDK has added transaction proposals that can support non-consensus contracts (such as transaction proposals between nodes A and B). The nodes involved in business logic calculations in the blockchain have built-in source code libraries for non-consensus contracts and zero-knowledge proofs, as well as virtual machines for non-consensus contracts.
[0053] It should be noted that Figure 1 This is only an example and does not limit the number of nodes involved in business logic processing. The nodes involved in business logic processing are not limited to one node. According to the needs of the business type, it can also include multiple nodes that execute non-consensus contracts locally, and the non-consensus contracts between different nodes are also different. It can be applied to the processing of larger or more complex businesses in consortium blockchains. While ensuring the security of blockchain privacy data, it also ensures that the processing performance of the blockchain will not decrease due to the complexity of the business, thereby supporting the processing of larger business data volumes and supporting the universality of business needs.
[0054] Based on the above overall implementation process, the embodiment of the present application provides a blockchain privacy protection method. The specific process of implementing the method is introduced below through the embodiment of the present application.
[0055] See also Figure 2 , Figure 2This is a flowchart of a blockchain privacy protection method provided by an embodiment of the present application. This method can be a node or nodes participating in the business logic calculation, and the node can be an electronic device, such as Figure 2 As shown, the method comprises the following steps:
[0056] S201, according to the call request sent by the client for the non-consensus contract, the non-consensus contract is executed locally to generate results and proofs.
[0057] In some embodiments, nodes participating in business logic calculations are deployed with non-consensus contracts, which are contracts that are only executed locally by the nodes and do not participate in the blockchain consensus. The business logic part of the non-consensus contract can be developed by blockchain application developers as needed.
[0058] For example, in the actual application process, the node in the blockchain provides a development interface for the blockchain application developer, and the node receives the business logic developed by the blockchain application developer according to the business needs based on the interface. Then the node compiles the code of the business logic according to the zero-knowledge proof logic through the compiler of the virtual machine to obtain an arithmetic circuit that can be verified by the consensus algorithm of the blockchain, and compiles the business logic in the non-consensus contract into machine executable code. The node executes the compiled executable code and arithmetic circuit locally, and obtains the result and proof through calculation.
[0059] Exemplarily, the blockchain SDK supports transaction proposals corresponding to non-consensus contracts. When the client initiates a call request, it calls the non-consensus contract of the node by calling the blockchain SDK. The node executes the non-consensus contract locally according to the parameters in the call request and the corresponding call method in the call request, performs local calculations, generates a result R and a proof, which can be a zero-knowledge proof P. The node returns the result R and the zero-knowledge proof P to the blockchain SDK.
[0060] It should be noted that the SDK of the blockchain can be the SDK of the entire blockchain system. If multiple nodes involved in business logic processing are deployed with non-consensus contracts, the call request initiated by the client can be called through the blockchain SDK to the non-consensus contract of the node corresponding to the call request, and the called node will execute the non-consensus contract locally. The blockchain SDK can be built into the entire blockchain system, or it can be deployed on the blockchain's master node or on a node with a non-consensus contract deployed.
[0061] Among them, in the embodiment of the present application, the blockchain SDK is built into the node participating in the local calculation of the business logic as an example, and the node is described as the execution subject; the client can also be an application running on the node, or an application running on a certain node or entity terminal (which can be connected to the node participating in the local calculation of the business logic). In this application, the carrier corresponding to the SDK is not limited, it can be on a certain node or on the entire blockchain system. The SDK can realize the function of supporting transaction proposals for non-consensus contracts, and the transaction proposals for non-consensus contracts can be call requests initiated by the above-mentioned client.
[0062] Exemplarily, the call request may also be initiated by a client corresponding to a node in the blockchain that participates in the business logic calculation. For example, node B broadcasts parameters for business logic calculation, and node A receives the parameters and calls the SDK to call the non-consensus contract, and node A executes the non-consensus contract locally.
[0063] Exemplarily, the generated proof is used to verify the credibility of the calculation process corresponding to the result. Since it is a calculation involving two or more parties, verification in the subsequent consensus process can ensure that the credibility of the consensus can be achieved even when the node executes non-consensus contracts locally and does not participate in the consensus.
[0064] Exemplarily, the call request is a request for a requesting node to execute a non-consensus contract, and the call request may include the method that needs to be called in the non-consensus contract and parameter information of the method call, etc.
[0065] In some embodiments, the non-consensus contract includes a zero-knowledge proof protocol, which is used to generate the proof when executing the non-consensus contract.
[0066] Exemplarily, since the nodes involved in the business logic calculation have a built-in source code library of the zero-knowledge proof protocol, when the nodes execute the non-consensus contract locally, they generate the proof by executing the arithmetic circuit of the zero-knowledge proof, which is used to ensure the credibility of the execution of the business logic code in the non-consensus contract.
[0067] In some embodiments, locally executing the non-consensus contract and generating a result and a proof includes:
[0068] The non-consensus contract is compiled by a non-consensus contract virtual machine to obtain an arithmetic circuit and constraints; the arithmetic circuit and the constraints are executed to obtain the proof and the result.
[0069] For example, through the improved compiler in the non-consensus contract virtual machine, the nodes participating in the local calculation of business logic can convert the non-consensus contract into arithmetic circuits and constraints, and compile the business logic code in the non-consensus contract into a circuit that can be verified by the consensus algorithm of the blockchain according to the logic of zero-knowledge proof; thereby, the nodes can achieve the credibility of consensus through verification when executing non-consensus contracts locally and do not participate in consensus.
[0070] S202, obtaining a consensus transaction proposal generated based on the result and the proof, and broadcasting the consensus transaction proposal.
[0071] The consensus transaction proposal is used to instruct the nodes in the blockchain to verify the proof based on the result and execute the consensus algorithm during the execution of the smart contract.
[0072] In some embodiments, after the node executes the results and proofs generated by the non-consensus contract locally, it can feed back to the SDK of the blockchain or the SDK of the node participating in the business logic calculation. The SDK packages the results and proofs and combines them with other input information to generate a consensus transaction proposal.
[0073] For example, after the node is executed locally, since it has not yet passed the consensus of the blockchain, the caller's SDK will use the result and proof as part of the consensus transaction proposal of the blockchain, combine it with other input information, package it to generate a consensus transaction proposal, and send the consensus transaction proposal to the consensus node of the blockchain.
[0074] Exemplarily, the consensus node can be a node that performs local computing, or any one or more nodes in the blockchain. If the consensus node that receives the consensus transaction proposal is a non-master node, the consensus node sends the consensus transaction proposal to the master node, and the master node broadcasts the consensus transaction proposal.
[0075] Exemplarily, if the node performing local computing is a master node, after receiving the consensus transaction proposal, the node broadcasts the consensus transaction proposal and executes a consensus algorithm based on the consensus transaction proposal.
[0076] Among them, when the consensus node of the blockchain executes the consensus algorithm, the proof in the consensus transaction proposal is verified by calling the verification method in the smart contract.
[0077] Exemplarily, during the execution of the consensus algorithm, each consensus node in the blockchain participates in the execution, including the node that previously performed local calculations. In the blockchain, after receiving the consensus transaction proposal, each consensus node parses the consensus transaction proposal, obtains the result of the local calculation and proves the parsed result of the smart contract input to the consensus node. During the execution of the smart contract, the consensus node internally verifies the result and proof, and executes the subsequent consensus algorithm based on the verification result.
[0078] For example, in the blockchain consensus process, the relationship between the verification result and the proof is verified by calling the verification method in the smart contract; after the verification is passed, the next logical operation in the smart contract is continued. If after the verification is passed, if the execution of the business logic has been completed and there is no logic to continue to execute in the smart contract, the verification is returned and the execution ends; if there is other business logic to be executed in the smart contract, the logic in the smart contract is continued to be executed after the verification is passed. The specific execution method can be determined according to the business type, and the blockchain consensus process is not specifically limited here.
[0079] It should be noted that in the process of executing smart contracts and consensus algorithms, each consensus node is an execution entity, including nodes that perform local calculations.
[0080] For example, Figure 3 As shown, if there is business logic to be processed between node A and node B, node C and node D do not participate; node A mainly performs the calculation of business logic, and the corresponding non-consensus contract is deployed on node A based on the business logic. Node B can send out the parameters required for processing business logic by broadcasting (such as step ①); based on the call of the blockchain software development kit (SDK), node A executes the non-consensus contract locally after receiving the parameters and obtains the result and proof (such as step ②); node A, as the execution subject, can package the result and proof into a new consensus transaction proposal through the blockchain SDK, and send the consensus transaction proposal to one or more nodes in the blockchain (such as step ③), and the master node of the one or more nodes broadcasts the consensus transaction proposal, and then executes the smart contract through the consensus node in the blockchain, and each consensus node verifies the proof in the consensus transaction proposal, and each node of the blockchain executes the process of consensus on the chain.
[0081] For example, Figure 4As shown in Figure 1, when the business logic to be processed requires the participation of multiple nodes, if there is business logic to be processed between nodes A and B, which requires the participation of nodes A and B, non-consensus contracts are deployed on both nodes A and B. Due to the different calculation processes of nodes A and B, the non-consensus contract deployed by node A is different from the non-consensus contract deployed by node B. Steps ① and ② are similar to Figure 3 The same as the embodiment in the embodiment, after node A executes the non-consensus contract locally based on the call of the blockchain SDK, the generated result and proof are fed back to the blockchain SDK, and the result and proof are packaged by the SDK to generate a transaction proposal; the transaction proposal can be directly sent to node B (such as solid line step ③) (it can also be sent through broadcast (such as dotted line step ③ and solid line step ③), but other nodes in the blockchain except node B will not process it after receiving it), and node B executes the non-consensus contract locally based on the transaction proposal (such as step ④, and the execution process can also include a verification process for the result and proof generated by node A), generates results and proofs, and feeds back the results and proofs to the blockchain SDK, and the results and proofs generated by node B are packaged by the SDK to generate a consensus transaction proposal, and the consensus transaction proposal is submitted to the master node of the blockchain (the master node can be node B), and the master node broadcasts the consensus transaction proposal (such as step ⑤), and each consensus node in the blockchain executes the smart contract and consensus algorithm based on the consensus transaction proposal to verify the result and proof relationship generated by node B.
[0082] Exemplarily, there can be multiple nodes participating in the local calculation of business logic. Based on the same implementation principle, the nodes participating in the local calculation execute non-consensus contracts locally and generate results and proofs. After completing the local calculation, in the process of executing the smart contract, the consensus node in the blockchain verifies the relationship between the result and the proof by calling the verification method, so that the local execution process that does not participate in the consensus can achieve the credibility of the consensus; at the same time, it can also support large-volume and complex logical calculations, ensuring the performance of the blockchain.
[0083] In some embodiments, after obtaining and generating a consensus transaction proposal based on the result and the proof, the method further comprises:
[0084] The consensus transaction proposal is sent to a master node in the blockchain, where the consensus transaction proposal is used to instruct the master node to broadcast the consensus transaction proposal.
[0085] Exemplarily, if the node performing local calculations is not the master node in the blockchain, after obtaining the consensus transaction proposal, it can also be sent to the master node of the blockchain, and the master node broadcasts it; or, after the blockchain SDK generates a consensus transaction proposal, it can also be sent directly to the master node of the blockchain, and the master node broadcasts it; or, after the blockchain SDK generates a consensus transaction proposal, it sends it to any one or more designated nodes. If there is a master node among any one or more designated nodes, the master node broadcasts it; if there is no master node among any one or more designated nodes, any one or more designated nodes send it to the master node, and the master node broadcasts the consensus transaction proposal.
[0086] In some embodiments, before broadcasting the consensus transaction proposal, the method further includes:
[0087] The result and the proof are sent to the client; the result and the proof are used to instruct the client to generate the consensus transaction proposal by combining the result and the proof with input parameters; and the consensus transaction proposal sent by the client is received.
[0088] Exemplarily, the client can be an application running on the node, or an application running on a terminal device associated with the node. If the client is an application running on the node, the blockchain-based SDK can receive the result and proof, and use the result and proof as input, combined with other input parameters to generate a new consensus transaction proposal, and the node obtains the consensus transaction proposal generated by the blockchain-based SDK.
[0089] In some embodiments, the method further comprises:
[0090] If the nodes in the blockchain verify the proof and pass the consensus algorithm, the state database is modified after the execution of the smart contract is completed based on the results.
[0091] For example, if there are other business logics in the smart contract, then after verification and consensus, other business logics in the smart contract can continue to be executed, and after execution is completed, each consensus node modifies the state database according to the execution results, and waits for the consensus transaction proposal to be packaged and blocked. If there are no other business logics in the smart contract, then after consensus is passed, each consensus node modifies the state database according to the results.
[0092] In some embodiments, the method further comprises:
[0093] If the nodes in the blockchain fail to verify the proof and the execution of the consensus algorithm passes, the execution of the smart contract is stopped.
[0094] For example, if a node makes a local execution error or an error occurs in the calculation process of generating a proof, the proof will fail to be verified during the execution of the smart contract, and a prompt message indicating the verification failure will be output; however, this information does not affect the blockchain consensus process; after the consensus is passed, the subsequent logic of the smart contract will be stopped due to the verification failure, and the consensus transaction proposal will wait for packaging and blocking.
[0095] In some embodiments, the method further comprises:
[0096] If the verification results of the nodes in the blockchain for the proof verification are inconsistent, the nodes corresponding to the abnormal verification results in the inconsistent verification results will be eliminated during the execution of the consensus algorithm.
[0097] For example, during the execution of a smart contract by a consensus node of a blockchain, after verifying the proof, if there is an inconsistency in the verification results, there may be a malicious node (for example, a node with a local calculation error), and the malicious node can be eliminated during the subsequent execution of the consensus algorithm.
[0098] For example, in actual application scenarios, take the alliance chain composed of four nodes A, B, C, and D as an example, where there is a clearing business between A and B, while C and D do not participate in the business. A and B will use the non-consensus contract NC to calculate the difference based on the local ledger data of the node VP, and obtain the other party's net claim or net debt R and the calculated proof P, and then pass R and P to the smart contract C for comparison within the consensus contract. After verifying P output by the non-consensus contract NC through the smart contract C, R can be used for the final step of clearing.
[0099] For example, if node A does not deploy a non-consensus contract, and node B deploys a non-consensus contract, node A receives the output of node B executing the non-consensus contract locally by executing the smart contract; node A uses the output as input and continues to execute the smart contract for calculation. In one embodiment, when node B executes the non-consensus contract locally, it may rely on some public data or data sent by node A; node A can first broadcast a data that node A can expose to node B, node C and node D on the smart contract, and nodes B, C and D can all see the data. However, only node B determines the purpose of the data. After receiving the data, node B uses the data as input, adds its own local private data, and uses both data as input to input into its own non-consensus contract, and executes the non-consensus contract locally to obtain the calculation result and proof. Then the result and proof are provided as input to the consensus smart contract. Then node A verifies the proof in the process of executing the smart contract and continues to execute the smart contract. In this process, node B's private data is not exposed, and node B's calculation process is not exposed. Node A knows that Node B is based on the data broadcast by Node A, its own local private data, and the calculation process of the non-consensus contract execution of Node B. Since Node B has reached an offline agreement with Node A before deploying the non-consensus contract, Node A knows the execution process of Node B, but does not know the private data of Node B. Node C and Node D only know the proof and results obtained after Node B executes the non-consensus contract, and can verify the relationship between the proof and the results in the process of executing the smart contract. Node C and Node D do not know other information; thus protecting the security of node privacy information under the complex operation logic of the smart contract.
[0100] Through the embodiments of the present application, the nodes participating in the calculation in the blockchain execute the non-consensus contract locally according to the call request sent by the client for the non-consensus contract, generate results and proofs; obtain a consensus transaction proposal based on the results and the proof, and broadcast the consensus transaction proposal; wherein the consensus transaction proposal is used to instruct the nodes in the blockchain to verify the proof based on the results and execute the consensus algorithm during the execution of the smart contract; the nodes of the present application execute the non-consensus contract locally, and verify the generated results and proofs in the blockchain consensus stage, which can ensure the privacy and security of the data and the calculation process involved in the calculation between the nodes participating in the calculation, and at the same time, the reliability of the node's local execution of the non-consensus contract can be guaranteed by verifying the results and proofs.
[0101] The embodiment of the present application expands the ability of private transfer transactions and protects the privacy of smart contracts under complex operation rules; through the zero-knowledge proof protocol, it can ensure that non-consensus contracts can achieve the credibility of participating in consensus even if they do not participate in the consensus during the execution process; the reliability of local execution logic is guaranteed by the zero-knowledge proof protocol; the improvement of the embodiment of the present application is less invasive to the original blockchain architecture, and only the zero-knowledge proof source code library is built into the node participating in the local calculation of the business, the blockchain SDK is modified to support the transaction proposal of non-consensus contracts, a non-consensus contract virtual machine is added to the node, and the original smart contract language compiler is modified to add a method function for verification proof. The embodiment of the present application combines the characteristics of the zk-SNARK algorithm with the execution mode of the smart contract to propose a smart contract execution scheme with node-level privacy protection capabilities; a transformation scheme with less intrusion and workload is achieved by transforming the source code level of the blockchain node.
[0102] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0103] Corresponding to the blockchain privacy protection method described in the above embodiment, Figure 5 A structural block diagram of the blockchain privacy protection device provided in an embodiment of the present application is shown. For the sake of convenience of explanation, only the parts related to the embodiment of the present application are shown.
[0104] Reference Figure 5 , the device comprises:
[0105] A local execution unit 51 is used to execute the non-consensus contract locally according to the call request sent by the client for the non-consensus contract, and generate a result and a proof;
[0106] The consensus execution unit 52 is used to obtain a consensus transaction proposal generated based on the result and the proof, and broadcast the consensus transaction proposal; wherein the consensus transaction proposal is used to instruct the nodes in the blockchain to verify the proof based on the result and execute the consensus algorithm during the execution of the smart contract.
[0107] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0108] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0109] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0110] An embodiment of the present application provides a computer program product. When the computer program product runs on a mobile terminal, the mobile terminal can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0111] Figure 6 This is a schematic diagram of the structure of an electronic device 6 provided in an embodiment of the present application. Figure 6 As shown, the electronic device 6 of this embodiment includes: at least one processor 60 ( Figure 6 Only one is shown), a memory 61, and a computer program 62 stored in the memory 61 and executable on the at least one processor 60, wherein the processor 60 implements the steps in the above-described embodiments when executing the computer program 62.
[0112] The electronic device 6 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The electronic device 6 may include, but is not limited to, a processor 60 and a memory 61. Those skilled in the art will appreciate that Figure 6 It is only an example of the electronic device 6 and does not constitute a limitation on the electronic device 6. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, it may also include input and output devices, network access devices, etc.
[0113] The processor 60 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0114] In some embodiments, the memory 61 may be an internal storage unit of the electronic device 6, such as a hard disk or memory of the electronic device 6. In other embodiments, the memory 61 may also be an external storage device of the electronic device 6, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 6. Further, the memory 61 may also include both an internal storage unit of the electronic device 6 and an external storage device. The memory 61 is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of the computer program, etc. The memory 61 may also be used to temporarily store data that has been output or is to be output.
[0115] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium can at least include: any entity or device that can carry the computer program code to the camera / terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0116] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0117] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0118] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0119] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0120] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A blockchain privacy protection method, characterized in that: The method comprises: According to the call request sent by the client for the non-consensus contract, the non-consensus contract is executed locally to generate results and proofs; Obtaining a consensus transaction proposal based on the result and the proof, and broadcasting the consensus transaction proposal; In the blockchain consensus process, the relationship between the results and proofs in the consensus transaction proposal is verified by calling the verification method in the smart contract; Among them, the blockchain SDK supports transaction proposals for non-consensus contracts, and the transaction proposal includes the call request sent by the client, and the non-consensus contract is executed locally on the node of the business participant; the consensus transaction proposal is used to instruct the nodes in the blockchain to verify the proof based on the result during the execution of the smart contract and execute the consensus algorithm.
2. The method according to claim 1, characterized in that The non-consensus contract includes a zero-knowledge proof protocol, which is used to generate the proof when executing the non-consensus contract.
3. The method according to claim 2, characterized in that The non-consensus contract is executed locally to generate results and proofs, including: Compile the non-consensus contract through a non-consensus contract virtual machine to obtain an arithmetic circuit and constraints; The arithmetic circuit and the constraint are executed to obtain the proof and the result.
4. The method according to claim 1, characterized in that After obtaining and generating a consensus transaction proposal based on the result and the proof, the method further includes: The consensus transaction proposal is sent to a master node in the blockchain, where the consensus transaction proposal is used to instruct the master node to broadcast the consensus transaction proposal.
5. The method according to claim 1, characterized in that Before broadcasting the consensus transaction proposal, the method further includes: Sending the result and the proof to the client; the result and the proof are used to instruct the client to generate the consensus transaction proposal by combining the result and the proof with input parameters; Receive the consensus transaction proposal sent by the client.
6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: If the nodes in the blockchain verify the proof and pass the consensus algorithm, the state database is modified after the execution of the smart contract is completed based on the results.
7. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: If the nodes in the blockchain fail to verify the proof and the execution of the consensus algorithm passes, the execution of the smart contract is stopped.
8. The method according to any one of claims 1 to 5, characterized in that The method further comprises: If the verification results of the nodes in the blockchain for the proof verification are inconsistent, the nodes corresponding to the abnormal verification results in the inconsistent verification results will be eliminated during the execution of the consensus algorithm.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 8 is implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 8.
