Intelligent contract execution method and device, computer equipment and storage medium

By extracting and verifying the subkeys in the smart contract execution request, and rebuilding the contract private keys after a certain number is reached, the execution failure problem of traditional smart contract execution solutions in the case of evil deeds is solved, achieving higher security and flexibility.

CN120180458APending Publication Date: 2025-06-20TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311762542.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-19
Publication Date
2025-06-20

AI Technical Summary

Technical Problem

If there are evil situations in the judgment of contract conditions in traditional smart contract execution plans, the smart contract cannot be executed correctly.

Method used

By receiving a smart contract execution request, extracting the requested content for legality verification, obtaining sub-keys and storing, and rebuilding the keys after a certain amount of accumulation to obtain the contract private key, which triggers the execution of the smart contract.

Benefits of technology

It improves the security and flexibility of smart contract execution, avoids execution failure caused by evil deeds by some participants, and enhances the reliability and applicability of the contract.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120180458A_ABST
    Figure CN120180458A_ABST
Patent Text Reader

Abstract

The invention relates to an intelligent contract execution method and device, computer equipment, a storage medium and a computer program product. The method comprises the steps of extracting request content in an execution request under the condition that the execution request for the smart contract is received; performing legality verification based on the request content, and acquiring a sub-key in the request content under the condition that the legality verification is passed; storing the obtained sub-key in a preset storage space; the preset storage space is used for storing a sub-key obtained from the execution request passing the legality verification each time; under the condition that the number of the sub-keys in the preset storage space reaches a first number, performing key reconstruction according to the first number of sub-keys to obtain a contract private key; and triggering the execution of the smart contract through the contract private key. By adopting the method, the flexibility of intelligent contract execution can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain technology, and in particular, to a method, apparatus, computer device, storage medium, and computer program product for executing smart contracts. Background Art

[0002] With the development of computer technology, smart contracts have emerged. Existing smart contracts are contracts that run in the network space relying on computer devices. They are propagated, verified, or executed in an information-based manner, read and executed by computer devices, and have the characteristics of self-service. Relying on the decentralization and data anti-tampering characteristics of the blockchain, smart contracts are usually implemented on the blockchain, which determines that the settings and executions of smart contracts cannot be modified once determined. Moreover, in order to be implemented by computer devices, the execution conditions of smart contracts must be uniquely determinable.

[0003] In the traditional smart contract execution scheme, when judging contract conditions, if one party behaves maliciously, the smart contract execution conditions cannot be met, resulting in the smart contract not being correctly executed. Summary of the Invention

[0004] Based on this, it is necessary to provide a method, apparatus, computer device, computer-readable storage medium, and computer program product for executing smart contracts to solve the above technical problems.

[0005] In a first aspect, the present application provides a method for executing a smart contract, the method comprising:

[0006] When receiving an execution request for a smart contract, extracting the request content in the execution request;

[0007] Performing a legality check based on the request content, and when the legality check passes, obtaining the sub-key in the request content;

[0008] Storing the obtained sub-key in a preset storage space; the preset storage space is used to store the sub-keys obtained from the execution requests that pass the legality check each time;

[0009] When the number of sub-keys in the preset storage space reaches a first number, performing key reconstruction according to the first number of sub-keys to obtain a contract private key;

[0010] Triggering the execution of the smart contract through the contract private key.

[0011] In a second aspect, the present application further provides a smart contract execution apparatus, comprising:

[0012] An extraction module, configured to extract the request content in the execution request when receiving an execution request for a smart contract;

[0013] An acquisition module, configured to perform a legality check based on the request content, and acquire the sub-key in the request content when the legality check passes;

[0014] A storage module, configured to store the acquired sub-key in a preset storage space; the preset storage space is used to store the sub-keys obtained from each execution request that passes the legality check;

[0015] A reconstruction module, configured to perform key reconstruction based on the first number of sub-keys to obtain a contract private key when the number of sub-keys in the preset storage space reaches the first number;

[0016] An invocation module, configured to trigger the execution of the smart contract through the contract private key.

[0017] In a third aspect, the present application further provides a computer device, including a memory and a processor, where the memory stores a computer program, and when the processor executes the computer program, the steps of the above method are implemented.

[0018] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0019] In a fifth aspect, the present application further provides a computer program product, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0020] For the above smart contract execution method, device, computer device, storage medium, and computer program product, whenever an execution request for a smart contract is received, the request content in the execution request is extracted for legality verification. If the legality verification passes, it can be considered that the execution request is a valid execution request, so the sub-key carried in the request content can be acquired and stored. In this way, as the number of sub-keys stored in the preset storage space increases, when the number of stored sub-keys reaches the first number, it can be considered that the first number of participants agree to execute the smart contract, and then key reconstruction can be performed based on the first number of sub-keys to obtain the contract private key. Furthermore, the smart contract is invoked and executed through the contract private key. On the one hand, the present application ensures the effectiveness of the execution request by verifying the legality of the execution request, and thus ensures the security of the smart contract execution; on the other hand, as long as the first number of participants preset agree to execute the smart contract, the execution of the smart contract can be triggered, avoiding the situation where the smart contract cannot be executed smoothly due to some participants acting maliciously, which can greatly improve the flexibility of the smart contract execution. Brief Description of the Drawings

[0021] To more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following will briefly introduce the drawings required for use in the description of the embodiments or related technologies. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0022] Figure 1 It is an application environment diagram of the intelligent contract execution method in an embodiment;

[0023] Figure 2 It is a schematic flowchart of the intelligent contract execution method in an embodiment;

[0024] Figure 3 It is a schematic flowchart of the intelligent contract execution method in another embodiment;

[0025] Figure 4 It is a schematic flowchart of the intelligent contract execution method in yet another embodiment;

[0026] Figure 5 It is a schematic diagram of sub - key distribution in an embodiment;

[0027] Figure 6 It is a schematic diagram of the release principle of an intelligent contract in an embodiment;

[0028] Figure 7 It is a scenario where each participating party votes in an embodiment;

[0029] Figure 8 It is a timing diagram of the intelligent contract execution method in an embodiment;

[0030] Figure 9 It is a structural block diagram of an intelligent contract execution device in an embodiment;

[0031] Figure 10 It is an internal structure diagram of a computer device in an embodiment. Detailed Description of the Embodiments

[0032] To make the objectives, technical solutions, and advantages of the present application more clearly understood, the following further details the present application in conjunction with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0033] The intelligent contract execution method provided by the embodiments of the present application can be applied to, for example Figure 1In the application environment shown. Among them, the terminal 102 communicates with the computer device 104 through the network. The data storage system can store the data that the computer device 104 needs to process. The data storage system can be integrated on the computer device 104, or can be placed on the cloud or other network servers. The computer device 104 receives an execution request for a smart contract initiated by the terminal 102, extracts the request content in the execution request, performs a legality check based on the request content, and in the case where the legality check passes, obtains the sub-key carried in the request content; stores the obtained sub-key in a preset storage space; the preset storage space is used to store the sub-keys obtained from each execution request that passes the legality check; in the case where the number of sub-keys in the preset storage space reaches the first number, performs key reconstruction according to the first number of sub-keys to obtain the contract private key; triggers the execution of the smart contract through the contract private key. Among them, the terminal 102 can be but is not limited to various personal computers, laptop computers, smart phones, tablet computers, Internet of Things devices, and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart vehicle-mounted devices (such as vehicle-mounted terminals), etc. The portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The computer device 104 can be a terminal or a server. Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, as well as big data and artificial intelligence platforms. The terminal and the server can be directly or indirectly connected through wired or wireless communication methods, and this application does not make any restrictions here.

