CN112632573B - Intelligent contract execution method, device, system, storage medium and electronic equipment - Google Patents
Intelligent contract execution method, device, system, storage medium and electronic equipment Download PDFInfo
- Publication number
- CN112632573B CN112632573B CN202011483371.1A CN202011483371A CN112632573B CN 112632573 B CN112632573 B CN 112632573B CN 202011483371 A CN202011483371 A CN 202011483371A CN 112632573 B CN112632573 B CN 112632573B
- Authority
- CN
- China
- Prior art keywords
- contract
- node
- intelligent contract
- target
- calling
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 101
- 230000004044 response Effects 0.000 claims abstract description 34
- 230000006854 communication Effects 0.000 claims description 59
- 238000004891 communication Methods 0.000 claims description 55
- 238000004590 computer program Methods 0.000 claims description 28
- 230000008569 process Effects 0.000 claims description 28
- 230000005540 biological transmission Effects 0.000 claims description 22
- 230000006870 function Effects 0.000 claims description 14
- 238000012790 confirmation Methods 0.000 claims description 8
- 230000000694 effects Effects 0.000 claims description 8
- 238000012795 verification Methods 0.000 claims description 8
- 238000010586 diagram Methods 0.000 description 15
- 230000006835 compression Effects 0.000 description 8
- 238000007906 compression Methods 0.000 description 8
- 230000002159 abnormal effect Effects 0.000 description 6
- 238000005516 engineering process Methods 0.000 description 6
- 239000003999 initiator Substances 0.000 description 4
- 230000005236 sound signal Effects 0.000 description 4
- 238000010200 validation analysis Methods 0.000 description 4
- 238000013459 approach Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- KLDZYURQCUYZBL-UHFFFAOYSA-N 2-[3-[(2-hydroxyphenyl)methylideneamino]propyliminomethyl]phenol Chemical compound OC1=CC=CC=C1C=NCCCN=CC1=CC=CC=C1O KLDZYURQCUYZBL-UHFFFAOYSA-N 0.000 description 1
- 201000001098 delayed sleep phase syndrome Diseases 0.000 description 1
- 208000033921 delayed sleep phase type circadian rhythm sleep disease Diseases 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 239000007858 starting material Substances 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/602—Providing cryptographic facilities or services
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/64—Protecting data integrity, e.g. using checksums, certificates or signatures
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/04—Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
- H04L63/0428—Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload
- H04L63/0435—Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload wherein the sending and receiving network entities apply symmetric encryption, i.e. same key used for encryption and decryption
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
- H04L67/141—Setup of application sessions
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Computer Hardware Design (AREA)
- General Health & Medical Sciences (AREA)
- Bioethics (AREA)
- Health & Medical Sciences (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- Signal Processing (AREA)
- General Physics & Mathematics (AREA)
- Computer Networks & Wireless Communication (AREA)
- Computing Systems (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
The disclosure relates to an intelligent contract executing method, device, system, storage medium and electronic equipment, wherein the method applied to contract calling nodes in a blockchain network comprises the following steps: acquiring contract information of a target intelligent contract to be called from a registered intelligent contract list, wherein the contract information comprises a contract identifier and a contract execution end address, and the contract execution end address corresponds to a contract execution end outside the blockchain network; sending an intelligent contract calling request to the contract executing end, wherein the intelligent contract calling request is used for the contract executing end to execute the target intelligent contract according to the contract identification and the contract executing data in the intelligent contract calling request; and receiving a contract execution response of the contract execution end to obtain an execution result of the target intelligent contract corresponding to the contract calling node.
Description
Technical Field
The present disclosure relates to the field of blockchain technologies, and in particular, to an intelligent contract execution method, apparatus, system, storage medium, and electronic device.
Background
Blockchains are a technique that enables collective maintenance of a reliable database by means of decentralization and de-trust. The method can store the transactions occurring in a period of time in blocks as units, and connect the blocks in time sequence by a cryptography algorithm to form a data structure similar to a chain. The blockchain technology has the characteristics of distributed account book, decentralization, non-falsification and the like, and has a high application prospect in various aspects.
In the related scene, a plurality of functions, such as reading, writing and the like of block data, can be realized in the blockchain network through intelligent contracts, so that the expansibility of the blockchain technology is improved. Taking a alliance chain as an example, by deploying the intelligent contract on the node, when the node calls the contract, the contract can be packaged into a mirror image and started, and then the contract is mounted on the node in a contract container mode for calling. However, such an approach requires more resources of the node, which may cause difficulty in normally performing related functions for the node with lower performance.
Disclosure of Invention
The disclosure aims to provide an intelligent contract executing method, an intelligent contract executing device, an intelligent contract executing system, a storage medium and electronic equipment, so as to solve the related technical problems.
To achieve the above object, according to a first aspect of embodiments of the present disclosure, there is provided an intelligent contract execution method applied to a contract invoking node in a blockchain network, the method including:
Acquiring contract information of a target intelligent contract to be called from a registered intelligent contract list, wherein the contract information comprises a contract identifier and a contract execution end address, and the contract execution end address corresponds to a contract execution end outside the blockchain network;
Sending an intelligent contract calling request to the contract executing end, wherein the intelligent contract calling request is used for the contract executing end to execute the target intelligent contract according to the contract identification and the contract executing data in the intelligent contract calling request;
and receiving a contract execution response of the contract execution end to obtain an execution result of the target intelligent contract corresponding to the contract calling node.
Optionally, before the acquiring the contract information of the target smart contract to be invoked from the registered smart contract list, the method further includes:
establishing communication connection with the contract execution end;
Sending a contract identification and a starting parameter of the target intelligent contract to the contract executing end so that the contract executing end starts the intelligent contract corresponding to the contract identification;
receiving a contract starting result sent by the contract executing end;
If the contract starting result represents that the contract executing end successfully starts the target intelligent contract, determining that the target intelligent contract is successfully registered;
Adding the contract identification of the target intelligent contract and the contract execution end address of the contract execution end to the intelligent contract list;
and sending a registration success message to the contract execution end.
Optionally, the establishing a communication connection with the contract executing end includes:
acquiring registration parameter information of the target intelligent contract;
According to the contract execution end address in the registration parameter information, a connection request is sent to a contract execution end corresponding to the contract execution end address, wherein the connection request comprises node information of the contract calling node and contract identification of the target intelligent contract;
Receiving a connection request response message sent by the contract execution end, wherein the connection request response message comprises address information of the contract execution end and configuration information of an intelligent contract corresponding to the contract identification;
Verifying the address information of the contract execution end and the configuration information of the intelligent contract corresponding to the contract identification in the connection request response message according to the address information of the contract execution end and the configuration information of the intelligent contract in the registration parameter information;
when verification is successful, sending connection confirmation information to the contract execution end;
And establishing communication connection with the contract execution end.
Optionally, in the process that the contract calling node communicates with the contract executing end, encrypting the data to be sent to obtain first target encrypted sent data by the following manner:
Obtaining a hash value of data to be transmitted through a target hash function;
encrypting the hash value based on a private key of the contract calling node to obtain a first encrypted hash value;
Randomly generating a first target symmetric key pair, and encrypting the first encryption hash value and the data to be transmitted through a private key of the first target symmetric key pair to obtain first encrypted transmission data;
and encrypting the first encrypted transmission data and the public key of the first target symmetric key pair through the public key of the contract executing end to obtain the first target encrypted transmission data.
Optionally, the intelligent contract calling request further includes consensus node information, and the contract executing end is configured to terminate the calling process of the target intelligent contract when determining that the consensus node information does not include the identification information of the contract calling node, where the consensus node is a node with the calling authority of the target intelligent contract; and/or
The intelligent contract calling request further comprises consensus strategy node information, and the method is used for terminating the calling process of the target intelligent contract when the contract executing end determines that any consensus strategy node in the consensus strategy node information is not in the calling permission list of the target intelligent contract of the contract executing end, wherein the consensus strategy node is a preset consensus node required by the target intelligent contract to take effect.
According to a second aspect of the embodiments of the present disclosure, there is provided an intelligent contract execution method applied to a contract execution end outside a blockchain network, the method including:
Receiving an intelligent contract calling request sent by a contract calling node in a blockchain network, wherein the intelligent contract calling request comprises a contract identification of a target intelligent contract to be called and contract execution data of the target intelligent contract;
Matching node identification information of the contract invoking node with node identification information in an invoking permission list corresponding to the target intelligent contract;
When the matching is successful, executing the target intelligent contract according to the contract identification and contract execution data in the intelligent contract call request;
and sending the execution result of the target intelligent contract to the contract calling node.
Optionally, before the receiving the intelligent contract invoking request sent by the contract invoking node in the blockchain network, the method further includes:
in response to receiving a connection request sent by the contract invoking node, establishing communication connection with the contract invoking node;
Receiving a contract identification and a starting parameter of the target intelligent contract sent by the contract calling node;
Searching an intelligent contract corresponding to the contract identification, and starting the intelligent contract;
sending a contract starting result to the contract calling node, wherein the contract starting result comprises a contract identifier of the started intelligent contract;
And receiving a registration success message sent by the contract calling node, and adding the node address and the node identification of the contract calling node into the calling permission list.
Optionally, the responding to the connection request sent by the contract invoking node establishes a communication connection with the contract invoking node, including:
receiving a connection request sent by the contract calling node, wherein the connection request comprises node information of the contract calling node and a contract identifier of the target intelligent contract;
searching configuration information of the intelligent contract corresponding to the contract identification;
Sending a connection request response message to the contract calling node, wherein the connection request response message comprises configuration information of the intelligent contract and address information of the contract execution end;
And receiving connection confirmation information sent by the contract invoking node, and establishing communication connection with the contract invoking node.
Optionally, in the process that the contract executing end communicates with the contract invoking node, encrypting the data to be sent to obtain second target encrypted sending data by the following manner:
Obtaining a hash value of data to be transmitted through a target hash function;
encrypting the hash value based on a private key of the contract executing end to obtain a second encrypted hash value;
Randomly generating a second target symmetric key pair, and encrypting the second encryption hash value and the data to be transmitted through a private key in the second target symmetric key pair to obtain second encrypted transmission data;
And encrypting the second encrypted sending data and the public key of the second target symmetric key pair by using the public key of the contract calling node to obtain the second target encrypted sending data.
Optionally, the smart contract invocation request further includes consensus node information, the method further comprising:
verifying node identification information of the contract calling node according to the consensus node information;
Terminating the calling process of the target intelligent contract when the identification information of the contract calling node is not included in the consensus node information, wherein the consensus node is a node with the calling authority of the target intelligent contract; and/or
The smart contract invocation request further includes consensus policy node information, the method further comprising:
verifying the consensus strategy node information according to the node identification information in the call permission list of the target intelligent contract;
And when any consensus strategy node in the consensus strategy node information is not in the call permission list, terminating the call process of the target intelligent contract, wherein the consensus strategy node is a preset consensus node required by the target intelligent contract to take effect.
According to a third aspect of the embodiments of the present disclosure, there is provided an intelligent contract execution apparatus, including:
The system comprises a first acquisition module, a second acquisition module and a second acquisition module, wherein the first acquisition module is used for acquiring contract information of a target intelligent contract to be called from a registered intelligent contract list, the contract information comprises a contract identifier and a contract execution end address, and the contract execution end address corresponds to a contract execution end outside the blockchain network;
The first sending module is used for sending an intelligent contract calling request to the contract executing end, wherein the intelligent contract calling request is used for the contract executing end to execute the target intelligent contract according to the contract identification and the contract executing data in the intelligent contract calling request;
And the first receiving module is used for receiving the contract execution response of the contract execution end and obtaining an execution result of the target intelligent contract corresponding to the contract calling node.
According to a fourth aspect of the embodiments of the present disclosure, there is provided an intelligent contract execution apparatus, including:
the second receiving module is used for receiving an intelligent contract calling request sent by a contract calling node in the blockchain network, wherein the intelligent contract calling request comprises a contract identification of a target intelligent contract to be called and contract execution data of the target intelligent contract;
the first matching module is used for matching the node identification information of the contract calling node with the node identification information in the calling permission list corresponding to the target intelligent contract;
the first execution module is used for executing the target intelligent contract according to the contract identification and contract execution data in the intelligent contract call request when the matching is successful;
And the second sending module is used for sending the execution result of the target intelligent contract to the contract calling node.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method of any of the first aspects described above.
According to a sixth aspect of embodiments of the present disclosure, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method of any of the second aspects described above.
According to a seventh aspect of embodiments of the present disclosure, there is provided a contract invoking node, comprising:
A memory having a computer program stored thereon;
A processor for executing the computer program in the memory to implement the steps of the method of any of the above first aspects.
According to an eighth aspect of the embodiments of the present disclosure, there is provided a contract execution end, including:
A memory having a computer program stored thereon;
A processor for executing the computer program in the memory to implement the steps of the method of any of the second aspects above.
According to a ninth aspect of an embodiment of the present disclosure, there is provided an intelligent contract execution system, including the contract invoking node described in the seventh aspect and the contract execution end described in the eighth aspect.
By adopting the technical scheme, when the contract calling node needs to call the target intelligent contract, the contract information of the target intelligent contract can be acquired from the registered intelligent contract list. In this way, an intelligent contract calling request can be sent to the corresponding contract execution end according to the contract execution end address in the contract information, so that the calling of the target intelligent contract is realized. In other words, according to the technical scheme, the intelligent contract program is arranged at the contract execution end outside the blockchain, so that the contract calling node does not need to independently mount the contract program, and node resource occupation caused by running the intelligent contract can be reduced. In addition, through the way of executing intelligent contracts outside the chain, related restrictions (such as calling restrictions of underlying elements) in the blockchain network can be broken through, so that the phenomenon of abnormal contract operation caused by the related restrictions is reduced.
Additional features and advantages of the present disclosure will be set forth in the detailed description which follows.
Drawings
The accompanying drawings are included to provide a further understanding of the disclosure, and are incorporated in and constitute a part of this specification, illustrate the disclosure and together with the description serve to explain, but do not limit the disclosure. In the drawings:
FIG. 1 is a flowchart illustrating a method of executing a smart contract according to an exemplary embodiment of the present disclosure.
FIG. 2 is a schematic diagram of a contract invocation node, as shown in an exemplary embodiment of the present disclosure.
FIG. 3 is a registration flow diagram of a smart contract as shown in an exemplary embodiment of the present disclosure.
Fig. 4 is an encryption diagram of data to be transmitted according to an exemplary embodiment of the present disclosure.
FIG. 5 is a flowchart illustrating a method of executing a smart contract, in accordance with an exemplary embodiment of the present disclosure.
FIG. 6 is a flow chart illustrating the invocation of a smart contract in accordance with an exemplary embodiment of the present disclosure.
Fig. 7 is a schematic diagram of a contract execution end, according to an exemplary embodiment of the present disclosure.
Fig. 8 is a decryption diagram of first target encrypted transmission data according to an exemplary embodiment of the present disclosure.
Fig. 9 is a block diagram of an intelligent contract execution apparatus according to an exemplary embodiment of the present disclosure.
Fig. 10 is a block diagram of an intelligent contract execution apparatus according to an exemplary embodiment of the present disclosure.
FIG. 11 is a block diagram of a contract invocation node, as shown in an exemplary embodiment of the present disclosure.
Fig. 12 is a block diagram of a contract execution end, as shown in an exemplary embodiment of the present disclosure.
Detailed Description
Specific embodiments of the present disclosure are described in detail below with reference to the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating and illustrating the disclosure, are not intended to limit the disclosure.
Before describing the method, the device, the system, the storage medium and the electronic equipment for executing the intelligent contract, application scenarios of embodiments provided by the present disclosure are first described, and the embodiments provided by the present disclosure can be applied to intelligent contract execution scenarios in a blockchain, such as public chains, alliance chains, and the like.
Taking a alliance chain as an example, in a related scene, an intelligent contract can be deployed on a node, so that when the node calls the contract, the contract can be packaged into a mirror image and started, and then the contract is mounted on the node in a contract container mode for calling. However, such an approach requires more resources of the node, which may cause difficulty in normally performing related functions for the node with lower performance.
Furthermore, in some federation chains, the operational rights may have stringent requirements, for example, there may be associated rights limits on the automated invocation of underlying elements, resulting in contract containers that cannot create or launch exceptions, ultimately limiting the production and application of blockchain technology.
To this end, the present disclosure provides an intelligent contract execution method applied to a contract invoking node in a blockchain network, referring to a flowchart of the intelligent contract execution method shown in fig. 1, the method comprising:
In step S11, contract information of a target smart contract to be invoked is acquired from the registered smart contract list.
The contract invoking node may be any node (e.g., a full node) in the blockchain network that needs to invoke an intelligent contract, and the intelligent contract list may be implemented, for example, in a registry, an index table, or the like, and may include contract information of various intelligent contracts registered in the node.
The contract information may include a contract identifier and a contract execution address, where the contract identifier may be, for example, a name, an ID (Identity) number, etc. of the smart contract, or a combination thereof. The contract execution end address may correspond to a contract execution end external to the blockchain network, which may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., tablet, personal digital assistant, notebook, netbook, etc.), mobile phone, wearable computing device, or other type of mobile device, or a stationary computing device such as a desktop computer, server, etc.
In step S12, an intelligent contract call request is sent to the contract execution end.
The contract invocation request may include, for example, an identification of the smart contract to be invoked, related parameters and data to execute the target smart contract, and the like. In some implementations, the smart contract invocation request may also provide parameters required for the target smart contract operation by providing a related data interface.
In other implementations, the smart contract invocation request may also include security authentication identification information for the target smart contract. When the security authentication identification information characterizes that the target intelligent contract needs security authentication, the communication process between the contract execution end and the contract calling node needs to verify the security certificate of the contract execution end. When the security authentication identification information characterizes that the target intelligent contract does not need security authentication, the communication process between the contract execution end and the contract calling node does not need to verify the security certificate of the contract execution end.
Further, in a possible implementation, the smart contract invocation request further includes consensus node information. The common node is a node with the calling authority of the target intelligent contract, and the common node information can be, for example, the identification of each common node, such as node address, number and the like.
Taking node addresses of common node information as common nodes as an example, when a contract executing end receives the contract calling request, the contract executing end can determine whether the contract calling node is the common node or not by comparing the node addresses of the contract calling nodes with the addresses of the common nodes. When the contract calling node is not the consensus node, the contract executing end can terminate the calling process of the target intelligent contract.
In another possible implementation manner, the smart contract call request may include consensus policy node information, where a consensus policy node is a preset consensus node required for the target smart contract to take effect. It should be appreciated that the smart contract requires that some nodes agree on during the validation process, and thus, this part of nodes may act as the consensus policy node.
The contract execution side may, for example, maintain a call permission list corresponding to each smart contract, the call permission list including node information of nodes that have completed registration at the contract execution side and are able to call the smart contract through the contract execution side. Still taking node information as a node address for example, when the contract executing end receives the contract calling request, the contract executing end can determine whether the corresponding consensus strategy node of the target intelligent contract completes registration at the contract executing end by comparing the node address of the consensus strategy node with the node addresses of all nodes in the calling permission list of the target intelligent contract.
In this way, when it is determined that any one of the common policy node information is not in the call permission list of the target smart contract of the contract execution side (assuming that the related nodes of the target smart contract all call the target smart contract through the external contract execution side), the contract execution side may terminate the call procedure of the target smart contract. Taking table 1 as an example, since the consensus policy node 10.0.0.2 g4f13 … yft is not in the call permission list of the target smart contract, the consensus policy node 10.0.0.2 g4f13 … yft cannot execute the target smart contract based on the contract execution end. Also, as shown in Table 1, target smart contract validation requires node 10.0.0.1:abc2d … asb and node 10.0.0.2:g4f13 … yft to complete a consensus. Therefore, in the case that the contract execution end cannot execute the target smart contract based on 10.0.0.2 g4f13 … yft, the target smart contract cannot be validated, and thus the contract execution end may terminate the calling process of the target smart contract.
TABLE 1
Of course, the foregoing embodiments are merely illustrative, not limiting, of the technical solutions of the present invention, and it should be understood by those of ordinary skill in the art that, in implementation, the smart contract invocation request may also include the consensus node information and the consensus policy node information at the same time as shown in table 1, which is not limited by the present disclosure.
Further, after the intelligent contract call request is sent to the contract execution end, the contract execution end may execute the target intelligent contract according to the contract identifier and the contract execution data in the intelligent contract call request. Of course, in some implementation scenarios, the contract executing end may also verify the contract invoking node before responding to the intelligent contract invoking request, so as to improve security, which will be described in the following embodiments.
Thus, after the contract execution end executes the target smart contract, the contract invoking node may receive a contract execution response of the contract execution end to obtain an execution result of the target smart contract corresponding to the contract invoking node in step S13.
By adopting the technical scheme, when the contract calling node needs to call the target intelligent contract, the contract information of the target intelligent contract can be acquired from the registered intelligent contract list. In this way, an intelligent contract calling request can be sent to the corresponding contract execution end according to the contract execution end address in the contract information, so that the calling of the target intelligent contract is realized. In other words, according to the technical scheme, the intelligent contract program is arranged at the contract execution end outside the blockchain, so that the contract calling node does not need to independently mount the contract program, and node resource occupation caused by running the intelligent contract can be reduced. In addition, through the way of executing intelligent contracts outside the chain, related restrictions (such as calling restrictions of underlying elements) in the blockchain network can be broken through, so that the phenomenon of abnormal contract operation caused by the related restrictions is reduced.
Optionally, before the acquiring the contract information of the target smart contract to be invoked from the registered smart contract list, the method further includes:
and establishing communication connection with the contract execution end. Corresponding descriptions already exist in related technologies of the manner of establishing communication connection through the network, and the disclosure is not repeated here.
In some possible embodiments, the contract invoking node may further perform a corresponding configuration file check when establishing a communication connection with the contract executing end, so as to determine that the contract executing end is capable of executing the target smart contract. In this case, the establishing a communication connection with the contract execution end includes:
and acquiring registration parameter information of the target intelligent contract.
In particular, referring to the schematic diagram of a contract invocation node shown in FIG. 2, the contract invocation node may include a builder and a contract compression package. The contract compression package may include the registration of the target intelligent contract and the related data of the execution environment, and when the target intelligent contract is deployed, the registration of the target intelligent contract and the related data of the execution environment may be compressed into the contract compression package, and stored in the local server where the node is located or in the address that the node can obtain. In the example of fig. 2, the contract compression package may include data for deployment, contract name, contract compression package storage path, contract execution end address, security authentication identification, and the like.
And the contract calling node is also provided with a constructor which is used for reading and analyzing the contract compression package and establishing the secure connection between the contract calling node and the contract execution end. For example, the determiner in the builder may determine the deployment policy of the target smart contract by obtaining the deployment style in the contract compression package. For example, the deployment may be local deployment, off-chain deployment, and so on. The local deployment can be used for carrying out intelligent contract deployment on the local of the contract calling node in a manner of mounting a contract container; and the out-of-chain deployment can deploy the contract program of the target intelligent contract in the contract execution end corresponding to the contract execution end address.
Of course, the deployment manner may further include a deployment identifier of the target smart contract, and when the target smart contract is deployed, the determiner may activate the connector to establish a communication connection with an external contract executing end. When the target intelligent contract is not deployed, the constructor can copy the contract file into a local storage space in the constructor through the contract name and the contract compression packet storage path, and the configuration and operation parameters of the target intelligent contract are analyzed through the configuration analyzer, such as registration parameter information including contract execution end address, whether security authentication identification and the like.
Thus, referring to the registration flowchart of an intelligent contract shown in fig. 3, after the registration parameter is acquired, the contract invoking node may send, according to the contract execution end address in the registration parameter information, a connection request to the contract execution end corresponding to the contract execution end address. Wherein the connection request includes node information (e.g., IP address, node ID, etc.) of the contract invoking node and a contract identification of the target smart contract. Correspondingly, after receiving the connection request, the contract execution end can save node information of the contract calling node in the connection request, and search configuration information of the intelligent contract corresponding to the contract identifier of the contract execution end according to the contract identifier. In this way, the contract execution end may send a connection request response message to the contract invoking node, where the connection request response message includes configuration information of the smart contract and address information of the contract execution end.
After receiving the connection request response message sent by the contract execution end, the contract calling node can verify the address information of the contract execution end in the connection request response message and the configuration information (for example, contract ID) of the intelligent contract corresponding to the contract identification according to the address information of the contract execution end in the registration parameter information and the configuration information of the intelligent contract.
Wherein, when the verification fails, the contract invoking node can terminate the connection request; and when the verification is successful, sending connection confirmation information to the contract execution end so as to establish communication connection with the contract execution end.
In this way, after successfully establishing the communication connection with the communication node, the contract invoking node may further send the contract identification of the target smart contract and the start-up parameter to the contract executing end. Correspondingly, the contract execution end can search the intelligent contract corresponding to the contract identification and start the intelligent contract. In addition, the contract execution end can also send a contract starting result to the contract calling node, wherein the contract starting result comprises a contract identification of the started intelligent contract.
After receiving the contract starting result sent by the contract executing end, the contract calling node can analyze the contract starting result, for example, by comparing the contract identification in the contract starting result with the contract identification of the target intelligent contract, so as to determine whether the intelligent contract started by the contract executing end is the target intelligent contract. And if the contract starting result represents that the contract executing end successfully starts the target intelligent contract, determining that the target intelligent contract is successfully registered. In this case, the contract identification of the target smart contract and the contract execution end address of the contract execution end may be added to the smart contract list to facilitate subsequent calls. Further, the contract calling node may further send a registration success message to the contract executing end, so that the contract executing end determines a registration result of the target intelligent contract. In this way, by setting the contract executing end and performing the contract registration flow, the out-of-chain execution of the intelligent contract can be realized, and the resource burden of the contract calling end can be reduced.
In one possible implementation manner, in the process that the contract calling node communicates with the contract executing end, the data to be sent may be encrypted to obtain first target encrypted sending data. In this way, by sending the first target encrypted sending data, the communication security between the contract calling node and the contract execution end can be improved.
For example, referring to fig. 3, the contract invoking node and the contract executing end may also upload their own public keys before registering the target intelligent contract, so as to facilitate the encryption of the communication between the two parties. Thus, referring to an encryption scheme of data to be transmitted shown in fig. 4, for the data to be transmitted, a hash value of the data to be transmitted may be obtained by the target hash function. The target hash function may be, for example, a function of MD5, SHA-1, SHA-256, etc., which is not limiting to the present disclosure.
After obtaining the hash value, the contract calling node may further encrypt the hash value based on a private key of the contract calling node to obtain a first encrypted hash value. In some possible embodiments, the corresponding key pair may also be set for the constructor, in which case the hash value may also be encrypted by the constructor's private key.
In addition, a first target symmetric key pair can be randomly generated through a key issuing mechanism in the constructor, and the encryption hash value and the data to be transmitted are encrypted through a private key in the first target symmetric key pair, so that first encrypted transmission data are obtained. Further, the first encrypted sending data and the public key of the first target symmetric key pair may be encrypted by the public key of the contract executing end, so as to obtain the first target encrypted sending data. Thus, the security of communication between the contract calling node and the contract execution end can be improved through double encryption.
Fig. 5 is a flowchart of an intelligent contract execution method according to an exemplary embodiment of the present disclosure, which may be applied to, for example, the contract execution end in the foregoing embodiment, with reference to fig. 1, and includes:
in step S51, an intelligent contract invocation request sent by a contract invocation node in the blockchain network is received.
Wherein the smart contract call request includes a contract identification of a target smart contract to be called and contract execution data of the target smart contract, and the contract identification may be, for example, a name, an ID (Identity) number, etc. of the smart contract, or a combination thereof. The contract execution data includes relevant parameters and data for executing the target intelligent contract, and the like. In some implementation scenarios, the smart contract call request may also include a related data interface, so that the contract execution end may obtain parameters required for the target smart contract operation through the data interface.
In some implementations, the smart contract invocation request may also include security authentication identification information for the target smart contract. When the security authentication identification information characterizes that the target intelligent contract needs security authentication, the communication process between the contract calling node and the contract execution end needs to verify the security certificate of the contract execution end. For example, the root certificate and the data to be sent of the contract execution end can be signed through a certificate private key, the root certificate and the data to be sent obtained through the signature are encrypted through the private key of the contract execution end, an encryption result is obtained, and then the encryption result and the root certificate are sent to the contract calling node. Of course, when the security authentication identification information characterizes that the target intelligent contract does not need security authentication, the communication process between the contract execution end and the contract invoking node does not need to verify the security certificate of the contract execution end.
In step S52, the node identification information of the contract invoking node is matched with the node identification information in the invoking permission list corresponding to the target smart contract.
Specifically, the contract execution end may, for example, maintain a corresponding call permission list for each intelligent contract, where the call permission list may include node information, such as a node address, a node ID number, and the like, corresponding to various intelligent contracts registered in the contract execution end. In specific implementation, the call permission list may be implemented, for example, in a registry, an index table, or the like.
Referring to the call flow chart of an intelligent contract shown in fig. 6, the contract execution end may perform matching verification on node identification information of the contract call node and node identification information in a call permission list corresponding to the target intelligent contract after receiving the contract call request. When the matching fails, a call failure response message may be sent to the contract invoking node to cause the contract invoking node to terminate the invoking process of the target intelligent contract.
In step S53, when the matching is successful, the target smart contract is executed according to the contract identification and contract execution data in the smart contract call request.
In step S54, the execution result of the target smart contract is sent to the contract invoking node.
By way of example, referring to a schematic diagram of a contract execution end including a starter and a contract is shown in FIG. 7. Wherein the initiator may be configured to initiate and execute a contract procedure and to link a connector in a builder in the contract invocation node via a connector in the initiator, thereby establishing a communication connection between the contract execution end and the contract invocation node.
In fig. 7, the initiator includes a connector, a program initiator, a configuration parser, an information configurator and a certificate/key issuing authority, and a node registry. Wherein the connector can receive a contract call request from the contract call node, and the configuration parser can obtain the contract identification of the target intelligent contract and the contract execution data by parsing the contract call request. In this way, the program starter can start the main process of the corresponding target intelligent contract, so that the target intelligent contract is executed based on the contract execution data, and a contract execution result is obtained.
The information configurator may convert the contract execution result into a corresponding data structure based on the contract configuration information, and send the contract call result to the contract call node through the connector. Of course, in some scenarios requiring encryption, the contract execution results may also be signed and encrypted by a certificate/key issuing authority before being sent to the contract invoking node.
In addition, the initiator may also respond to the contract call requests of multiple contract call nodes at the same time, for example, the contract call requests of different contract call nodes may be respectively processed in a multithreading manner.
According to the technical scheme, the intelligent contract program is arranged at the contract execution end outside the blockchain, so that the contract calling node does not need to independently mount the contract program, and node resource occupation caused by running the intelligent contract can be reduced. In addition, through the way of executing intelligent contracts outside the chain, related restrictions (such as calling restrictions of underlying elements) in the blockchain network can be broken through, so that the phenomenon of abnormal contract operation caused by the related restrictions is reduced.
In a possible implementation manner, the intelligent contract invoking request further includes consensus node information, where a consensus node is a node with invoking authority of the target intelligent contract, and the consensus node information may be, for example, an identifier, such as a node address, a number, and the like, of each consensus node. In this case, the method further comprises:
verifying node identification information of the contract calling node according to the consensus node information;
and when the identification information of the contract calling node is not included in the consensus node information, terminating the calling process of the target intelligent contract.
Taking node addresses of common node information as common nodes as an example, when a contract executing end receives the contract calling request, the contract executing end can determine whether the contract calling node is the common node or not by comparing the node addresses of the contract calling nodes with the addresses of the common nodes. When the contract calling node is not the consensus node, the contract executing end can terminate the calling process of the target intelligent contract.
In another possible implementation manner, the smart contract call request further includes consensus policy node information, wherein the consensus policy node is a consensus node required for the preset target smart contract to take effect. It should be appreciated that the smart contract requires that some nodes agree on during the validation process, and thus, this part of nodes may act as the consensus policy node.
In this case, the method further comprises:
verifying the consensus strategy node information according to the node identification information in the call permission list of the target intelligent contract;
And when any consensus strategy node in the consensus strategy node information is not in the call permission list, terminating the call process of the target intelligent contract.
Still taking node information as a node address for example, when the contract executing end receives the contract calling request, the contract executing end can determine whether the corresponding consensus strategy node of the target intelligent contract completes registration at the contract executing end by comparing the node address of the consensus strategy node with the node addresses of all nodes in the calling permission list of the target intelligent contract.
In this way, the contract execution end may terminate the call procedure of the target smart contract when it is determined that any one of the consensus policy node information is not in the call permission list of the target smart contract of the contract execution end. Taking table 1 as an example, since the consensus policy node 10.0.0.2 g4f13 … yft is not in the call permission list of the target smart contract, the consensus policy node 10.0.0.2 g4f13 … yft cannot execute the target smart contract based on the contract execution end. Also, as shown in Table 1, target smart contract validation requires node 10.0.0.1:abc2d … asb and node 10.0.0.2:g4f13 … yft to complete a consensus. Therefore, in the case that the contract execution end cannot execute the target smart contract based on 10.0.0.2 g4f13 … yft, the target smart contract cannot be validated, and thus the contract execution end may terminate the calling process of the target smart contract.
Of course, the foregoing embodiments are merely for illustrating the technical solution of the present invention, and not for limiting the same, and it should be understood by those of ordinary skill in the art that, in implementation, the smart contract invoking request may also include the consensus node information and the consensus policy node information at the same time as shown in table 1, and the contract executing end may also determine whether to execute the target smart contract according to the consensus node information and the consensus policy node information at the same time, which is not limited in this disclosure.
Optionally, before the receiving the intelligent contract invoking request sent by the contract invoking node in the blockchain network, the method further includes:
and in response to receiving a connection request sent by the contract invoking node, establishing communication connection with the contract invoking node. Corresponding descriptions already exist in related technologies of the manner of establishing communication connection through the network, and the disclosure is not repeated here.
In some possible embodiments, the contract invoking node may further perform a corresponding configuration file check when establishing a communication connection with the contract executing end, so as to determine that the contract executing end is capable of executing the target smart contract. In this case, the establishing a communication connection with the contract invoking node in response to receiving a connection request sent by the contract invoking node includes:
and receiving a connection request sent by the contract calling node. Wherein the connection request includes node information (e.g., IP address, node ID, etc.) of the contract invoking node and a contract identification of the target smart contract. Correspondingly, after receiving the connection request, the contract execution end can save node information of the contract calling node in the connection request, and search configuration information of the intelligent contract corresponding to the contract identifier of the contract execution end according to the contract identifier. In this way, the contract execution end may send a connection request response message to the contract invoking node, where the connection request response message includes configuration information of the smart contract and address information of the contract execution end.
Further, after receiving the connection confirmation information sent by the contract invoking node, the contract executing end may establish a communication connection with the contract invoking node.
In this way, after the communication connection is successfully established, the contract execution end can also receive the contract identification and the starting parameter of the target intelligent contract sent by the contract calling node, search the intelligent contract corresponding to the contract identification, and further start the intelligent contract. In addition, the contract execution end can also send a contract starting result to the contract calling node, wherein the contract starting result comprises a contract identification of the started intelligent contract. Further, after receiving the registration success message sent by the contract invoking node, the contract invoking node may add the node address and the node identifier of the contract invoking node to the invoking permission list, so as to complete registration. In this way, by setting the contract executing end and performing the contract registration flow, the out-of-chain execution of the intelligent contract can be realized, and the resource burden of the contract calling end can be reduced.
In one possible implementation manner, in the process that the contract execution end communicates with the contract invoking node, encryption is performed on data to be sent to obtain second target encrypted sending data by the following manner:
Obtaining a hash value of data to be transmitted through a target hash function;
encrypting the hash value based on a private key of the contract executing end to obtain a second encrypted hash value;
Randomly generating a second target symmetric key pair, and encrypting the second encryption hash value and the data to be transmitted through a private key in the second target symmetric key pair to obtain second encrypted transmission data;
And encrypting the second encrypted sending data and the public key of the second target symmetric key pair by using the public key of the contract calling node to obtain the second target encrypted sending data.
The encryption method is described with reference to an embodiment of encryption method steps on the contract invoking node side, and the disclosure is not repeated here.
For the decryption process, referring to fig. 8, after receiving the first target encrypted transmission data sent by the contract invoking node, the contract executing end may decrypt the first target encrypted transmission data through its own private key, so as to obtain the first encrypted transmission data and the public key of the first target symmetric key pair. In this way, the first encrypted transmission data can be decrypted through the public key of the first target symmetric key pair to obtain the first encrypted hash value and the data to be transmitted.
Further, whether the hash value obtained by verifying the data to be sent through the target hash function is consistent with the hash value obtained by decrypting the first encrypted hash value or not can be verified, and when the hash value obtained by decrypting the data to be sent is consistent with the hash value obtained by decrypting the first encrypted hash value, the correctness of the data to be sent obtained by decrypting can be determined. In this way, by adopting the double encryption mode, the security of communication between the contract execution end and the contract calling node can be improved.
Of course, the above embodiment has been described taking the example that the contract executing end decrypts the first target encrypted transmission data of the contract invoking node, but those skilled in the art will know that the contract invoking node may also decrypt the second target encrypted transmission data sent by the contract executing end based on the same concept. For brevity of description, the disclosure is not repeated herein.
The present disclosure also provides an intelligent contract execution apparatus, referring to a block diagram of an intelligent contract execution apparatus shown in fig. 9, the apparatus 900 includes:
a first obtaining module 901, configured to obtain, from a registered intelligent contract list, contract information of a target intelligent contract to be invoked, where the contract information includes a contract identifier and a contract execution end address, and the contract execution end address corresponds to a contract execution end outside the blockchain network;
a first sending module 902, configured to send an intelligent contract invoking request to the contract executing end, where the intelligent contract invoking request is used for the contract executing end to execute the target intelligent contract according to the contract identifier and the contract executing data in the intelligent contract invoking request;
The first receiving module 903 is configured to receive a contract execution response of the contract execution end, and obtain an execution result of the target intelligent contract corresponding to the contract call node.
By adopting the technical scheme, when the contract calling node needs to call the target intelligent contract, the contract information of the target intelligent contract can be acquired from the registered intelligent contract list. In this way, an intelligent contract calling request can be sent to the corresponding contract execution end according to the contract execution end address in the contract information, so that the calling of the target intelligent contract is realized. In other words, according to the technical scheme, the intelligent contract program is arranged at the contract execution end outside the blockchain, so that the contract calling node does not need to independently mount the contract program, and node resource occupation caused by running the intelligent contract can be reduced. In addition, through the way of executing intelligent contracts outside the chain, related restrictions (such as calling restrictions of underlying elements) in the blockchain network can be broken through, so that the phenomenon of abnormal contract operation caused by the related restrictions is reduced.
Optionally, the apparatus 900 further includes:
The first communication connection establishment module is used for establishing communication connection with the contract execution end before the first acquisition module acquires the contract information of the target intelligent contract to be called from the registered intelligent contract list;
The third sending module is used for sending the contract identification and the starting parameter of the target intelligent contract to the contract executing end so that the contract executing end starts the intelligent contract corresponding to the contract identification;
the third receiving module is used for receiving a contract starting result sent by the contract executing end;
the first determining module is used for determining that the target intelligent contract is successfully registered when the contract starting result characterizes that the contract executing end successfully starts the target intelligent contract;
A first adding module, configured to add a contract identifier of the target intelligent contract and a contract execution end address of the contract execution end to the intelligent contract list;
And the fourth sending module is used for sending a registration success message to the contract execution end.
Optionally, the first communication connection establishment module includes:
the first acquisition sub-module is used for acquiring registration parameter information of the target intelligent contract;
a first sending sub-module, configured to send a connection request to a contract execution end corresponding to a contract execution end address according to the contract execution end address in the registration parameter information, where the connection request includes node information of the contract calling node and a contract identifier of the target intelligent contract;
the first receiving sub-module is used for receiving a connection request response message sent by the contract execution end, wherein the connection request response message comprises address information of the contract execution end and configuration information of the intelligent contract corresponding to the contract identification;
The first verification sub-module is used for verifying the address information of the contract execution end and the configuration information of the intelligent contract corresponding to the contract identification in the connection request response message according to the address information of the contract execution end and the configuration information of the intelligent contract in the registration parameter information;
The second sending submodule is used for sending connection confirmation information to the contract execution end when verification is successful;
and the first communication connection establishment sub-module is used for establishing communication connection with the contract execution end.
Optionally, the apparatus 900 further includes:
The first encryption module is configured to encrypt data to be sent in a process that the contract calling node communicates with the contract execution end, so as to obtain first target encrypted sent data, where the first encryption module includes:
The second acquisition submodule is used for acquiring a hash value of data to be transmitted through a target hash function;
The first encryption sub-module is used for encrypting the hash value based on the private key of the contract calling node to obtain a first encrypted hash value;
The second encryption sub-module is used for randomly generating a first target symmetric key pair, and encrypting the first encryption hash value and the data to be transmitted through a private key in the first target symmetric key pair to obtain first encrypted transmission data;
And the third encryption sub-module is used for encrypting the first encrypted transmission data and the public key of the first target symmetric key pair through the public key of the contract executing end to obtain the first target encrypted transmission data.
Optionally, the intelligent contract calling request further includes consensus node information, and the contract executing end is configured to terminate the calling process of the target intelligent contract when determining that the consensus node information does not include the identification information of the contract calling node, where the consensus node is a node with the calling authority of the target intelligent contract; and/or
The intelligent contract calling request further comprises consensus strategy node information, and the method is used for terminating the calling process of the target intelligent contract when the contract executing end determines that any consensus strategy node in the consensus strategy node information is not in the calling permission list of the target intelligent contract of the contract executing end, wherein the consensus strategy node is a preset consensus node required by the target intelligent contract to take effect.
The present disclosure also provides an intelligent contract execution apparatus, referring to a block diagram of an intelligent contract execution apparatus shown in fig. 10, the apparatus 1000 includes:
A second receiving module 1001, configured to receive an intelligent contract call request sent by a contract call node in a blockchain network, where the intelligent contract call request includes a contract identifier of a target intelligent contract to be called and contract execution data of the target intelligent contract;
A first matching module 1002, configured to match node identification information of the contract invoking node with node identification information in an invoking permission list corresponding to the target intelligent contract;
A first execution module 1003, configured to execute, when the matching is successful, the target smart contract according to the contract identifier and the contract execution data in the smart contract call request;
and the second sending module 1004 is configured to send an execution result of the target intelligent contract to the contract calling node.
According to the technical scheme, the intelligent contract program is arranged at the contract execution end outside the blockchain, so that the contract calling node does not need to independently mount the contract program, and node resource occupation caused by running the intelligent contract can be reduced. In addition, through the way of executing intelligent contracts outside the chain, related restrictions (such as calling restrictions of underlying elements) in the blockchain network can be broken through, so that the phenomenon of abnormal contract operation caused by the related restrictions is reduced.
Optionally, the apparatus 1000 further includes:
The second communication connection establishment module is used for responding to the connection request sent by the contract calling node before the second receiving module receives the intelligent contract calling request sent by the contract calling node in the blockchain network, and establishing communication connection with the contract calling node;
a fourth receiving module, configured to receive a contract identifier and a start parameter of the target intelligent contract sent by the contract calling node;
the second execution module is used for searching the intelligent contract corresponding to the contract identification and starting the intelligent contract;
a fifth sending module, configured to send a contract starting result to the contract invoking node, where the contract starting result includes a contract identifier of the started intelligent contract;
and the third execution module is used for receiving the successful registration message sent by the contract calling node and adding the node address and the node identification of the contract calling node into the calling permission list.
Optionally, the second communication connection establishment module includes:
the second receiving sub-module is used for receiving a connection request sent by the contract calling node, wherein the connection request comprises node information of the contract calling node and contract identification of the target intelligent contract;
The first searching sub-module is used for searching configuration information of the intelligent contract corresponding to the contract identification;
a third sending sub-module, configured to send a connection request response message to the contract invoking node, where the connection request response message includes configuration information of the intelligent contract and address information of the contract executing end;
and the third receiving sub-module is used for receiving the connection confirmation information sent by the contract calling node and establishing communication connection with the contract calling node.
Optionally, the apparatus 1000 further includes:
The second encryption module is configured to encrypt data to be sent in a process that the contract execution end communicates with the contract invoking node to obtain second target encrypted sending data, where the second encryption module includes:
a third obtaining sub-module, configured to obtain a hash value of data to be sent through a target hash function;
a fourth encryption sub-module, configured to encrypt the hash value based on a private key of the contract executing end, to obtain a second encrypted hash value;
a fifth encryption sub-module, configured to randomly generate a second target symmetric key pair, and encrypt the second encrypted hash value and the data to be sent by using a private key in the second target symmetric key pair to obtain second encrypted sent data;
And the sixth encryption sub-module is used for encrypting the second encrypted transmission data and the public key of the second target symmetric key pair through the public key of the contract calling node to obtain the second target encrypted transmission data.
Optionally, the smart contract invocation request further includes consensus node information, and the apparatus 1000 further includes:
The first verification module is used for verifying the node identification information of the contract calling node according to the consensus node information;
The first termination calling module is used for terminating the calling process of the target intelligent contract when the identification information of the contract calling node is not included in the consensus node information, wherein the consensus node is a node with the calling authority of the target intelligent contract; and/or
The smart contract invocation request further includes consensus policy node information, the apparatus 1000 further comprising:
The second checking module is used for checking the node information of the consensus strategy according to the node identification information in the call permission list of the target intelligent contract;
and the second termination calling module is used for terminating the calling process of the target intelligent contract when any consensus strategy node in the consensus strategy node information is not in the calling permission list, wherein the consensus strategy node is a preset consensus node required by the target intelligent contract to take effect.
The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.
The present disclosure also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the smart contract execution method for contract invoking nodes provided by the present disclosure.
The present disclosure also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the smart contract execution method for a contract execution side provided by the present disclosure.
The present disclosure also provides a contract invoking node, comprising:
A memory having a computer program stored thereon;
And a processor for executing the computer program in the memory to implement the steps of the intelligent contract execution method for contract invoking nodes provided by the present disclosure.
Fig. 11 is a block diagram illustrating a contract invoking node 1100, according to an example embodiment. As shown in fig. 11, the contract invoking node 1100 may include: processor 1101, memory 1102. The contract invoking node 1100 may also include a multimedia component 1103, an input/output (I/O) interface 1104, and one or more of the communication components 1105.
Wherein the processor 1101 is configured to control the overall operation of the contract invoking node 1100 to perform all or part of the steps in the intelligent contract execution method for contract invoking nodes described above. Memory 1102 is used to store various types of data to support operation at the contract invoking node 1100, which may include, for example, instructions for any application or method operating on the contract invoking node 1100, as well as application related data, such as transceived messages, pictures, blocks, registries, and the like. The Memory 1102 may be implemented by any type or combination of volatile or non-volatile Memory devices, such as static random access Memory (Static Random Access Memory, SRAM for short), electrically erasable programmable Read-Only Memory (ELECTRICALLY ERASABLE PROGRAMMABLE READ-Only Memory, EEPROM for short), erasable programmable Read-Only Memory (Erasable Programmable Read-Only Memory, EPROM for short), programmable Read-Only Memory (Programmable Read-Only Memory, PROM for short), read-Only Memory (ROM for short), magnetic Memory, flash Memory, magnetic disk, or optical disk. The multimedia component 1103 may include a screen and an audio component. Wherein the screen may be, for example, a touch screen, the audio component being for outputting and/or inputting audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signals may be further stored in memory 1102 or transmitted through communications component 1105. The audio assembly further comprises at least one speaker for outputting audio signals. The I/O interface 1104 provides an interface between the processor 1101 and other interface modules, which may be a keyboard, mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. Communication component 1105 is used for wired or wireless communication between contract invoking node 1100 and other devices. Wireless Communication, such as Wi-Fi, bluetooth, near Field Communication (NFC) for short, 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or one or a combination of more of them, is not limited herein. The corresponding communication component 1105 may thus comprise: wi-Fi module, bluetooth module, NFC module, etc.
In an exemplary embodiment, the contract invoking node 1100 may be implemented by one or more Application Specific Integrated Circuits (ASIC), digital signal Processor (DIGITAL SIGNAL Processor, DSP), digital signal processing device (DIGITAL SIGNAL Processing Device, DSPD), programmable logic device (Programmable Logic Device, PLD), field programmable gate array (Field Programmable GATE ARRAY, FPGA), controller, microcontroller, microprocessor, or other electronic component for performing the intelligent contract execution method for contract invoking nodes described above.
In another exemplary embodiment, a computer readable storage medium is also provided, comprising program instructions which, when executed by a processor, implement the steps of the smart contract execution method for a contract invoking node described above. For example, the computer readable storage medium may be the memory 1102 described above including program instructions executable by the processor 1101 of the contract invoking node 1100 to perform the intelligent contract execution method described above for the contract invoking node.
The present disclosure also provides a contract execution end, including:
A memory having a computer program stored thereon;
And the processor is used for executing the computer program in the memory to realize the steps of the intelligent contract executing method for the contract executing end.
Fig. 12 is a block diagram illustrating a contract execution end 1200, according to an example embodiment. For example, the contract execution side 1200 may be provided as a server. Referring to fig. 12, the contract execution side 1200 includes a processor 1222, which may be one or more in number, and a memory 1232 for storing computer programs executable by the processor 1222. The computer program stored in memory 1232 may include one or more modules each corresponding to a set of instructions. Further, the processor 1222 may be configured to execute the computer program to perform the smart contract execution method for the contract execution side described above.
In addition, the contract execution 1200 may further include a power component 1226 and a communication component 1250, the power component 1226 may be configured to perform power management of the contract execution 1200, and the communication component 1250 may be configured to enable communication, e.g., wired or wireless communication, of the contract execution 1200. In addition, the contract execution side 1200 may also include an input/output (I/O) interface 1258. The contract execution side 1200 may operate based on an operating system stored in the memory 1232, such as Windows Server TM,Mac OS XTM,UnixTM,LinuxTM, or the like.
In another exemplary embodiment, a computer readable storage medium is also provided, which includes program instructions that, when executed by a processor, implement the steps of the smart contract execution method for a contract execution side described above. For example, the computer readable storage medium may be the memory 1232 including program instructions executable by the processor 1222 of the contract execution 1200 to perform the smart contract execution method described above for the contract execution.
The disclosure also provides an intelligent contract executing system, which comprises the contract calling node and the contract executing end.
In the system, when the contract calling node needs to call the target intelligent contract, the contract information of the target intelligent contract can be obtained from a registered intelligent contract list. In this way, an intelligent contract calling request can be sent to the corresponding contract execution end according to the contract execution end address in the contract information, so that the calling of the target intelligent contract is realized. In other words, according to the technical scheme, the intelligent contract program is arranged at the contract execution end outside the blockchain, so that the contract calling node does not need to independently mount the contract program, and node resource occupation caused by running the intelligent contract can be reduced. In addition, through the way of executing intelligent contracts outside the chain, related restrictions (such as calling restrictions of underlying elements) in the blockchain network can be broken through, so that the phenomenon of abnormal contract operation caused by the related restrictions is reduced.
In another exemplary embodiment, a computer program product is also provided, the computer program product comprising a computer program executable by a programmable apparatus, the computer program having code portions for performing the above-described smart contract execution method for a contract invoking node when executed by the programmable apparatus.
In another exemplary embodiment, a computer program product is also provided, comprising a computer program executable by a programmable apparatus, the computer program having code portions for performing the above-described smart contract execution method for a contract execution side when executed by the programmable apparatus.
The preferred embodiments of the present disclosure have been described in detail above with reference to the accompanying drawings, but the present disclosure is not limited to the specific details of the embodiments described above, and various simple modifications may be made to the technical solutions of the present disclosure within the scope of the technical concept of the present disclosure, and all the simple modifications belong to the protection scope of the present disclosure.
In addition, the specific features described in the foregoing embodiments may be combined in any suitable manner, and in order to avoid unnecessary repetition, the present disclosure does not further describe various possible combinations.
Moreover, any combination between the various embodiments of the present disclosure is possible as long as it does not depart from the spirit of the present disclosure, which should also be construed as the disclosure of the present disclosure.
Claims (15)
1. An intelligent contract execution method, characterized by being applied to a contract invoking node in a blockchain network, the method comprising:
Acquiring contract information of a target intelligent contract to be called from a registered intelligent contract list, wherein the contract information comprises a contract identifier and a contract execution end address, and the contract execution end address corresponds to a contract execution end outside the blockchain network;
Sending an intelligent contract calling request to the contract executing end, wherein the intelligent contract calling request is used for the contract executing end to execute the target intelligent contract according to the contract identification and the contract executing data in the intelligent contract calling request;
Receiving a contract execution response of the contract execution end to obtain an execution result of the target intelligent contract corresponding to the contract calling node;
Before the contract information of the target intelligent contract to be called is obtained from the registered intelligent contract list, the method further comprises:
establishing communication connection with the contract execution end;
Sending a contract identification and a starting parameter of the target intelligent contract to the contract executing end so that the contract executing end starts the intelligent contract corresponding to the contract identification;
receiving a contract starting result sent by the contract executing end;
If the contract starting result represents that the contract executing end successfully starts the target intelligent contract, determining that the target intelligent contract is successfully registered;
Adding the contract identification of the target intelligent contract and the contract execution end address of the contract execution end to the intelligent contract list;
and sending a registration success message to the contract execution end.
2. The method of claim 1, wherein the establishing a communication connection with the contract execution includes:
acquiring registration parameter information of the target intelligent contract;
According to the contract execution end address in the registration parameter information, a connection request is sent to a contract execution end corresponding to the contract execution end address, wherein the connection request comprises node information of the contract calling node and contract identification of the target intelligent contract;
Receiving a connection request response message sent by the contract execution end, wherein the connection request response message comprises address information of the contract execution end and configuration information of an intelligent contract corresponding to the contract identification;
Verifying the address information of the contract execution end and the configuration information of the intelligent contract corresponding to the contract identification in the connection request response message according to the address information of the contract execution end and the configuration information of the intelligent contract in the registration parameter information;
when verification is successful, sending connection confirmation information to the contract execution end;
And establishing communication connection with the contract execution end.
3. The method according to claim 1 or 2, wherein in the process of the contract invoking node communicating with the contract executing end, the data to be sent is encrypted to obtain the first target encrypted sending data by:
Obtaining a hash value of data to be transmitted through a target hash function;
encrypting the hash value based on a private key of the contract calling node to obtain a first encrypted hash value;
Randomly generating a first target symmetric key pair, and encrypting the first encryption hash value and the data to be transmitted through a private key of the first target symmetric key pair to obtain first encrypted transmission data;
and encrypting the first encrypted transmission data and the public key of the first target symmetric key pair through the public key of the contract executing end to obtain the first target encrypted transmission data.
4. The method according to claim 1 or 2, wherein the intelligent contract call request further includes consensus node information for terminating a call procedure of the target intelligent contract when the contract execution end determines that identification information of the contract call node is not included in the consensus node information, wherein the consensus node is a node having a call authority of the target intelligent contract; and/or
The intelligent contract calling request further comprises consensus strategy node information, and the method is used for terminating the calling process of the target intelligent contract when the contract executing end determines that any consensus strategy node in the consensus strategy node information is not in the calling permission list of the target intelligent contract of the contract executing end, wherein the consensus strategy node is a preset consensus node required by the target intelligent contract to take effect.
5. An intelligent contract execution method, which is applied to a contract execution end outside a blockchain network, the method comprising:
Receiving an intelligent contract calling request sent by a contract calling node in a blockchain network, wherein the intelligent contract calling request comprises a contract identification of a target intelligent contract to be called and contract execution data of the target intelligent contract;
Matching node identification information of the contract invoking node with node identification information in an invoking permission list corresponding to the target intelligent contract;
When the matching is successful, executing the target intelligent contract according to the contract identification and contract execution data in the intelligent contract call request;
sending an execution result of the target intelligent contract to the contract calling node;
before receiving the intelligent contract call request sent by the contract call node in the blockchain network, the method further includes:
in response to receiving a connection request sent by the contract invoking node, establishing communication connection with the contract invoking node;
Receiving a contract identification and a starting parameter of the target intelligent contract sent by the contract calling node;
Searching an intelligent contract corresponding to the contract identification, and starting the intelligent contract;
sending a contract starting result to the contract calling node, wherein the contract starting result comprises a contract identifier of the started intelligent contract;
And receiving a registration success message sent by the contract calling node, and adding the node address and the node identification of the contract calling node into the calling permission list.
6. The method of claim 5, wherein the establishing a communication connection with the contract invoking node in response to receiving a connection request sent by the contract invoking node comprises:
receiving a connection request sent by the contract calling node, wherein the connection request comprises node information of the contract calling node and a contract identifier of the target intelligent contract;
searching configuration information of the intelligent contract corresponding to the contract identification;
Sending a connection request response message to the contract calling node, wherein the connection request response message comprises configuration information of the intelligent contract and address information of the contract execution end;
And receiving connection confirmation information sent by the contract invoking node, and establishing communication connection with the contract invoking node.
7. The method according to claim 5 or 6, wherein in the process of the contract execution end communicating with the contract invoking node, the data to be sent is encrypted to obtain second target encrypted sending data by:
Obtaining a hash value of data to be transmitted through a target hash function;
encrypting the hash value based on a private key of the contract executing end to obtain a second encrypted hash value;
Randomly generating a second target symmetric key pair, and encrypting the second encryption hash value and the data to be transmitted through a private key in the second target symmetric key pair to obtain second encrypted transmission data;
And encrypting the second encrypted sending data and the public key of the second target symmetric key pair by using the public key of the contract calling node to obtain the second target encrypted sending data.
8. The method of claim 5 or 6, wherein the smart contract invocation request further includes consensus node information, the method further comprising:
verifying node identification information of the contract calling node according to the consensus node information;
Terminating the calling process of the target intelligent contract when the identification information of the contract calling node is not included in the consensus node information, wherein the consensus node is a node with the calling authority of the target intelligent contract; and/or
The smart contract invocation request further includes consensus policy node information, the method further comprising:
verifying the consensus strategy node information according to the node identification information in the call permission list of the target intelligent contract;
And when any consensus strategy node in the consensus strategy node information is not in the call permission list, terminating the call process of the target intelligent contract, wherein the consensus strategy node is a preset consensus node required by the target intelligent contract to take effect.
9. An intelligent contract execution apparatus, characterized by being applied to a contract invoking node in a blockchain network, comprising:
The system comprises a first acquisition module, a second acquisition module and a second acquisition module, wherein the first acquisition module is used for acquiring contract information of a target intelligent contract to be called from a registered intelligent contract list, the contract information comprises a contract identifier and a contract execution end address, and the contract execution end address corresponds to a contract execution end outside the blockchain network;
The first sending module is used for sending an intelligent contract calling request to the contract executing end, wherein the intelligent contract calling request is used for the contract executing end to execute the target intelligent contract according to the contract identification and the contract executing data in the intelligent contract calling request;
The first receiving module is used for receiving the contract execution response of the contract execution end and obtaining an execution result of the target intelligent contract corresponding to the contract calling node;
The first communication connection establishment module is used for establishing communication connection with the contract execution end before the first acquisition module acquires the contract information of the target intelligent contract to be called from the registered intelligent contract list;
The third sending module is used for sending the contract identification and the starting parameter of the target intelligent contract to the contract executing end so that the contract executing end starts the intelligent contract corresponding to the contract identification;
the third receiving module is used for receiving a contract starting result sent by the contract executing end;
the first determining module is used for determining that the target intelligent contract is successfully registered when the contract starting result characterizes that the contract executing end successfully starts the target intelligent contract;
A first adding module, configured to add a contract identifier of the target intelligent contract and a contract execution end address of the contract execution end to the intelligent contract list;
And the fourth sending module is used for sending a registration success message to the contract execution end.
10. An intelligent contract execution apparatus, comprising:
the second receiving module is used for receiving an intelligent contract calling request sent by a contract calling node in the blockchain network, wherein the intelligent contract calling request comprises a contract identification of a target intelligent contract to be called and contract execution data of the target intelligent contract;
the first matching module is used for matching the node identification information of the contract calling node with the node identification information in the calling permission list corresponding to the target intelligent contract;
the first execution module is used for executing the target intelligent contract according to the contract identification and contract execution data in the intelligent contract call request when the matching is successful;
The second sending module is used for sending the execution result of the target intelligent contract to the contract calling node;
The second communication connection establishment module is used for responding to the connection request sent by the contract calling node before the second receiving module receives the intelligent contract calling request sent by the contract calling node in the blockchain network, and establishing communication connection with the contract calling node;
a fourth receiving module, configured to receive a contract identifier and a start parameter of the target intelligent contract sent by the contract calling node;
the second execution module is used for searching the intelligent contract corresponding to the contract identification and starting the intelligent contract;
a fifth sending module, configured to send a contract starting result to the contract invoking node, where the contract starting result includes a contract identifier of the started intelligent contract;
and the third execution module is used for receiving the successful registration message sent by the contract calling node and adding the node address and the node identification of the contract calling node into the calling permission list.
11. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the steps of the method according to any one of claims 1-4.
12. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the steps of the method according to any of claims 5-8.
13. A contract invocation node, comprising:
A memory having a computer program stored thereon;
A processor for executing the computer program in the memory to implement the steps of the method of any one of claims 1-4.
14. A contract execution terminal, comprising:
A memory having a computer program stored thereon;
a processor for executing the computer program in the memory to implement the steps of the method of any one of claims 5-8.
15. An intelligent contract execution system, comprising the contract invoking node of claim 13 and the contract execution end of claim 14.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011483371.1A CN112632573B (en) | 2020-12-15 | 2020-12-15 | Intelligent contract execution method, device, system, storage medium and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011483371.1A CN112632573B (en) | 2020-12-15 | 2020-12-15 | Intelligent contract execution method, device, system, storage medium and electronic equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112632573A CN112632573A (en) | 2021-04-09 |
CN112632573B true CN112632573B (en) | 2024-06-21 |
Family
ID=75314153
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011483371.1A Active CN112632573B (en) | 2020-12-15 | 2020-12-15 | Intelligent contract execution method, device, system, storage medium and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112632573B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113190285B (en) * | 2021-04-23 | 2023-06-20 | 神荼科技(山东)有限公司 | Virtual environment safety detection method and device based on block chain and storage medium |
CN113472512A (en) * | 2021-06-10 | 2021-10-01 | 东软集团股份有限公司 | Intelligent contract execution method and device, storage medium and electronic equipment |
CN113988845B (en) * | 2021-08-12 | 2022-07-12 | 腾讯科技(深圳)有限公司 | Data processing method and device based on intelligent contract and readable storage medium |
EP4411562A4 (en) * | 2022-12-22 | 2024-10-09 | Tencent Tech Shenzhen Company Limited | Data processing method and apparatus, electronic device, computer storage medium and computer program product |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111401903A (en) * | 2020-06-03 | 2020-07-10 | 腾讯科技(深圳)有限公司 | Block chain message processing method, device, computer and readable storage medium |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109272335A (en) * | 2018-09-17 | 2019-01-25 | 深圳市元征科技股份有限公司 | A kind of intelligence contract administration method, system, equipment and computer storage medium |
KR102118921B1 (en) * | 2018-12-31 | 2020-06-05 | 주식회사 코인플러그 | Method and server for managing user identity using blockchain network, and method and terminal for verifying user using user identity based on blockchain network |
CN110297689B (en) * | 2019-05-06 | 2021-09-14 | 百度在线网络技术(北京)有限公司 | Intelligent contract execution method, device, equipment and medium |
CN111258725B (en) * | 2020-01-17 | 2023-07-25 | 北京百度网讯科技有限公司 | Data processing method, device, equipment and medium based on block chain |
CN111464589A (en) * | 2020-03-03 | 2020-07-28 | 深圳壹账通智能科技有限公司 | Intelligent contract processing method, computer equipment and storage medium |
CN111597269A (en) * | 2020-05-21 | 2020-08-28 | 昆明大棒客科技有限公司 | Block chain-based contract implementation method, device and equipment |
-
2020
- 2020-12-15 CN CN202011483371.1A patent/CN112632573B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111401903A (en) * | 2020-06-03 | 2020-07-10 | 腾讯科技(深圳)有限公司 | Block chain message processing method, device, computer and readable storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN112632573A (en) | 2021-04-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11601809B2 (en) | Method and system for updating certificate issuer public key, and related device | |
CN112632573B (en) | Intelligent contract execution method, device, system, storage medium and electronic equipment | |
US11432150B2 (en) | Method and apparatus for authenticating network access of terminal | |
US7913086B2 (en) | Method for remote message attestation in a communication system | |
WO2017177383A1 (en) | Remote management method and device | |
CN112559993B (en) | Identity authentication method, device and system and electronic equipment | |
US20220245631A1 (en) | Authentication method and apparatus of biometric payment device, computer device, and storage medium | |
EP3598333B1 (en) | Electronic device update management | |
CN111414640B (en) | Key access control method and device | |
CN112398826A (en) | Data processing method and device based on state password, storage medium and electronic equipment | |
CN114584306B (en) | Data processing method and related device | |
CN116346341A (en) | Private key protection and server access method, system, equipment and storage medium | |
EP3820078A1 (en) | Device and method for mediating configuration of authentication information | |
CN113992387A (en) | Resource management method, device, system, electronic equipment and readable storage medium | |
CN108574658B (en) | Application login method and device | |
CN110602051B (en) | Information processing method based on consensus protocol and related device | |
EP3547231B1 (en) | Electronic device management | |
WO2018018419A1 (en) | Configuration file batch-obtaining and downloading method, and server and terminal | |
CN107846390B (en) | Authentication method and device for application program | |
CN113098685B (en) | Security verification method and device based on cloud computing and electronic equipment | |
CN114679287B (en) | Data processing method, system, electronic device and storage medium | |
US20220035924A1 (en) | Service trust status | |
CN108156162B (en) | Authentication method and device for mobile application program | |
Linh et al. | Analysing open-source 5G core networks for TLS vulnerabilities and 3GPP compliance | |
WO2023089438A1 (en) | Correlating remote attestation quotes with a virtualized network function (vnf) resource allocation event |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |