Task certification method, device, task execution method, equipment and medium

By using hash functions to generate and verify keys and difficulty values ​​in computing tasks, the accuracy of verifying the completion degree of computing task executors in the prior art is solved, and the verification accuracy and security of computing tasks are improved.

CN119254543BActive Publication Date: 2025-05-23ZHEJIANG NANOMICRO TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411779317.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-05
Publication Date
2025-05-23
Estimated Expiration
2044-12-05

AI Technical Summary

Technical Problem

In the prior art, it is relatively low to verify whether the computing task executor completes the computing task, and it is easy to be reverse engineered or guessed to obtain the calculation results of lightweight operations.

Method used

By obtaining the task parameters of the calculation task to be executed, a first key and parameter value are generated based on the preset hash function, a first verification parameter is generated, and sent to the server. During the execution of the calculation task or after obtaining the calculation result, the second difficulty value and the first variable value obtained by hashing the calculation, assisting the client to verify whether the server has completed the calculation task.

Benefits of technology

Improves the accuracy of the client verifying whether the server completes the calculation task, prevents the server from obtaining the calculation results of hash calculations through guessing or reverse engineering, forcing the server to invest actual computing resources, and prevents cheating.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119254543B_ABST
    Figure CN119254543B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention relates to the field of information security technology, and discloses a task certification method, device, task execution method, equipment and medium. The task certification method is to obtain task parameters including input parameters, task identification and timestamp, generate a first key and parameter value based on a hash function and task parameters; generate a first verification parameter based on the parameter value, the first key and the first numerical value; send the task identification, parameter value and the first key to a server, receive the calculation result corresponding to the task identification sent by the server, and receive the difficulty threshold, the second difficulty value and the first variable value sent by the server if the first verification parameter is less than the second numerical value; generate a third difficulty value based on the hash function, the parameter value and the first variable value, and prove that the computing task is executed if the third difficulty value is equal to the second difficulty value and the third difficulty value is less than the difficulty threshold. The computing task is verified to be executed through the interactive steps of hash calculation. The accuracy of verifying that the computing task is executed is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of information security technology, and in particular to a task certification method, device, task execution method, equipment and medium. Background Art

[0002] In the field of information security technology, in order to solve the problem that devices with weak computing power have difficulty completing more complex computing tasks with large amounts of computing power, complex computing tasks with large amounts of computing power are usually outsourced to more powerful computing services, such as cloud computing. However, more powerful computing services have lower credibility and are prone to returning seemingly reasonable computing results without executing the computing task. In the prior art, to verify whether the computing service (executor) of the computing task has actually executed the computing task, an interactive proof step of lightweight computing can be inserted into the computing process of the computing task. The requester of the computing task and the executor of the computing task prove that the executor has completed the computing task through a series of interactive proof steps. However, lightweight computing is usually a simple calculation, and it is easy to obtain the calculation results of lightweight computing through reverse engineering or guessing. Therefore, this method has low accuracy in verifying whether the executor has completed the computing task. Summary of the invention

[0003] The purpose of the present invention is to at least provide a task certification method, device, task execution method, equipment and medium, which can at least solve the problem of low accuracy in verifying whether the executor has completed the computing task, and at least improve the accuracy of verifying whether the executor has completed the computing task.

[0004] To solve the above technical problems, at least one embodiment of the present application provides a task proof method, which is applicable to a client, including: obtaining task parameters of a computing task to be executed, wherein the task parameters include input parameters, a task identifier and a timestamp; generating a first key and a parameter value based on a preset hash function and the task parameters; generating a first verification parameter based on the parameter value, the first key and a preset first numerical value; sending the task identifier, the parameter value and the first key to a server, receiving a calculation result corresponding to the task identifier sent by the server, and when the first verification parameter is less than a preset second numerical value, receiving a difficulty threshold sent by the server, a second difficulty value obtained by hash calculation processing and a first variable value obtained by hash calculation processing, wherein the first numerical value is much larger than the second numerical value; generating a third difficulty value based on the hash function, the parameter value and the first variable value, if the third difficulty value is equal to the second difficulty value, and the third difficulty value is less than the difficulty threshold, it proves that the computing task is executed and the calculation result is valid.

[0005] At least one embodiment of the present application also provides a task execution method, applicable to a server, comprising: receiving a task identifier, a parameter value and a first key sent by a client; executing a to-be-executed computing task corresponding to the task identifier to obtain a computing result; wherein, during the execution of the to-be-executed computing task corresponding to the task identifier or after obtaining the computing result, a second verification parameter is generated according to the parameter value, the first key and a preset third numerical value; if the second verification parameter is less than a preset fourth numerical value, the parameter value and the preset first variable value are processed based on a preset hash function to generate a first difficulty value, and if the first difficulty value is not less than a preset difficulty threshold, the value of the first variable value plus one is repeatedly used as a new first variable value, and the parameter value and the new first variable value are processed based on the hash function to generate a second difficulty value, until the second difficulty value is less than the difficulty threshold, the calculation result, the most recently obtained second difficulty value, the difficulty threshold and the first variable value are sent to the client.