[0034] The smart contract in this application can be a smart contract deployed on the blockchain. Among them, the blockchain is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithms. The blockchain (Blockchain), essentially a decentralized database, is a string of data blocks generated by using cryptographic methods. Each data block contains information about a batch of network transactions, which is used to verify the validity (anti-counterfeiting) of the information and generate the next block. The blockchain can include the blockchain underlying platform, the platform product service layer, and the application service layer.

[0035] The underlying blockchain platform may include processing modules such as user management, basic services, smart contracts, and operation monitoring. Among them, the user management module is responsible for managing the identity information of all blockchain participants, including maintaining the generation of public and private keys (account management), key management, and maintaining the correspondence between the real identity of the user and the blockchain address (permission management). And under authorization, it supervises and audits the transaction situations of certain real identities, and provides rule configuration for risk control (risk control and audit); the basic service module is deployed on all blockchain node devices to verify the validity of business requests, and records the valid requests on the storage after consensus. For a new business request, the basic service first performs interface adaptation parsing and authentication processing (interface adaptation), then encrypts the business information through a consensus algorithm (consensus management), transmits it to the shared ledger in a complete and consistent manner after encryption (network communication), and performs record storage; the smart contract module is responsible for the registration and issuance of contracts, contract triggering, and contract execution. Developers can define contract logic through a certain programming language, publish it to the blockchain (contract registration), trigger the execution by calling keys or other events according to the logic of the contract terms, complete the contract logic, and also provide functions for contract upgrade and cancellation; the operation monitoring module is mainly responsible for the deployment, configuration modification, contract setting, cloud adaptation during the product release process, and visual output of the real-time state during product operation, such as: alarm, monitoring network conditions, monitoring the health status of node devices, etc.

[0036] The platform product service layer provides the basic capabilities and implementation frameworks of typical applications. Developers can build on these basic capabilities and overlay the characteristics of the business to complete the blockchain implementation of the business logic. The application service layer provides application services based on the blockchain solution for business participants to use.

[0037] In an exemplary embodiment, as Figure 2 shown, a smart contract execution method is provided. In this embodiment, it is exemplified that the method is applied to a computer device. The method includes the following steps:

[0038] Step 202, when receiving an execution request for a smart contract, extract the request content in the execution request.

[0039] Among them, a smart contract is a computer protocol designed to spread, verify, or execute a contract in an information-based manner. Smart contracts allow for trusted transactions without a third party, and these transactions are traceable and irreversible. Generally speaking, a smart contract is a set computer program that can automatically execute the content of a trusted contract without the participation of a third-party intermediary, and all operations are publicly visible and irreversible.

[0040] The process of concluding a smart contract includes: after the parties participating in the conclusion reach an agreement, they jointly formulate a smart contract; the smart contract is broadcast to the fulcrums of each blockchain in the world through the blockchain network and stored; the successfully constructed smart contract waits for the conditions to be met and then automatically executes the contract content.

[0041] In this application, there are multiple (at least two) parties participating in the conclusion of the smart contract. Each party stores a sub-key and is responsible for judging one of the judgment conditions. When the judgment condition of any one party is met, an execution request carrying the sub-key stored by it can be sent to the computer device. It should be noted that the sub-keys stored by different parties are different from each other, and the judgment conditions responsible for different parties can be the same or different.

[0042] It should be noted that the sub-key is the share obtained by splitting the main key S. The number of sub-keys can be set when splitting, for example, set to the second number N. When splitting the main key S, a threshold k (i.e., the first number) can be set. Gathering no less than k sub-keys can jointly recover the main key S, while less than k sub-keys cannot obtain any information about the main key S. In this application, the main key can specifically be the contract private key.

[0043] Specifically, when the computer device receives an execution request for the smart contract sent by the terminal, it can extract the request content in the execution request. The request content can specifically be encrypted data including the sub-key. This encrypted data can be signed by the private key of the party or encrypted by a symmetric key.

[0044] In some embodiments, the computer device can receive one execution request at a time, or can receive multiple execution requests at a time, which depends on the time when different parties send the execution requests. The embodiments of this application do not limit this. In other embodiments, multiple execution requests can be sent by the same party at different time points.

[0045] In some embodiments, when any one party judges that the condition is met, it can encrypt the sub-key to obtain the request content, and then generate an execution request for the smart contract based on the request content. In addition, the party can also encrypt other data and the sub-key together to obtain the request content, and then generate an execution request for the smart contract based on the request content. Other data can be, for example, data proving that the judgment condition is met, or the current timestamp, or identification information for proving its own identity, etc. The embodiments of this application do not limit this.

[0046] Step 204, perform a legality check based on the request content, and obtain the sub-key in the request content when the legality check passes.

[0047] Specifically, the computer device can perform a legality check on the execution request based on the request content. If the check passes, it indicates that the source of the execution request is legal or the request content is legal. Among them, if the source of the execution request is legal, it means that the execution request comes from one of the participating parties.

[0048] In some embodiments, the computer device can perform a legality check on the request content through a preset check rule. If the check passes, it obtains the sub-key carried in the request content and stores the obtained sub-key in a preset storage space. Specifically, the preset check rule can be to decrypt using a preset key. If the decryption is successful, it is determined that the check passes; it can also be to compare with preset data. If the comparison result indicates consistency, it is determined that the check passes; or, perform an operation through a preset algorithm. If the result after the operation is a preset result, it is determined that the check passes, etc. The embodiments of the present application do not limit this.

[0049] Step 206: Store the obtained sub-key in the preset storage space; the preset storage space is used to store the sub-keys obtained from each execution request that passes the legality check.

[0050] Among them, the preset storage space can be a storage space associated with the smart contract, specifically for storing the sub-keys in the execution requests that are for the smart contract and pass the legality check. The preset storage space can specifically be a cache queue, a table, a database, or other forms of storage space, etc. The embodiments of the present application do not limit this.

[0051] In some embodiments, the computer device can determine the preset storage space corresponding to the smart contract, and then store the obtained sub-key in the preset storage space. It should be noted that the number of execution requests for the smart contract can be multiple. For any one execution request, if it passes the legality check, the computer device can store the sub-key carried in it.

[0052] Step 208: When the number of sub-keys in the preset storage space reaches a first number, perform key reconstruction according to the first number of sub-keys to obtain the contract private key.

[0053] Specifically, when the number of stored sub-keys reaches the first number, the computer device can perform key reconstruction according to the first number of sub-keys through the interpolation method to obtain the master key, and this master key is the contract private key. In some embodiments, the computer device can calculate through the Lagrange interpolation formula and based on k sub-keys to obtain the contract private key. In other embodiments, the computer device can adopt the difference interpolation method and calculate based on k sub-keys to obtain the contract private key.

[0054] It should be noted that multiple sub-keys can be obtained by pre-processing the contract private key in the following manner:

[0055] A computer device or a smart contract deployer can construct a polynomial of degree k - 1, with the contract private key as the constant term. The polynomial of degree k - 1 is as follows: ; where s is the contract private key, a 1、 a2……a k-1 are the coefficients of the polynomial, P is a prime number, and mod(P) is the modulo operation with respect to P. The computer device can substitute N different x values into F(x) to obtain N sets of sub - keys [x1, F(x1)], [x2, F(x2)]……[x N , F(x N )], and distribute these N sets of sub - keys to N participants for their respective custody.

[0056] After the computer device obtains k sub - keys, it can construct the following polynomial: , which is a transformation of the above polynomial. Among them, x i is the x value in the i - th set of sub - keys, y i is the value of F(x i ) in the i - th set of sub - keys, and x j is the x value in the j - th set of sub - keys.

[0057] Furthermore, the computer device can set x = 0 and substitute the k sub - keys into this polynomial respectively to solve for F(0), which is also the value of the contract private key.

[0058] In some embodiments, the computer device can also generate a second number of sub - keys through other means using the contract private key, and then reconstruct the first number of sub - keys to obtain the contract private key through a reconstruction method that matches the sub - key generation method. For example, the computer device can generate a second number of sub - keys based on the contract private key through Shamir secret sharing (a threshold secret sharing technique), Blakley secret sharing (a threshold secret sharing technique), or CRT (Chinese Remainder Theorem) secret sharing, etc., and then reconstruct the contract private key based on k sub - keys through a reconstruction method that matches the sub - key generation method.

[0059] Step 210, trigger the execution of the smart contract through the contract private key.

[0060] Specifically, after the computer device reconstructs the contract private key, it can trigger the automatic execution of the smart contract. In some embodiments, after the computer device reconstructs the contract private key, it can call the smart contract through the contract private key to control the execution of the smart contract.

[0061] In some embodiments, the computer device may directly send a contract call request including a contract private key. When the smart contract detects that the contract call request includes a contract private key, it can automatically execute the contract content. Alternatively, the smart contract may compare the key stored in the contract with the contract private key. When the stored key is consistent with the contract private key, the contract content is automatically executed.

[0062] In some embodiments, the computer device may sign preset data with the contract private key to obtain signature data, and then call the smart contract based on the signature data to trigger the execution of the smart contract. Among them, the preset data may specifically be at least one of the following data: contract call parameters, current timestamp, preset information pre-agreed with the smart contract, service data extracted from the request content that has passed the legality check, etc. The embodiments of the present application do not limit this. Among them, the service data extracted from the request content that has passed the legality check, such as voting data or evaluation data, etc., is determined based on the actual business scenario, and the embodiments of the present application do not limit this.

[0063] In some embodiments, the computer device may sign preset data with the contract private key to obtain signature data, and generate a contract call request based on the signature data. The computer device sends the contract call request to the smart contract, and the smart contract verifies the signature data based on the contract public key stored in advance. If the verification passes, the smart contract is executed.

[0064] It should be noted that the computer device may be a computer device capable of communicating with a blockchain node in the blockchain network, or a blockchain node in the blockchain network where the smart contract is deployed.

[0065] When the computer device is a blockchain node where the smart contract is deployed, the processing performed by the computer device mentioned in each embodiment may specifically be executed by the smart contract deployed on the computer device. For example, the smart contract receives an execution request, extracts the request content in the execution request, performs a legality check based on the request content, and when the legality check passes, obtains the sub-key carried in the request content; stores the obtained sub-key in a preset storage space; the preset storage space is used to store the sub-keys obtained from each execution request that has passed the legality check; when the number of sub-keys in the preset storage space reaches a first number, performs key reconstruction according to the first number of sub-keys to obtain the contract private key; and executes the contract content of the smart contract with the contract private key.

[0066] In the above-mentioned smart contract execution method, whenever an execution request for the smart contract is received, the request content in the execution request is extracted for legality verification. If the legality verification passes, it can be considered that the execution request is a valid execution request, so the sub-key carried in the request content can be obtained and stored. In this way, as the number of sub-keys stored in the preset storage space increases, when the number of stored sub-keys reaches the first number, it can be considered that the first number of participating parties agree to execute the smart contract, and then the contract private key can be reconstructed based on the first number of sub-keys. Furthermore, the smart contract is called and executed through the contract private key. On the one hand, the present application ensures the effectiveness of the execution request by verifying the legality of the execution request, and thus ensures the security of smart contract execution; on the other hand, as long as the first number of participating parties preset agree to execute the smart contract, the execution of the smart contract can be triggered, avoiding the situation where the smart contract cannot be executed smoothly due to some participating parties acting maliciously, which can greatly improve the flexibility of smart contract execution.

[0067] In addition, in the smart contract execution method provided by the present application, by decoupling the conditions for controlling the execution of the smart contract into personalized judgment conditions and generalized judgment conditions, the execution judgment of the smart contract becomes more flexible, greatly improving the applicability. Among them, the personalized judgment conditions are the judgment conditions distributed to each participating party, and when the participating party judgment conditions are met, an execution request for the smart contract can be initiated to the computer device; the generalized judgment conditions are the contract judgment conditions written into the smart contract, that is, the judgment conditions related to the contract private key. In this way, in some special scenarios, for example, when it comes to conditions that are not easy to be judged quantitatively or objectively, they can be decoupled to the participating parties for self-judgment, which can expand the scope of use of the smart contract.

[0068] Moreover, through this way of decoupling the conditions for controlling the execution of the smart contract, the generalized judgment conditions of smart contracts applicable to different business scenarios can be kept consistent. In the scenario where multiple smart contracts need to be constructed, the time cost and labor cost of smart contract construction can be reduced.

[0069] Reference Figure 3 , in some embodiments, the smart contract execution method includes the following steps:

[0070] Step 302, when an execution request for the smart contract is received, determine the first time point when the execution request is received.

[0071] Specifically, the computer device can record the first time point when the execution request is received. Alternatively, the execution request carries a sending time point, and the computer device records the sending time point of the execution request as the first time point.

[0072] Step 304, determine the validity period corresponding to the smart contract.

[0073] Specifically, the validity period of the smart contract is pre-stored in the computer device. If an execution request for the smart contract is received within the validity period, subsequent processing can be performed on it. If an execution request for the smart contract is received after the expiration of the validity period, it can be considered an invalid request, and the computer device does not need to respond to it.

[0074] Step 306, determine whether the first time point is within the validity period. If the first time point is not within the validity period, execute step 308. If the first time point is within the validity period, execute steps 310 to 318.

[0075] Step 308, discard the execution request.

[0076] Step 310, extract the request content in the execution request.

[0077] Step 312, perform a legality check based on the request content, and obtain the sub-key in the request content when the legality check passes.

[0078] Step 314, store the obtained sub-key in a preset storage space; the preset storage space is used to store the sub-keys obtained from the execution requests that pass the legality check each time.

[0079] Step 316, when the number of sub-keys in the preset storage space reaches the first quantity, perform key reconstruction according to the first quantity of sub-keys to obtain the contract private key.

[0080] Step 318, trigger the execution of the smart contract through the contract private key.

[0081] In the above embodiments, by responding to the execution requests within the validity period of the smart contract and not responding to the execution requests that exceed the validity period of the smart contract, the effectiveness of the smart contract execution can be ensured, the processing of invalid requests can be avoided, and the useless processing workload can be reduced.

[0082] Reference Figure 4 , in some embodiments, the smart contract execution method includes the following steps:

[0083] Step 402, when receiving an execution request for a smart contract, determine the first time point when the execution request is received.

[0084] Specifically, the computer device can record the first time point when the execution request is received. Alternatively, the execution request carries a sending time point, and the computer device records the sending time point of the execution request as the first time point.

[0085] Step 404, determine the second time point for receiving the execution request from which the last stored sub-key originated.

[0086] Specifically, the computer device can determine the execution request from which the sub-key last stored in the preset storage space originated, and then obtain the second time point for receiving the execution request.

[0087] Step 406, determine whether the time interval between the first time point and the second time point meets the preset interval condition. If not, execute Step 408; if so, execute Steps 410 to 418.

[0088] Specifically, the computer device can determine the time interval between the first time point and the second time point, and then compare this time interval with the preset interval threshold. If the time interval is less than the preset interval threshold, it is determined that the preset interval condition is met. Or, if the time interval is greater than the preset interval threshold, it is determined that the preset interval condition is met. The specific preset interval condition can be set based on the actual business.

[0089] Step 408, discard the execution request.

[0090] Step 410, extract the request content from the execution request.

[0091] Step 412, perform a legality check based on the request content, and if the legality check passes, obtain the sub-key in the request content.

[0092] Step 414, store the obtained sub-key in the preset storage space; the preset storage space is used to store the sub-keys obtained from each execution request that passes the legality check.

[0093] Step 416, when the number of sub-keys in the preset storage space reaches the first quantity, perform key reconstruction based on the first quantity of sub-keys to obtain the contract private key.

[0094] Step 418, trigger the execution of the smart contract through the contract private key.

[0095] In some implementations, each participating party is responsible for judging one of the conditions. When the condition judged by any participating party is met, the corresponding sub-key can be sent to the computer device. The computer device records the reception time. After the computer device receives each execution request, it will judge with the reception time of the previous sub-key. If the time interval reaches the preset interval threshold, the sub-key in the execution request will be put into the queue; if the time interval does not reach the preset interval threshold, it will not be put into the queue. When the number of sub-keys in the queue reaches k, the computer device can recover based on these k sub-keys. If the contract private key can be successfully reconstructed, the smart contract will be called through this contract private key; if the contract private key cannot be reconstructed, relevant prompt information will be fed back to the user.

[0096] This way of contract execution restricts the storage of at least k sub - keys on the one hand, and on the other hand, the time interval between the reception times of every two adjacent execution requests needs to meet the preset interval condition, which can avoid malicious behavior and make the execution of the smart contract more secure.

[0097] In a feasible application scenario, taking the application of this method to an evaluation scenario as an example for illustration:

[0098] The target object conducts a business test through a terminal. This business test includes multiple test metrics. This business test can be an authentication test or an academic test, and the corresponding test metrics can be multiple skills tests or multiple course tests. The embodiments of the present application do not limit this.

[0099] Taking the authentication test scenario as an example, this authentication test includes a second number of skills tests, and the examination duration for completing any one skills test is at least a preset interval threshold (such as 30 minutes). Whenever the target object completes a skills test, the terminal can send the sub - key corresponding to this skills test to the computer device. Or, when the target object completes a skills test and the evaluation score is above a preset score (the preset score is, for example, 90 points), the terminal sends the sub - key corresponding to this skills test to the computer device.

[0100] In this way, the computer device records the reception time of each received execution request. Only when the time interval between this reception time and the reception time corresponding to the previously stored sub - key reaches the preset interval threshold, will the sub - key in this execution request be stored, otherwise it will be discarded. In this way, when the number of sub - keys stored in the computer device reaches the first number, the computer device can recover the contract private key, sign to obtain signature data through the contract private key. The computer device feeds back the signature data to the smart contract, and the smart contract decrypts it through the contract public key. If the decryption is successful, the smart contract is executed. In this scenario, executing the smart contract can specifically be generating the authentication evaluation result of the target object. The authentication evaluation result can include the scoring data of each skills test and the conclusion of whether it is qualified.

[0101] In the above - mentioned embodiments, determine the first time point for receiving the execution request, and determine the second time point for receiving the execution request from which the previously stored sub - key originated. If the time interval between the first time point and the second time point meets the preset interval condition, then respond to the execution request, otherwise discard the execution request. This enables each responded execution request to meet the preset interval condition, which can achieve more flexible control over the storage of sub - keys and greatly improve the application scenarios of the smart contract.

[0102] In some embodiments, the requested content should theoretically be encrypted data obtained by the participating party through the private key of the participating party. Therefore, the legality verification can be performed using the public key of the participating party corresponding to the private key of the participating party. That is, in some embodiments, the legality verification is performed based on the requested content, and when the legality verification passes, the sub-key in the requested content is obtained, including: determining the source party identifier in the execution request; searching for the source party identifier in the list of participating party identifiers, and if a participating party identifier that matches the source party identifier is found, obtaining the public key of the participating party based on the found participating party identifier; decrypting the requested content using the public key of the participating party, and if the decryption is successful, determining that the legality verification passes, and storing the decrypted sub-key.

[0103] Among them, the source party identifier is used to uniquely identify the initiator of the execution request, and specifically can be the terminal identifier or account identifier of the initiator of the execution request, etc., and is usually represented by letters, characters, numbers, or strings, etc. The participating party refers to the object that receives the sub-key during the previous distribution of the sub-key, and the list of participating party identifiers is a list composed of the participating party identifiers of all participating parties. The participating party identifier is used to uniquely identify the participating party, and specifically can be letters, characters, numbers, or strings, etc.

[0104] Specifically, the computer device can extract the source party identifier from the execution request, and then, by means of table lookup, determine whether the source party identifier exists in the list of participating party identifiers. If it exists, it is determined that a match is found, and then the public key of the participating party can be obtained based on the successfully matched participating party identifier.

[0105] In some embodiments, the computer device may pre-store the public keys of the participating parties corresponding to each participating party respectively. These public keys of the participating parties can be the public keys publicly disclosed by the participating parties, or the keys transmitted by the participating parties to the computer device through a trusted communication environment.

[0106] In some embodiments, the computer device can associatively store the participating party identifiers and public keys of the participating parties in the form of a table or a database, and then, in a scenario where legality verification is required, obtain the public key of the participating party according to the participating party identifier.

[0107] Furthermore, the computer device can decrypt the requested content using the public key of the participating party. If the decryption is successful, it indicates that the requested content is encrypted based on the private key of the participating party, that is, it is sent by a legitimate participating party. Therefore, the computer device can save the decrypted sub-key for subsequent processing.

[0108] In the above embodiments, the public key of the participating party is used to verify the legality of the identity of the source party of the execution request. Only when the legality verification passes, the sub-key carried in the request content will be obtained and stored, which can ensure the authenticity and reliability of the source of the sub-key, avoid malicious behavior, and further enhance the security of the execution of the smart contract.

[0109] In some embodiments, the legality verification is performed based on the request content, and when the legality verification passes, the sub-key in the request content is obtained, including: extracting the content to be verified in the request content; obtaining the judgment condition corresponding to the content to be verified; verifying the content to be verified based on the judgment condition, and if the verification passes, it is determined that the legality verification passes, and the sub-key in the request content is extracted.

[0110] Among them, the judgment condition is the condition for the participating party to confirm whether the smart contract can be executed, which can be submitted to the computer device by the creator of the smart contract when deploying the smart contract. The judgment conditions responsible for different participating parties can be the same or different. The content to be verified is the content submitted by the participating party to prove that the judgment condition is met.

[0111] For example, when the judgment condition responsible for the participating party is whether the interval between the current time point and the creation time point of the smart contract reaches the preset time interval, the content to be verified submitted by the participating party can be the time stamp when the execution request is initiated. Also for example, when the judgment condition responsible for the participating party is whether user A is 18 years old, the content to be verified submitted by the participating party can be the date of birth of user A.

[0112] Specifically, the computer device can extract the judgment condition corresponding to the participating party related to the execution request from the data pre-stored related to the smart contract. Then, based on the content to be verified, it is determined whether the judgment condition can be met. If it can, it means that the initiation timing of the execution request is appropriate, so it is determined that the legality verification passes. Furthermore, the computer device can extract the sub-key in the request content.

[0113] In some embodiments, when the computer device determines whether the judgment condition can be met based on the content to be verified, it can also obtain established knowledge for auxiliary judgment. For example, when the judgment condition involves time, the computer device can obtain the current system time. When the judgment condition involves a fact that has occurred, the computer device can obtain the fact that has occurred from the network, etc. In this way, the accurate judgment of the content to be verified can be achieved together with the judgment condition by the established knowledge, making the setting of the offline judgment condition more flexible.

