Disclosure of Invention
Accordingly, an objective of the present application is to provide a privacy calculating method and related device based on intelligent contracts in blockchain.
Based on the above object, the present application provides a privacy calculation method, which is performed by an intelligent contract system in a blockchain, the method comprising:
In response to determining that a computing transaction contained in an intelligent contract in the blockchain meets a trigger condition, for each of a plurality of participants involved in the computing transaction, invoking encrypted data and a digital certificate of the participant, and decrypting the encrypted data with the digital certificate to obtain original data of the participant;
Based on all the original data, executing the calculation logic corresponding to the calculation transaction to obtain a calculation result,
Wherein the smart contract is pre-established by the plurality of participants for the computing transaction and is signed with a private key of each of the plurality of participants and stored in the blockchain,
After the original data of each of the plurality of participants is encrypted in advance with the private key of that participant, the encrypted data as that participant is stored into the blockchain together with the digital certificate of that participant,
The digital certificate is generated by authenticating the public key of the participant through a certificate center and encrypting the basic information of the participant by using the public key of the certificate center.
Further, the method also comprises encrypting the calculation result through the digital certificate of each of the plurality of participants and returning the calculation result to the service demander.
Further, when each of the plurality of participants is preregistered with the blockchain, the blockchain generates a pair of public and private keys for that participant.
Further, the decrypting the encrypted data using the digital certificate to obtain the original data of the party includes:
Decrypting the digital certificate by the public key of the certificate center to obtain the public key of the party, and decrypting the encrypted data by the public key of the party.
Further, the intelligent agent, approximately before being stored into the blockchain, comprises:
Each of the plurality of participants respectively carries out code audit on the intelligent contract, signs the intelligent contract through the private key after the audit is finished, and links the signed intelligent contract.
Further, the smart contract is stored into the blockchain, including:
Broadcasting the intelligent contracts in a blockchain, initiating consensus verification after a verification node in the blockchain receives the intelligent contracts, packaging the plurality of intelligent contracts subjected to the consensus verification into a contract set, broadcasting the contract set in the blockchain in a block mode, verifying each intelligent contract by the node receiving the contract set, and storing the intelligent contracts in the blockchain after the intelligent contracts pass the verification.
Further, the smart contract system periodically checks a trigger condition of a state machine and the computing transaction contained by the smart contract and pushes the computing transaction to each validation node in the blockchain in response to determining that the state machine indicates that the smart contract is not complete and the trigger condition is satisfied;
In response to receiving validation passing information for the computing transaction by a majority of the validation nodes in the blockchain, the smart contract system determines that the computing transaction satisfies the trigger condition and executes the computing transaction.
Based on the same inventive concept, the application also provides an intelligent contract system for privacy calculation in a blockchain, which comprises the following steps:
The data acquisition module is used for responding to the fact that the computing transaction contained in the intelligent contract in the blockchain meets the triggering condition, calling the encryption data and the digital certificate of each party in a plurality of parties involved in the computing transaction, and decrypting the encryption data by utilizing the digital certificate to obtain the original data of the party;
a calculation module for executing the calculation logic corresponding to the calculation transaction based on all the original data to obtain a calculation result,
Wherein the smart contract is pre-established by the plurality of participants for the computing transaction and is signed with a private key of each of the plurality of participants and stored in the blockchain,
After the original data of each of the plurality of participants is encrypted in advance with the private key of that participant, the encrypted data as that participant is stored into the blockchain together with the digital certificate of that participant,
The digital certificate is generated by authenticating the public key of the participant through a certificate center and encrypting the basic information of the participant by using the public key of the certificate center.
Based on the same inventive concept, the application also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable by the processor, wherein the processor realizes the method for privacy calculation based on intelligent contracts in blockchain as described in any of the above when executing the computer program.
From the above, the privacy computing method and the related device based on the intelligent contract in the blockchain provided by the application ensure the security and privacy of data in the privacy computing process by using the intelligent contract system in the blockchain, ensure the accuracy and reliability of the data by calling the intelligent contract computing which cannot be tampered, and solve the data security trust problem of users in the computing process.
Detailed Description
The present application will be further described in detail below with reference to specific embodiments and with reference to the accompanying drawings, in order to make the objects, technical solutions and advantages of the present application more apparent.
It should be noted that unless otherwise defined, technical or scientific terms used in the embodiments of the present application should be given the ordinary meaning as understood by one of ordinary skill in the art to which the present application belongs. The terms "first," "second," and the like, as used in embodiments of the present application, do not denote any order, quantity, or importance, but rather are used to distinguish one element from another. The word "comprising" or "comprises", and the like, means that elements or items preceding the word are included in the element or item listed after the word and equivalents thereof, but does not exclude other elements or items. The terms "connected" or "connected," and the like, are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "upper", "lower", "left", "right", etc. are used merely to indicate relative positional relationships, which may also be changed when the absolute position of the object to be described is changed.
As described in the background art, when the computing program runs, all the original data needs to be called, so that the problem of user data leakage is easy to occur. The development of blockchain technology has led us to a system that is decentralised, non-tamperable and highly reliable. The intelligent contract is automatically executed when a certain condition is met, but the problem that both sides of the contract trust, such as malicious tampering operation, cannot be guaranteed. The intelligent contract deployment based on the blockchain system can solve the trust problem of both transaction parties. The non-tamperability of the blockchain ensures that the content of the contract cannot be changed, the high reliability ensures that the contract is executed when the conditions are met, and the decentralization and the full network backup ensure the post audit. The privacy calculation is realized based on intelligent contracts in the blockchain, so that the safety and privacy of the multiparty user data can be well ensured, and the data security trust problem in the calculation process is solved.
All data on the blockchain is transparent to the application, so the data processing of the smart contract is transparent to the application, and any party can view the code and data during running. All data of the blockchain is not tamperable, so that intelligent contract codes deployed on the blockchain and data output generated by running are also not tamperable, and nodes running the intelligent contract do not need to worry about malicious modification of codes and data by other nodes. The nodes supporting the blockchain network often reach hundreds or even thousands, and the failure of part of the nodes does not lead to the stopping of the intelligent contract, and the reliability of the nodes is close to the permanent operation theoretically, so that the intelligent contract can be ensured to be effective at all times like a paper contract.
Embodiments of the present application are described in detail below with reference to the accompanying drawings.
Referring to fig. 1, the present application provides a privacy calculation method, which is performed by an intelligent contract system in a blockchain, comprising the steps of:
step S101, in response to determining that a computing transaction included in an intelligent contract in the blockchain meets a trigger condition, for each of a plurality of participants involved in the computing transaction, invoking encrypted data and a digital certificate of the participant, and decrypting the encrypted data by using the digital certificate to obtain original data of the participant.
Specifically, the smart contract includes a state machine, a computing transaction and a trigger condition, and when the computing transaction in the smart contract system meets the trigger condition, the smart contract needs to call the original data related to the computing transaction to execute the computation. The source of the raw data is multi-point, and may involve multiple parties depending on the business needs to provide or collect the data. Each party obtains a unique digital certificate from a certificate center in advance, and the intelligent contract calls the digital certificate of the party to decrypt the encrypted original data according to the authorization of the plurality of parties, and obtains the original data of the plurality of parties after the decryption is completed.
Step S102, based on all the original data, executing the calculation logic corresponding to the calculation transaction to obtain a calculation result,
Wherein the smart contract is pre-established by the plurality of participants for the computing transaction and is signed with a private key of each of the plurality of participants and stored in the blockchain,
After the original data of each of the plurality of participants is encrypted in advance with the private key of that participant, the encrypted data as that participant is stored into the blockchain together with the digital certificate of that participant,
The digital certificate is generated by authenticating the public key of the participant through a certificate center and encrypting the basic information of the participant by using the public key of the certificate center.
In particular, two or more participants in a presence transaction agree on a commitment and privacy calculation function contract in concert, based on specific needs. The contracts contain the rights and obligations of two or more parties, which are electronically recorded to form intelligent contracts, and the functional logic required for the private calculation data. Referring to fig. 2, a party 1 participating in the calculation registers a node account with a blockchain system, the blockchain system returns a public key and a private key for registering the node to the party 1, and the party 2 applies for registering the node account in the same manner. Party 1 and party 2 develop smart contract content for the specific computational logic and generate smart contract records. The participants send the smart contract content to the blockchain system, which signs and encrypts the smart contract content with the participants' private key, generating and returning the smart contract to the participants.
After the intelligent contract invokes the original data required by executing the computing transaction, executing corresponding computing logic to obtain a computing result. The original data is stored in the blockchain together with the digital certificate after being encrypted by the private key of each party. Meanwhile, the block chain calculates a Hash value of each piece of original data through a Hash algorithm, and stores the Hash value in a database in one-to-one correspondence with the original data. The Hash value is a unique identification of the original data to be queried, whereby each of said original data corresponds to one of the encrypted data and the Hash value. The digital certificate is issued to the participants by a third party organization certificate center, the certificate center authenticates the public key of the participants of the original data, and the public key of the participants, the identity information and the identity mark of the participants are encrypted by using the private key of the certificate center, so that the digital certificate is generated.
In some embodiments, the calculation is encrypted by the digital certificate of each of the plurality of participants and returned to the business demander.
Specifically, after the calculation transaction is executed to obtain a calculation result, the intelligent contract encrypts the calculation result through digital certificates of a plurality of participants and returns the calculation result to the service demander. If the calculation result relates to the situation of returning the data ID of the opposite party, for example, the recommendation system needs to return the user ID of the opposite party system, after the Hash value is comprehensively calculated by using the true data id+the random number of the opposite party, the opposite party user ID mixed by the random number numbers is returned to the service demand party.
In some embodiments, when each of the plurality of participants is preregistered with the blockchain, the blockchain generates a pair of public and private keys for that participant. Users participating in the smart contract must first register as users of the blockchain, which returns to the user a pair of public and private keys. The public key is used as an account address of the user on the blockchain, and the private key is used as a unique key for operating the account.
In some embodiments, decrypting the encrypted data using the digital certificate to obtain the primary data for the party includes:
Decrypting the digital certificate by the public key of the certificate center to obtain the public key of the party, and decrypting the encrypted data by the public key of the party. When the encrypted data needs to be decrypted, firstly, a digital certificate corresponding to the encrypted data is queried, then, the digital certificate is decrypted by using a public key of a certificate center to obtain a public key of a party to which the encrypted data belongs, the data encrypted by a private key of the party is decrypted by the public key of the party, the encryption process is also called asymmetric encryption, and the certificate center provides security assurance for the public key and the private key of the asymmetric encryption.
In some embodiments, the intelligence is about before being stored into the blockchain, comprising:
Each of the plurality of participants respectively carries out code audit on the intelligent contract, signs the intelligent contract through the private key after the audit is finished, and links the signed intelligent contract.
Specifically, for the privacy calculation logic of the business to be executed, two or more parties participating in the privacy calculation encapsulate the calculation process into executable functions according to the possibility of different businesses so as to ensure that the correct calculation logic is called when the intelligent contract is executed. Each participant performs code audit, to ensure the accuracy of calculation and the integrity of service, it is necessary to comb the service flow and provide test data, and then package test cases to perform test audit on the calculation logic code. In the calculation process of each participant, the data is ensured not to be transmitted and leaked. After the audit is finished, each participant confirms the intelligent contract in a uplink mode by triggering the triggering condition of the intelligent contract after the uplink is finished, executing the calculation transaction, acquiring the data of the calculation result and comparing the correctness of the calculation result.
In some embodiments, the smart contract is stored into the blockchain, including:
Broadcasting the intelligent contracts in a blockchain, initiating consensus verification after a verification node in the blockchain receives the intelligent contracts, packaging the plurality of intelligent contracts subjected to the consensus verification into a contract set, broadcasting the contract set in the blockchain in a block mode, verifying each intelligent contract by the node receiving the contract set, and storing the intelligent contracts in the blockchain after the intelligent contracts pass the verification.
Specifically, after the multiple parties reach the intelligent contract, the intelligent contract is broadcast in the blockchain whole network in a P2P mode, and each node receives a contract enabling. And after receiving the broadcasted intelligent contract, the verification node in the block chain firstly stores the intelligent contract into a memory to wait for the arrival of the consensus time.
After the consensus time comes, the verification node packages all intelligent contracts received in the time interval into a contract Set, calculates the Hash value of the contract Set, packages the Hash value of the contract Set in a block structure, and broadcasts the block structure.
After receiving the block structure, other verification nodes decompose the Hash value of the contract set in the structure, the current node compares the Hash value obtained by calculating the contract set with the Hash value in the block structure sent by other nodes after decomposing the block, the same is the correct calculation, then one contract set approved by the verification node is sent to other nodes, and through the multi-round sending and comparing, all verification nodes finally agree on the latest contract set in a specified time.
The newly agreed contract set is spread over the whole network in the form of blocks. Each block contains the Hash value of the current block, the Hash value of the previous block, the timestamp at which the consensus was reached, and other descriptive information. And after receiving the nodes of the latest contract set, verifying each intelligent contract in the contract set, wherein the verified intelligent contracts are finally stored in the blockchain, and the verified content mainly comprises whether the private key signature of the participant is matched with the account or not, and whether the signature is consistent with the original data or not is checked by decrypting the signature by using the public key of the participant.
Referring to fig. 3, parties 1 and 2 broadcast the smart contract in a blockchain, verifying that node 1 receives the smart contract and stores it within the node. When the consensus time comes, the verification node 1 packages all contracts stored in the node to form a contract set, calculates the Hash value of the contract set, packages the Hash value of the contract set in a block structure and broadcasts the Hash value in a block chain. After the verification node 2 receives the block structure, decomposing the block structure to obtain a Hash value, comparing the Hash value with the Hash value of the node to obtain a contract set approved by the node to the next verification node, obtaining the latest contract set until the nth verification point is reached, and finally broadcasting the latest contract set in a block form in a block chain network.
In some embodiments, the smart contract system periodically checks a state machine contained by the smart contract and a trigger condition for the computing transaction, and in response to determining that the state machine indicates that the smart contract is incomplete and the trigger condition is satisfied, pushes the computing transaction to each validation node in the blockchain;
In response to receiving validation passing information for the computing transaction by a majority of the validation nodes in the blockchain, the smart contract system determines that the computing transaction satisfies the trigger condition and executes the computing transaction.
Specifically, the intelligent contracts can periodically check the state of the automaton, traverse the state machines, the computing transactions and the triggering conditions contained in each intelligent contract one by one, push the computing transactions meeting the triggering conditions to the queue to be verified, wait for consensus, and store the computing transactions which do not meet the triggering conditions on the blockchain.
The computing transaction entering the latest round of verification is diffused to each verification node, the verification nodes firstly perform signature verification to ensure the validity of the computing transaction, the computing transaction passing verification enters a set to be agreed, and after most verification nodes reach agreement, the computing transaction is successfully executed and a service requiring party is notified.
After the execution of the computing transaction is successful, the state opportunity of the intelligent contract is carried by the intelligent contract to judge the state of the intelligent contract, when all the computing transactions included in the intelligent contract are sequentially executed, the state opportunity marks the state of the intelligent contract as being completed, and removes the intelligent contract from the latest block, otherwise, marks the state of the intelligent contract as being in progress, and then the state opportunity is stored in the latest block to wait for the next round of processing until the processing is completed. The whole calculation transaction and state processing is automatically completed by an intelligent contract system arranged in a block chain bottom layer, and the whole process is transparent and can not be tampered.
Referring to fig. 4, the intelligent contract system in the blockchain traverses the trigger condition of each intelligent contract at regular time, pushes the computing transaction meeting the trigger condition to the transaction queue to be verified, and the transaction queue to be verified includes computing transaction 1 and computing transaction 2. After the computing transaction in the transaction queue to be verified is sent to the verification node, the verification node firstly performs signature verification on the computing transaction, and after verification is passed, the computing transaction is stored in the set to be agreed. Each verification node verifies the calculation transaction respectively, and when most verification nodes reach consensus, the intelligent contract system executes the calculation transaction, and returns the calculation result to the service demand party after the calculation is finished. When all computing transactions in a contract are completed, the contract is removed from the block of validation nodes, and the contract state is marked as complete.
It should be noted that, the method of the embodiment of the present application may be performed by a single device, for example, a computer or a server. The method of the embodiment can also be applied to a distributed scene, and is completed by mutually matching a plurality of devices. In the case of such a distributed scenario, one of the devices may perform only one or more steps of the method of an embodiment of the present application, the devices interacting with each other to accomplish the method.
It should be noted that the foregoing describes some embodiments of the present application. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments described above and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
Based on the same inventive concept, the application also provides an intelligent contract system for privacy calculation in the blockchain, which corresponds to the method of any embodiment.
Referring to fig. 5, the intelligent contract system for privacy computation in a blockchain includes:
A data acquisition module 501, configured to, in response to determining that a computing transaction included in an intelligent contract in the blockchain meets a trigger condition, for each of a plurality of participants involved in the computing transaction, invoke encrypted data and a digital certificate of the participant, and decrypt the encrypted data with the digital certificate to obtain original data of the participant;
A calculation module 502, configured to execute calculation logic corresponding to the calculation transaction based on all the raw data, obtain a calculation result,
Wherein the smart contract is pre-established by the plurality of participants for the computing transaction and is signed with a private key of each of the plurality of participants and stored in the blockchain,
After the original data of each of the plurality of participants is encrypted in advance with the private key of that participant, the encrypted data as that participant is stored into the blockchain together with the digital certificate of that participant,
The digital certificate is generated by authenticating the public key of the participant through a certificate center and encrypting the basic information of the participant by using the public key of the certificate center.
For convenience of description, the above devices are described as being functionally divided into various modules, respectively. Of course, the functions of each module may be implemented in the same piece or pieces of software and/or hardware when implementing the present application.
The device of the foregoing embodiment is configured to implement the corresponding privacy calculation method based on the intelligent contract in the blockchain in any foregoing embodiment, and has the beneficial effects of the corresponding method embodiment, which is not described herein.
Based on the same inventive concept, the application also provides an electronic device corresponding to the method of any embodiment, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor implements the privacy calculation method based on the intelligent contract in the blockchain according to any embodiment when executing the program.
Fig. 6 shows a more specific hardware architecture of an electronic device provided by the present embodiment, which may include a processor 1010, a memory 1020, an input/output interface 1030, a communication interface 1040, and a bus 1050. Wherein processor 1010, memory 1020, input/output interface 1030, and communication interface 1040 implement communication connections therebetween within the device via a bus 1050.
The processor 1010 may be implemented by a general-purpose CPU (Central Processing Unit ), a microprocessor, an Application SPECIFIC INTEGRATED Circuit (ASIC), or one or more integrated circuits, etc. for executing related programs to implement the technical solutions provided in the embodiments of the present disclosure.
The Memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory ), static storage, dynamic storage, etc. Memory 1020 may store an operating system and other application programs, and when the embodiments of the present specification are implemented in software or firmware, the associated program code is stored in memory 1020 and executed by processor 1010.
The input/output interface 1030 is used to connect with an input/output module for inputting and outputting information. The input/output module may be configured as a component in a device (not shown) or may be external to the device to provide corresponding functionality. Wherein the input devices may include a keyboard, mouse, touch screen, microphone, various types of sensors, etc., and the output devices may include a display, speaker, vibrator, indicator lights, etc.
Communication interface 1040 is used to connect communication modules (not shown) to enable communication interactions of the present device with other devices. The communication module may implement communication through a wired manner (such as USB, network cable, etc.), or may implement communication through a wireless manner (such as mobile network, WIFI, bluetooth, etc.).
Bus 1050 includes a path for transferring information between components of the device (e.g., processor 1010, memory 1020, input/output interface 1030, and communication interface 1040).
It should be noted that although the above-described device only shows processor 1010, memory 1020, input/output interface 1030, communication interface 1040, and bus 1050, in an implementation, the device may include other components necessary to achieve proper operation. Furthermore, it will be understood by those skilled in the art that the above-described apparatus may include only the components necessary to implement the embodiments of the present description, and not all the components shown in the drawings.
The electronic device of the foregoing embodiment is configured to implement the corresponding privacy calculation method based on the intelligent contract in the blockchain in any foregoing embodiment, and has the beneficial effects of the corresponding method embodiment, which is not described herein.
Based on the same inventive concept, the present application also provides a non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the blockchain-based intelligent contract-in-block-chain-based privacy calculation method according to any of the above embodiments, corresponding to the above any of the above embodiments.
The computer readable media of the present embodiments, including both permanent and non-permanent, removable and non-removable media, may be used to implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device.
The storage medium of the above embodiment stores computer instructions for causing the computer to perform the privacy calculation method based on the intelligent contract in blockchain according to any of the above embodiments, and has the advantages of the corresponding method embodiments, which are not described herein.
It will be appreciated by persons skilled in the art that the foregoing discussion of any embodiment is merely exemplary and is not intended to imply that the scope of the application (including the claims) is limited to these examples, that combinations of technical features in the foregoing embodiments or in different embodiments may be implemented in any order and that many other variations of the different aspects of the embodiments described above exist within the spirit of the application, which are not provided in detail for clarity.
Additionally, well-known power/ground connections to Integrated Circuit (IC) chips and other components may or may not be shown within the provided figures, in order to simplify the illustration and discussion, and so as not to obscure the embodiments of the present application. Furthermore, the devices may be shown in block diagram form in order to avoid obscuring the embodiments of the present application, and also in view of the fact that specifics with respect to implementation of such block diagram devices are highly dependent upon the platform within which the embodiments of the present application are to be implemented (i.e., such specifics should be well within purview of one skilled in the art). Where specific details (e.g., circuits) are set forth in order to describe example embodiments of the application, it should be apparent to one skilled in the art that embodiments of the application can be practiced without, or with variation of, these specific details. Accordingly, the description is to be regarded as illustrative in nature and not as restrictive.
While the application has been described in conjunction with specific embodiments thereof, many alternatives, modifications, and variations of those embodiments will be apparent to those skilled in the art in light of the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed.
The present embodiments are intended to embrace all such alternatives, modifications and variances which fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, and the like, which are within the spirit and principles of the embodiments of the application, are intended to be included within the scope of the application.