[0006] At least one embodiment of the present application also provides a task proof device, which is applicable to a client, including: an acquisition module, used to obtain task parameters of a computing task to be executed, wherein the task parameters include input parameters, a task identifier and a timestamp; a generation module, used to generate a first key and a parameter value based on a preset hash function and the task parameters; the generation module is also used to generate a first verification parameter based on the parameter value, the first key and a preset first numerical value; a sending module, used to send the task identifier, the parameter value and the first key to a server, receive a calculation result corresponding to the task identifier sent by the server, and when the first verification parameter is less than a preset second numerical value, receive a difficulty threshold sent by the server, a second difficulty value obtained by hash calculation processing and a first variable value obtained by hash calculation processing, wherein the first numerical value is much larger than the second numerical value; a proof module, used to generate a third difficulty value based on the hash function, the parameter value and the first variable value, if the third difficulty value is equal to the second difficulty value, and the third difficulty value is less than the difficulty threshold, then it is proved that the computing task is executed and the calculation result is valid.

[0007] At least one embodiment of the present application also provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the above-mentioned task certification method or task execution method.

[0008] At least one embodiment of the present application further provides a computer-readable storage medium storing a computer program, wherein the computer program implements the above-mentioned task certification method or task execution method when executed by a processor.

[0009] The task certification method provided by the embodiment of the present application obtains the task parameters of the computing task to be executed, wherein the task parameters include input parameters, a task identifier and a timestamp; generates a first key and a parameter value based on a preset hash function and the task parameters; generates a first verification parameter based on the parameter value, the first key and a preset first numerical value; sends the task identifier, the parameter value and the first key to a server, receives the calculation result corresponding to the task identifier sent by the server, and when the first verification parameter is less than a preset second numerical value, receives the difficulty threshold sent by the server, the second difficulty value obtained by hash calculation processing and the first variable value obtained by hash calculation processing, wherein the first numerical value is much larger than the second numerical value; generates a third difficulty value based on the hash function, the parameter value and the first variable value, and if the third difficulty value is equal to the second difficulty value, and the third difficulty value is less than the difficulty threshold, it proves that the computing task is executed and the calculation result is valid. The client and the server interact with each other through the numerical values ​​obtained by hash calculation, and based on the second difficulty value and the first variable value obtained by hash calculation when the server executes the calculation task, assist the client in verifying whether the server has completed the calculation task; and utilize the one-way and collision constraint characteristics of hash calculation to ensure that it is difficult for the server to obtain the calculation result of hash calculation by guessing or reverse engineering, effectively improving the accuracy of the client's verification of whether the server (executor) has completed the calculation task.

[0010] In some optional embodiments, the generation of the first key and parameter value based on the preset hash function and the task parameters includes: generating a dynamic key based on the task parameters; generating a first subkey based on the dynamic key, a random value and a preset key derivation function; processing the first subkey according to the preset hash function to obtain the first key; processing the input parameter according to the hash function to obtain the parameter value. The first subkey generated using the dynamic key and the random value is richer and less likely to be guessed, and the first subkey is processed using the hash function to obtain the first key, so that the first key has better security and is less likely to be cracked.

[0011] In some optional embodiments, the generating of the dynamic key based on the task parameter includes: concatenating the task parameter as a character string to obtain the dynamic key; or, calculating the task parameter as a numerical value to obtain the dynamic key, wherein the calculation includes addition calculation, subtraction calculation, multiplication calculation, division calculation, function processing, etc. Providing multiple ways to generate the dynamic key makes it difficult to guess the dynamic key, thereby improving the security of the dynamic key.

[0012] In some optional embodiments, the generating of the first verification parameter based on the parameter value, the first key and the preset first value includes: concatenating the parameter value and the first key as a character string to obtain a first concatenation result; processing the first concatenation result using a hash function to generate a hash value; and taking the remainder value of the hash value divided by the preset first value as the first verification parameter. Processing the first concatenation result using a hash function makes the generated hash value more secure.

[0013] In some optional embodiments, the generating of the third difficulty value based on the hash function, the parameter value and the first variable value includes: concatenating the parameter value and the first variable value as a string to obtain a second concatenation result; and processing the second concatenation result using the hash function to obtain a third difficulty value. The client generates the third difficulty value using the parameter value and the first variable value sent by the server, and uses the third difficulty value to assist the client in verifying whether the server has completed the computing task, thereby realizing a quick verification of whether the server has completed the computing task based on simple computing processing.

[0014] In some optional embodiments, a task execution method is applicable to a server, comprising: receiving a task identifier, a parameter value and a first key sent by a client; executing a to-be-executed computing task corresponding to the task identifier to obtain a computing result; wherein, during the execution of the to-be-executed computing task corresponding to the task identifier or after obtaining the computing result, a second verification parameter is generated according to the parameter value, the first key and a preset third numerical value; if the second verification parameter is less than a preset fourth numerical value, the parameter value and the preset first variable value are processed based on a preset hash function to generate a first difficulty value, and if the first difficulty value is not less than a preset difficulty threshold, the first variable value plus one is repeatedly executed as a new first variable value, and the parameter value and the new first variable value are processed based on the hash function to generate a second difficulty value, until the second difficulty value is less than the difficulty threshold, the calculation result, the most recently obtained second difficulty value, the difficulty threshold and the first variable value are sent to the client. By performing a series of hash calculations during the server's computing task or after obtaining the calculation results of the computing task, the server cannot obtain the calculation results of the hash calculations by guessing or reverse engineering. Therefore, the server needs to perform a large number of hash calculations to obtain the calculation results of the hash calculations, and use the calculation results of the hash calculations to prove that the server itself has completed the computing task. This makes it more accurate to verify whether the server has completed the computing task.

