A two-stage outsourcing service transaction method based on data encryption and blockchain
By adopting a two-stage outsourcing service transaction method based on data encryption and blockchain in the data auction process, the problem of data leakage risk is solved, and the secure transaction of data and the healthy development of the market is achieved.
Patent Information
- Application Number
- CN202410929932.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-11
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2044-07-11
AI Technical Summary
There is a risk of data leakage during the data auction process, and it is difficult for existing technology to effectively solve this problem.
Using a two-stage outsourcing service transaction method based on data encryption and blockchain, the service data is divided into the first data segment and the second data segment, and the blockchain is used to confirm and trade data to ensure the security and privacy of the data.
It effectively prevents the risk of data leakage, ensures the originality and integrity of data, provides a fair and reliable trading platform, and promotes the healthy development of the data trading market.
Smart Images

Figure CN118917844B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of blockchain and relates to a transaction method, and specifically to a two-stage outsourcing service transaction method based on data encryption and blockchain. Background Art
[0002] In today's digital age, data has become one of the most valuable assets for businesses and individuals. However, the privacy and security issues of data transactions have increasingly become the focus of social attention. When faced with data transaction privacy and security issues, businesses and individuals are looking for effective solutions.
[0003] As an emerging market mechanism, data auctions allow data providers to sell their data as commodities to maximize the value of data. However, this process is also accompanied by many security risks. During the data auction process, if security measures are not perfect, sensitive data may be accessed or stolen by unauthorized persons during transmission or storage. Summary of the invention
[0004] In view of the above-mentioned deficiencies in the prior art, the present invention provides a two-stage outsourcing service transaction method based on data encryption and blockchain, which solves the risk of data leakage in the data auction process.
[0005] In order to achieve the above-mentioned purpose of the invention, the technical solution adopted by the present invention is: a two-stage outsourcing service transaction method based on data encryption and blockchain, which is applied to the contractor, comprising the following steps:
[0006] S1. Obtain service data from the blockchain, and divide the service data into a first data fragment and a second data fragment;
[0007] The data size of the first data segment is larger than that of the second data segment, and the first data segment includes a main part of the service data, and the second data segment includes decryption information;
[0008] S2. Send the first data fragment to the contractor. The first data fragment is sent to the contractor in an on-chain or off-chain manner.
[0009] S3, respectively calculating the first hash value and the second hash value of the first data fragment and the second data fragment, and publishing the fused hash value and the first hash value on the blockchain according to the first hash value and the second hash value;
[0010] S4. Deposit the contract recipient's deposit into the smart contract within the preset first time period;
[0011] S5, receiving transaction information; when the transaction information is confirmation information from the smart contract, sending the second data fragment to the blockchain within a preset second time period; when the transaction information is off-chain arbitration information of the arbitrator, executing step S6;
[0012] The confirmation information is used to determine whether the data received by the sender matches the first data fragment;
[0013] S6. Send the service data to the arbitrator. The service data may be sent to the arbitrator on-chain or off-chain.
[0014] A two-stage outsourcing service transaction method based on data encryption and blockchain, applied to the contractor, includes the following steps:
[0015] S1a, deposit the contractor's deposit and purchase funds into the smart contract;
[0016] S1b, receiving a first data fragment from a packet receiver;
[0017] The first data fragment is sent by the receiver, and the sending method includes on-chain and off-chain;
[0018] The first data segment is obtained by obtaining service data from the blockchain by the recipient and dividing the service data into the first data segment and the second data segment;
[0019] The data size of the first data segment is larger than that of the second data segment, and the first data segment includes a main part of the service data, and the second data segment includes decryption information;
[0020] S1c, calculating a third hash value of the first data segment;
[0021] S1d, comparing the third hash value with the first hash value, where the first hash value is calculated by the sender based on the first data fragment and published on the blockchain;
[0022] When the third hash value is the same as the first hash value, a confirmation message is sent to the smart contract, and step S1e is executed; when the third hash value is different from the first hash value, off-chain arbitration is initiated;
[0023] S1e, obtaining a second data segment from the packet receiver, calculating a fourth hash value of the second data segment, and determining a fifth hash value according to the third hash value and the fourth hash value;
[0024] The second data segment is sent by the recipient to the blockchain within a preset second time period;
[0025] S1f, comparing the fifth hash value and the fused hash value, when the fifth hash value and the fused hash value are different, executing step S1g; when the fifth hash value and the fused hash value are the same, sending transaction instruction information to the smart contract;
[0026] The transaction instruction information is used to instruct the smart contract to release the deposits of both parties to the transaction and deliver the purchase funds to the recipient;
[0027] S1g. Use a preset algorithm to automatically arbitrate disputes, re-compare the fifth hash value and the fused hash value, and determine the malicious party, and execute different punishment measures according to different malicious parties.
[0028] The beneficial effects of the above scheme are:
[0029] (1) The present invention focuses on the data ownership mechanism and the efficient data transaction method based on blockchain. It uses a non-repudiation protocol to confirm the data, ensure the originality and integrity of the data, and effectively prevent data plagiarism and abuse. It conducts safe and efficient transactions on successfully confirmed data. It adopts a blockchain-based data transaction model to provide a fair and reliable transaction platform for contractors and buyers, ensuring that contractors can obtain the economic returns they deserve. At the same time, it protects the legitimate rights and interests of contractors, promotes the healthy development of the data transaction market, and contributes new impetus to the prosperity of the data economy.
[0030] (2) The two-stage data transaction scheme of the present invention demonstrates high accuracy and speed in confirming and managing data. In the blockchain auction process, by using homomorphic encryption technology, the bidding information of participants can be effectively protected, ensuring that even in the event of a hacker attack, the attacker can only obtain the encrypted data and cannot know the actual data. The application of this technology greatly enhances the data privacy and security in the auction process, protects the interests of the contractor and the buyer, and improves the reliability and trust of the entire auction system.
[0031] (3) The present invention generates a new block after the transaction is completed, and the block records the specific details of all transactions, including the addresses of both parties to the transaction, the transaction amount, the timestamp, the transaction fee, etc. In the event of a transaction dispute, the information recorded in the block can serve as conclusive evidence to provide support.
[0032] Further, the first data segment is an encrypted first data segment;
[0033] Step S2 specifically includes:
[0034] S21. Determine the public key and private key required for the RSA homomorphic encryption algorithm;
[0035] S22. Encrypt the first data segment using the public key to obtain an encrypted first data segment;
[0036] S23: Send the encrypted first data segment to the packet sender.
[0037] Furthermore, step S21 specifically includes:
[0038] S211, randomly select two large prime numbers;
[0039] S212, determining a modulus according to two large prime numbers;
[0040] S213, calculating the Euler function according to two large prime numbers and the modulus;
[0041] S214, randomly selecting an integer so that the integer satisfies a preset relationship related to the Euler function;
[0042] S215. Determine the public key and the private key according to the integer and the Euler function.
[0043] Furthermore, the process of respectively calculating the first hash value and the second hash value of the first data segment and the second data segment in step S3 specifically includes:
[0044] S31, converting the first data segment and the second data segment into UTF-8 encoded byte sequences respectively to obtain a first byte sequence and a second byte sequence;
[0045] S32, preprocessing the first byte sequence and the second byte sequence respectively, adding specific padding bits, to obtain a first padding sequence and a second padding sequence;
[0046] The lengths of the first filling sequence and the second filling sequence are integer multiples of 512;
[0047] The padding bits include 0x80, 0x00 and 0;
[0048] S33, dividing the first filling sequence and the second filling sequence into at least two data blocks for processing respectively, to obtain a first data block set and a second data block set;
[0049] The length of each of at least two data blocks is 512;
[0050] The first data block set and the second data block set are obtained by further segmenting at least two data blocks;
[0051] S34, generating a first message scheduling array and a second message scheduling array according to the first data block set and the second data block set;
[0052] S35, iteratively processing the first message scheduling array and the second message scheduling array respectively to obtain a first processing result set and a second processing result set;
[0053] S36: Merge the first processing results to generate a first Hash value, and merge the second processing result set to generate a second Hash value.
[0054] The beneficial effect of the above further scheme is that for the traded data, the automated smart contract and arbitration mechanism not only simplifies the transaction process, but also improves real-time performance and efficiency, reduces manual intervention, and allows users to only follow preset steps, so that both contractors and buyers can easily participate in data transactions.
[0055] Furthermore, in step S33, further segmenting the at least two data blocks to obtain a first data block set and a second data block set specifically includes:
[0056] S331, further split each of the at least two data blocks according to the length 32 to obtain the split result of each data block;
[0057] S332. Store the segmentation results of each data block in arrays with indexes from 0 to 15 in sequence, and obtain a first data block set and a second data block set respectively.
[0058] Further, step S34 specifically includes:
[0059] According to the first data block set and the second data block set, and in accordance with a preset message scheduling array calculation formula, respectively obtain a first message scheduling array and a second message scheduling array;
[0060] The preset message scheduling array calculation formula is:
[0061]
[0062] w[i]=w[i-16]+s0+w[i-7]+s1
[0063] Wherein, w[i] represents the message scheduling array, s0 represents the result of transforming the element w[i-15] in the message scheduling array, and s1 represents the result of transforming the element w[i-2] in the message scheduling array. Represents the exclusive OR operation.
[0064] Further, step S35 specifically includes:
[0065] S351, setting the initial hash value and state variables;
[0066] S352, iteratively updating the initial hash values of the first message scheduling array and the second message scheduling array respectively according to the state variable and the preset iteration formula to obtain updated hash values;
[0067] The preset iteration formula is:
[0068]
[0069] t2=s0+maj
[0070] t1=h+s1+ch+k[i]+w[i]
[0071] Wherein, a, b, c, d, e, f, g, h represent preset working variables respectively, and a=h0, b=h1, c=h2, d=h3, e=h4, f=h5, g=h6, h=h7, h0, h1, h2, h3, h4, h5, h6, h7 are the set initial hash values respectively, s'0 and s1' represent the transformation results of variables a and e respectively, maj represents the majority logic of variables a, b, c, ch represents the selection logic of variables e, f, g, t1 and t2 represent intermediate variables, k[i] represents a constant array, and w[i] represents a message scheduling array;
[0072] S353: Merge the updated hash values according to a preset merging calculation formula to obtain a first processing result set and a second processing result set respectively;
[0073] The default merge calculation formula is:
[0074] digest=h0||h1||h2||h3||h4||h5||h6||h7
[0075] Among them, h0, h1, h2, h3, h4, h5, h6, and h7 represent the updated hash values respectively, and digest represents the final hash value.
[0076] Furthermore, the fused hash value is obtained by fusing the first hash value and the second hash value according to a preset fusion formula, and the fusion formula is:
[0077] Tag(D)=Hash(D1)⊕Hash(D2)
[0078] Among them, Tag(D) represents the fused hash value, Hash(D1) represents the first hash value, and Hash(D2) represents the second hash value.
[0079] The beneficial effect of the above further scheme is that through the predefined automatic arbitration algorithm, it is possible to prevent malicious persons from defrauding funds to a certain extent, thereby ensuring the fairness and security of transactions. BRIEF DESCRIPTION OF THE DRAWINGS
[0080] Figure 1 A flowchart of a two-stage outsourcing service transaction method based on data encryption and blockchain. DETAILED DESCRIPTION
[0081] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments.
[0082] Example 1
[0083] like Figure 1 As shown, a two-stage outsourcing service transaction method based on data encryption and blockchain is applied to the contractor, including the following steps:
[0084] S1. Obtain service data from the blockchain, and divide the service data into a first data fragment and a second data fragment;
[0085] The data size of the first data segment is larger than that of the second data segment, and the first data segment includes a main part of the service data, and the second data segment includes decryption information.
[0086] For example, the receiver generates two parts from the requested data D: a larger data fragment D1 and a relatively smaller data fragment D2. D1 usually represents the main part of the data, and in order to ensure the security of the data, this part will be encrypted before transmission. Correspondingly, D2 contains the corresponding decryption information, that is, the decryption key, which enables the sender to further use D2 to decrypt the data after receiving D1 to obtain the original and usable data content.
[0087] S2. Send the first data fragment to the contractor. The first data fragment is sent to the contractor in two ways: on-chain and off-chain.
[0088] In this embodiment, the first data segment is an encrypted first data segment; step S2 specifically includes:
[0089] S21. Determine the public key and private key required for the RSA homomorphic encryption algorithm;
[0090] S22. Encrypt the first data segment using the public key to obtain an encrypted first data segment;
[0091] S23: Send the encrypted first data segment to the packet sender.
[0092] In this embodiment, step S21 specifically includes:
[0093] S211, randomly select two large prime numbers;
[0094] S212, determining a modulus according to two large prime numbers;
[0095] S213, calculating the Euler function according to two large prime numbers and the modulus;
[0096] S214, randomly selecting an integer so that the integer satisfies a preset relationship related to the Euler function;
[0097] S215. Determine the public key and the private key according to an integer and the Euler's totient function.
[0098] Exemplarily, in step S211, two large prime numbers p and q can be randomly selected, calculate n = pq, where n will be used as the modulus of the public key and the private key, calculate the Euler's totient function φ(n) = (p - 1)(q - 1), randomly select an integer e such that 1 < e < φ(n) and e is relatively prime to φ(n), calculate d such that d·e ≡ 1 (mod φ(n)), and finally the public key is (n, e) and the private key is (n, d).
[0099] Optionally, in step S22, use the public key to encrypt the first data segment to obtain the encrypted first data segment. If the data is greater than the modulus n, it needs to be decomposed into a set of integers less than n. For each plaintext block m less than n i , calculate its corresponding ciphertext block c i , and the calculation formula is:
[0100] c i ≡ m i e (mod n)
[0101] where m i is the plaintext block to be encrypted, e is the public key exponent, and n is the modulus.
[0102] S3. Calculate the first hash value of the first data segment and the second hash value of the second data segment respectively, and publish the combined hash value and the first hash value on the blockchain according to the first hash value and the second hash value.
[0103] In this embodiment, the calculation process of calculating the first hash value of the first data segment and the second hash value of the second data segment in step S3 specifically includes:
[0104] S31. Convert the first data segment and the second data segment into byte sequences encoded in UTF-8 respectively to obtain the first byte sequence and the second byte sequence;
[0105] S32. Preprocess the first byte sequence and the second byte sequence respectively, and add specific padding bits to obtain the first padding sequence and the second padding sequence;
[0106] The lengths of the first padding sequence and the second padding sequence are integer multiples of 512;
[0107] The padding bits include 0x80, 0x00, and 0;
[0108] S33. Divide the first padding sequence and the second padding sequence into at least two data blocks for processing respectively to obtain the first data block set and the second data block set;
[0109] The length of each of at least two data blocks is 512;
[0110] The first data block set and the second data block set are obtained by further segmenting at least two data blocks;
[0111] S34, generating a first message scheduling array and a second message scheduling array according to the first data block set and the second data block set;
[0112] S35, iteratively processing the first message scheduling array and the second message scheduling array respectively to obtain a first processing result set and a second processing result set;
[0113] S36: Merge the first processing results to generate a first Hash value, and merge the second processing result set to generate a second Hash value.
[0114] Exemplarily, in step S3, data hash processing may be performed in the following manner: converting the data into a UTF-8 encoded byte sequence; preprocessing the data and adding specific padding bits to ensure that the data meets the input requirements of the algorithm; dividing the data into multiple blocks for processing; generating a message scheduling array; iteratively processing each data block; and merging the processing results of all blocks to form a final hash value.
[0115] Optionally, in step S32, according to the requirements of the SHA-256 algorithm, the number of padding bits to be added is calculated, requiring that the data length plus the padding bits is a multiple of 512 bits; according to the calculation result, the corresponding padding bits are added to the end of the data. Use 0x80 as the first padding bit, followed by a series of 0x00 until the length requirement is met; after the padding bit, append the 64-bit representation of the original data length, and add 0 in front if it is less than 64 bits; add the length of the original message to the end of the message in the form of a 64-bit big-endian integer value.
[0116] In this embodiment, in step S33, further segmenting the at least two data blocks to obtain a first data block set and a second data block set specifically includes:
[0117] S331, further split each of the at least two data blocks according to the length 32 to obtain the split result of each data block;
[0118] S332. Store the segmentation results of each data block in arrays with indexes from 0 to 15 in sequence, and obtain a first data block set and a second data block set respectively.
[0119] In this embodiment, step S34 specifically includes:
[0120] According to the first data block set and the second data block set, and in accordance with a preset message scheduling array calculation formula, respectively obtain a first message scheduling array and a second message scheduling array;
[0121] The preset message scheduling array calculation formula is:
[0122]
[0123] w[i]=w[i-16]+s0+w[i-7]+s1
[0124] Wherein, w[i] represents the message scheduling array, s0 represents the result of transforming the element w[i-15] in the message scheduling array, and s1 represents the result of transforming the element w[i-2] in the message scheduling array. Represents the exclusive OR operation.
[0125] Optionally, in step S33, the pre-processed message is divided into 512-bit segments; each 512-bit data block is further divided into 16 32-bit arrays; these arrays are usually represented as integers in memory and are numbered according to the order in which they appear in the data block. Each 32-bit array is read as a big-endian integer. These 32-bit integers are stored in an array w, and the array indexes are from 0 to 15, and each index corresponds to a 32-bit array.
[0126] Optionally, in step S35, the following logic is executed and iterated for each data block: given the existing w[0] to w
[15] , the algorithm calculates the next w
[16] to w
[63] . For i from 16 to 63, the calculation formula is the same as the preset message scheduling array calculation formula.
[0127] In this embodiment, step S35 specifically includes:
[0128] S351, setting the initial hash value and state variables;
[0129] S352, iteratively updating the initial hash values of the first message scheduling array and the second message scheduling array respectively according to the state variable and the preset iteration formula to obtain updated hash values;
[0130] The preset iteration formula is:
[0131]
[0132]
[0133] t2=s0+maj
[0134] t1=h+s1+ch+k[i]+w[i]
[0135] Wherein, a, b, c, d, e, f, g, h represent preset working variables respectively, and a=h0, b=h1, c=h2, d=h3, e=h4, f=h5, g=h6, h=h7, h0, h1, h2, h3, h4, h5, h6, h7 are the set initial hash values respectively, s'0 and s1' represent the transformation results of variables a and e respectively, maj represents the majority logic of variables a, b, c, ch represents the selection logic of variables e, f, g, t1 and t2 represent intermediate variables, k[i] represents a constant array, and w[i] represents a message scheduling array;
[0136] S353: Merge the updated hash values according to a preset merging calculation formula to obtain a first processing result set and a second processing result set respectively;
[0137] The default merge calculation formula is:
[0138] digest=h0||h1||h2||h3||h4||h5||h6||h7
[0139] Among them, h0, h1, h2, h3, h4, h5, h6, and h7 represent the updated hash values respectively, and digest represents the final hash value.
[0140] For example, in step S35, the following may be done: first, set the initial hash value and state variables, let a to h be working variables, assign h0 to h7 to a to h, where h0 to h7 are 8 initial hash values. Then, iterate 64 times, and in each iteration, execute the following logic:
[0141] Calculate s'0 and s1', which are the transformation results of variables a and e, and the calculation formula is as follows:
[0142]
[0143] Compute the majority logic of variables a, b, and c:
[0144]
[0145] Calculate the selection logic of variables e, f and g:
[0146]
[0147] t1, t2 intermediate variables, the calculation formula is:
[0148] t2=s0+maj
[0149] t1=h+s1+ch+k[i]+w[i]
[0150] Among them, k[i] is a constant array in the algorithm, and w[i] is an element in the message scheduling array;
[0151] Next, the algorithm updates the values of variables a through h.
[0152] In this embodiment, the fused hash value is obtained by fusing the first hash value and the second hash value according to a preset fusion formula, and the fusion formula is:
[0153]
[0154] Among them, Tag(D) represents the fused hash value, Hash(D1) represents the first hash value, and Hash(D2) represents the second hash value.
[0155] S4. Deposit the contractor's deposit into the smart contract within the preset first time period.
[0156] For example, if the contractor confirms that the data is correct, the smart contract transfers the purchase funds of the buyer to the owner and releases the deposits of both parties.
[0157] In this embodiment, for the traded data, the automated smart contract and arbitration mechanism not only simplifies the transaction process, but also improves real-time performance and efficiency. Completing a data auction involves secure segmentation and encryption of data, locking of buyers' funds, on-chain publication of data hash values, deposit of deposit by the receiver, confirmation of data receipt by the buyer, and automatic fund release and arbitration mechanism based on smart contracts. The automated smart contract simplifies the transaction process and reduces manual intervention, so that users only need to follow preset steps, allowing both receivers and buyers to easily participate in data transactions.
[0158] S5. Receive transaction information. When the transaction information is confirmation information from a smart contract, send the second data fragment to the blockchain within a preset second time period. When the transaction information is off-chain arbitration information from an arbitrator, execute step S6. The confirmation information is used to determine whether the data received by the contractor matches the first data fragment.
[0159] Optionally, if the sender confirms that the data is correct, the smart contract transfers the buyer’s funds to the owner and releases the deposits of both parties.
[0160] Exemplarily, the way in which the sender confirms that the data has been verified by decrypting the data is as follows:
[0161] For each ciphertext block c less than n i , calculate its corresponding plaintext block m i , the calculation formula is:
[0162] m i ≡c id (mod n)
[0163] Among them, c i is the encrypted ciphertext block, d is the private key exponent, and n is the modulus.
[0164] S6. Send the service data to the arbitrator. The service data may be sent to the arbitrator on-chain or off-chain.
[0165] A two-stage outsourcing service transaction method based on data encryption and blockchain, applied to the contractor, includes the following steps:
[0166] S1a, deposit the contractor's deposit and purchase funds into the smart contract;
[0167] S1b, receiving a first data fragment from a packet receiver;
[0168] The first data fragment is sent by the receiver, and the sending method includes on-chain and off-chain;
[0169] The first data segment is obtained by obtaining service data from the blockchain by the recipient and dividing the service data into the first data segment and the second data segment;
[0170] The data size of the first data segment is larger than that of the second data segment, and the first data segment includes a main part of the service data, and the second data segment includes decryption information;
[0171] S1c, calculating a third hash value of the first data segment;
[0172] S1d, comparing the third hash value with the first hash value, where the first hash value is calculated by the sender based on the first data fragment and published on the blockchain;
[0173] When the third hash value is the same as the first hash value, a confirmation message is sent to the smart contract, and step S1e is executed; when the third hash value is different from the first hash value, off-chain arbitration is initiated;
[0174] S1e, obtaining a second data segment from the packet receiver, calculating a fourth hash value of the second data segment, and determining a fifth hash value according to the third hash value and the fourth hash value;
[0175] The second data segment is sent by the recipient to the blockchain within a preset second time period;
[0176] S1f, comparing the fifth hash value and the fused hash value, when the fifth hash value and the fused hash value are different, executing step S1g; when the fifth hash value and the fused hash value are the same, sending transaction instruction information to the smart contract;
[0177] The transaction instruction information is used to instruct the smart contract to release the deposits of both parties to the transaction and deliver the purchase funds to the recipient;
[0178] S1g. Use a preset algorithm to automatically arbitrate disputes, re-compare the fifth hash value and the fused hash value, and determine the malicious party, and execute different punishment measures according to different malicious parties.
[0179] In this embodiment, in step S1g, the preset algorithm is:
[0180] Hash(D1)⊕Hash(D2)=Tag * (D)
[0181] If Tag′(D)=Tag * (D)return submitter is invalid
[0182] else worker is invalid
[0183] Among them, Hash(D1) represents the third hash value, Hash(D2) represents the fourth hash value, and Tag * (D) represents five hash values, and Tag′(D) represents the hash value obtained based on the fused hash value.
[0184] The preset algorithm can be explained as follows: when the fifth hash value and the hash value obtained according to the fused hash value are the same, the malicious party is determined to be the sender; when the fifth hash value and the hash value obtained according to the fused hash value are different, the malicious party is determined to be the receiver.
[0185] In this embodiment, for malicious parties in some transactions, the recipient may tamper with the data content to increase the value of the data or hide the real problem of the data. The sender may refuse to pay or try to withdraw the confirmed payment after receiving the data. Therefore, through the predefined automatic arbitration algorithm, malicious parties can be prevented from defrauding funds to a certain extent, ensuring the fairness and security of transactions.
[0186] In this embodiment, the automatic arbitration algorithm is based on the immutable nature of blockchain, ensuring the fairness and transparency of the arbitration process. All terms and conditions of data transactions are integrated into the smart contract, including data delivery, fund payment, deposit management, and dispute resolution. In this way, the present invention eliminates the reliance on trusted third-party intermediaries, reduces transaction costs, improves transaction efficiency, and protects the rights and interests of both parties to the transaction through the automatic execution of smart contracts.
[0187] Example 2
[0188] A two-stage outsourcing service transaction system based on data encryption and blockchain, including the following modules:
[0189] An acquisition module, used to acquire service data from the blockchain, and divide the service data into a first data segment and a second data segment; the data size of the first data segment is larger than that of the second data segment, and the first data segment includes the main part of the service data, and the second data segment includes decryption information;
[0190] A sending module, used for sending the first data fragment to the contractor, wherein the first data fragment is sent to the contractor in a manner including on-chain and off-chain;
[0191] a calculation module, configured to calculate a first hash value and a second hash value of the first data fragment and the second data fragment, respectively, and publish a fused hash value and the first hash value on a blockchain according to the first hash value and the second hash value;
[0192] A storage module, used to deposit the deposit of the contractor into the smart contract within a preset first time period;
[0193] A transaction module, configured to receive transaction information; when the transaction information is confirmation information from a smart contract, the second data segment is sent to the blockchain within a preset second time period; when the transaction information is off-chain arbitration information from an arbitrator, step S6 is executed; the confirmation information is used to determine whether the data received by the sender matches the first data segment;
[0194] The ownership confirmation module is used to verify the ownership and originality of the data and ensure the legitimate control of the data by the contractor;
[0195] Verification module, used to detect and prevent data abuse or duplicate sales during data transactions;
[0196] The smart contract module is used to automatically compare the quotations of the contractors according to the preset conditions, and execute the delivery of data and the transfer of funds when the transaction conditions are met.
[0197] This embodiment focuses on the data ownership mechanism and efficient data transaction method based on blockchain, using advanced data fingerprint technology and non-repudiation protocol to authenticate data, ensure the originality and integrity of data, and effectively prevent data plagiarism and abuse.
[0198] Those skilled in the art will appreciate that the embodiments described herein are intended to help readers understand the principles of the present invention, and should be understood that the protection scope of the present invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific variations and combinations that do not deviate from the essence of the present invention based on the technical revelations disclosed by the present invention, and these variations and combinations are still within the protection scope of the invention.
Claims
1. A two-stage outsourcing service transaction method based on data encryption and blockchain, characterized in that: Applied to the package receiver, the method includes: S1. Obtain service data from the blockchain, and divide the service data into a first data fragment and a second data fragment; The data size of the first data segment is larger than that of the second data segment, and the first data segment includes the main part of the service data, and the second data segment includes decryption information; S2. Sending the first data fragment to the contractor, wherein the method of sending the first data fragment to the contractor includes on-chain and off-chain; S3. Calculate the first hash value and the second hash value of the first data fragment and the second data fragment respectively, and publish the fused hash value and the first hash value on the blockchain according to the first hash value and the second hash value; S4. Deposit the contract recipient's deposit into the smart contract within the preset first time period; S5, receiving transaction information; when the transaction information is confirmation information from the smart contract, sending the second data fragment to the blockchain within a preset second time period; when the transaction information is off-chain arbitration information of the arbitrator, executing step S6; The confirmation information is used to determine whether the data received by the sender matches the first data fragment; S6. Send the service data to the arbitrator. The method of sending the service data to the arbitrator includes on-chain and off-chain.
2. The method according to claim 1, characterized in that The first data segment is an encrypted first data segment; The step S2 specifically includes: S21. Determine the public key and private key required for the RSA homomorphic encryption algorithm; S22. Encrypt the first data segment using a public key to obtain an encrypted first data segment; S23: Send the encrypted first data fragment to the packet sender.
3. The method according to claim 2, characterized in that The step S21 specifically includes: S211, randomly select two large prime numbers; S212, determining a modulus according to the two large prime numbers; S213, calculating the Euler function according to the two large prime numbers and the modulus; S214, randomly selecting an integer so that the integer satisfies a preset relationship related to the Euler function; S215. Determine a public key and a private key according to the integer and the Euler function.
4. The method according to claim 1, characterized in that: The process of respectively calculating the first hash value and the second hash value of the first data fragment and the second data fragment in step S3 specifically includes: S31. Convert the first data segment and the second data segment into UTF-8 encoded byte sequences respectively to obtain a first byte sequence and a second byte sequence; S32, preprocessing the first byte sequence and the second byte sequence respectively, adding specific padding bits, to obtain a first padding sequence and a second padding sequence; The lengths of the first filling sequence and the second filling sequence are integer multiples of 512; The padding bits include 0x80, 0x00 and 0; S33, dividing the first filling sequence and the second filling sequence into at least two data blocks for processing respectively, to obtain a first data block set and a second data block set; The length of each of the at least two data blocks is 512; The first data block set and the second data block set are obtained by further segmenting the at least two data blocks; S34. Generate a first message scheduling array and a second message scheduling array according to the first data block set and the second data block set; S35, iteratively processing the first message scheduling array and the second message scheduling array respectively to obtain a first processing result set and a second processing result set; S36: Merge the first processing results to generate the first Hash value, and merge the second processing result sets to generate the second Hash value.
5. The method according to claim 4, characterized in that The step S33 further divides the at least two data blocks to obtain the first data block set and the second data block set, specifically including: S331, further dividing each of the at least two data blocks according to a length of 32 to obtain a division result of each data block; S332. Store the segmentation results of each data block in arrays with indexes from 0 to 15 in sequence, and obtain the first data block set and the second data block set respectively.
6. The method according to claim 5, characterized in that The step S34 specifically includes: According to the first data block set and the second data block set, and in accordance with a preset message scheduling array calculation formula, respectively obtain the first message scheduling array and the second message scheduling array; The preset message scheduling array calculation formula is: s0=(w[i-15])>>>>7⊕(w[i-15])>>>>18⊕(w[i-15])>>>>3 s1=(w[i-2])>>>>17⊕(w[i-2])>>>>19⊕(w[i-2])>>>>10 w[i]=w[i-16]+s0+w[i-7]+s1 Among them, w[i] represents the message scheduling array, s0 represents the result of transforming the element w[i-15] in the message scheduling array, s1 represents the result of transforming the element w[i-2] in the message scheduling array, and ⊕ represents an exclusive OR operation.
7. The method according to claim 6, characterized in that The step S35 specifically includes: S351, setting the initial hash value and state variables; S352: Iteratively update the initial hash values of the first message scheduling array and the second message scheduling array respectively according to the state variable and a preset iteration formula to obtain updated hash values; The preset iteration formula is: s'0=(a>>>>2)⊕(a>>>>13)⊕(a>>>>22) s′1=(e>>>>6)⊕(e>>>>11)⊕(e>>>>25) maj=(a∧b)⊕(a∧c)⊕(b∧c) t2=s0+maj t1=h+s1+ch+k[i]+w[i] Wherein, a, b, c, d, e, f, g, h represent preset working variables respectively, and a=h0, b=h1, c=h2, d=h3, e=h4, f=h5, g=h6, h=h7, h0, h1, h2, h3, h4, h5, h6, h7 are the set initial hash values respectively, s'0 and s'1 represent the transformation results of variables a and e respectively, maj represents the majority logic of variables a, b, c, ch represents the selection logic of variables e, f, g, t1 and t2 represent intermediate variables, k[i] represents a constant array, and w[i] represents a message scheduling array; S353: Merge the updated hash values according to a preset merging calculation formula to obtain a first processing result set and a second processing result set respectively; The preset merging calculation formula is: digest=h0||h1||h2||h3||h4||h5||h6||h7 Among them, h0, h1, h2, h3, h4, h5, h6, and h7 represent the updated hash values respectively, and digest represents the final hash value.
8. The method according to claim 1, characterized in that The fused hash value is obtained by fusing the first hash value and the second hash value according to a preset fusion formula, and the fusion formula is: Tag(D)=Hash(D1)⊕Hash(D2) Among them, Tag(D) represents the fused hash value, Hash(D1) represents the first hash value, and Hash(D2) represents the second hash value.
9. A two-stage outsourcing service transaction method based on data encryption and blockchain, characterized in that: Applied to the contractor, the method comprises: S1a, deposit the contractor's deposit and purchase funds into the smart contract; S1b, receiving a first data fragment from a packet receiver; The first data fragment is sent by the receiver, and the sending method includes on-chain and off-chain; The first data segment is obtained by obtaining service data from the blockchain by the recipient and dividing the service data into a first data segment and a second data segment; The data size of the first data segment is larger than that of the second data segment, and the first data segment includes the main body of the service data, and the second data segment includes decryption information; S1c, calculating a third hash value of the first data segment; S1d. Compare the third hash value with the first hash value, where the first hash value is calculated by the sender based on the first data fragment and published on the blockchain; When the third hash value is the same as the first hash value, a confirmation message is sent to the smart contract, and step S1e is executed; when the third hash value is different from the first hash value, off-chain arbitration is initiated; S1e, obtaining a second data segment from the packet receiver, calculating a fourth hash value of the second data segment, and determining a fifth hash value according to the third hash value and the fourth hash value; The second data fragment is sent by the recipient to the blockchain within a preset second time period; S1f, comparing the fifth hash value and the fused hash value, and when the fifth hash value and the fused hash value are different, executing step S1g; when the fifth hash value and the fused hash value are the same, sending transaction instruction information to the smart contract; The transaction instruction information is used to instruct the smart contract to release the deposits of both parties to the transaction and deliver the purchase funds to the recipient; S1g. Use a preset algorithm to automatically arbitrate disputes, re-compare the fifth hash value and the fused hash value, determine the malicious party, and execute different punishment measures according to different malicious parties.
Citation Information
Patent Citations
Fair data transaction method and device based on block chain smart contract
CN112801785A
Data transaction method and system for copyright protection and image encryption based on block chain
CN117610031A