[0114] In some embodiments, by decoupling the conditions for controlling the execution of the smart contract and dividing them into personalized judgment conditions and generalized judgment conditions, the execution judgment of the smart contract becomes more flexible, greatly improving its applicability. Among them, the personalized judgment conditions are the judgment conditions distributed to each participating party, and the generalized judgment conditions are the contract judgment conditions written into the smart contract (such as detecting and verifying the signature data). Moreover, through this way of decoupling the conditions for controlling the execution of the smart contract, the generalized judgment conditions of smart contracts applicable to different business scenarios can be kept consistent. In scenarios where multiple smart contracts need to be constructed, the time cost and labor cost of smart contract construction can be reduced.

[0115] In some embodiments, the request content is encrypted data. The computer device can decrypt the request content with the public key of the participating party corresponding to the execution request to obtain the participating party data. The participating party data includes the content to be verified and the sub-key. Then, the computer device verifies the content to be verified based on the judgment conditions, and stores the sub-key in the participating party data after the verification passes.

[0116] In the above embodiments, by verifying the content to be verified in the request content and only extracting and storing the sub-key therein after the verification passes, the validity of the execution request for the smart contract can be further ensured, preventing participating parties from acting maliciously and initiating an execution request when the execution conditions are not met, and ensuring the security and reliability of the smart contract execution process.

[0117] In some embodiments, calling the smart contract and triggering its execution with the contract private key includes: generating signature data with the contract private key, generating a contract call request based on the signature data, and sending the contract call request to the smart contract to instruct the smart contract to verify the signature data based on the pre-stored contract public key; triggering the execution of the smart contract when the signature data passes the verification.

[0118] In some embodiments, generating signature data with the contract private key includes: obtaining contract call parameters; encrypting the contract call parameters with the contract private key to obtain signature data.

[0119] Among them, the contract call parameters are pre-set parameters for contract calls, which can specifically be contract call interface parameters or preset tokens agreed upon with the smart contract. Specifically, the computer device can obtain the contract call parameters and then encrypt the contract call parameters with the contract private key to obtain signature data.

[0120] Exemplarily, the computer device can obtain the signature data through the following pseudo-code:

[0121] if (collectSubKeys(subKeys)==k){

[0122] SK = recoverPrivateKey(subkeys)

[0123] Sign = signWithPrivateKey(contractCallParameters, SK)

[0124] executeSmartContract(contractCallParameters, Sign)

[0125] }

[0126] In the above embodiments, the contract private key obtained by reconstruction is used to sign the contract call parameters, and this is used as the basis for calling the smart contract, which can ensure the security of the smart contract call process.

[0127] Furthermore, the computer device can generate a contract call request based on the signature data and send the contract call request to the smart contract deployed in the blockchain. After receiving the contract call request, the smart contract decrypts the signature data based on the pre-stored contract public key. If the decryption is successful and the contract call parameters are obtained by decryption, the contract content in the smart contract is executed.

[0128] Exemplarily, the computer device can initiate a contract call request for the smart contract through the following pseudocode: contractCallResult = requestContractExecution(Sign, contractCallParameters);

[0129] The smart contract can verify the signature data through the following pseudocode:

[0130] function executeAction (parameters, signature){

[0131] if (verifySignature(parameters, signature, PK)) {

[0132] / / Execute the contract logic

[0133] } else {

[0134] / / Handling for failed signature verification

[0135] }

[0136] }

[0137] In some embodiments, if the smart contract can be successfully decrypted and the contract call parameters are obtained after decryption, the contract content in the smart contract is executed. When the smart contract is a contract for resource transfer, automatic resource transfer can be achieved by automatically executing the smart contract, such as automatically transferring resource Z from account A to account B.

[0138] Exemplarily, once the signature data passes the verification, the smart contract executes its internal logic and returns the result, and its pseudo-code implementation is as follows: executeAction(contractCallParameters).

[0139] In the above embodiments, the signature data is generated by reconstructing the contract private key and used as the basis for calling the smart contract. After receiving the signature data, the smart contract decrypts it using the contract public key. If the decryption is successful, it indicates that the contract execution condition is met, and the contract content of the smart contract is automatically executed. In this way, the security of the smart contract call process can be ensured.

[0140] In some embodiments, the smart contract execution method further includes a key distribution step, which specifically includes: obtaining an asymmetric key pair, where the asymmetric key pair includes a contract public key and a contract private key; generating a second number of mutually different sub-keys based on the contract private key; the second number is greater than the first number; and passing the second number of sub-keys to the second number of participants, where each participant saves one of the sub-keys.