[0015] In some optional embodiments, the processing of the parameter value and the preset first variable value based on a preset hash function to generate the first difficulty value includes: concatenating the parameter value and the preset first variable value as a character string to obtain a third concatenation result; and processing the third concatenation result using a preset hash function to generate the first difficulty value. The hash function is used to enable the server to obtain the first difficulty value, and the server generates the first difficulty value using the hash function, the parameter value, and the preset first variable value. The first difficulty value is used to obtain relevant information that can verify that the server itself has completed the execution of the computing task, thereby preventing the server from using cheating methods to forge that it has completed the execution of the computing task, thereby improving the accuracy of the verification result. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] One or more embodiments are exemplarily described by the pictures in the corresponding drawings, and these exemplary descriptions do not constitute limitations on the embodiments.

[0017] Figure 1 It is a schematic diagram of the structure of a task proof system;

[0018] Figure 2 It is a flowchart of a task proof method;

[0019] Figure 3It is a flowchart of a task execution method;

[0020] Figure 4 is a schematic diagram of a task certification device provided by another embodiment of the present application;

[0021] Figure 5 is a schematic diagram of a task execution device provided by another embodiment of the present application;

[0022] Figure 6 It is a schematic diagram of the structure of an electronic device provided by another embodiment of the present application. DETAILED DESCRIPTION

[0023] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the embodiments of the present application will be described in detail below in conjunction with the accompanying drawings. However, it will be appreciated by those skilled in the art that in the present application, many technical details are proposed in order to enable the reader to better understand the present application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical scheme claimed in the present application can also be implemented. The division of the following embodiments is for the convenience of description, and the specific implementation of the present application should not be construed as any limitation, and the various embodiments can be combined and referenced with each other under the premise of no contradiction.

[0024] With the development of crowdsourcing computing, big data, and generative AI, the phenomenon of "outsourcing" computing tasks to untrusted users in projects is becoming more and more common. By outsourcing computing tasks to more powerful computing services, such as cloud computing, the computing requirements for devices with weak computing power can be reduced. However, this model of outsourcing computing tasks also introduces new security and trust issues, especially when the computing provider may not be trustworthy. Some dishonest computing providers may modify the client software to return seemingly reasonable results without performing actual computing tasks based on various factors such as economic interests, lack of supervision, technical capability limitations, and competitive pressure.

[0025] In the prior art, in order to verify the validity of the calculation results and verify whether the calculation provider (executor of the calculation task) has actually executed the calculation task, an interactive proof step of lightweight calculation is usually inserted into the calculation process of the calculation task. The requester of the calculation task asks random questions to test whether the executor of the calculation task has truly completed the calculation task. For example, the requester of the calculation task and the executor of the calculation task use a series of interactive proof steps to prove that the executor has completed the calculation task. However, lightweight calculations are usually simple calculations, and the calculation results of lightweight calculations can be easily obtained through reverse engineering or guesswork. For the executor of the calculation task, the calculation results of lightweight calculations can be forged at a relatively low cost. Therefore, the accuracy of verifying whether the executor has completed the calculation task in this way is relatively low.

[0026] Figure 1 A structural diagram of a task certification system provided for an exemplary embodiment of the present application, the system includes: a client and a server:

[0027] Among them, the client is a requester of the computing task, and the client is used to obtain the task parameters of the computing task to be executed, wherein the task parameters include input parameters, task identifier and timestamp; generate a first key and parameter value based on a preset hash function and the task parameters; generate a first verification parameter based on the parameter value, the first key and a preset first numerical value; send the task identifier, the parameter value and the first key to the server, receive the calculation result corresponding to the task identifier sent by the server, and when the first verification parameter is less than the preset second numerical value, receive the difficulty threshold sent by the server, the second difficulty value obtained by hash calculation processing and the first variable value obtained by hash calculation processing, wherein the first numerical value is much larger than the second numerical value; generate a third difficulty value based on the hash function, the parameter value and the first variable value, if the third difficulty value is equal to the second difficulty value, and the third difficulty value is less than the difficulty threshold, it proves that the computing task is executed and the calculation result is valid.

[0028] The server refers to an untrusted server with strong computing power, that is, a computing provider and an executor of a computing task. The server is used to receive a task identifier, a parameter value, and a first key sent by a client; execute the computing task to be executed corresponding to the task identifier to obtain a computing result; wherein, during the execution of the computing task to be executed corresponding to the task identifier or after obtaining the computing result, a second verification parameter is generated according to the parameter value, the first key, and a preset third value; if the second verification parameter is less than the preset fourth value, the parameter value and the preset first variable value are processed based on a preset hash function to generate a first difficulty value; if the first difficulty value is not less than a preset difficulty threshold, the value of the first variable value plus one is repeatedly executed as a new first variable value, and the parameter value and the new first variable value are processed based on the hash function to generate a second difficulty value, until the second difficulty value is less than the difficulty threshold, the calculation result, the most recently obtained second difficulty value, the difficulty threshold, and the first variable value are sent to the client.

