Private electricity transaction matching method based on block chain
By using homomorphic encryption algorithms and smart contracts to encrypt and match power transaction values in smart grids, the problems of single point failure and privacy leakage in the power trading process in smart grids are solved, and efficient and safe power transaction matching is achieved.
Patent Information
- Application Number
- CN202410667221.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-28
- Publication Date
- 2024-09-10
AI Technical Summary
In smart grids, there is a single point of failure problem in the traditional power transaction matching process, and due to the openness and transparency of the blockchain, the leakage of users' power transaction data may destroy user privacy and affect their business strategies.
Adopting a blockchain-based private power transaction matching method, the user's transaction power value is encrypted through a homomorphic encryption algorithm, and smart contracts are used to match the ciphertext to ensure that the power value is not leaked during the transaction process and avoid single point failure problems. .
In the smart grid, user privacy is protected and efficient power transaction matching is achieved, avoiding the single point failure problem in traditional smart grids and ensuring the security and privacy of transactions.
Smart Images

Figure BDA0004861498370000042 
Figure FDA0004861498360000058 
Figure FDA0004861498360000041
Abstract
Description
Technical Field
[0001] The present invention relates to blockchain technology, and in particular to a privacy-preserving electricity transaction matching method based on blockchain. Background Art
[0002] The power system is a network that connects power generation companies and power users, and is used to generate, transmit, distribute and use electricity. In traditional power systems, electricity can only be transmitted from centralized power generation companies to power users in one direction, which causes great power losses during the transmission process. The emergence of smart grids has effectively solved this problem. In smart grids, each user is equipped with power generation equipment such as solar panels or wind turbines, which can generate electricity autonomously. At the same time, smart grids allow two-way power transmission between power users, allowing neighboring power users to trade electricity in a point-to-point manner. This avoids power losses caused by long-distance transmission in the power system.
[0003] However, the power transmission and transaction information in the traditional smart grid is still managed by a centralized organization, which leads to a single point of failure problem. Once the smart grid management organization is breached by the adversary, the power transaction will be completely controlled by the adversary. The use of blockchain technology can effectively improve the robustness of the smart grid. As a distributed public ledger, the blockchain is jointly maintained by all network nodes connected to the blockchain, and no node can tamper with or delete the data recorded on the blockchain. This enables the blockchain-based smart grid to safely complete power transactions in a decentralized network environment, avoiding the single point of failure problem in the traditional smart grid. At the same time, it is noted that transaction matching is an important function of the smart grid, which is used to find two users with opposite transaction intentions (selling and buying) in the same time period. Transaction matching ensures the effective use of electricity and reduces delays in the smart grid. During the transaction matching process, users need to publish the power values they want to buy or sell in order to find matching users. However, the open and transparent nature of the blockchain makes the data involved in the transaction matching process visible to all users, which inevitably destroys the privacy of power users. The leakage of data during the matching process may cause losses to power users. For example, if an increase in the amount of electricity sold by a factory means a decrease in production, its competitors can use this information to infer the factory's future business strategy, thereby harming its interests. Summary of the invention
[0004] The problem to be solved by the present invention is how to achieve efficient power transaction matching while ensuring user privacy in a smart grid and avoid the single point failure problem in a traditional smart grid.
[0005] The solution adopted by the present invention to solve the above technical problems is a privacy power transaction matching method based on blockchain, comprising the following steps:
[0006] 1) Initialization steps:
[0007] The system determines public parameters based on security parameters and divides power trading periods;
[0008] 2) Registration steps:
[0009] Each user selects a random number and uses the random number to generate a commitment for the power value that he or she wishes to trade in each time period; each power value is represented by 0 bits and 1 bits, and each bit is split into a first power value component and a second power value component; then a random number is selected for each power value component and the random number is used to generate a commitment for the power value component;
[0010] The user generates a temporary random number and sends the first matching information to the smart contract. The first matching information includes the transaction requirements corresponding to each transaction time period, the power value commitment related data, the correctness proof of the first matching information and the temporary random number; the power value commitment related data includes the power value commitment, the power value first component commitment, the power value second component commitment, the power value second component and the random number used to generate the power value second component commitment;
[0011] Smart contracts verify the legitimacy of matching information and save it;
[0012] 3) Matching steps:
[0013] The user retrieves the first matching information of other users from the smart contract, and uses the temporary random number of other users to calculate the shared secret value with other users;
[0014] The user generates his own second matching information and other users' second matching information according to his own first matching information and other users' first matching information respectively; the second matching information includes power value commitment, power value first component commitment, power value second component commitment, power value second component and random number used to generate power value second component commitment; the user matches his own second matching information with other users' second matching information in turn; during the matching process, the user first generates power value matching intermediate parameters, power value commitment matching intermediate parameters and commitment random number matching intermediate parameters; then the user generates a matching random permutation and a set of matching random numbers according to the shared secret value with other users; finally, the user uses matching random permutation and matching random numbers to blind power value matching auxiliary parameters, power value commitment matching auxiliary parameters and commitment random number matching auxiliary parameters to obtain user-side matching results; the user-side matching results include power value first matching result, power value second matching result, power value commitment first matching result, power value commitment second matching result, commitment random number first matching result and commitment random number second matching result; the user sends the user-side matching results to the smart contract;
[0015] 4) Execution steps:
[0016] After receiving the matching results from all users, the smart contract calculates the final matching results and makes them public;
[0017] According to the final matching result, the user with the smaller power value in each pair of matched users secretly sends its power value to the other party;
[0018] The party with the larger power value verifies whether the received power value is correct based on the power value commitment of the other party. If the verification is correct, the transaction is completed.
[0019] The party with the larger power value verifies whether the received power value is correct based on the power value commitment of the other party. This ensures that the two matching parties can trade according to the demand of the user with the smaller power value, while not leaking the power demand of the party with the larger power value.
[0020] The present invention uses random numbers to generate a commitment to the power value that the user wishes to trade in each time period, that is, a homomorphic encryption algorithm is used to encrypt the user's transaction power value, and the power value ciphertext is matched using the smart contract in the blockchain. The homomorphic nature of the ciphertext enables the smart contract to match the user's transaction needs without obtaining the power value. The embodiment further provides a specific matching process, which only involves linear operations and is suitable for scenarios such as blockchain where the computational cost is high.
[0021] The beneficial effects of the present invention are that efficient power transaction matching is achieved while ensuring user privacy in the smart grid, and single point failure problems in traditional smart grids are avoided. DETAILED DESCRIPTION
[0022] In order to achieve efficient power transaction matching while ensuring user privacy in smart grids and avoid single point failure problems in traditional smart grids, the present invention designs a privacy power transaction matching method based on blockchain. The user first encrypts the power value that he wants to trade in each time period, and then sends the power value ciphertext and the matching request to the smart contract. The present invention adopts a homomorphic encryption algorithm, so that the smart contract can match users based on the power value ciphertext. After the matching is completed, the one with the smaller power value of the two successfully matched users reveals its power value to the other party, while the power value of the other party is kept confidential. At the same time, the user can verify whether the power value sent by the other user is consistent with the value used for matching. If it is inconsistent, the user can report to the smart contract.
[0023] 1) The specific steps of the initialization phase are:
[0024] 1-1) The system determines the public parameters based on the security parameters λ Where p is a large prime number, is the ring of residue classes of integers modulo p, is a multiplicative group of order p, and g is The generator of , m is the number of users participating in the power trading matchmaking, Com is the homomorphic commitment algorithm, BitPro is the zero-knowledge proof algorithm that proves that the commitment value is 0 / 1 bits, BitVrfy is the verification algorithm of BitPro, EqPro is the zero-knowledge proof algorithm that proves that two commitment values are equal, and EqVrfy is the verification algorithm of EqPro;
[0025] 1-2) The system divides each day into 24 time periods, each of which is 1 hour. Users can choose to sell or buy electricity in each time period.
[0026] 2) The specific steps of the registration phase are:
[0027] 2-1) Each user U i , i∈(1,m), build a matching request list OL i ={dir i,l , vol i,l} l∈(0,23) , where transaction requirements dir i,l ∈{+,-} indicates that user U i In time period l, do you want to buy electricity + or sell electricity -? i,l Is user U iThe amount of electricity you want to sell or buy in time period l, time period variable l∈(0,23);
[0028] 2-2) Each user U i First randomly select a set of random numbers r i,l , and then use the random number r i,l Calculate the commitment cv of the amount of electricity it wishes to sell or buy i,l =Com(vol i,l ; r i,l ); 2-3) For l∈(0,23), each user U i The power value is decomposed into bits. Each value bit v i,l,j ∈{0, 1}, n is the number of bits in the binary representation of the power value, and j is the number of bits variable;
[0029] 2-4) For l∈(0, 23) and j∈(0, n-1), user U i Split each bit into 0 and 1, v i,l,j =v i,l,j,0 +v i,l,j,1 , where v i,l,j,0 is the first component of the power value and v i,l,j,1 is the second component of the power value,
[0030] 2-5) For l∈(0,23), j∈(0,n-1) and k∈(0,1), user U i Select random number Generate commitment cv for each power value bit component i,l,j,k =Com(v i,l,j,k ; r i,l,j,k ), k is a numerical bit component variable;
[0031] 2-6) User U i Generate two zero-knowledge proofs qPro and BitPro, and π i,l,j =BitPro(cv i,l,j,0 ·cv i,l,j,1 );
[0032] 2-7) User U i Select random number Calculate temporary random number 2-8) User U i Send the first matching information minf i =(g i ,dir i,l , cv i,l , cvi,l,j,0 , cv i,l,j,1 , v i,l,j,1 , r i,l,j,1 , π i,l , π i,l,j ) to the smart contract SC, where l∈(0, 23), j∈(0, n-1); dir i,l For trading needs; power value commitment related data includes power value commitment cv i,l , Commitment Cv of the first component of power value i,l,j,0 、Commitment cv of the second component of power value i,l,j,1 , the second component of power value v i,l,j,1 and a random number r for generating the second component of the power value i,l,j,1 ; π i,l , π i,l,j are two zero-knowledge proofs, g i is a temporary random number;
[0033] 2-9) Smart contract SC uses BitVrfy and EqVrfy algorithms to verify the first matching information minf i Zero-knowledge proof π in i,l , π i,l,j If the verification is successful, the user's matchmaking request is accepted, otherwise the user is rejected.
[0034] The specific steps of the matching phase are:
[0035] 3-1) For the i-th user U i , i∈(1,m), retrieve the first matching information of other users from the smart contract where i * ∈(1,m) and i * ≠i;
[0036] 3-2) For the matching request list OL i ={dir i,l , vol i,l} l∈(0,23) Each tuple in dir i,l , vol i,l ), user U i Constructing a match list Satisfy i * ∈(1,m),i * ≠i, First matching information The transaction requirements contained in
[0037] 3-3) For i * ∈(1,m) and i * ≠i, user Ui Using random numbers i And temporary random numbers of other users To calculate the shared secret value
[0038] 3-4) For l∈(0,23), user U i Generate a local second matching information (cv i,l , cv i,l,j,0 , cv i,l,j,1 , v i,l,j,0 , r i,i,j,o ) and the matching list ML i The power value commitment related data in the matching information of each other user The second matching information includes the same power value commitment data as the power value commitment related data in the first matching information. i,l 、Commitment cv of the first component of power value i,l,j,0 and the power value of the second component of the commitment cv i,l,j,1 , and the first power value component v different from the power value commitment related data in the first matching information i,l,j,0 and generating a random number r for the first component of the power value i,l,j,o ;
[0039] 3) The specific matching process is as follows:
[0040] 3-4-1) User U i Set the middle value Intermediate Commitment Value
[0041] 3--4-2) For l∈(0, 23), j∈(1, n-1), the user iteratively calculates the intermediate parameters as follows:
[0042]
[0043]
[0044]
[0045]
[0046]
[0047]
[0048] 3-4-3) User U i Using a shared secret value Generate a random permutation The intermediate parameters Rearrange the bits to
[0049] 3-4-8) For j∈(1,n), the user uses the shared secret value Generate random numbers
[0050] 3-4-9) User U i Use random numbers for intermediate parameters after bit rearrangement Blindly obtain each matching item in the user-side matching result.
[0051] 3-5) User U i Match the results of the user end Sent to the smart contract SC, where i * ∈(1,m) and i * ≠i,j∈(1,n),l∈(0,23).
[0052] 4) The specific steps of the execution phase are:
[0053] 4-1) Receive user U i User-side matching results and users User-side matching results The smart contract performs the following calculations to obtain the contract-side matching results
[0054]
[0055]
[0056]
[0057] 4-2) Smart contract SC matches the items in the contract end matching results and To calculate the verification commitment value com i,l,j and Each item in the contract-side matching result is the linear sum of each item in the user-side matching result, that is, the user-side matching result is the result of matching based on the first component of the power value and the second component of the power value, while the contract-side matching result is the matching result based on the complete power value. This allows the user to complete the power value matching in a distributed manner without knowing the complete power value, and finally complete the summary of the matching results on the contract side.
[0058]
[0059] 4-3) Determine and verify the commitment value com i,l,j and whether as well as If yes, go to step 4-4), otherwise, the smart contract SC terminates and requires the user U i and users Provide correct user-side matching results;
[0060] 4-4) For l∈(0, 23), j∈(1, n), if there exists Descriptionvol i,l Less than Smart Contract SC Order Final Matching Item Otherwise, the smart contract SC orders If exists illustrate Less than vol i,l , the smart contract SC orders the final matching item Otherwise, the smart contract SC orders
[0061] 4-5) Smart contract SC broadcasts the final matching results The party with the larger power value verifies whether the received power value is correct based on the power value commitment of the other party;
[0062] 4-6) User U i and Get the final matching result from the smart contract
[0063] 4-7) If Represents user U i The user U is the one with the smaller power value in a pair. i Its power value vol i,l The secret and the corresponding random number r i,l Send to users Go to step 4-9); if user Its power value And the corresponding random number Sent privately to user U i , proceed to step 4-8);
[0064] 4-8) User U i Received by user Power value And the corresponding random number U i Calculating Commitment Value and matches the promised value received during the matching phase Match if It means that user U i Received power value is correct, both parties can trade according to this power value. Report the user to the smart contract
[0065] 4-9) User Received user U i The power value of vol i,l And the corresponding random number N i,l , Calculating Commitment Value and matches the commitment value cv received during the matching phase i,l To match, if It means household Received power value vol i,l is correct, both parties can trade according to this power value. Report user U to the smart contract i .
Claims
1. A privacy-preserving electricity transaction matching method based on blockchain, characterized in that: The following steps are involved: 1) Initialization steps: The system determines public parameters based on security parameters and divides power trading periods; 2) Registration steps: Each user selects a random number and uses it to generate a commitment to the amount of electricity he or she wishes to trade in each time period; Each power value is represented by 0 bits and 1 bits, and each bit is split into a first power value component and a second power value component; Then a random number is selected for each power numerical component and a commitment for that power numerical component is generated using the random number; The user generates a temporary random number and sends the first matching information to the smart contract. The first matching information includes the transaction requirements corresponding to each transaction time period, the power value commitment related data, the correctness proof of the first matching information and the temporary random number; the power value commitment related data includes the power value commitment, the power value first component commitment, the power value second component commitment, the power value second component and the random number used to generate the power value second component commitment; Smart contracts verify the legitimacy of matching information and save it; 3) Matching steps: The user retrieves the first matching information of other users from the smart contract, and uses the temporary random number of other users to calculate the shared secret value with other users; The user generates his own second matching information and other users' second matching information according to his own first matching information and other users' first matching information respectively; the second matching information includes power value commitment, power value first component commitment, power value second component commitment, power value second component and random number used to generate power value second component commitment; the user matches his own second matching information with other users' second matching information in turn; during the matching process, the user first generates power value matching intermediate parameters, power value commitment matching intermediate parameters and commitment random number matching intermediate parameters; then the user generates a matching random permutation and a set of matching random numbers according to the shared secret value with other users; finally, the user uses matching random permutation and matching random numbers to blind power value matching auxiliary parameters, power value commitment matching auxiliary parameters and commitment random number matching auxiliary parameters to obtain user-side matching results; the user-side matching results include power value first matching result, power value second matching result, power value commitment first matching result, power value commitment second matching result, commitment random number first matching result and commitment random number second matching result; The user sends the user-side matching results to the smart contract; 4) Execution steps: After receiving the matching results from all users, the smart contract calculates the final matching results and makes them public; According to the final matching result, the user with the smaller power value in each pair of matched users secretly sends its power value to the other party; The party with the larger power value verifies whether the received power value is correct based on the power value commitment of the other party. If the verification is correct, the transaction is completed.
2. The method according to claim 1, characterized in that: Step 1) specifically includes: 1-1) The system determines the public parameters based on the security parameters λ Where p is a large prime number, is the ring of residue classes of integers modulo p, is a multiplicative group of order p, and g is The generator of , m is the number of users participating in the power trading matchmaking, Com is the homomorphic commitment algorithm, BitPro is the zero-knowledge proof algorithm that proves that the commitment value is 0 / 1 bits, BitVrfy is the verification algorithm of BitPro, EqPro is the zero-knowledge proof algorithm that proves that two commitment values are equal, and EqVrfy is the verification algorithm of EqPro; 1-2) The system divides each day into 24 time periods, each of which is 1 hour. Users can choose to sell or buy electricity in each time period.
3. The method according to claim 2, characterized in that: Step 2) performed by each user specifically includes: 2-1) For the i-th user U i , i∈(1,m), build a matching request list OL i ={dir i,l , vol i,l } l∈(0,23) , where transaction requirements dir i,l ∈{+,-} indicates that user U i In time period l, do you want to buy electricity + or sell electricity -? i,l is the value of electricity that user U wants to buy or sell in time period l, and the time period variable l∈(0,23); 2-2) Each user U i First randomly select a set of random numbers r i,l , and then use the random number r i,l Calculate the commitment cv of the electricity value it wants to buy and the electricity value it wants to sell i,l =Com(vol i,l ; r i,l ); 2-3) For l∈(0,23), each user U i The power value is decomposed into bits. Each value bit v i,l,j ∈{0, 1}, n is the number of bits in the binary representation of the power value, and j is the number of bits variable; 2-4) For l∈(0, 23) and j∈(0, n-1), user U i Each value bit is randomly split into two components, v i,l,j =v i,l,j,0 +v i,l,j,1 , where v i,l,j,0 and v i,l,j,1 are the first component of the power value and the second component of the power value, v i,l,j,0 , 2-5) For l∈(0,23), j∈(0,n-1) and k∈(0,1), user U i Select random number Generate commitment cv for each power value bit component i,l,j,k =Com(v i,l,j,k ; r i,l,j,k ), k is the power numerical component variable; 2-6) User U i Generate two zero-knowledge proofs qPro and BitPro, and π i,l,j =BitPro(cv i,l,j,0 ·cv i,l,j,1 ); 2-7) User U i Select random number Calculate temporary random number 2-8) User U i Send the first matching information minf i =(g i ,dir i,l , cv i,l , cv i,l,j,0 , cv i,l,j,1 , v i,l,j,1 , r i,l,j,1 , π i,l, π i,l,j ) to the smart contract SC, where l∈(0, 23), j∈(0, n-1); dir i,l For trading needs; power value commitment related data includes power value commitment cv i,l 、Power value first component commitment cv i,l,j,0 、Power value second component commitment cv i,l,j,1 , the second component of power value v i,l,j,1 and a random number r used to generate the second component of the power value commitment i,l,j,1 ; π i,l , π i,l,j are two zero-knowledge proofs, g i is a temporary random number; 2-9) Smart contract SC uses BitVrfy and EqVrfy algorithms to verify the first matching information minf i Zero-knowledge proof π in i,l , π i,l,j If the verification is successful, the user's matchmaking request is accepted, otherwise the user is rejected.
4. The method according to claim 3, characterized in that: Step 3) performed by each user specifically includes: 3-1) For the i-th user U i , i∈(1,m), retrieve the first matching information of other users from the smart contract where i * ∈(1,m) and i * ≠i; 3-2) For the matching request list OL i ={dir i,l , vol i,l } l∈(0,23) Each tuple in dir i,l , vol i,l ), user U i Constructing a match list Satisfy i * ∈(1,m),i * ≠i, First matching information The transaction requirements contained in 3-3) For i * ∈(1,m) and i * ≠i, user U i Using random numbers i And temporary random numbers of other users To calculate the shared secret value 3-4) For l∈(0,23), user U i Generate your own second matching information (cv i,l , cv i,l,j,0 , cv i,l,j,1 , v i,l,j, 0r i,l,j,0 ), and according to the matching list ML i The first matching information of each other user in the matching information generates the second matching information of other users; then the second matching information of the user is combined with the power value commitment related data in the second matching information of other users. Matching is performed in sequence, and the second matching information includes the same power value commitment cv as the power value commitment related data in the first matching information i,l 、Power value first component commitment cv i,l,j,0 and power value second component commitment cv iτlτjτ1 , and the first power value component v different from the power value commitment related data in the first matching information iτl,jτ and a random number r used to generate the first component of the power value commitment i,l,j,0 ; The specific matching process is as follows: 3-4-1) User U i Set the middle value Intermediate Commitment Value 3--4-2) For l∈(0, 23), j∈(1, n-1), the user iteratively calculates the intermediate parameters as follows: 3-4-3) User U i Using a shared secret value Generate a matching random permutation The intermediate parameters Rearrange to 3-4-8) For j∈(1,n), the user uses the shared secret value Generate random numbers 3-4-9) User U i Use random numbers for the rearranged intermediate parameters Blindly obtain each matching item in the user-side matching result. 3-5) User U i Match the results of the user end Sent to the smart contract SC.
5. The method according to claim 4, characterized in that: Step 4) specifically includes: 4-1) Receive user U i User-side matching results and user U i* User-side matching results The smart contract performs the following calculations to obtain the contract-side matching results 4-2) Smart contract SC matches the items in the contract end matching results and To calculate the verification commitment value com i,l,j and com i*,l,j ; 4-3) Determine and verify the commitment value com i,l,j and com i*,l,j whether as well as If yes, go to step 4-4), otherwise, the smart contract SC terminates and requires the user U i and user U i* Provide correct user-side matching results; 4-4) For l∈(0, 23), j∈(1, n), if there exists Smart contract SC orders final matching item b i,i*,l =1, otherwise the smart contract SC orders b i,i*,l =0; if exists Smart contract SC orders final matching item b i*,i,l =1, otherwise the smart contract SC orders b i,i*,l =0; 4-5) Smart contract SC broadcasts the final matching result (b i,i*,l , b i*,i,l ); 4-6) User U i with U i* Get the final matching result from the smart contract (b i,i*,l , b i*,i,l ); 4-7) If (b i,i*,l , b i*,i,l )=(1,0), user U i Its power value vol i,l Sent secretly to user U i* , otherwise user U i* Its power value vol i*,l Sent secretly to user U i .
Citation Information
Cited By
Privacy protection electricity transaction matching method and system based on alliance chain smart contract
CN119205339A