[0141] It should be noted that the steps of generating and distributing the asymmetric key pair can be implemented by the computer device that implements the smart contract execution method in this application, or can be implemented by other computer devices (such as the developer's terminal or the device where the smart contract is deployed). The embodiments of this application do not limit this. Therefore, the following descriptions are all described through the implementation by the computer device:

[0142] In some embodiments, the computer device can generate an asymmetric key pair (including a contract public key and a contract private key) through an encryption algorithm. The encryption algorithm can be, for example, RSA (a type of asymmetric encryption algorithm) or ECDSA (elliptic curve digital signature algorithm). Exemplarily, the computer device can generate an asymmetric key pair (public key PK and private key SK) through the following pseudo-code: (PK,SK)=generateAsymmetrickeyPair().

[0143] Furthermore, the computer device can send the contract public key in the asymmetric key pair to the deployer of the smart contract, and the smart contract deployer writes the contract public key into the smart contract for subsequent permission verification and signature verification. Exemplarily, the computer device can mention the contract public key through the following pseudocode: contract.submitPublicKey(PK).

[0144] The pseudocode for writing the smart contract is shown as follows:

[0145] contract SimpleContract{

[0146] PublicKey PK;

[0147] Function SimpleContract(PublicKey -PK) {

[0148] PK=-PK;

[0149] }

[0150] / / Other contract functions…

[0151] }

[0152] Exemplarily, the computer device can deploy the smart contract to the blockchain network through the following pseudocode: deployContract(SimpleContract).

[0153] The computer device can generate a second number of distinct sub-keys through the contract private key, where at least k sub-keys can be used to recover the contract private key. Exemplarily, the computer device can generate N sub-keys through the following pseudocode: subKeys=generateSubKeys(SK,N,k).

[0154] Specifically, the computer device can construct a polynomial of degree k - 1, using the contract private key as the constant term, as follows: ; where s is the contract private key, a 1、 a2……a k-1 are the coefficients of the polynomial, and P is a prime number. The computer device can substitute N different x into F(x) to obtain N groups of sub-keys, and distribute these N groups of sub-keys to N participants for their respective custody.

[0155] Of course, the computer device can also generate multiple sub-keys based on the master key through other methods, such as through Blakley secret sharing or CRT secret sharing, etc. The embodiments of the present application do not limit this.

[0156] Furthermore, please refer to Figure 5, the computer device can transfer the second number of sub-keys to the second number of participants, and each participant stores one of the sub-keys. Exemplarily, the computer device can implement the distribution of sub-keys through the following pseudo-code: distributeSubKeys(subKeys, participants).

[0157] In some embodiments, the computer device can distribute the sub-keys through a network security channel or a preset security protocol. Alternatively, a hardware device can also be used to distribute the sub-keys. Each sub-key is stored in a different hardware device, such as a USB token, and then the hardware devices are distributed to different participants.

[0158] In some embodiments, the computer device can transfer the sub-keys in the following manner, that is, any sub-key can be transferred in the following manner: receive the key-encrypted data sent by the participant; the key-encrypted data is obtained by encrypting the first shared key with the participant's private key; decrypt the key-encrypted data with the participant's public key to obtain the first shared key; encrypt the sub-key with the first shared key and transfer the encrypted sub-key to the participant.

[0159] Specifically, before transferring the sub-keys, the participant and the computer device can agree on a shared key for encrypting the sub-keys, that is, the first shared key, to ensure the security of the sub-key transmission. The participant can generate a symmetric key, use the symmetric key as the first shared key, and then transfer the symmetric key to the computer device through a secure transmission method.

[0160] In some embodiments, the participant can generate a symmetric key through an encryption algorithm and encrypt the symmetric key with its own participant private key to obtain the key-encrypted data. Then, the key-encrypted data is sent to the computer device. The computer device decrypts the key-encrypted data with the participant's public key to obtain the symmetric key, and uses the symmetric key as the first shared key. Then, the computer device can use the first shared key to encrypt the sub-keys and send the encrypted sub-keys to the participant.

[0161] It should be noted that each participant can negotiate a shared key with the computer device. When the computer device distributes the sub-keys, it can encrypt the sub-keys with the corresponding shared key and then distribute them, which can ensure the security of the sub-key distribution. Of course, it is also possible for multiple participants to share a shared key. When the computer device distributes the sub-keys, it encrypts them with the same shared key and then distributes them, avoiding the non-participant from obtaining the sub-keys and also ensuring the security of the sub-key transmission process.

[0162] In the above embodiments, the first shared key can be transmitted through the private key of the participant, and then the sub-key can be securely transmitted through the first shared key, which can ensure the security of the sub-key transmission process and avoid potential security risks such as sub-key leakage or theft.

[0163] In some embodiments, the computer device can also distribute the sub-key through quantum key distribution. Specifically, it includes the following steps: obtaining a random bit string, for any bit value in the random bit string, randomly selecting a polarization basis, and encoding the targeted bit value according to the selected polarization basis to obtain a quantum bit; sending each quantum bit to the participant to instruct the participant to measure each quantum bit based on the randomly selected polarization basis to obtain the measurement results of each quantum bit; obtaining each polarization basis selected by the participant, and matching each locally selected polarization basis with each polarization basis selected by the participant to determine the successfully matched polarization bases; determining the second shared key based on the bit values corresponding to the successfully matched polarization bases; encrypting the sub-key with the second shared key, and transmitting the encrypted sub-key to the participant.

[0164] Specifically, the computer device can utilize the characteristics of quantum mechanics to achieve secure sub-key distribution. Its core idea is that certain properties of the quantum system will be disturbed when measured, so any third party attempting to intercept or measure will inevitably destroy the state of the quantum bits in transmission, and this interference can be detected by the sender and receiver of the key.

[0165] The computer device can select a random bit string as the original information, randomly select a polarization basis (e.g., rectangular basis or diagonal basis) within a preset range for each bit value in the random bit string, and encode the bit value with the selected polarization basis.

[0166] For example, if the random bit string has m bit values, such as A1A2A3A4…A m , then for each bit value, a polarization basis will be randomly selected to encode the bit value to obtain a quantum bit. These m polarization bases can be represented as: sequence L1L2L3L4……L m ; the m quantum bits can be represented as: B1B2B3B4…B m .

[0167] Furthermore, the computer device can send each quantum bit (i.e., the encoded bit data, whose manifestation form can be a photon in a polarization state) to the participant.

[0168] After receiving each quantum bit, the participant randomly selects a polarization basis to measure it. The participant records the measurement results and the polarization basis used for each quantum bit, which can be denoted as sequence l1l2l3l4……l m .

[0169] The computer device and the participating party disclose the polarization bases they use, but do not disclose the actual bit values. In this way, the computer device can, according to the sequence of polarization bases l1l2l3l4... l disclosed by the participating party m , and the sequence of polarization bases L1L2L3L4... L selected locally by itself m For example. If the polarization bases with the same serial number are the same, it is considered that the polarization bases corresponding to the serial number match successfully. Furthermore, the computer device can filter out the bit values corresponding to the serial numbers of the successfully matched polarization bases, discard the bit values with unmatched polarization bases, and then can construct a second shared key based on the filtered bit values. Specifically, the filtered bit values can be combined to form a shared key. Furthermore, the sub-key is encrypted with the shared key to achieve the secure transmission of the sub-key.

[0170] In the above embodiments, a shared key is agreed with the participating party through the quantum key distribution method, and then the sub-key is encrypted based on the shared key for the encrypted transmission of the sub-key, which can ensure the security of the sub-key transmission process and avoid potential security risks such as sub-key leakage or theft.

[0171] Furthermore, determining the second shared secret key based on the bit values corresponding to the successfully matched polarization bases includes: taking the bit values corresponding to the successfully matched polarization bases as target bit values; publicly disclosing some of the target bit values and obtaining some data publicly disclosed by the participating party; if the publicly disclosed part of the bit values is consistent with the part of the data publicly disclosed by the participating party, then determine the shared key based on the target bit values, otherwise discard the target bit values and return to the step of obtaining a random bit string to continue execution until the second shared key is obtained and then stop.

[0172] In some embodiments, in order to detect the risk of information leakage, the computer device and the participating party can publicly disclose a part of the target bit values and compare them. If the publicly disclosed bit values match successfully, it is very likely that there is no risk of information leakage; if there are unmatched bit values, it indicates that there may be information leakage. If there is information leakage, the step of obtaining a random bit string can be returned to continue execution to obtain a secure shared key again.

[0173] It can be understood that in the above embodiments, the computer device is used as the sender and the participating party is used as the receiver to negotiate the shared key. In actual applications, it can be that the computer device is used as the receiver and the participating party is used as the sender to negotiate the shared key, and the embodiments of the present application do not limit this.

[0174] It will be appreciated that the terms "first", "second", etc. used in this application may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish a first element from another element. For example, without departing from the scope of this application, the first shared key may be referred to as the second shared key.

[0175] In the above embodiments, by disclosing some bit values to determine whether there is a risk of information leakage, and retaining the shared key for subsequent sub-key encryption in the absence of information leakage, the security of the sub-key encrypted transmission process can be further guaranteed.

[0176] In some embodiments, the smart contract execution method further includes a step of deploying the smart contract, and this step includes: obtaining a contract public key, determining contract execution conditions, and contract content; constructing a smart contract based on the contract public key, contract execution conditions, and contract content; and publishing the smart contract in the blockchain network.

[0177] Specifically, the computer device can obtain the contract public key provided by the settler of the smart contract. Determine the contract execution conditions and contract content agreed upon by each participating party, and then perform code writing and compilation based on the contract public key, contract execution conditions, and contract content to construct the smart contract. Then publish the smart contract to the blockchain network to ensure that the smart contract is public, transparent, and immutable.

[0178] In some embodiments, the contract execution condition may specifically be to verify the signature data in the contract call request through the contract public key, and if the verification passes, the contract content is executed. The contract content may be content related to specific business scenarios, such as resource transfer operations in a resource transfer scenario, vote data statistics and feedback in a voting scenario, score data statistics and feedback in a test scenario, etc., and can be set based on actual business needs, and the embodiments of this application do not make any limitations in this regard.

[0179] In some embodiments, please refer to Figure 6 , after the computer device constructs the smart contract, it can submit the smart contract to the blockchain network to facilitate the deployment of the smart contract in each node of the blockchain network.

[0180] In the above embodiments, by constructing a smart contract through the contract public key, contract execution conditions, and contract content, and publishing the smart contract in the blockchain network, the smart contract can be ensured to be public, transparent, and immutable.

[0181] In a schematic application scenario, the method for executing the smart contract further includes a step of voting data statistics, and this step includes: during the execution of the smart contract, obtaining the voting data in the request content that has passed the legality verification through the smart contract, and obtaining the voting result obtained by statistics based on the voting data through the smart contract.

[0182] In some embodiments, the computer device can encrypt the service data extracted from the execution request that has passed the validity verification by using the contract private key to generate signature data, and feedback the signature data to the smart contract. After decrypting through the contract public key, the smart contract can obtain the service data.

[0183] In an exemplary scenario, when the smart contract is a smart contract related to processing voting data, the service data sent by the computer device to the smart contract can specifically be voting data. During the execution of the smart contract, the smart contract can obtain the voting data and perform statistics to obtain the voting result. Furthermore, the smart contract can feedback the voting result to the computer device.

[0184] In some embodiments, the smart contract in the computer device receives the execution request and extracts the service data (including voting data) in the execution request. In the case of reconstructing the contract private key, the voting data in the request content that has passed the legality verification can be directly used for statistics to obtain the voting result or the election result.

[0185] Reference Figure 7 , Figure 7 is a scenario where each participant votes in an embodiment. The participant can encapsulate the voting data in the execution request and send it to the server through the execution request, and then submit it to the smart contract. In some embodiments, during the execution of the smart contract, the smart contract can receive the voting data sent by the participant who has passed the validity verification, and then perform statistics on the voting data to obtain the voting result.

[0186] In the above embodiments, after the voting data of the first set number of participants is reached, the smart contract can perform statistics based on the voting data to obtain the voting result.

[0187] In a schematic application scenario, the method for executing the smart contract further includes a step of evaluation data statistics, and this step includes: during the execution of the smart contract, obtaining the scoring data in the request content that has passed the legality verification through the smart contract, and obtaining the evaluation result obtained by statistics based on the scoring data through the smart contract.

[0188] In some embodiments, the computer device may encrypt the service data extracted from the execution request that has passed the validity check using the contract private key to generate signature data, and feedback the signature data to the smart contract. After decrypting with the contract public key, the smart contract can obtain the service data.

[0189] In an exemplary scenario, when the smart contract is a smart contract for processing rating data, the service data sent by the computer device to the smart contract may specifically be rating data. During the execution of the smart contract, the smart contract can obtain the rating data and perform statistics to obtain the evaluation result. Furthermore, the smart contract can feedback the evaluation result to the computer device.

[0190] In some embodiments, the smart contract in the computer device receives the execution request and extracts the service data (including rating data) in the execution request. In the case where the contract private key is reconstructed, the rating data in the request content that has passed the legality check can be directly used for statistics to obtain the evaluation result.

[0191] In the above embodiments, after reaching the first set number of rating data, the smart contract can perform statistics based on the rating data to obtain the evaluation result.

[0192] In some embodiments, after the smart contract finishes execution, it will obtain the corresponding execution result. The computer device can construct a transaction based on the execution result and store the execution result in the blockchain network by means of data on-chain, so that the execution result is public and cannot be tampered with.

[0193] It can be understood that the above scenario description is only a schematic description of the applicable scenarios of this application and is not used to limit this application. The smart contract of this application can also be a smart contract for other scenarios, such as a smart contract for resource transfer scenarios, where resource transfer can be achieved when the smart contract is executed, or a smart contract for data transmission scenarios, where data transmission can be automatically performed when the smart contract is executed, etc. The embodiments of this application do not limit this.

[0194] In one embodiment, refer to Figure 8 , Figure 8 is the timing diagram of the smart contract execution method. As Figure 8 shown, the developer's terminal generates an asymmetric key pair, including a contract public key and a contract private key. Furthermore, the developer's terminal generates N sub-keys based on the contract private key. The developer's terminal constructs a smart contract based on the contract public key. Specifically, the smart contract code can be written based on the contract public key, and after compiling the smart contract code, it is sent to the server, and the smart contract is deployed to the blockchain network through the server. When the smart contract is successfully deployed, feedback information will be fed back to the developer's terminal.

[0195] The developer's terminal distributes sub-keys to each participant, and each participant keeps its own sub-key. When the time arrives, the participant can generate an execution request for the smart contract based on the sub-key. The server verifies the execution request and stores the sub-key in the verified execution request. When the server collects k sub-keys, it can recover the contract private key, generate signature data through the contract private key, that is, sign the smart contract call parameters through the contract private key to generate a signature Sign. The server sends a contract call request carrying the signature data to the smart contract, and the smart contract uses the contract public key to verify the signature data. If the verification passes, it executes its internal logic and returns the contract execution result. At the same time, the server can feedback the contract execution result to each participant.

[0196] The above smart contract execution method is a decentralized method that requires multiple parties to confirm to trigger the execution of the smart contract, ensuring that even if some participants act maliciously, the contract can still be correctly triggered. At the same time, it also provides the possibility of flexible execution of the contract, that is, when any part of the preset number of conditions is met, the smart contract can also be executed, making the execution of the smart contract more flexible.

[0197] This application decouples the conditions for controlling the execution of the smart contract into personalized judgment conditions and generalized judgment conditions, making the execution judgment of the smart contract more flexible and greatly improving the applicability. Among them, the personalized judgment conditions are the judgment conditions distributed to each participant. When the participant's judgment conditions are met, an execution request for the smart contract can be initiated to the computer device; the generalized judgment conditions are the contract judgment conditions written into the smart contract, that is, the judgment conditions related to the contract private key. In some special scenarios, for example, when it comes to conditions that are not easy to judge quantitatively or objectively, they can be decoupled to the participant for self-judgment, which can improve the use and access of the smart contract.

[0198] Moreover, through this way of decoupling the conditions for controlling the execution of the smart contract, the generalized judgment conditions of smart contracts applicable to different business scenarios can be kept consistent. In scenarios where multiple smart contracts need to be constructed, the time cost and labor cost of smart contract construction can be reduced.

[0199] It should be understood that although the steps in the flowcharts involved in the above embodiments are sequentially shown according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear indication in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or steps or stages in other steps.

[0200] Based on the same inventive concept, an embodiment of the present application also provides a smart contract execution device for implementing the smart contract execution method involved above. The solution provided by this device to solve the problem is similar to the solution described in the above method. Therefore, the specific limitations in one or more embodiments of the smart contract execution device provided below can refer to the limitations on the smart contract execution method in the above text, and will not be repeated here.

[0201] In an exemplary embodiment, as Figure 9 shown, a smart contract execution device 900 is provided, including: an extraction module 901, an acquisition module 902, a storage module 903, a reconstruction module 904, and a call module 905, where:

[0202] The extraction module is used to extract the request content in the execution request when receiving an execution request for a smart contract.

[0203] The acquisition module is used to perform a legality check based on the request content, and obtain the sub-key in the request content when the legality check passes.

[0204] The storage module is used to store the obtained sub-key in a preset storage space; the preset storage space is used to store the sub-key obtained from each execution request that passes the legality check.

[0205] The reconstruction module is used to perform key reconstruction to obtain the contract private key according to the first number of sub-keys when the number of sub-keys in the preset storage space reaches the first number.

[0206] The call module is used to trigger the execution of the smart contract through the contract private key.

[0207] In some embodiments, the device further includes a determination module, configured to determine a first time point for receiving an execution request; determine a validity period corresponding to the smart contract; if the first time point is within the validity period, then execute the step of extracting the request content in the execution request, otherwise, discard the execution request.

[0208] In some embodiments, the device further includes a determination module, configured to determine a first time point for receiving an execution request; determine a second time point for the execution request from which the last stored sub-key is sourced; if the time interval between the first time point and the second time point meets a preset interval condition, then execute the step of extracting the request content in the execution request, otherwise, discard the execution request.

[0209] In some embodiments, the acquisition module is further configured to determine the source party identifier in the execution request; search for the source party identifier in the list of participant identifiers, if a matching participant identifier is found, then obtain the participant public key based on the found participant identifier; decrypt the request content with the participant public key, if the decryption is successful, then determine that the legality verification passes, and store the decrypted sub-key.

[0210] In some embodiments, the acquisition module is further configured to extract the content to be verified in the request content; obtain the judgment condition corresponding to the content to be verified; verify the content to be verified based on the judgment condition, if the verification passes, then determine that the legality verification passes, and extract the sub-key in the request content.

[0211] In some embodiments, the invocation module is further configured to generate signature data with the contract private key, generate a contract invocation request based on the signature data; send the contract invocation request to the smart contract to instruct the smart contract to verify the signature data based on the pre-stored contract public key; in the case where the signature data passes the verification, trigger the execution of the smart contract.

[0212] In some embodiments, the invocation module is further configured to obtain contract invocation parameters; encrypt the contract invocation parameters with the contract private key to obtain signature data.

[0213] In some embodiments, the device further includes a smart contract deployment module, configured to obtain the contract public key, determine the contract execution conditions and the contract content; construct a smart contract based on the contract public key, the contract execution conditions and the contract content; publish the smart contract in the blockchain network.

[0214] In some embodiments, the device further includes a transfer module, configured to obtain an asymmetric key pair, the asymmetric key pair including the contract public key and the contract private key; generate a second number of mutually different sub-keys based on the contract private key; the second number is greater than the first number; transfer the second number of sub-keys to the second number of participants, where each participant saves one of the sub-keys.

[0215] In some embodiments, the calling module is further configured to, during the execution of the smart contract, obtain the voting data in the request content that has passed the legality verification through the smart contract, and obtain the voting result obtained by statistics based on the voting data through the smart contract.

[0216] In some embodiments, the calling module is further configured to, during the execution of the smart contract, obtain the scoring data in the request content that has passed the legality verification through the smart contract, and obtain the evaluation result obtained by statistics based on the scoring data through the smart contract.

[0217] Each module in the above smart contract execution device can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor of the computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above respective modules.

[0218] In an exemplary embodiment, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 10 shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O), and a communication interface. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store smart contract data. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals through a network connection. When the computer program is executed by the processor, it implements a smart contract execution method.