[0029] The execution principles and interaction processes of the various components in the system embodiment, such as the first server, the second server and the client, can be found in the description of the following method embodiments.

[0030] In order to solve the above-mentioned technical problem of low accuracy in verifying whether the executor has completed the computing task, the present invention proposes a task proof method. The implementation details of the task proof method of this embodiment are specifically described below. The following content is only the implementation details provided for the convenience of understanding and is not necessary for the implementation of this solution.

[0031] Embodiment 1:

[0032] The task certification method of this embodiment can be applied to electronic devices with communication, computing and data storage capabilities, specifically clients, and its specific process can be as follows: Figure 2 As shown, the steps include steps 101 to 105:

[0033] Step 101: Obtain task parameters of a computing task to be executed, wherein the task parameters include input parameters, a task identifier, and a timestamp;

[0034] Specifically, the client refers to the requester of the computing task; the input parameter refers to the initial data of the computing task to be executed, so as to ensure that the computing task to be executed can correctly perform the required operations; the task identifier refers to the task ID of the computing task to be executed.

[0035] Step 102: Generate a first key and a parameter value based on a preset hash function and the task parameters;

[0036] In some examples, the generating of the first key and the parameter value based on the preset hash function and the task parameter includes steps 201 to 204:

[0037] Step 201: Generate a dynamic key based on the task parameters;

[0038] In some examples, generating a dynamic key based on the task parameters includes: concatenating the task parameters as strings to obtain a dynamic key; or, calculating and processing the task parameters as numerical values ​​to obtain a dynamic key, wherein the calculation processing includes addition calculation processing, subtraction calculation processing, multiplication calculation processing, division calculation processing, function processing, etc.

[0039] Step 202: Generate a first subkey based on the dynamic key, the random value and a preset key derivation function;

[0040] Specifically, the random value can be obtained by any method of generating random numbers. The specific method of generating random numbers can be found in the prior art, and will not be described in detail here.

[0041] Specifically, the preset key derivation function is any function in KDF (Key derivation function), KDF includes multiple key derivation function categories, such as HMAC, PBKDF2, HKDF and other categories, and each key derivation function category includes multiple key derivation functions. Among them, HMAC, PBKDF2, HKDF can be referred to in the prior art, and will not be described in detail here.

[0042] Specifically, generating the first subkey based on the dynamic key, the random value and the preset key derivation function can be achieved by the following formula:

[0043] SubKey = KDF(MasterKey, Salt)

[0044] Among them, SubKey is the first subkey, MasterKey is the dynamic key, and Salt is a random value.

[0045] Step 203: Process the first subkey according to a preset hash function to obtain a first key;

[0046] Specifically, the first subkey is processed according to a preset hash function to obtain the first key, which can be achieved by the following formula:

[0047] HashedSubKey = Hash(SubKey)

[0048] Among them, HashedSubKey is the first key and SubKey is the first subkey.

[0049] Step 204: Process the input parameter according to the hash function to obtain a parameter value.

[0050] Specifically, the input parameter is processed according to the hash function to obtain the parameter value, which can be achieved by the following formula:

[0051] InternalParameter = Hash(InputData)

[0052] Among them, InternalParameter is the parameter value and InputData is the input parameter.

[0053] Step 103: Generate a first verification parameter based on the parameter value, the first key and a preset first value;

[0054] Specifically, generating the first verification parameter based on the parameter value, the first key and the preset first value can be achieved by the following formula:

[0055] C = Hash(InternalParameter || HashedSubKey) mod N

[0056] Among them, C is the first verification parameter, InternalParameter is the parameter value, || is the string concatenation symbol, HashedSubKey is the first key, mod is the modulus symbol, and N is the preset first value.

[0057] In some examples, generating a first verification parameter based on the parameter value, the first key, and a preset first numerical value includes: concatenating the parameter value and the first key as a string to obtain a first concatenation result; processing the first concatenation result using a hash function to generate a hash value; and taking the remainder value of dividing the hash value by the preset first numerical value as the first verification parameter.

[0058] Step 104: sending the task identifier, the parameter value, and the first key to a server, receiving a calculation result corresponding to the task identifier sent by the server, and when the first verification parameter is less than a preset second value, receiving a difficulty threshold, a second difficulty value obtained by hash calculation, and a first variable value obtained by hash calculation sent by the server, wherein the first value is much greater than the second value;

[0059] Specifically, the first verification parameter refers to a verification parameter for determining whether the computing task to be executed needs to be verified; and the preset second value refers to a threshold for determining whether the computing task to be executed needs to be verified.

[0060] In some examples, if the first verification parameter is not less than a preset second value, there is no need to obtain the difficulty threshold sent by the server, the second difficulty value obtained by hash calculation, and the first variable value obtained by hash calculation. It is only necessary to receive the calculation result sent by the server.

