A privacy protection method for smart grid based on Ethereum smart contract
By introducing proxy nodes and scheduling contracts on the Ethereum platform, the data privacy leakage and security threat issues of scheduled transactions in smart grids are solved, and scheduled transactions and data security protection are realized in a decentralized environment.
Patent Information
- Application Number
- CN202211710663.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-29
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2042-12-29
AI Technical Summary
The existing Ethereum smart contract platform cannot support scheduled transactions and there are data privacy leaks and security threats when executing transactions. In particular, functions cannot be automatically called when users are offline, and the centralized approach violates the decentralized design principle.
By introducing proxy nodes and scheduling contracts on the Ethereum platform, users select proxy nodes and pay a deposit within a set time window. The proxy nodes save and verify function inputs within the execution time window, use secret channels to encrypt data transmission, and build a malicious behavior reporting mechanism to prevent data leakage and malicious behavior.
It enables users to conduct scheduled transactions in a decentralized environment, protects data privacy, reduces the risk of user privacy leakage, and verifies lower gas and time consumption through simulation.
Abstract
Description
Technical Field
[0001] The present invention relates to the field of smart grid technology, and in particular to a smart grid privacy protection method based on Ethereum smart contracts. Background Art
[0002] Traditional power grids have significant limitations. First, electricity is always transmitted from one end to the other, without fully considering the power distribution and information exchange between the two ends, resulting in a lack of flexibility. Second, traditional power grids are mostly produced by large, centralized power plants, resulting in concentrated power generation and significant losses during long-distance transmission. Furthermore, due to poor information security, attackers can easily steal users' valuable data, exposing personal privacy. Furthermore, due to equipment and technological limitations, traditional power grids have little room for improvement.
[0003] Compared to traditional power grids, smart grids support bidirectional transmission of power and data, increasing the flexibility of power. However, while this enhanced interaction inevitably raises data privacy security concerns. For example, attackers could steal and analyze the power usage information of large numbers of users, assess their lifestyles and routines, and then conduct illegal activities, causing unnecessary losses to users. Therefore, the development of smart grids urgently requires the protection of power data privacy.
[0004] The emergence of blockchain technology makes it possible to protect user privacy and security. Blockchain is a distributed internet database technology. Its decentralized, trustless, and transparent nature enables trusted point-to-point value transfer between unfamiliar nodes without relying on third-party trusted institutions. Its primary advantage is that it significantly reduces trust consumption and improves interaction efficiency.
[0005] A smart contract is a piece of contract code executed on the blockchain. This code represents pre-agreed rules. Once implemented, it is maintained by all nodes in the blockchain network during the contract's execution. The execution process and data input and output of the smart contract are recorded on the blockchain, and the execution results are immutable. The blockchain network's vast computing resources provide unstoppable trusted computing, ensuring the unrestricted execution of smart contracts. This solves the trust issue inherent in real-world execution.
[0006] Smart contracts were originally designed as computer-based transaction protocols for enforcing pre-defined contractual terms in scenarios lacking a trusted third party. With the development of blockchain technology, and in particular the emergence of the Ethereum blockchain platform, smart contracts have garnered significant attention. Blockchain smart contracts are considered the laws of the blockchain. They are decentralized, require no trust, are tamper-proof once deployed, and can be designed and programmed to suit specific application scenarios and business needs. On the Ethereum platform, smart contracts are implemented as self-executing scripts, with their code and data stored in the blockchain ledger. On the Ethereum platform, smart contracts are typically issued and executed through transactions. Smart contract programs can be executed by any node in the distributed network, verifying the accuracy of the data and state stored on the blockchain after the contract is executed. The development of smart contracts in smart grid scenarios offers greater flexibility.
[0007] Existing Ethereum platforms for executing smart contracts suffer from a critical fundamental limitation: the inability to schedule user-scheduled transactions. When a user is offline, their target function cannot be called at a later time. For example, when a user is on vacation, they cannot respond to Ethereum's voting mechanism within a specified timeframe. In this case, a mechanism is needed to automatically call reveal() and vote() functions to respond to transactions within a specific timeframe. The inputs to these functions, such as bids or votes, are highly sensitive, and even when the user is offline, such data must be securely protected until the network completes its response within the specified timeframe. Furthermore, centralized approaches to supporting scheduled transactions create a single point of trust, violating the decentralization inherent in blockchain-based smart contract platforms.
[0008] Typically, the design of smart contract transaction execution in decentralized platforms like Ethereum faces two challenges. First, when a transaction that calls a function is deployed to the network, the called function is executed immediately, making it difficult to support scheduled transactions when the user is offline. Second, to ensure the verifiability of the function output, the function input needs to be placed on the blockchain. This results in the function input and output being inevitably exposed to all peer nodes when the process table is initialized, which poses privacy risks and security threats to the input data. Summary of the Invention
[0009] The technical problem to be solved by the present invention is to provide a smart grid privacy protection method based on Ethereum smart contracts to solve technical problems such as the risk of smart grid data privacy leakage and security threats.
[0010] The technical solution of the present invention is:
[0011] A smart grid privacy protection method based on Ethereum smart contracts, the method comprising:
[0012] Step 1: At any time point, the externally owned account EOA sends a S Apply to be added to the maintained pool of proxy node candidates by C S Submit the working time window and pay the deposit; within the working time window, EOA connects with Ethereum and sends the transaction to the proxy contract C P ;
[0013] Step 2: Set the time window w s In the scheduler, the user registers the schedule to the scheduler's scheduling contract C S In the deployment, the proxy contract C P And secretly select proxy nodes from the pool to arrange transactions;
[0014] Step 3: In the execution time window w e The selected proxy node submits the function input to the proxy contract C through a transaction P , trigger C P Use C S To verify the correctness of the function input, and then call the target contract C t The planning function in ;
[0015] Step 4. Build a malicious behavior reporting mechanism that allows any witness of malicious behavior to report it to the scheduling contract CS, and confiscate the deposit paid by the suspicious proxy node if the report is proven to be true.
[0016] The agent node selected in step 2 is executed in the time window w e Before privately saving the function input, while in w e During the process, open them so that the target function can be executed; in the setting window w s During this period, the user will schedule contract C S Notify the scheduler and deploy the proxy contract C P ;The user then randomly selects three EOAs from the candidate pool as proxy nodes and signs an agreement with the proxy nodes through a dedicated channel created by a secret protocol; all data exchanged through the secret channel is encrypted and can only be viewed by the data sender and data receiver.
[0017] In step 3, in w e During this period, the proxy node submits the stored data to the proxy contract C P ; Use storage in scheduling contract C S After verifying the received data with the hash value in C P Then in C t Calling the function.
[0018] The proxy node application method in step 1 includes: first, when the user creates a new EOA in the Ethereum node, each proxy node candidate is a newly generated EOA; the EOA submits the margin d to the scheduling contract C s , in the execution time window w e Public account private key; EOA is sent to C s Send a transaction with the following five pieces of information to apply for a proxy node candidate; the user flow table module will use this public key to generate an onion; "onion" refers to the output of iterative encryption of data; the key will be used by the user in the user planning module to establish a dedicated channel with this EOA through a secret agreement.
[0019] Deploy proxy contract C P The method is to register the process table information to the scheduling contract and implement two rounds of proxy node elections.
[0020] Deploy proxy contract C P Specific methods include:
[0021] In the initialization phase, user U determines the function input IN and the execution time window w e , number of layers l, shared parameters (m,n), 256-bit key Key and 256-bit random number R U ; Then calculate the total salary that user U should pay as r = nlr d t+r e , where r d is fixed at C s and r e In the example, the salary of each proxy node is a fixed amount of reward, which is used to pay w e During the period in C t The first proxy node that calls execute() in the process; the proxy node can only execute in the execution time window w e After the end, withdraw d and r e ; User U will proxy contract C p Deploy to the network and include parameters (w e ,m,n,l,C p addr ,r)'s process table is registered to the scheduling contract C s and receive the process table Idsid;
[0022] The user flow table performs the first round of proxy node election: user U randomly selects n(l-1) proxy nodes and sends a (sid, tid), where tid is the range of non-repeated IDs distributed to proxy nodes [0, n(l-1)]; the following operations are performed on each selected proxy node: use C s Verification addr,sid,tid,w e ,r), generate a 256-bit random number R T ; Extract the SHA-256 hash h(T addr ,R T ); Use the private key pair of the proxy node T (U addr ,sid,tid,h(T addr ,R T )) to sign, thus obtaining the signature vrs=(v,r,s); then h(T addr ,R T ) and vrs are sent back to user U; user U encrypts the fragments into onions using the public key of the selected proxy node, extracts the SHA-256 hash h(onion) of each onion and submits the hash value to C s ;
[0023] The user process table performs the second round of proxy node election: user U randomly selects n proxy nodes and sends a (sid, tid, onion) to each proxy node, where tid is not repeated in [n(l-1),nl]; C s h(onion) in verifies the received onion; the ciphertext and hash are public; user U uses the key pair (IN, vrs, R U ) encrypts and publishes E(Key,(IN,vrs,R U )), and to C s Submit the SHA-256 hash h(IN,R U ) and h(T addr ,R T ).
[0024] The specific implementation method of step 3 is: execute window w e The first half of the process, during which the first and second round proxy nodes submit their private keys and stored onions respectively; the proxy node provides the random number R generated in the user plan T ; Execute window w e In the second half of the process, the verified proxy node converts the onion back to the key fragment; based on the Shamir sharing scheme, any m shares are combined to recover the key created by user S in the user process. After obtaining the key, any proxy node can decrypt the encrypted (IN, vrs, R U ); Finally, in w e Before the end, the verified proxy node obtains the function input IN and the random number R U Afterwards, to the agent contract C p Send a message containing IN and R U Transaction; C pImmediately through the scheduler contract C s h(IN,R U ) Verify the received IN and R U If all are correct, then C p Immediately send a message containing IN to the target contract C t , to call the scheduled function.
[0025] Building a malicious behavior reporting mechanism includes:
[0026] Proxy node identity disclosure report: handles the malicious behavior of proxy node identity disclosure during the execution of the target function. e Before starting, the proxy node chooses to reveal its identity to seek collusion. In order to prove the identity of the proxy node, the violator must reveal the random number R created by itself in the user plan. T , so that through C s h(T addr ,R T ) verify their identity;
[0027] Early disclosure reporting: Early disclosure behavior in the execution of the target function, in w e Before the start, the first round of proxy nodes choose to disclose their private keys, which will help malicious nodes e Before starting, decrypt onion into shares, restore the key and obtain IN; through this reporting mechanism, any EOA will be reported after knowing w e After the private key of the previous violator is S Reporting a violator to betray the violator;
[0028] Proxy node disconnection report: handle the proxy node disconnection behavior described in the target function execution; e During this period, any proxy node may lose connection, which increases the chance of transaction failure. After obtaining the signatures of all other proxy nodes, any proxy node can locally verify whether all other proxy nodes are lost, so that it can send a confirmation to C. S Report lost proxy nodes;
[0029] Fake submission report: handles fake submission behavior in the execution of the target function. When the contract executes decrypt(), the private key submitted may not be the correct private key. Any proxy node can locally verify the private key submitted by the suspicious proxy node by obtaining the corresponding public key from the private key and comparing it with the public key submitted by the proxy node during the application process. S Report violators.
[0030] Beneficial effects of the present invention:
[0031] This paper proposes a privacy-preserving protocol method for smart contracts to address the problem of Ethereum timed transactions in the context of smart grids. This method enables users of Ethereum-based decentralized applications to schedule timed transactions without displaying sensitive inputs before the user-selected execution time window, thereby ensuring data security.
[0032] The privacy protection protocol proposed in this invention protects sensitive inputs by using a group of proxy nodes in a decentralized blockchain network. Therefore, the inputs are only disclosed during the execution process, reducing the possibility of user privacy leakage.
[0033] The present invention uses the Ethereum test network to simulate and evaluate the system using reliability, verifying that the solution has lower gas and time consumption.
[0034] It solves technical problems such as the risk of data privacy leakage and security threats in smart grids. DETAILED DESCRIPTION
[0035] This invention addresses the technical issues of timed transactions in Ethereum based on power grids, and proposes solutions including:
[0036] (1) Proxy Node
[0037] At any point in time, an externally owned account (EOA) can send a S Apply to be added to the pool of proxy node candidates maintained by C S Submit their working time window and pay the deposit. During the working time window, EOA should be able to connect with Ethereum to send transactions to the proxy contract C P .
[0038] (2) User flow table
[0039] In setting the time window w s In the scheduler, users can register their schedules with the scheduler's scheduling contract C S In the deployment, the proxy contract C P And secretly select a proxy node from the pool to arrange the transaction. The selected proxy node should be within the execution time window w e Before privately saving the function input, while in w e During the process, they are exposed so that the objective function can be executed. In the settings window w s During this period, the user will schedule contract C S The scheduler is notified and the proxy contract C is deployed PThe user then randomly selects three EOAs from the candidate pool as proxy nodes and signs an agreement with the proxy nodes through a private channel created via a secret protocol. All data exchanged through the secret channel is encrypted and can only be viewed by the data sender and data receiver.
[0040] (3) Contract Execution
[0041] In the execution time window w e The selected proxy node submits the function input to the proxy contract C through a transaction P , which triggers C P Use C S To verify the correctness of the function input, and then call the target contract C t The planning function in w e During this period, the proxy node submits the stored data to the proxy contract C P . Using storage in the scheduling contract C S After verifying the received data with the hash value in C P Then it will be in C t Call this function in .
[0042] (4) Reporting of Malicious Behavior
[0043] Throughout the process, the proxy node may perform several malicious behaviors that violate the protocol, such as e Data previously stored secretly or publicly on w e To solve these problems, this protocol will build several malicious behavior reporting mechanisms that allow any witness of malicious behavior to report it to the scheduling contract C. S , and confiscate part of the deposit paid by the suspicious proxy node if the report is confirmed to be true.
[0044] There are several key security challenges faced by the present invention, which can be roughly categorized into two types of attacks: Time difference attack: When a malicious node aims to execute a e Previous time point t d Get the function input so that you can use t d With w e The time difference between the two can be used to conduct a time difference attack. e To achieve his goal, there are two key methods to launch a time difference attack.
[0045] (1) Publicity of Proxy Node Identity: In the user planning module of this protocol, proxy nodes are secretly selected by user U. Therefore, from the perspective of EOAs, in addition to the selected proxy nodes and user U, all EOAs in the network that meet U's required working time window have an equal chance of being selected by U, thereby protecting the identity of the selected proxy node with the highest entropy and uncertainty. However, after being selected, the proxy node can announce its identity to the public in order to seek transactions with malicious nodes that store relevant data. To prevent such malicious behavior, the proposed protocol adopts a proxy node identity disclosure reporting mechanism in the protocol's malicious behavior reporting module, which forces the proxy node to disclose its identity at the expense of the confiscation of its security deposit.
[0046] (2) Early disclosure: Proxy nodes can choose to voluntarily disclose their stored data to the entire network. To punish such malicious behavior, an early disclosure reporting mechanism is adopted in the malicious behavior reporting module, which means that any proxy node that discloses its stored data in advance will lose its deposit.
[0047] Target function execution failure attack: When a malicious node aims to make the execution of the target function within the execution time window w e When an execution fails, an execution failure attack occurs.
[0048] (1) The proxy node loses connection: During the execution time window w e In the past few years, the proxy node may lose its connection, which will cause the data it stores to be lost. To prevent this type of malicious behavior, the user scheduling module of the protocol requires each selected proxy node to provide a signature that is only available when w e The period is displayed together with the function input. Therefore, in w e Previously, the identity of the proxy node was kept secret. e During this period, the identity will be made public, so any current proxy node can report the lost proxy node through the proxy node loss reporting mechanism in the malicious behavior reporting part of the protocol. The lost proxy node will have its deposit confiscated as a penalty.
[0049] (2) False submission: The proxy node may be in w e During the period, the agency contract C p Submitting forged storage data, which may cause the recovery of function inputs to fail. This type of malicious behavior is handled using the false submission reporting mechanism in the protocol's malicious behavior reporting module. If the submission is proven to be false, the offender's deposit will also be confiscated.
[0050] The solution of this invention is mainly divided into four parts: proxy node application, user process table, contract execution and malicious behavior reporting. The following describes these four steps respectively:
[0051] Proxy node application:
[0052] First, when a user creates a new EOA in the Ethereum node, each proxy node candidate should be a newly generated EOA. This EOA will be submitted to the scheduling contract C as a deposit d s , and we need to execute time window w e Publicly disclose the private key of the account.
[0053] EOA should be submitted to C s Send a transaction with the five listed pieces of information to apply for a proxy node candidacy. The User Flow Table module will later use this public key to generate an onion. Here, the term "onion" refers to the output of data encrypted iteratively using multiple public keys. The key will later be used by the user in the User Plan module to establish a dedicated channel with this EOA via a secret protocol.
[0054] User Flow Chart
[0055] The user flow table specifies how users should set up the flow table through three key operations: deploying the proxy contract, registering the flow table information to the scheduling contract, and implementing two rounds of proxy node elections.
[0056] In the initialization phase, user U determines the function input IN and the execution time window w e , number of layers l, shared parameters (m,n), 256-bit key Key and 256-bit random number R U Then calculate the total remuneration that user U should pay as r = nlr d t+r e , where r d is fixed at C s and r e In the example, the salary of each proxy node is a fixed amount of reward, which is used to pay w e During the period in C t The first proxy node that calls execute() in the process. The proxy node can only execute in the execution time window w e After the end, withdraw d and r e .
[0057] Next, user U will proxy contract C p Deploy to the network and include parameters (w e ,m,n,l,C p addr ,r)'s process table is registered to the scheduling contract C s In C, and receive the process table IDsid. sOnce the process table is registered in the chain, the on-chain process table information cannot be modified. Therefore, the proxy node can later verify the information sent from user U through the off-chain secret channel. User U splits the key Key into n fragments through (m,n)-Shamir sharing. The parameters (m,n) of the Shamir sharing scheme mean that the key will be split into n shares. Then, any m fragments out of the n can be merged to recover the key, while even (m-1) shares cannot do this. Therefore, even if some shares are compromised, the compromised fragments may not be enough to recover the key within the execution window w. e The remaining fragments may still be sufficient to restore the key before e The key is restored during this period. Assuming (m,n) = (2,3) is set, three fragments will be generated after the key is split.
[0058] After initialization, the user flow table performs the first round of proxy node election. User U randomly selects n(l-1) proxy nodes and sends a (sid, tid), where tid is the range of non-repeated IDs distributed to proxy nodes [0, n(l-1)]. For each selected proxy node, perform the following operations: Use C s Verification addr ,sid,tid,w e ,r), generate a 256-bit random number R T Extract the SHA-256 hash h(T addr ,R T ). Use the private key pair (U addr ,sid,tid,h(T addr ,R T )) to sign, thus obtaining the signature vrs=(v,r,s). Then h(T addr ,R T ) and vrs are sent back to user U. User U encrypts the fragments into onions using the public key of the selected proxy node, extracts the SHA-256 hash h(onion) of each onion, and submits the hash value to C s .
[0059] Finally, the user process table performs the second round of proxy node election. User U randomly selects n proxy nodes and sends a (sid, tid, onion) to each proxy node, where tid is not repeated in [n(l-1),nl]. In addition, C s h(onion) in the onion is used to verify the received onion. The ciphertext and hash are public. User U uses the key pair (IN, vrs, R U ) encrypts and publishes E(Key,(IN,vrs,R U )). and to C sSubmit the SHA-256 hash h(IN,R U ) and h(T addr ,R T ).
[0060] The design of two-round proxy node election realizes distributed secret trust. In the first round of proxy node election, users should agree to use their public keys to encrypt key fragments in multiple layers, so that the fragments become onions and are more difficult to crack. Then, the proxy nodes selected in the second round should be responsible for storing these onions. After that, in w e During this period, once the private key of the first-round proxy node and the onion stored by the second-round proxy node are disclosed, the key can be recovered through the decryption function.
[0061] Among other things, the process provides the following additional security features:
[0062] The identity of the selected proxy node is kept secret. Each proxy node communicates with the user only through a secret channel, and all information that needs to be made public is announced by the user. Therefore, the identity of each proxy node is only known to the user R T This feature helps prevent collusion between proxy nodes.
[0063] The identity of the selected proxy node is verifiable and only the proxy node can be verified. To verify a specific proxy node, the address T of the proxy node addr and current R T Must be submitted to C s , and their hashes should match the hashes submitted by the user. T Since it is created by the proxy node, only the proxy node can pass the verification. This step also helps prevent collusion between proxy nodes. We will discuss this in detail later in the Malicious Behavior Reporting Module.
[0064] Once the identity of the proxy node is selected, it cannot be denied. The user has the signature of the proxy node and will make the encrypted signature public after the second round of proxy node election. e If the key is recovered during the process, the decrypted signature can reveal the identity of all proxy nodes. This feature helps to detect e The proxy node that lost contact during the period.
[0065] Contract Execution
[0066] Contract execution will instruct the agent node selected in the user planning module how to execute the contract within the execution window w e During this period, the function input is displayed collaboratively and the transaction containing the function input is sent to the proxy contract C through two stages. p , that is, submission and execution.
[0067] The commit phase indicates the execution window w e During the first half of the protocol, the first and second round proxy nodes are required to submit their private keys and stored onions respectively. To submit a private key or onion, the proxy node should also provide a random number R generated in the user plan. T , so that h(T addr ,R T ) to verify their identity.
[0068] The execution phase refers to the execution window w e Since both the onion and the private key have been submitted, at this stage, any verified proxy node should be able to convert the onion back into the key fragment. Then, based on the Shamir sharing scheme, any m shares can be combined to recover the key created by user S in step 1 of the user process. After obtaining the key, any proxy node can decrypt the encrypted (IN, vrs, R U ). Finally, in w e Before the end, the verified proxy node obtains the function input IN and the random number R U After that, the agent contract C should be p Send a message containing IN and R U Then, C p will be immediately passed to the scheduler contract C s h(IN,R U ) Verify the received IN and R U If they are all correct, then C p Immediately send a message containing IN to the target contract C t , to call the scheduled function.
[0069] Report malicious behavior
[0070] Malicious behavior reporting represents the final component of the protocol and covers four types of malicious behavior that will result in the violator's security deposit being confiscated. All of these malicious behaviors are identifiable, and the protocol rewards the violator with a portion of their security deposit as an incentive, while sending the rest of the violator's security deposit to the user.
[0071] The four types of malicious behavior are:
[0072] Proxy node identity disclosure report: This reporting mechanism is designed to handle the malicious behavior of proxy node identity disclosure introduced in the target function execution. e Before starting, the proxy node can choose to reveal its identity to seek collusion. To prove the identity of the proxy node, the offender must reveal the random number R created by itself in step 7 / 11 of the user plan.T , so that it can be s h(T addr ,R T ) to verify their identity. However, through this reporting mechanism, any EOA who knows w e Previous R T After that, you can report it to C S to get rewards.
[0073] Early disclosure reporting: Early disclosure behavior introduced in the target function execution can be handled using this reporting mechanism. e Before starting, the first round of proxy nodes can choose to disclose their private keys, which will help malicious nodes e Before starting, decrypt the onion into shares, restore the key and obtain IN. However, through this reporting mechanism, any EOA will be e After the private key of the previous violator is obtained, it can be obtained by sending S Report a violator to betray the violator.
[0074] Proxy node disconnection report: This reporting mechanism mainly handles the proxy node disconnection behavior described in the target function execution. e During this period, any proxy node may lose connection, which increases the chance of transaction failure. With this reporting mechanism, any proxy node can locally verify whether all other proxy nodes are lost after obtaining the signatures of all other proxy nodes, so that it can report to C S Report a lost proxy node.
[0075] Fake submission report: The fake submission report is designed to handle the fake submission behavior introduced in the target function execution. When the contract executes decrypt(), the submitted private key may not be the correct private key. Any proxy node can locally verify the private key submitted by the suspicious proxy node by obtaining the corresponding public key from the private key and comparing it with the public key submitted by the proxy node during the proxy node application. S Report violators.
Claims
1. A smart grid privacy protection method based on Ethereum smart contracts, characterized by: The method comprises: Step 1: At any time point, the externally owned account EOA sends a S Apply to be added to the maintained pool of proxy node candidates by C S Submit the working time window and pay the deposit; within the working time window, EOA connects with Ethereum and sends the transaction to the proxy contract C P ; Step 2: Set the time window w s In the scheduler, the user registers the schedule to the scheduler's scheduling contract C S In the deployment, the proxy contract C P And secretly select proxy nodes from the pool to arrange transactions; The agent node selected in step 2 is executed in the time window w e Before privately saving the function input, while in w e During the process, open them so that the target function can be executed; in the setting window w s During this period, the user will schedule contract C S Notify the scheduler and deploy the proxy contract C P The user then randomly selects three EOAs from the candidate pool as proxy nodes and signs an agreement with the proxy nodes through a dedicated channel created through a secret protocol. All data exchanged through the secret channel is encrypted and can only be viewed by the data sender and the data receiver. Step 3: In the execution time window w e The selected proxy node submits the function input to the proxy contract C through a transaction P , trigger C P Use C S To verify the correctness of the function input, and then call the target contract C t The planning function in ; The specific implementation method of step 3 is: execute window w e The first half of the process, during which the first and second round proxy nodes submit their private keys and stored onions respectively; the proxy node provides the random number R generated in the user plan T ; Execute window w e In the second half of the process, the verified proxy node converts the onion back to the key fragment; based on the Shamir sharing scheme, any m shares are combined to recover the key created by user S in the user process. After obtaining the key, any proxy node can decrypt the encrypted (IN, vrs, R U ); Finally, in w e Before the end, the verified proxy node obtains the function input IN and the random number R U Afterwards, to the agent contract C p Send a message containing IN and R U Transaction; C p Immediately through the scheduler contract C s h(IN,R U ) Verify the received IN and R U If all are correct, then C p Immediately send a message containing IN to the target contract C t , to call the planned function; Step 4. Build a malicious behavior reporting mechanism that allows any witness of malicious behavior to report it to the scheduling contract CS, and confiscate the deposit paid by the suspicious proxy node if the report is proven to be true.
2. The method for protecting privacy in a smart grid based on an Ethereum smart contract according to claim 1, wherein: In step 3, in w e During this period, the proxy node submits the stored data to the proxy contract C P ; Use storage in scheduling contract C S After verifying the received data with the hash value in C P Then in C t Calling the function.
3. The method for protecting privacy in a smart grid based on an Ethereum smart contract according to claim 1, wherein: The proxy node application method in step 1 includes: first, when the user creates a new EOA in the Ethereum node, each proxy node candidate is a newly generated EOA; the EOA submits the margin d to the scheduling contract C s , in the execution time window w e Public account private key; EOA is sent to C s Send a transaction with the following five pieces of information to apply for a proxy node candidate; the user flow table module will use the public key to generate an onion; "onion" refers to the output of iterative encryption of data; the key will be used by the user in the user plan module to establish a dedicated channel with this EOA through a secret agreement.
4. The method for protecting privacy in a smart grid based on an Ethereum smart contract according to claim 1, wherein: Deploy proxy contract C P The method is to register the process table information to the scheduling contract and implement two rounds of proxy node elections.
5. The method for protecting privacy in a smart grid based on an Ethereum smart contract according to claim 4, wherein: Deploy proxy contract C P Specific methods include: In the initialization phase, user U determines the function input IN and the execution time window w e , number of layers l, shared parameters (m,n), 256-bit key Key and 256-bit random number R U ; Then calculate the total salary that user U should pay as r = nlr d t+r e , where r d is fixed at C s and r e In the example, the salary of each proxy node is a fixed amount of reward, which is used to pay w e During the period in C t The first proxy node that calls execute() in the process; the proxy node can only execute in the execution time window w e After the end, withdraw d and r e ; User U will proxy contract C p Deploy to the network and include parameters (w e ,m,n,l,C p addr ,r)'s process table is registered to the scheduling contract C s and receive the process table Idsid; The user flow table performs the first round of proxy node election: user U randomly selects n(l-1) proxy nodes and sends a (sid, tid), where tid is the range of non-repeated IDs distributed to proxy nodes [0, n(l-1)]; the following operations are performed on each selected proxy node: use C s Verification addr ,sid,tid,w e ,r), generate a 256-bit random number R T ; Extract the SHA-256 hash h(T addr ,R T ); Use the private key pair of the proxy node T (U addr ,sid,tid,h(T addr ,R T )) to sign, thus obtaining the signature vrs=(v,r,s); then h(T addr ,R T ) and vrs are sent back to user U; user U encrypts the fragments into onions using the public key of the selected proxy node, extracts the SHA-256 hash h(onion) of each onion and submits the hash value to C s ; The user process table performs the second round of proxy node election: user U randomly selects n proxy nodes and sends a (sid, tid, onion) to each proxy node, where tid is not repeated in [n(l-1),nl]; C s h(onion) in verifies the received onion; the ciphertext and hash are public; user U uses the key pair (IN, vrs, R U ) encrypts and publishes E(Key,(IN,vrs,R U )), and to C s Submit the SHA-256 hash h(IN,R U ) and h(T addr ,R T ).
6. The method for protecting privacy in a smart grid based on an Ethereum smart contract according to claim 1, wherein: Building a malicious behavior reporting mechanism includes: Proxy node identity disclosure report: handles the malicious behavior of proxy node identity disclosure during the execution of the target function. e Before starting, the proxy node chooses to reveal its identity to seek collusion. In order to prove the identity of the proxy node, the violator must reveal the random number R created by itself in the user plan. T , so that through C s h(T addr ,R T ) verify their identity; Early disclosure reporting: Early disclosure behavior in the execution of the target function, in w e Before the start, the first round of proxy nodes choose to disclose their private keys, which will help malicious nodes e Before starting, decrypt onion into shares, restore the key and obtain IN; through this reporting mechanism, any EOA will be reported after knowing w e After the private key of the previous violator is S Reporting a violator to betray the violator; Proxy node disconnection report: handle the proxy node disconnection behavior described in the target function execution; e During this period, any proxy node may lose connection, which increases the chance of transaction failure. After obtaining the signatures of all other proxy nodes, any proxy node can locally verify whether all other proxy nodes are lost, so that it can send a confirmation to C. S Report lost proxy nodes; Fake submission report: handles fake submission behavior in the execution of the target function. When the contract executes decrypt(), the private key submitted may not be the correct private key. Any proxy node can locally verify the private key submitted by the suspicious proxy node by obtaining the corresponding public key from the private key and comparing it with the public key submitted by the proxy node during the application process. S Report violators.
Citation Information
Patent Citations
Excitation method for K anonymous position privacy protection based on blockchain smart contract
CN110557375A
Off-chain security payment method and system based on alliance chain, medium and equipment
CN112241884A