[0219] Those skilled in the art can understand that Figure 10 the structure shown in

[0220] is only a block diagram of some structures related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have a different component layout.

[0221] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps in the foregoing method embodiments are implemented.

[0222] In one embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in the foregoing method embodiments are implemented.

[0223] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with relevant regulations.

[0224] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memories. Non-volatile memories can include read-only memory (ROM), magnetic tapes, floppy disks, flash memories, optical memories, high-density embedded non-volatile memories, resistive random access memories (ReRAM), magnetoresistive random access memories (MRAM), ferroelectric random access memories (FRAM), phase change memories (PCM), graphene memories, etc. Volatile memories can include random access memory (RAM) or external cache memories, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in the present application can be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, data processing logics based on quantum computing, etc., without limitation.

[0225] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded in this specification.

[0226] The above-described embodiments only represent several implementation manners of the present application. The description is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.

Claims

1. An intelligent contract execution method, characterized in that, The method includes: Upon receiving an execution request for a smart contract, extracting the request content in the execution request; Performing a legality check based on the request content, and upon passing the legality check, obtaining the sub-key in the request content; Storing the obtained sub-key in a preset storage space; the preset storage space is used to store the sub-keys obtained from each execution request that passes the legality check; Upon the number of sub-keys in the preset storage space reaching a first quantity, performing key reconstruction based on the first quantity of sub-keys to obtain the contract private key; Triggering the execution of the smart contract through the contract private key.