[0061] In summary, the first value is much larger than the second value, which increases the randomness of the generated first verification parameter being less than the second value, and avoids the situation where the first value is much smaller than or less than the second value, resulting in a high probability that the first verification parameter is less than the second value, thereby requiring verification for most of the computing tasks to be executed, wasting more computing resources.

[0062] Step 105: Generate a third difficulty value based on the hash function, the parameter value and the first variable value. If the third difficulty value is equal to the second difficulty value and the third difficulty value is less than the difficulty threshold, it proves that the computing task is executed and the computing result is valid.

[0063] Specifically, the third difficulty value refers to a value calculated by the client based on data fed back by the server and used to verify whether the server has actually completed the computing task to be executed.

[0064] Specifically, the difficulty threshold refers to a preset difficulty value used to measure the difficulty of a hash calculation task performed by the server, wherein the hash calculation task is a task performed by the server other than the calculation task to be executed, to obtain a second difficulty value obtained by hash calculation processing and a first variable value obtained by hash calculation processing.

[0065] The difficulty threshold refers to a preset difficulty value used to measure the difficulty of a hash calculation task performed by the server, wherein the hash calculation task is a task performed by the server other than the calculation task to be performed, to obtain a second difficulty value obtained through hash calculation processing and a first variable value obtained through hash calculation processing.

[0066] In some examples, a third party trusted by the client or a computing task operator of the client may generate a third difficulty value based on the hash function, the parameter value, and the first variable value to provide a better customer experience.

[0067] In some examples, generating a third difficulty value based on the hash function, the parameter value and the first variable value includes: concatenating the parameter value and the first variable value as a string to obtain a second concatenation result; and processing the second concatenation result using the hash function to obtain a third difficulty value.

[0068] In some examples, if the third difficulty value is not equal to the second difficulty value, or the third difficulty value is not less than the difficulty threshold, it proves that the to-be-executed computing task has not been executed and the computing result is invalid.

[0069] The task certification method provided in this embodiment obtains the task parameters of the computing task to be executed, wherein the task parameters include input parameters, task identifier and timestamp; generates a first key and parameter value based on a preset hash function and the task parameters; generates a first verification parameter based on the parameter value, the first key and a preset first value; sends the task identifier, the parameter value and the first key to the server, receives the calculation result corresponding to the task identifier sent by the server, and when the first verification parameter is less than the preset second value, receives the difficulty threshold sent by the server, the second difficulty value obtained by hash calculation and the first variable value obtained by hash calculation, wherein the first value is much larger than the second value; generates a third difficulty value based on the hash function, the parameter value and the first variable value, and if the third difficulty value is equal to the second difficulty value, and the third difficulty value is less than the difficulty threshold, it proves that the computing task is executed and the computing result is valid. The client interacts with the server through the value obtained by hash calculation, and based on the second difficulty value and the first variable value obtained by hash calculation when the server executes the computing task, the client is assisted in verifying whether the server has completed the computing task. By utilizing the one-way and collision-constrained characteristics of hash calculations, it is ensured that it is difficult for the server to obtain the results of hash calculations by guessing or reverse engineering, forcing the server to invest actual computing resources to prevent cheating by skipping calculations or falsifying results. This improves the accuracy of the client's verification of whether the server (executor) has completed the calculation task.

[0070] In addition, the server obtains the second difficulty value and the first variable through a hash calculation with a large amount of computation. The client can also verify whether the server has completed the computing task to be executed through the second difficulty value and the first variable, so that the client can verify in a simple and fast way, which is relatively convenient. It also prevents the server from tampering with or attacking the client to forge the results of the computing task to be executed, thereby maintaining the security and integrity of the system. By adjusting the second numerical value, the amount of computation required by the server to obtain the second difficulty value and the first variable can be adjusted. Based on different needs, the difficulty of the server to perform hash calculations to obtain the second difficulty value and the first variable can be set. For important computing tasks to be executed, a high difficulty amount of computation can be set so that the server invests more computing resources to avoid server cheating, so that the client can obtain the calculation results of the computing task to be executed more securely.

[0071] Embodiment 2:

[0072] The task execution method of this embodiment can be applied to electronic devices with communication, computing and data storage capabilities, and is specifically applicable to servers. The specific process can be as follows: Figure 3 As shown, it includes steps 301 to 304:

[0073] Step 301: Receive a task identifier, a parameter value, and a first key sent by a client;

[0074] Specifically, the server refers to a server that is not trusted by the client.

[0075] Step 302: Execute the to-be-executed computing task corresponding to the task identifier to obtain a computing result;

[0076] Step 303, wherein, during the execution of the to-be-executed computing task corresponding to the task identifier or after obtaining the computing result, a second verification parameter is generated according to the parameter value, the first key and a preset third value;

[0077] Specifically, the preset third value is the same as the aforementioned first value.

[0078] In some examples, generating a second verification parameter based on the parameter value, the first key, and the first numerical value includes: concatenating the parameter value and the first key as a string to obtain a first concatenation result; processing the first concatenation result using a hash function to generate a hash value; and taking the remainder value of dividing the hash value by a preset first numerical value as the second verification parameter.

