A fair and verifiable smart contract matrix outsourcing calculation method
By designing a fair and verifiable smart contract on the blockchain, generating an auxiliary blinding matrix and performing deblinding processing, the problems of transaction unfairness and verification dilemma in matrix outsourcing calculations are solved, and safe, fair and verifiable matrix outsourcing calculations are achieved.
Patent Information
- Application Number
- CN202411257464.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2044-09-09
AI Technical Summary
Existing matrix outsourcing calculation methods cannot guarantee the fairness and verifiability of transactions, especially in the "pay first, use later" cloud computing model. Users cannot verify the correctness of cloud computing results, and workers face the verifier's dilemma, resulting in delayed or erroneous calculation results.
By designing fair and verifiable smart contracts on the blockchain, using smart contracts to verify cloud computing results, generating auxiliary blinded matrices and performing deblinding processing, the verification complexity is reduced, ensuring the security and fairness of matrix calculations.
It realizes safe, fair and verifiable matrix outsourcing calculation on the blockchain, reduces the complexity of verification time, avoids the verifier's dilemma, protects the interests of users and cloud computing service providers, and ensures the fairness and accuracy of transactions.
Smart Images

Figure CN119232434B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain matrix computing technology, and in particular to a fair and verifiable smart contract matrix outsourcing computing method. Background Art
[0002] Matrix computation plays a crucial role in scientific computing and cryptography. Many cryptographic protocols, scientific computing, and numerical computation problems involve matrix computation. However, for users with limited computing power, the large data volumes and computational complexity make it difficult to independently perform matrix computations. Consequently, matrix computation outsourcing services have emerged. Users outsource matrix computation tasks to cloud computing service providers, which then compute the results and send them to the user to complete the transaction. However, various incentives exist for dishonesty on both sides of the transaction. In a simple outsourcing model, users cannot verify the absolute correctness of the matrix computation results returned by the cloud computing service provider. Therefore, dishonest cloud servers may return random results to save resources. Under the current "pay-as-you-go" cloud computing operating model, even if the cloud computing service provider returns an incorrect result, the user has already paid for the service. Meanwhile, the cloud server may return the correct result, but dishonest users can claim they did not receive the correct answer and refuse to pay. We classify this type of dishonest behavior as unfair, and current cloud outsourcing of matrix computation fails to meet this requirement.
[0003] Fortunately, blockchain, a distributed ledger technology, can solve this problem. Due to the decentralized consensus nature of blockchain, participants can achieve fair and equitable transactions without any third-party interference. Furthermore, the smart contract technology supported by Ethereum opens up a wider range of application scenarios and dimensions for blockchain. Ethereum supports a Turing-complete cryptocurrency scripting language through smart contracts and provides the Ethereum Virtual Machine (EVM) as the execution environment for smart contracts. Users invoke contracts by sending transactions to the contract's interface with specified parameters. Upon receiving the transaction request, the smart contract triggers the execution of the specified code logic and facilitates subsequent execution. The contract's execution process and results are agreed upon by each node and recorded as transactions on the blockchain. Consequently, workers also need to verify all transactions executed by smart contracts. In our example, workers need to verify the matrix calculation results sent by the cloud server. A simple verification method is to re-execute the complex calculation process. However, due to the large amount of data involved in the matrix calculation, the platform may face a very large verification computation load, which may delay the platform's ability to compete for the Proof-of-Work (PoW) computation in the next block. This presents a dilemma for workers. The first option is to skip verifying complex transactions, ensuring they don't fall behind in the block race. However, this option results in incorrect transactions being included in the block. If a block contains incorrect transaction data, not only will the erroneous block be invalidated, but block rewards will also be revoked, and more seriously, the reputation of the entire blockchain ecosystem will be affected. The second option for workers is to continue with honest verification. In this case, they will fall behind in the block race compared to workers who skipped verification. They may be vulnerable to resource consumption attacks, where attackers maliciously send large-scale transactions to delay competitors' mining efficiency, thereby winning the mining competition. This is the Ethereum validator's dilemma.
[0004] While existing verifiable outsourced matrix calculation methods can prevent malicious cloud computing service providers from cheating, reduce computational complexity, and meet verifiability requirements, they still cannot guarantee transaction fairness. Given the current "pay-as-you-go" cloud service operating model, even if users discover dishonest behavior from the cloud service, they have already paid for the transaction. Blockchain-based smart contracts can address this issue by outsourcing matrix calculations and enabling real-time, synchronized transactions. However, this smart contract-based solution still presents numerous challenges. The large amount of data and computation required for matrix operations can expose workers to the verifier's dilemma, leading to transaction delays, rejections, and even erroneous calculation results. Therefore, to address these challenges in outsourcing matrix calculations, a secure, fair, verifiable, and verifier-dilemma-resistant smart contract-based matrix calculation method is proposed, thereby facilitating the secure implementation of matrix outsourcing. Summary of the Invention
[0005] The purpose of this invention is to provide a fair and verifiable smart contract matrix outsourcing calculation method to overcome the shortcomings of the existing technology.
[0006] To achieve the above object, the present invention provides the following technical solutions:
[0007] This application discloses a fair and verifiable smart contract matrix outsourcing calculation method, involving smart contracts, users, and cloud computing service providers, and specifically includes the following steps:
[0008] S1. The user inputs initial data; the initial data includes the matrix to be calculated, several random permutation arrays, and several non-zero random arrays; several auxiliary blinding matrices are generated based on the random permutation arrays, the non-zero random arrays, and the Kronecker function; several blinding matrices are constructed based on the auxiliary blinding matrices, and the content to be calculated by the cloud computing service provider is determined;
[0009] S2: The user enters the content in S1 that needs to be calculated by the cloud computing service provider into the smart contract, and the smart contract waits for the cloud computing service provider to initiate a calculation request;
[0010] S3. The cloud computing service provider submits a computation request to the smart contract, and the smart contract hands the blinded matrix to the cloud computing service provider.
[0011] S4. The cloud computing service provider calculates the matrix result based on the blinded matrix and returns the matrix result to the smart contract.
[0012] S5. After the smart contract receives the matrix result, the verifier deblinds the matrix result to obtain the deblinded result; the deblinded result is compared to determine whether the matrix result is correct; if the matrix result is correct, the smart contract sends the matrix result to the user and rewards the cloud computing service provider; if the matrix result is incorrect, the matrix result is deemed invalid.
[0013] Preferably, the initial data in step S1 includes two matrices M1 and M2 to be calculated, the number of rows of matrix M1 is m and the number of columns is n; the number of rows of matrix M2 is n and the number of columns is k; three random permutation arrays π1, π2, ρ, where π1∈{1,…,n}, π2∈{1,…,n}, ρ∈{1,…,m}; three non-zero random arrays {a1,…,a n}、{b1,…,b n} and {p1,…,p m}.
[0014] As a preference, in step S2, according to the random permutation arrays π1, π2, ρ, the non-zero random array {a1, ..., a n}、{b1,…,b n}、{p1,…,p m} and Kronecker function Generate three auxiliary blinding matrices P1, P2, P3, where Ρ3(i,j)=p i δ ρ(i),j , where i, j belong to the row and column sizes of the three matrices respectively.
[0015] As a preference, in step S2, four matrices X1, X2, X3, and X4 are constructed based on the auxiliary blinding matrices P1, P2, and P3, where X2=P1M2, X4=P2M2; the content that needs to be calculated by the cloud computing service provider is C1=X1×X2, C2=X3×X4.
[0016] Preferably, in step S5, the verifier performs unblinding processing on the matrix result to obtain unblinding results Y1 and Y2, where Y2=P3C2.
[0017] Preferably, the unblinding results are compared to determine whether the matrix result is correct. The specific operation is: determine the size of the unblinding results Y1 and Y2; if Y1 is equal to Y2, the matrix result is correct; otherwise, the matrix result is incorrect.
[0018] Preferably, the initial data also includes a result specific value res, wherein Where x and y are random numbers specified by the user; in step S5, the blinding result is compared to determine whether the matrix result is correct. The specific operation is: determine the size of the blinding results Y1 and Y2. If Y1 is equal to Y2, then further determine c xy Is it equal to Y1(x,y)? If c xy If it is equal to Y1(x,y), the matrix result is correct; if c xy If Y1 is not equal to Y2, the matrix result is incorrect.
[0019] Beneficial effects of the present invention:
[0020] Compared with existing solutions, this invention does not rely on any trusted third party or encryption assumptions; it uses smart contracts as an outsourcing carrier to ensure the security and public verifiability of OMC; it proposes a fair and verifiable smart contract matrix outsourcing calculation method, which reduces the verification time complexity from O(n 3 ) is reduced to O(n 2 ), thereby significantly reducing the computational difficulty of verification and avoiding the verifier dilemma of blockchain workers; other challenges in the implementation and execution of smart contracts, including principal restrictions and parameter exposure, are also considered and corresponding solutions are given.
[0021] The features and advantages of the present invention will be described in detail through embodiments with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 This is a diagram of the relationship between this smart contract, users, and cloud computing service providers; DETAILED DESCRIPTION
[0023] To make the objectives, technical solutions, and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and examples. However, it should be understood that the specific embodiments described herein are merely illustrative of the present invention and are not intended to limit the scope of the present invention. In addition, in the following description, descriptions of well-known structures and technologies are omitted to avoid unnecessary confusion of the present invention.
[0024] See Figure 1 A user submits a smart contract, initiates a matrix outsourcing computation task on the blockchain, and waits for the computation results. The cloud, willing to receive the reward, performs the matrix computation and sends the transaction result to the smart contract. After receiving the result, the worker needs to verify its correctness and choose whether to recognize the transaction. If verified, the smart contract automatically executes the following process, sending the matrix computation result to the user and the reward to the cloud. Due to the security of the blockchain, attackers cannot tamper with the result unless they possess more than half the computing power of the blockchain system, which is impossible in our model. Furthermore, since the reward is sent to the chain along with the outsourcing request transaction, the user cannot violate the contract or terminate it prematurely, thus protecting the interests of the server. Conversely, the contract can only verify the correctness of the result and reward the server after the server sends a transaction with the correct answer. This protects the interests of users and ensures that the server can only be rewarded by sending correct computation results.
[0025] This smart contract matrix outsourcing computing system involves three parties: the problem provider, the cloud computing server that performs the computation, and the worker responsible for execution and verification. The user is the initiator and demander of the matrix computation, aiming to obtain the correct matrix calculation result. However, due to insufficient computing power, the user cannot complete the computation independently and therefore chooses to outsource the computation task. Specifically, in this outsourced computing model, the user is responsible for providing matrices A and B as computation inputs, as well as the address where the computation result is returned and the corresponding computation reward. In this model, the user is rational, meaning that they are not completely honest. They may honestly abide by the transaction rules or betray the client. They will choose the optimal strategy based on the principle of maximizing their own interests. The cloud server is the matrix computation operator and acts as the task solver, receiving the corresponding reward. It is assumed that the cloud server will never refuse a computation, but may return arbitrary results. A dishonest cloud server may maliciously tamper with a value in the result or return two equal but incorrect random results. As a working node in the blockchain, the worker should not be a party in our model. However, given the impact of the verifier's dilemma brought about by large-scale matrix computation transactions, the worker is considered a virtual, trusted, but vulnerable third party. They will honestly verify the correctness of transactions without affecting the mining process. However, they may be overwhelmed when faced with the validator's dilemma.
[0026] The business process for smart contract matrix outsourcing is as follows: a user publishes a matrix outsourcing smart contract on the Ethereum blockchain, initiates a matrix outsourcing task, and awaits the results. The cloud, which is willing to receive the reward, obtains the relevant parameters, performs the matrix calculation, and sends the resulting transaction to the smart contract. After receiving the result, the worker needs to verify its correctness and choose whether to approve the transaction. If verification passes, the smart contract automatically executes the process, sending the matrix calculation result to the user and the reward to the cloud. If verification fails, the transaction fails, and the subsequent smart contract processes cannot be continued. Therefore, the cloud must send a correct calculation result to pass verification, ensuring the accuracy and reliability of the data. Furthermore, the automatic execution of the contract ensures that the cloud will receive the corresponding computing reward as long as it returns the correct calculation result, preventing default or refusal of payment, protecting the interests of the cloud, and ensuring overall fairness in the transaction between both parties.
[0027] The initiator of the matrix calculation calls the smart contract and calls the function of initializing the parameters, and stores the parameters in the smart contract. Since there are no real random numbers in Ethereum, only pseudo-random numbers are provided, and the random numbers are determined by the timestamp of the current time. In order to prevent malicious users from choosing to guess the blinded random numbers through the timestamp. First, we need to obtain the matrices M1 and M2, where the number of rows of M1 is m, the number of columns of M1 and M2 is n, and the number of columns of M2 is k. The initiator of the matrix calculation is required to provide two random permutations π1, π2, where π1, π2∈{1,…,n}, two non-zero random number sets {a1,…,a n}, {b1,…,b n} and a random permutation ρ, where the elements ρ in ρ i ∈{1,…,m} and a set of non-zero random numbers {p1,…,p m}.
[0028] First use the Kronecker delta function:
[0029] Combining random permutation and non-zero random number sets to obtain three matrices P1, P2, P3, where Ρ3(i,j)=p i δ ρ(i),j , where i, j belong to the row and column sizes of the three matrices respectively.
[0030] The following will generate the blinded matrices X1, X2, X3, and X4. The user uses the generated P1, P2, and P3 to construct four matrices X2=P1M2, X4=P2M2. The four matrices obtained are sent to the smart contract. The cloud computing service provider can obtain the four matrices from the contract and needs to calculate C1=X1×X2, C2=X3×X4. After the calculation is completed, the cloud computing service provider needs to call the data storage function in the smart contract to return the calculated matrix results to the smart contract. C1=P3M1M2, If the cloud computing server performs the calculation correctly, then C1=M1M2,Y2=P3C2=M1M2,then Y1=Y2. In the algorithm design, Y1 and Y2 are given to a specific function that receives data for input storage and verification. In order to increase the correctness of the matrix results and prevent malicious clouds from providing a set of results that can satisfy Y1=Y2 but C1 and C2 are not correct (for example, multiplying C1 and C2 by a constant c at the same time), the user needs to select a specific value of the result at the beginning.
[0031] When verifying a smart contract, workers need to verify the correctness of the transfer results and the matrix calculation results. Verifying the matrix results requires prior knowledge of the smart contract implemented in this article. To verify the results, workers simply call the corresponding verification function interface to determine whether the returned data is equal. To ensure verification accuracy, workers can add an additional check digit: res = Y1[x][y] = Y2[x][y] (Since Y1 = Y2, theoretically, the calculation result is correct, hence the term Y). x and y are user-specified random numbers corresponding to their positions in matrix Y. The correctness of the result is verified by verifying that res is equal to Y(x, y). This simplifies the verification process. Users can even call the same function to verify the results. By simplifying the computational verification process, workers are encouraged to verify the execution of smart contracts, effectively reducing unnecessary computational waste.
[0032] Example:
[0033] Inits: The user inputs the square matrix M1, M2, random permutation array π1, π2, ρ1, and non-zero random array {a1,…,a n}, {b1,…,b n}, {p1,…,p n}.
[0034] Create: After receiving the user's input data
[0035] 1. Generate 3 auxiliary blinding matrices P i .
[0036] 2. Generate auxiliary blinding matrix according to auxiliary blinding matrix Pi
[0037] 3. Use the auxiliary blinding matrix to generate the blinding matrix X i ,in X2=P1M2, X4=P2M2.
[0038] 4. Set state:=Produced.
[0039] Calculate: After receiving the calculation request from the cloud computing service provider
[0040] 1. Check if stat is :=Produced.
[0041] 2. Set rights:=out.
[0042] 3. Set the address of CalculatedUserRole to the address of the cloud computing service provider.
[0043] GetParams: After receiving the Calculate request from the cloud computing service provider
[0044] 1. Check if CalculatedUserRole = sender.address.
[0045] 2. Check if rights = out.
[0046] 3. The cloud computing service provider obtains the calculation data C1 = X1 × X2, C2 = X3 × X4.
[0047] 4. Set state:=sended.
[0048] GetAnswer: After receiving the calculation completion request from the cloud computing service
[0049] 1. Check if state is := sent.
[0050] 2. Check if rights = out.
[0051] 3. Check if CalculatedUserRole = sender.address.
[0052] 4. The cloud computing server provides calculation results C1 and C2.
[0053] 5. Set state:=calculated.
[0054] Verify: After receiving the verification request initiated by the verifier
[0055] 1. Check if CalculatedUserRole !=sender.address.
[0056] 2. Check state:=calculated.
[0057] 3. Unblind the calculation results C1 and C2 to obtain the results Y2=P3C2=M1M2.
[0058] 4. The verifier obtains data Y1 and Y2 and compares whether Y1 = Y2.
[0059] 5. The verifier obtains the matrix M1, M2 and the subscripts x, y of the verification value. The verifier needs to calculate c xy in And check whether Y1(x,y) is equal to c xy .
[0060] The algorithm briefly describes a verifiable smart contract implementation for matrix outsourcing based on a blinded matrix. In the Create function, users must enter the data required by the algorithm. The Calculate function requires the cloud computing service provider to provide its address to prevent malicious attackers from interfering with the transaction process by calling the GetAnswer function. The cloud computing service provider obtains the corresponding calculation data from GetParams and submits the calculated answer through the GetAnswer function. The worker obtains the required verification data from Verify and, based on the theoretical basis of this smart contract, compares whether Y1 = Y2.
[0061] The security of this invention is based on smart contracts, or rather, the security of the blockchain. If an attacker wishes to tamper with the data in the contract, they would require more than half the computing power of the entire blockchain network, which is difficult to achieve in this scenario and has no practical value. Because transactions between users and the cloud are conducted through smart contracts, which are automatically judged and executed by the contract, the fairness of this invention is based on the fairness of the blockchain. To maintain system consistency, workers will honestly verify each transaction to ensure its accuracy. If the cloud returns an incorrect calculation answer, the transaction will be deemed invalid by the worker, and the cloud will not receive the corresponding reward. However, if the cloud returns a correct answer, the user cannot retrieve the reward because they have already sent it to the contract. Once the worker verifies the transaction is correct, the money will be automatically transferred to the cloud server account, thus preventing malicious users from defrauding the calculation results. Overall, fairness is guaranteed for both parties.
[0062] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions or improvements made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A fair and verifiable smart contract matrix outsourcing calculation method, including smart contracts, users and cloud computing service providers, characterized in that: The specific steps include: S1. The user inputs initial data; the initial data includes the matrix to be calculated, several random permutation arrays, and several non-zero random arrays; several auxiliary blinding matrices are generated based on the random permutation arrays, the non-zero random arrays, and the Kronecker function; several blinding matrices are constructed based on the auxiliary blinding matrices, and the content to be calculated by the cloud computing service provider is determined; S2: The user enters the content in S1 that needs to be calculated by the cloud computing service provider into the smart contract, and the smart contract waits for the cloud computing service provider to initiate a calculation request; S3. The cloud computing service provider submits a computation request to the smart contract, and the smart contract hands the blinded matrix to the cloud computing service provider. S4. The cloud computing service provider obtains a matrix result based on the blinded matrix calculation; And return the matrix result to the smart contract; S5. After the smart contract receives the matrix result, the verifier performs unblinding processing on the matrix result to obtain the unblinded result; Compare the deblinding results to determine whether the matrix result is correct; if the matrix result is correct, the smart contract sends the matrix result to the user and rewards the cloud computing service provider; If the matrix result is incorrect, the matrix result is deemed invalid.
2. A fair and verifiable smart contract matrix outsourcing calculation method as claimed in claim 1, characterized in that: The initial data in step S1 include two matrices M1 and M2 to be calculated, where the number of rows of matrix M1 is m and the number of columns is n; the number of rows of matrix M2 is n and the number of columns is k; three random permutation arrays π1, π2, ρ, where π1∈{1,…,n}, π2∈{1,…,n}, ρ∈{1,…,m}; three non-zero random arrays {a1,…,a n }、{b1,…,b n } and {p1,…,p m }.
3. A fair and verifiable smart contract matrix outsourcing calculation method as described in claim 2, characterized in that: In step S2, according to the random permutation arrays π1, π2, ρ, the non-zero random array {a1,…,a n }、 {b1,…,b n }、{p1,…,p m } and Kronecker function Generate three auxiliary blinding matrices P1, P2, P3, where Ρ3(i,j)=p i δ ρ(i),j , where i, j belong to the row and column sizes of the three matrices respectively.
4. A fair and verifiable smart contract matrix outsourcing calculation method as described in claim 3, characterized in that: In step S2, four matrices X1, X2, X3, and X4 are constructed based on the auxiliary blinding matrices P1, P2, and P3, where X4=P2M2; the content that needs to be calculated by the cloud computing service provider is C1=X1×X2, C2=X3×X4.
5. A fair and verifiable smart contract matrix outsourcing calculation method as described in claim 4, characterized in that: In step S5, the verifier performs unblinding processing on the matrix results to obtain unblinding results Y1 and Y2, where Y2=P3C2。 6. A fair and verifiable smart contract matrix outsourcing calculation method as claimed in claim 5, characterized in that: Compare the unblinding results to determine whether the matrix result is correct. The specific operation is: determine the size of the unblinding results Y1 and Y2; if Y1 is equal to Y2, the matrix result is correct; otherwise, the matrix result is incorrect.
7. A fair and verifiable smart contract matrix outsourcing calculation method as claimed in claim 1, characterized in that: The initial data also includes a result specific value res, where Where x and y are random numbers specified by the user; in step S5, the blinding result is compared to determine whether the matrix result is correct. The specific operation is: determine the size of the blinding results Y1 and Y2. If Y1 is equal to Y2, then further determine c xy Is it equal to Y1(x,y)? If c xy If it is equal to Y1(x,y), the matrix result is correct; if c xy If Y1 is not equal to Y2, the matrix result is incorrect.
Citation Information
Patent Citations
Data outsourcing calculation transaction method based on smart contract
CN114969815A
Privacy protection verifiable polynomial calculation outsourcing method based on block chain
CN117034334A