2. The method according to claim 1, characterized in that, Before extracting the request content in the execution request, the method further includes: Determining a first time point for receiving the execution request; Determining the validity period corresponding to the smart contract; If the first time point is within the validity period, then performing the step of extracting the request content in the execution request, otherwise, discarding the execution request.

3. The method according to claim 1, characterized in that, Before extracting the request content in the execution request, the method further includes: Determining a first time point for receiving the execution request; Determining a second time point for receiving the execution request from which the previously stored sub-key originated; If the time interval between the first time point and the second time point satisfies a preset interval condition, then performing the step of extracting the request content in the execution request, otherwise, discarding the execution request.

4. The method according to claim 1, characterized in that, The performing a legality check based on the request content, and upon passing the legality check, obtaining the sub-key in the request content, includes: Determining the source party identifier in the execution request; Searching for the source party identifier in the list of participant identifiers, and if a matching participant identifier is found, obtaining the participant public key based on the found participant identifier; Decrypting the request content with the participant public key, and if the decryption is successful, determining that the legality check passes and storing the decrypted sub-key.

5. The method according to claim 1, characterized in that, The performing a legality check based on the request content, and upon passing the legality check, obtaining the sub-key in the request content, includes: Extracting the content to be verified in the request content; Obtaining the judgment condition corresponding to the content to be verified; Verifying the content to be verified based on the judgment condition, and if the verification passes, determining that the legality check passes and extracting the sub-key in the request content.

6. The method according to claim 1, characterized in that, The triggering the execution of the smart contract through the contract private key, includes: Generating signature data through the contract private key, and generating a contract call request based on the signature data; Sending the contract call request to the smart contract to instruct the smart contract to verify the signature data based on the pre-stored contract public key; Upon the signature data passing the verification, triggering the execution of the smart contract.

7. The method according to claim 6, characterized in that, The generating signature data through the contract private key, includes: Obtaining contract call parameters; Encrypting the contract call parameters with the contract private key to obtain signature data.

8. The method according to claim 1, characterized in that, The smart contract is deployed through the following steps: Obtaining the contract public key, determining the contract execution conditions, and the contract content; Construct a smart contract based on the contract public key, the contract execution conditions, and the contract content; Publish the smart contract in the blockchain network.

9. The method according to claim 1, characterized in that, The method further includes: Obtain an asymmetric key pair, where the asymmetric key pair includes a contract public key and a contract private key; Generate a second number of distinct sub-keys based on the contract private key; the second number is greater than the first number; Transmit the second number of sub-keys to the second number of participating parties, where each participating party stores one of the sub-keys.

10. The method according to any one of claims 1 to 9, characterized in that, The method further includes: During the execution of the smart contract, obtain the voting data in the request content that has passed the legality check through the smart contract, and obtain the voting result obtained by statistical analysis based on the voting data through the smart contract.

11. The method according to any one of claims 1 to 9, characterized in that, The method further includes: During the execution of the smart contract, obtain the scoring data in the request content that has passed the legality check through the smart contract, and obtain the evaluation result obtained by statistical analysis based on the scoring data through the smart contract.

12. An intelligent contract execution device, characterized in that, The device includes: An extraction module, configured to extract the request content in the execution request when receiving an execution request for a smart contract; An acquisition module, configured to perform a legality check based on the request content, and obtain the sub-key in the request content when the legality check passes; A storage module, configured to store the obtained sub-key in a preset storage space; the preset storage space is used to store the sub-key obtained from each execution request that has passed the legality check; A reconstruction module, configured to perform key reconstruction to obtain the contract private key according to the first number of sub-keys when the number of sub-keys in the preset storage space reaches the first number; An invocation module, configured to trigger the execution of the smart contract through the contract private key.

13. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, the steps of the method according to any one of claims 1 to 11 are implemented.

14. A computer-readable storage medium, on which a computer program is stored, characterized in that, When the computer program is executed by the processor, the steps of the method according to any one of claims 1 to 11 are implemented.

15. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, the steps of the method according to any one of claims 1 to 11 are implemented.