[0079] Step 304: If the second verification parameter is less than a preset fourth value, the parameter value and the preset first variable value are processed based on a preset hash function to generate a first difficulty value; if the first difficulty value is not less than a preset difficulty threshold, the first variable value plus one is repeatedly executed as a new first variable value, and the parameter value and the new first variable value are processed based on the hash function to generate a second difficulty value, until the second difficulty value is less than the difficulty threshold, the calculation result, the most recently obtained second difficulty value, the difficulty threshold and the first variable value are sent to the client.

[0080] Specifically, the default value of the preset first variable value is 0.

[0081] Specifically, the preset fourth value is the same as the aforementioned preset second value.

[0082] In some examples, the processing of the parameter value and the preset first variable value based on a preset hash function to generate a first difficulty value includes: concatenating the parameter value and the preset first variable value as a string to obtain a third concatenation result; and processing the third concatenation result using a preset hash function to generate a first difficulty value.

[0083] Specifically, the parameter value and the preset first variable value are concatenated as a character string to obtain a third concatenation result; the third concatenation result is processed using a preset hash function to generate a first difficulty value, which can be achieved by the following formula:

[0084] HashValue = Hash*(InternalParameter||Nonce)

[0085] Among them, HashValue is the first difficulty value, * refers to selecting a hash function with high security, such as SHA-256 or double SHA-256, InternalParameter is the parameter value, Nonce is the preset first variable value, || is the string concatenation symbol, and InternalParameter||Nonce is the third concatenation result.

[0086] In some examples, if the second verification parameter is not less than the second value, the calculation result is sent to the client.

[0087] In summary, due to the unidirectionality and unpredictability of the hash function, the server cannot quickly obtain a second difficulty value less than the difficulty threshold based on the first variable value and the parameter value. It must gradually increase the first variable value and perform calculations in sequence to obtain the second difficulty value that meets the preset conditions. The server needs to perform a large number of hash calculations to obtain the second difficulty value. Therefore, when the verification process, that is, a large number of hash calculation processes, are inserted into the calculation task to be executed, the server will basically continue to execute the remaining part of the calculation task to be executed on the basis of having executed part of the calculation task to be executed and executing a large number of hash calculations, in order not to waste the consumed resources, thereby ensuring the correctness of the verification result. Of course, in order to avoid the extreme server that obtains the second difficulty value by performing a large number of hash calculations on the basis of having executed part of the calculation task to be executed, and then no longer executes the remaining part of the calculation task to be executed, this solution also sets up that after the server executes the calculation task to be executed and obtains the calculation result, the verification process (a large number of hash calculations) is inserted to make the verification result more accurate.

[0088] Embodiment three:

[0089] Another embodiment of the present application relates to a task certification device, which is applicable to a client. The implementation details of the task certification device of this embodiment are specifically described below. The following content is only for the convenience of understanding the implementation details provided, and is not necessary for the implementation of this solution. The schematic diagram of the task certification device of this embodiment can be as follows Figure 4 As shown, it includes an acquisition module 401, a generation module 402, a sending module 403 and a certification module 404.

[0090] The acquisition module 401 is used to acquire task parameters of the computing task to be executed, wherein the task parameters include input parameters, task identifier and timestamp.

[0091] The generating module 402 is used to generate a first key and a parameter value based on a preset hash function and the task parameters.

[0092] The generating module 402 is further configured to generate a first verification parameter based on the parameter value, the first key and a preset first numerical value.

[0093] The sending module 403 is used to send the task identifier, the parameter value and the first key to the server, receive the calculation result corresponding to the task identifier sent by the server, and when the first verification parameter is less than a preset second value, receive the difficulty threshold sent by the server, the second difficulty value obtained by hash calculation and the first variable value obtained by hash calculation, wherein the first value is much larger than the second value.

[0094] The proof module 404 is used to generate a third difficulty value based on the hash function, the parameter value and the first variable value. If the third difficulty value is equal to the second difficulty value and the third difficulty value is less than the difficulty threshold, it proves that the computing task is executed and the computing result is valid.

[0095] In some examples, the generation module 402 is used to generate a first key and a parameter value based on a preset hash function and the task parameters, and is specifically used to: generate a dynamic key based on the task parameters; generate a first sub-key based on the dynamic key, a random value and a preset key derivation function; process the first sub-key according to a preset hash function to obtain a first key; process the input parameter according to the hash function to obtain a parameter value.

[0096] In some examples, the generation module 402 is used to generate a dynamic key based on the task parameters, specifically to: concatenate the task parameters as strings to obtain a dynamic key; or, perform calculation processing on the task parameters as numerical values ​​to obtain a dynamic key, wherein the calculation processing includes addition calculation processing, subtraction calculation processing, multiplication calculation processing, division calculation processing, function processing, etc.

[0097] In some examples, the generation module 402 is used to generate a first verification parameter based on the parameter value, the first key and a preset first numerical value, specifically for: concatenating the parameter value and the first key as a string to obtain a first concatenation result; processing the first concatenation result using a hash function to generate a hash value; and taking the remainder value of the hash value divided by the preset first numerical value as the first verification parameter.

[0098] In some examples, the proof module 404 is used to generate a third difficulty value based on the hash function, the parameter value and the first variable value, specifically for: concatenating the parameter value and the first variable value as a string to obtain a second concatenation result; and processing the second concatenation result using the hash function to obtain a third difficulty value.

[0099] It is worth mentioning that all modules involved in this embodiment are logic modules. In practical applications, a logic unit can be a physical unit, a part of a physical unit, or a combination of multiple physical units. In addition, in order to highlight the innovative part of this application, this embodiment does not introduce units that are not closely related to solving the technical problems proposed by this application, but this does not mean that there are no other units in this embodiment.

[0100] Embodiment 4:

[0101] Another embodiment of the present application relates to a task execution device, which is applicable to a server. The implementation details of the task execution device of this embodiment are described in detail below. The following content is only for the convenience of understanding the implementation details, and is not necessary for the implementation of this solution. The schematic diagram of the task execution device of this embodiment can be as follows Figure 5 As shown, it includes a receiving module 501, an execution module 502, a generation module 503 and a processing module 504.

[0102] The receiving module 501 is used to receive a task identifier, a parameter value and a first key sent by a client.

[0103] The execution module 502 is used to execute the to-be-executed computing task corresponding to the task identifier to obtain a computing result.

[0104] The generation module 503 is used to generate a second verification parameter according to the parameter value, the first key and a preset third value during the execution of the to-be-executed computing task corresponding to the task identifier or after obtaining the computing result.

[0105] Processing module 504 is used to, if the second verification parameter is less than a preset fourth value, execute processing on the parameter value and the preset first variable value based on a preset hash function to generate a first difficulty value; if the first difficulty value is not less than a preset difficulty threshold, repeatedly execute taking the first variable value plus one as a new first variable value, and process the parameter value and the new first variable value based on the hash function to generate a second difficulty value, until the second difficulty value is less than the difficulty threshold, then send the calculation result, the most recently obtained second difficulty value, the difficulty threshold and the first variable value to the client.

[0106] In some examples, the processing module 504 is used to process the parameter value and the preset first variable value based on a preset hash function to generate a first difficulty value, specifically for: concatenating the parameter value and the preset first variable value as a string to obtain a third concatenation result; and processing the third concatenation result using a preset hash function to generate a first difficulty value.

[0107] It is worth mentioning that all modules involved in this embodiment are logic modules. In practical applications, a logic unit can be a physical unit, a part of a physical unit, or a combination of multiple physical units. In addition, in order to highlight the innovative part of this application, this embodiment does not introduce units that are not closely related to solving the technical problems proposed by this application, but this does not mean that there are no other units in this embodiment.

[0108] Embodiment five:

[0109] Another embodiment of the present application relates to an electronic device, such as Figure 6 As shown, it includes: at least one processor 901; and a memory 902 that is communicatively connected to the at least one processor 901; wherein the memory 902 stores instructions that can be executed by the at least one processor 901, and the instructions are executed by the at least one processor 901 so that the at least one processor 901 can execute the task certification method or task execution method in the above-mentioned embodiments.

[0110] Among them, the memory and the processor are connected in a bus manner, and the bus may include any number of interconnected buses and bridges, and the bus connects various circuits of one or more processors and memories together. The bus can also connect various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be one element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices on a transmission medium. The data processed by the processor is transmitted on a wireless medium via an antenna, and further, the antenna also receives data and transmits the data to the processor.

[0111] The processor is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory can be used to store data used by the processor when performing operations.

[0112] Embodiment six:

[0113] Another embodiment of the present application relates to a computer-readable storage medium storing a computer program, which implements the above method embodiment when executed by a processor.

[0114] That is, those skilled in the art can understand that all or part of the steps in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium, including a number of instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as: ROM), random access memory (Random Access Memory, referred to as: RAM), disk or optical disk and other media that can store program codes.

[0115] Those skilled in the art will appreciate that the above embodiments are specific embodiments for implementing the present application, and in actual applications, various changes may be made thereto in form and detail without departing from the spirit and scope of the present application.

Claims

1. A task certification method, characterized in that: Applicable to clients, including: Obtaining task parameters of a computing task to be executed, wherein the task parameters include input parameters, a task identifier, and a timestamp; Generate a first key and a parameter value based on a preset hash function and the task parameter; Generate a first verification parameter based on the parameter value, the first key and a preset first value; Sending the task identifier, the parameter value, and the first key to a server, receiving a calculation result corresponding to the task identifier sent by the server, and when the first verification parameter is less than a preset second value, receiving a difficulty threshold sent by the server, a second difficulty value obtained through hash calculation, and a first variable value, wherein the first value is much greater than the second value, and the second value refers to a threshold for measuring whether the computing task to be executed needs to be verified; generating a third difficulty value based on the hash function, the parameter value and the first variable value, and if the third difficulty value is equal to the second difficulty value and the third difficulty value is less than the difficulty threshold, it proves that the computing task is executed and the computing result is valid; The second difficulty value refers to the second difficulty value obtained most recently, and the second difficulty value is calculated as follows: during the execution of the to-be-executed computing task corresponding to the task identifier or after obtaining the computing result, the server generates a second verification parameter according to the parameter value, the first key and a preset third value; if the second verification parameter is less than the preset fourth value, the parameter value and the preset first variable value are processed based on a preset hash function to generate a first difficulty value; if the first difficulty value is not less than a preset difficulty threshold, the value of the first variable plus one is repeatedly used as a new first variable value, and the parameter value and the new first variable value are processed based on the hash function to generate a second difficulty value, until the second difficulty value is less than the difficulty threshold.

2. The task certification method according to claim 1, characterized in that: The generating of the first key and the parameter value based on the preset hash function and the task parameter includes: generating a dynamic key based on the task parameters; Generate a first subkey based on the dynamic key, the random value and a preset key derivation function; Processing the first subkey according to a preset hash function to obtain a first key; The input parameter is processed according to the hash function to obtain a parameter value.

3. The task certification method according to claim 2, characterized in that: The generating a dynamic key based on the task parameter comprises: The task parameters are concatenated as strings to obtain a dynamic key; or, The task parameters are taken as numerical values ​​and calculated to obtain a dynamic key.

4. The task certification method according to claim 1, characterized in that: The generating a first verification parameter based on the parameter value, the first key and a preset first value includes: Concatenate the parameter value and the first key as a character string to obtain a first concatenation result; Processing the first concatenation result using a hash function to generate a hash value; The remainder value of dividing the hash value by a preset first value is used as a first verification parameter.

5. The task certification method according to any one of claims 1 to 4, characterized in that: The generating a third difficulty value based on the hash function, the parameter value and the first variable value comprises: Concatenate the parameter value and the first variable value as a character string to obtain a second concatenation result; The second concatenation result is processed by using the hash function to obtain a third difficulty value.

6. A task execution method, characterized in that: For servers, including: Receive a task identifier, a parameter value, and a first key sent by a client; Execute the to-be-executed computing task corresponding to the task identifier to obtain a computing result; wherein, during the execution of the to-be-executed computing task corresponding to the task identifier or after obtaining the computing result, a second verification parameter is generated according to the parameter value, the first key and a preset third value; If the second verification parameter is less than a preset fourth value, the parameter value and the preset first variable value are processed based on a preset hash function to generate a first difficulty value. If the first difficulty value is not less than a preset difficulty threshold, the first variable value plus one is repeatedly used as a new first variable value, and the parameter value and the new first variable value are processed based on the hash function to generate a second difficulty value. When the second difficulty value is less than the difficulty threshold, the calculation result, the most recently obtained second difficulty value, the difficulty threshold and the first variable value are sent to the client, so that the client generates a third difficulty value based on the hash function, the parameter value and the first variable value. If the third difficulty value is equal to the second difficulty value and the third difficulty value is less than the difficulty threshold, it is proved that the calculation task is executed and the calculation result is valid.

7. The task execution method according to claim 6, characterized in that: The processing of the parameter value and the preset first variable value based on a preset hash function to generate a first difficulty value includes: The parameter value and the preset first variable value are concatenated as a character string to obtain a third concatenation result; The third concatenation result is processed using a preset hash function to generate a first difficulty value.

8. A task certification device, characterized in that: Applicable to clients, including: An acquisition module, used to acquire task parameters of a computing task to be executed, wherein the task parameters include input parameters, a task identifier, and a timestamp; A generation module, used to generate a first key and a parameter value based on a preset hash function and the task parameters; The generating module is further configured to generate a first verification parameter based on the parameter value, the first key and a preset first numerical value; a sending module, configured to send the task identifier, the parameter value, and the first key to a server, receive a calculation result corresponding to the task identifier sent by the server, and when the first verification parameter is less than a preset second value, receive a difficulty threshold sent by the server, a second difficulty value obtained through hash calculation, and a first variable value, wherein the first value is much greater than the second value, and the second value refers to a threshold for measuring whether the computing task to be executed needs to be verified; a proving module, configured to generate a third difficulty value based on the hash function, the parameter value and the first variable value, and if the third difficulty value is equal to the second difficulty value and the third difficulty value is less than the difficulty threshold, then proving that the computing task is executed and the computing result is valid; The second difficulty value refers to the second difficulty value obtained most recently, and the second difficulty value is calculated as follows: during the execution of the to-be-executed computing task corresponding to the task identifier or after obtaining the computing result, the server generates a second verification parameter according to the parameter value, the first key and a preset third value; if the second verification parameter is less than the preset fourth value, the parameter value and the preset first variable value are processed based on a preset hash function to generate a first difficulty value; if the first difficulty value is not less than a preset difficulty threshold, the value of the first variable plus one is repeatedly used as a new first variable value, and the parameter value and the new first variable value are processed based on the hash function to generate a second difficulty value, until the second difficulty value is less than the difficulty threshold.

9. An electronic device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the task certification method described in any one of claims 1 to 5 or the task execution method described in any one of claims 6 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, it implements the task certification method described in any one of claims 1 to 5 or the task execution method described in any one of claims 6 to 7.

Citation Information

Patent Citations

  • Block chain consensus system and method based on distributed verifiable delay function

    CN112988894A

  • Battery passport storage method and device based on block chain and storage medium

    CN117390114A