Energy transaction protection method and system based on block chain online transaction

By establishing an energy data change curve and credibility evaluation model in the blockchain energy trading system, identifying and isolating abnormal data, the problem of data tampering in blockchain energy trading is solved, and the security of the system and transaction transparency are improved.

CN120218933APending Publication Date: 2025-06-27STATE GRID SHANDONG ELECTRIC POWER CO
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510660198.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-22
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

In blockchain energy transactions, attackers can use man-in-the-middle attacks or side channel attacks to forge or tamper with energy transaction data, resulting in market price distortion and pollution of blockchain ledger data.

Method used

By obtaining energy transaction data of energy trading equipment, an energy data change curve is established, and an energy data credibility assessment model is established based on multi-source data fusion to conduct data integrity verification and abnormal marking. If the data is abnormal, the traceability mechanism and blockchain smart contracts will be triggered for data isolation and transaction freezing.

Benefits of technology

Effectively identify and isolate maliciously tampered data, prevent it from affecting transaction settlement, improve the system's anti-attack capabilities and data security, and ensure the transparency and credibility of energy transactions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120218933A_ABST
    Figure CN120218933A_ABST
Patent Text Reader

Abstract

The invention discloses an energy transaction protection method and system based on block chain online transaction, and particularly relates to the technical field of data management. Energy data are collected regularly, an energy data sequence is formed, a credibility evaluation model is adopted, a transaction data link stability index and an energy consumption deviation value are integrated, low-credibility data are identified and abnormal marking is carried out, and abnormal data points are compared with adjacent energy transaction equipment data, so that the energy transaction efficiency is improved. According to the method and the system, whether the abnormity is caused by malicious tampering or not is judged, for the data which are confirmed to be tampered, if the credibility of all the data meets a set threshold value, transaction data are stored in an uplink mode, and settlement is automatically executed by an intelligent contract. The method and the system can effectively prevent man-in-the-middle attack, side channel attack and data forgery; the authenticity and credibility of the energy transaction data are improved, and the fairness and long-term stability of the block chain energy market are ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data management, and particularly to an energy trading protection method and system based on blockchain online trading. Background Art

[0002] With the digital transformation of global energy trading, blockchain technology has been widely applied to the field of online energy trading due to its characteristics of decentralization, immutability, and smart contract execution. Traditional energy trading platforms usually rely on centralized servers for order matching and settlement, which not only poses risks of data tampering and single-point failures, but also may lead to problems such as transaction opacity and delayed fund settlement. Through blockchain technology, energy trading can achieve peer-to-peer transactions, reduce intermediary costs, and improve transaction transparency.

[0003] The existing technologies have the following deficiencies: In blockchain energy trading, when data acquisition devices such as smart meters and energy gateways submit energy trading data to the blockchain, attackers can use man-in-the-middle attacks (MITM) or side-channel attacks to forge energy trading data or tamper with energy metering data, causing smart contracts to execute transactions based on incorrect data. For example, attackers can tamper with the solar power generation data uploaded by users to make it higher than the actual power generation, so as to obtain extra profits during transaction settlement, or arbitrage by artificially adjusting the data during trading periods using the peak-valley electricity price difference. Such attacks not only lead to distorted energy market prices, but may also cause blockchain ledger data pollution, affecting the long-term stability of energy trading. Currently, most blockchain energy trading systems mainly rely on traditional digital signatures and hash checks for data integrity protection and cannot effectively cope with dynamic data tampering attacks against smart metering devices. Summary of the Invention

[0004] The purpose of the present invention is to provide an energy trading protection method and system based on blockchain online trading to solve the deficiencies in the background art.

[0005] To achieve the above purpose, the present invention provides the following technical solution: An energy trading protection method based on blockchain online trading, comprising: Obtain energy trading data corresponding to an energy trading device, and establish an energy data change curve ET based on historical trading records and device status. Obtain the energy data at corresponding moments on ET at preset time intervals to form an energy data sequence E; Perform data integrity verification on the energy data sequence E, establish an energy data credibility evaluation model based on multi-source data fusion, and perform anomaly marking on low-credibility data according to the evaluation results; If the data points in the energy data sequence E If an anomaly exists, the traceability mechanism is triggered to trace back the data generation process and compare it with the data of adjacent energy trading devices to determine whether the anomaly is caused by malicious tampering; If the traceability result indicates that the data point has been maliciously tampered with, the blockchain smart contract is triggered to isolate the abnormal data, and the abnormal transaction freezing strategy is initiated to prevent the tampered data from entering the final transaction settlement; If the credibility of all data in E meets the set threshold, the transaction data is uploaded to the blockchain, and the energy transaction settlement is executed through the smart contract. At the same time, the device status and energy transaction records are updated.

[0006] Preferably, the energy trading device includes, but is not limited to, a smart meter, a photovoltaic power generation inverter, a wind turbine, and an energy storage device, and the energy trading data is collected in real time through the device data interface, including power generation, power consumption, transaction amount, and transaction timestamp.

[0007] Preferably, an energy data credibility evaluation model is established based on multi-source data fusion. The multi-source data includes the transaction data link stability index and the deviation value of energy consumption from the historical model. The transaction data link stability index and the deviation value of energy consumption from the historical model are normalized so that they are both in the range of [0, 1]. The energy data credibility score is calculated according to the normalized transaction data link stability index and the deviation value of energy consumption from the historical model; The calculation expression of the energy data credibility evaluation model is: ; where is the energy data credibility score, TLSI is the transaction data link stability index, ECD is the deviation value of energy consumption from the historical model, are the weight coefficients of the transaction data link stability index and the deviation value of energy consumption from the historical model, and are all greater than 0.

[0008] Preferably, the method for obtaining the transaction data link stability index is: calculate the initial transaction data link stability index , and the expression is: ; where: represents the number of transactions without data loss or tampering in the most recent M times of transaction data transmission; represents the total amount of transaction data in the most recent M times; Set a time window to record the effective transaction ratio at each time point t, and the calculation formula is: ; where: represents the number of transactions successfully completed within time t, represents the total number of transactions within time t. Set a smoothing coefficient λ and calculate the transaction data link stability index. The expression is: ; where: TLSI is the transaction data link stability index.

[0009] Preferably, the method for obtaining the deviation value of energy consumption from the historical model is as follows: Set a time window Q, and collect energy consumption data and the characteristics affecting energy consumption. Identify normal and abnormal data points by calculating the density around the data points through DBSCAN, and calculate the similarity between data points using the Euclidean distance , and the expression is: ; where: The energy consumption value, The weather influence factor, The number of energy transactions; Classify all data points into core points, border points, and abnormal points, and calculate the mean value of all data points classified as normal clusters by DBSCAN , and calculate the deviation value of energy consumption from the historical model. The expression is: ; represents the actual energy consumption value at time t, and ECD is the deviation value of energy consumption from the historical model.

[0010] Preferably, compare the obtained energy data credibility score with a pre-set energy credibility score threshold. If the energy data credibility score is greater than or equal to the pre-set energy credibility score threshold, classify the energy data as high-credibility energy data; if the energy data credibility score is less than the pre-set energy credibility score threshold, classify the energy data as low-credibility energy data, and mark the low-credibility data as abnormal.

[0011] Preferably, the traceability mechanism uses blockchain hash comparison and adjacent device data comparison, specifically including: Search for transaction records in the blockchain ledger, calculate the hash value of the currently stored data, and compare it with the hash value stored in the blockchain; Select adjacent energy trading devices and obtain energy trading data with the same time stamp; Calculate the deviation MK of the abnormal data point from the average energy consumption of adjacent devices: ; In the formula, is the energy consumption data, is the average energy consumption of adjacent devices, is the standard deviation of the energy consumption of adjacent devices; If MK ≤ 2, it is considered that the data anomaly is caused by transmission errors; if MK > 2, it is caused by malicious tampering.

[0012] Preferably, if the traceability analysis indicates that there is malicious tampering with the data point, the blockchain smart contract is triggered to execute abnormal data isolation, which specifically includes: marking the status of the abnormal data as pending review and stripping it from the normal transaction flow; freezing all transactions dependent on the data to prevent it from affecting the ledger settlement; recording information such as device ID, transaction time, and uploading node for attack traceability and abnormal analysis.

[0013] Preferably, the transaction data is uploaded to the blockchain using the Merkle tree data structure, and the transaction is verified through the blockchain consensus mechanism. The transaction process is as follows: calculating the unique hash value of the transaction data; automatically settling through the execution of the smart contract, calculating the transaction amount, deducting the transaction amount from the purchaser's account, and transferring it to the seller's account; after the transaction is successful, updating the device status to ensure the traceability of the ledger data.

[0014] The present invention also provides an energy trading protection system based on blockchain online trading, including a data acquisition module, a credibility evaluation module, a comparative analysis module, a data isolation module, and a smart contract execution module; Data acquisition module: Obtain the energy trading data corresponding to the energy trading device, and establish an energy data change curve ET based on historical transaction records and device status. Obtain the energy data at the corresponding moment on ET every preset time interval to form an energy data sequence E; Credibility evaluation module: Verify the data integrity of the energy data sequence E, establish an energy data credibility evaluation model based on multi-source data fusion, and mark abnormal data with low credibility according to the evaluation results; Comparative analysis module: If the data points in the energy data sequence E are abnormal, trigger the traceability mechanism, trace back the data generation process, and compare it with the data of adjacent energy trading devices to determine whether the abnormality is caused by malicious tampering; Data isolation module: If the traceability result indicates that the data points are maliciously tampered with, trigger the blockchain smart contract to isolate the abnormal data and start the abnormal transaction freezing strategy to prevent the tampered data from entering the final transaction settlement; Smart contract execution module: If the credibility of all data in E meets the set threshold, upload the transaction data to the blockchain, and execute the energy trading settlement through the smart contract, while updating the device status and energy trading records.

[0015] In the above technical solution, the technical effects and advantages provided by the present invention: 1. Through multi-source data fusion, credibility evaluation, data traceability, and smart contract control, the present invention effectively solves the problems of market distortion and ledger pollution caused by data tampering, device attacks, or abnormal transactions in existing blockchain energy trading. By constructing an energy data change curve (ET) and calculating the credibility score of energy data based on the stability index of the transaction data link and the deviation value of energy consumption from the historical model, this method can accurately identify low-credibility data and trigger a traceability mechanism for abnormal data analysis. Combining blockchain ledger evidence storage with comparison of adjacent devices, the system can effectively detect malicious data tampering behavior and prevent attackers from forging transaction data to obtain illegal benefits.

[0016] 2. The present invention further uses blockchain smart contracts to achieve abnormal data isolation and transaction freezing, ensuring that tampered data does not affect the final transaction settlement, while enhancing the anti-attack ability and data security of the system. By adopting the Merkle tree structure and consensus mechanism, the integrity and immutability of transaction data uploaded to the blockchain are ensured, making the energy trading process more transparent and trustworthy. In addition, combined with decentralized storage, the present invention makes transaction records traceable and enhances the fairness and stability of the energy market. Compared with traditional blockchain energy trading systems, this method not only provides stronger anti-tampering ability but also improves the credibility evaluation ability of transaction data, providing an efficient, secure, and traceable energy trading protection solution for the decentralized energy market. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments recorded in the present invention, and those of ordinary skill in the art can also obtain other drawings based on these drawings.

[0018] Figure 1 It is a flowchart of the method of the present invention.

[0019] Figure 2 It is a system module diagram of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0020] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts fall within the protection scope of the present invention.

[0021] Example 1, please refer to Figure 1As shown in the figure, a method for protecting energy transactions based on blockchain online transactions in this embodiment includes: Obtain the energy transaction data corresponding to the energy transaction device, and establish an energy data change curve ET based on historical transaction records and device status. Obtain the energy data at corresponding moments on ET at preset time intervals to form an energy data sequence E; Perform data integrity verification on the energy data sequence E, establish an energy data credibility evaluation model based on multi-source data fusion, and perform anomaly marking on low-credibility data according to the evaluation results; If the data points in the energy data sequence E are abnormal, trigger the traceability mechanism, trace back the data generation process, and compare it with the data of adjacent energy transaction devices to determine whether the anomaly is caused by malicious tampering; If the traceability result indicates that the data points are maliciously tampered with, trigger the blockchain smart contract to isolate the abnormal data, and initiate the abnormal transaction freezing strategy to prevent the tampered data from entering the final transaction settlement; If the credibility of all data in E meets the set threshold, upload the transaction data to the blockchain, and perform energy transaction settlement through the smart contract. At the same time, update the device status and energy transaction records.

[0022] Obtain the energy transaction data corresponding to the energy transaction device and establish an energy data change curve ET, specifically including: Identify energy transaction devices, including but not limited to smart meters, photovoltaic power generation inverters, wind turbines, energy storage devices, etc. Through the device data interface, real-time collect energy transaction data, including: power generation data (P): the output power of photovoltaic or wind power generation equipment (unit: kW). electricity consumption data (C): the electricity consumption at the user load end (unit: kWh). transaction amount (T): the real-time settlement amount in the energy trading market (unit: $). transaction timestamp (Ts): the timestamp of each transaction, used for data sorting and traceability. Obtain historical transaction records, including: past transaction data, device operating status, energy supply situation, transaction settlement information, etc. Combine blockchain ledger data to ensure data integrity and traceability.

[0023] Establish an energy data change curve ET to describe the change trend of energy transaction data over time: ET = f(Ts, P, C, T), that is, the energy data change curve ET is controlled by the timestamp Ts. As time goes by, record the power generation P, electricity consumption C, and transaction amount T at each moment for subsequent data analysis and anomaly detection.

[0024] Collect energy data based on ET to form an energy data sequence E, specifically including: Set a preset time interval Δt (such as every 5 seconds, every minute, every hour, etc.), and obtain the energy trading data on ET according to Δt. At each time point (k = 1, 2, ..., n), extract the corresponding energy trading data from ET , including: power generation P k , power consumption C k , transaction amount T k and timestamp Ts k . Form an energy data sequence , where: represents the energy trading data collected at the k-th time point. The data sequence E is used as the basic data input for subsequent data integrity verification, anomaly detection, and smart contract execution.

[0025] To comprehensively evaluate the credibility of energy data, obtain the transaction data link stability index TLSI and the energy consumption and historical model deviation value ECD from two directions: data security and device operation characteristics.

[0026] The transaction data link stability index reflects whether the energy data is externally tampered with or network interfered during the transmission process. The method for obtaining the transaction data link stability index is: calculate the initial transaction data link stability index , and the expression is: ; where: represents the number of transactions without data loss or tampering in the most recent M transaction data transmissions; represents the total amount of the most recent M transaction data; Set a time window (such as the most recent 10 transaction data or the transaction data within the most recent 1 hour). Record the effective transaction ratio at each time point t, and the calculation formula is: ; where: represents the number of transactions successfully completed within time t, represents the total number of transactions within time t (including successful and failed transactions). Set a smoothing coefficient λ (0 < λ < 1), and its value is usually set according to the system's sensitivity to recent data. For example: λ = 0.2 (more sensitive to long-term historical data); λ = 0.5 (balanced consideration of recent data and historical data); λ = 0.8 (more sensitive to changes in the latest data). Calculate the transaction data link stability index, and the expression is: ; where TLSI is the transaction data link stability index. If TLSI is lower than the set threshold (such as 90%), it indicates that the data link may be subject to a man-in-the-middle attack (MITM) or a data hijacking attack.

[0027] The deviation value of energy consumption from the historical model reflects the deviation of current energy data from the historical energy consumption pattern to detect whether there are abnormal operations (such as malicious device data tampering). The method for obtaining the deviation value of energy consumption from the historical model is as follows: Set a time window Q (such as the energy consumption data in the last 7 days). Collect energy consumption data and the characteristics affecting energy consumption, such as: timestamp t (such as a certain time point every day), energy consumption (actual energy consumption at the current time point), weather factors (temperature, humidity, etc.), energy trading volume (trading volume at the current time point).

[0028] Identify normal and abnormal data points by calculating the density around the data points through DBSCAN. Set DBSCAN parameters: ε is the neighborhood radius: defining the search radius around a certain point, which determines the range of density calculation; MinPts is the minimum number of points: defining the minimum number of data points required in a certain area to be regarded as a "high-density area". Empirical setting: ε = 0.05 to 0.2 (adjusted according to data distribution). MinPts = 5 to 10 (adjusted according to the number of data points).

[0029] Neighborhood radius ε: It represents the reachable distance adjacent to a certain data point in the multi-dimensional feature space; in the present invention, the initial value of ε is set between 0.05 and 0.2; the selection of ε is related to the normalized range of feature data. After all input data (such as energy consumption value, weather factor, trading volume, etc.) are normalized to the [0,1] interval, ε is set to "a spatial distance between 5% and 20%"; Empirical recommendation: ε = 0.05: applicable to scenarios with high data density and small device fluctuations (such as industrial parks); ε = 0.1 - 0.15: applicable to users with obvious fluctuations such as households or distributed photovoltaics; ε > 0.2: applicable to environments with sparse data or heterogeneous device types.

[0030] Minimum number of points MinPts: It represents the minimum number of adjacent points required for a point to be considered a "core point"; in the present invention, the recommended value range of MinPts is 5 to 10, which can be adjusted according to the device sampling frequency and clustering effect; rule suggestion: if the feature dimension is d, then MinPts ≥ d + 1; The typical feature dimension used in the present invention is 35 dimensions (such as energy consumption value, temperature, trading volume, time period, etc.), so MinPts is recommended to be set to 610.

[0031] To improve the clustering robustness and the adaptive ability of different deployment scenarios, the present invention further introduces a parameter optimization mechanism, including but not limited to the following two methods: (1)For each data point, calculate the distance to its MinPts-th nearest neighbor and plot the K-distance graph; observe the position of the "inflection point" (the point where the slope increases significantly) in the graph as the optimal ε value; This method is applicable to most power sampling data, with simple calculation and stable effect.

[0032] (2)Perform clustering on multiple ε / MinPts parameter combinations, and calculate the silhouette coefficient for each set of clustering results; The higher the silhouette coefficient (close to 1), the clearer the clustering effect, indicating a stable clustering structure; The system automatically selects the set of parameters with the highest silhouette coefficient as the optimal value for the current deployment; It can be re-evaluated periodically (such as daily / weekly) to cope with changes in data distribution.

[0033] Use Euclidean distance to calculate the similarity between data points , and the expression is: ; where: Energy consumption value, Weather influence factor, Energy trading quantity; Perform DBSCAN clustering: Divide all data points into core points, border points, and outliers: Core points: The number of data points in the neighborhood ≥ MinPts; Border points: The number of data points in the neighborhood < MinPts, but belonging to the neighborhood of a certain core point; Noise points (outliers): Points that do not belong to any core point or border point; Mark all outlier points, that is, the noise points (energy anomaly data) identified by DBSCAN.

[0034] Calculate the mean of all data points classified as normal clusters by DBSCAN , and calculate the deviation value of energy consumption from the historical model. The expression is: ; represents the actual energy consumption value at time t, and ECD is the deviation value of energy consumption from the historical model.

[0035] If ECD exceeds the set threshold (such as 0.15), then this point is determined to be an energy consumption anomaly point. Record this abnormal data point and store it in the anomaly log. Trigger the energy trading audit mechanism to prevent malicious data tampering from affecting the market. If multiple consecutive data points are determined to be abnormal, then warn the energy management system that there may be data attacks or equipment failures.

[0036] Normalize the transaction data link stability index and the deviation value of energy consumption from the historical model so that they are both in the range of [0,1], and calculate the energy data credibility score based on the normalized transaction data link stability index and the deviation value of energy consumption from the historical model.

[0037] For example, the present invention can calculate the credibility score of energy data using the following formula, and the calculation expression is: ; where BAF is the credibility score of energy data, TLSI is the transaction data link stability index, ECD is the deviation value of energy consumption from the historical model, are the weight coefficients of the transaction data link stability index and the deviation value of energy consumption from the historical model (which can be optimized according to experimental experience or machine learning), and are all greater than 0.

[0038] The dynamic optimization method of weight coefficients includes: collecting a historical sample data set: including energy transaction samples with known true labels (for example, trusted / anomaly labeled data). Constructing a matrix of TLSI and ECD values of the samples; constructing a binary classification or regression model with whether it is labeled as a true anomaly as the target variable; using methods such as logistic regression, ridge regression, or least squares method with minimizing the misjudgment rate / maximizing the accuracy as the objective function to inversely fit the optimal weight coefficients ( ); automatically updating the model parameter library with the results and re-evaluating and adjusting the weight values within a certain period.

[0039] Compare the obtained credibility score of energy data with the pre-set energy credibility score threshold. If the credibility score of energy data is greater than or equal to the pre-set energy credibility score threshold, classify the energy data as high-credibility energy data; if the credibility score of energy data is less than the pre-set energy credibility score threshold, classify the energy data as low-credibility energy data and mark the low-credibility data as abnormal.

[0040] When a certain data point in the energy data sequence E is identified as abnormal (such as the credibility score of energy data being lower than the set threshold), the system needs to trigger a traceability mechanism, trace back the generation process of this data point, and compare it with the data of adjacent energy trading devices to determine whether the anomaly is caused by malicious tampering. Record the detailed information of the abnormal data point: transaction time, device ID (such as smart meter, photovoltaic inverter number), transaction amount, transaction energy consumption, transaction data link stability index, and energy consumption deviation value.

[0041] Trace back the historical transaction records of the abnormal data point to check whether the data has been tampered with during transmission or storage.

[0042] Search for the transaction record in the blockchain ledger, query the transaction hash value, and obtain the original data uploaded to the chain.

[0043] Calculate the hash value of the currently stored data and check if it matches. If it doesn't match, the data may have been tampered with during upload, and proceed to compare with adjacent devices.

[0044] Check the data transfer logs, analyze the transfer path of this data point from the smart device to the blockchain network, and find out if there is data loss or man-in-the-middle attack. Compare the data stored locally on the device with the data stored on the blockchain to determine if they are consistent.

[0045] Check whether the abnormal data conforms to the energy consumption pattern of adjacent devices through spatial correlation, so as to determine whether the abnormality is caused by malicious tampering.

[0046] Select adjacent energy trading devices, choose devices that are physically closest or within the same microgrid, such as: smart meters: compare the energy consumption data of adjacent users. Photovoltaic power generation devices: compare the power generation data of nearby photovoltaic systems. Wind power generation devices: compare the power generation data under the same wind speed.

[0047] Extract the transaction data of adjacent devices at the same time t , and form a comparison data set: ; calculate the average value and standard deviation of the energy consumption of adjacent devices; then, calculate the deviation MK of the abnormal data point from the adjacent data, and the expression is: ; in the formula, is the energy consumption data, is the average energy consumption of adjacent devices, is the standard deviation of the energy consumption of adjacent devices.

[0048] Judgment criterion: If MK ≤ 2 (that is, the data deviation is within 2 times the standard deviation), it is considered that this data point conforms to the historical pattern and may be an abnormality caused by transmission error; if MK > 2, this data point significantly deviates from the energy consumption pattern of adjacent devices and may be an abnormality caused by malicious tampering. After completing data tracing and comparing with the data of adjacent devices, it is necessary to comprehensively analyze the characteristics of the abnormal data point to determine its source of abnormality. The judgment rules are as follows: If the hash value of the original data in the blockchain ledger does not match the hash value of the currently stored data, and at the same time the energy consumption deviation of this data point significantly exceeds the historical pattern of adjacent devices (MK is greater than 2), it can be judged that this data is very likely to be caused by malicious tampering. This situation indicates that the data has suffered a man-in-the-middle attack, smart meter hijacking or other forms of external attacks during transmission or storage. For such abnormalities, the system should immediately trigger the smart contract to reject the data and send an alarm to the energy trading platform or system administrator to prevent malicious data from affecting transaction settlement.

[0049] If the hash value of the original data in the blockchain ledger is the same as the currently stored data hash value, but the energy consumption deviation still exceeds the normal range (MK > 2), it indicates that the data has not been tampered with, but may be caused by equipment failures or sensor abnormalities. Such anomalies may be caused by false alarms from smart meters, sensor malfunctions, or short-term failures of power equipment. In this case, the system should not directly reject the data, but should send a maintenance alert to the energy management system, notify technicians to check the equipment status, and decide whether to correct or eliminate the data point based on subsequent data performance.

[0050] If the hash value of the original data in the blockchain ledger is the same as the currently stored data hash value, and the energy consumption deviation is within a reasonable range (MK ≤ 2), it indicates that the data conforms to the historical energy consumption pattern and is within the normal fluctuation range. Although the data was marked as abnormal in the preliminary screening, its authenticity can be confirmed through traceability and comparative analysis. Therefore, the system can remove the abnormal mark of the data and let it enter the normal transaction settlement process without further processing.

[0051] When the traceability analysis results show that a certain energy data point has been maliciously tampered with (i.e., the data hash value does not match and deviates from the energy consumption patterns of adjacent devices), the system will immediately trigger the blockchain smart contract to execute the abnormal data isolation and transaction freezing strategy to prevent the tampered data from entering the final transaction settlement.

[0052] The smart contract will mark the transaction status of the abnormal data point as "pending review" and strip it from the normal transaction settlement process to prevent the tampered data from entering the ledger. The data point will not be immediately deleted but will be stored in the isolation area for subsequent review or investigation of the attack source. In addition, the smart contract will record the source of the data, including device ID, transaction time, data upload node, etc., for subsequent tracking of the attack path.

[0053] After the transaction of the abnormal data point is frozen, all transactions dependent on this data (such as settlement transactions based on this energy consumption data) will automatically enter a suspended execution state to ensure that unvalidated data will not affect the fairness of the entire blockchain ledger. If multiple data points come from the same smart meter or energy gateway in the same area and there are continuous tampering phenomena, the smart contract can further freeze all energy transactions of related devices to prevent a larger range of data pollution.

[0054] The system will generate an exception report and submit it to the energy trading platform or regulatory agency for manual review or further analysis by an automatic anomaly detection system. If the system has an automatic correction mechanism (such as predicting normal energy consumption values through machine learning), it can try to correct the data and resubmit it.

[0055] If, after review, it is found that the data has indeed been maliciously tampered with, the smart contract will permanently reject the transaction and record the data point in the "blacklist" of the blockchain to prevent the same device from submitting similar malicious data in the future. If subsequent analysis shows that the data anomaly is only caused by a temporary device failure, the system can lift the freeze and allow the transaction to re-enter the blockchain ledger.

[0056] When the credibility scores of all data points in the energy data sequence E are greater than or equal to the set credibility threshold, it indicates that all transaction data are of high credibility and there is no risk of anomaly or tampering. At this time, the system will automatically trigger the process of uploading transaction data to the chain, execute the energy transaction settlement through the smart contract, and update the device status and energy transaction records simultaneously to ensure the integrity and traceability of the transaction.

[0057] Select energy transaction data whose credibility meets the threshold Perform packaging to construct a transaction data block. Each transaction data includes: device ID (smart meter / energy gateway), transaction timestamp, transaction electricity volume (user consumption or power generation), transaction amount, transaction data link stability index, and energy consumption deviation value. Calculate each transaction data 's unique hash value , ensuring data integrity. Use the Merkle tree structure to store transaction hash values to improve query efficiency.

[0058] The transaction data is broadcast to the blockchain network and handed over to multiple verification nodes for consensus verification (such as PoW, PoS, or PBFT consensus mechanisms). After verifying the authenticity and uniqueness of the data through the consensus mechanism, the transaction is confirmed and written into the blockchain ledger.

[0059] After being uploaded to the chain, the smart contract automatically executes the preset energy transaction rules, such as: calculating the transaction amount : ; Fund settlement: Deduct the transaction amount from the purchaser's account and transfer it to the seller's account. Calculate the settlement handling fee (such as 1%): .

[0060] After the transaction is successful, the smart contract updates the transaction status to "settled" to ensure that the transaction cannot be tampered with or revoked. When the transaction fails (such as insufficient account balance), the smart contract will roll back the transaction and notify the relevant parties.

[0061] Each energy trading device (such as a smart meter, PV inverter) needs to maintain the most recent transaction status, including: the latest transaction timestamp, cumulative transaction electricity volume, and cumulative transaction amount. The device status data is synchronized to the blockchain ledger to ensure data traceability.

[0062] Deposit the transaction details into a decentralized storage (such as IPFS) for subsequent auditing and data analysis. The transaction records can be queried by users to ensure the transparency and fairness of the energy market.

[0063] After all transaction data are uploaded to the blockchain, the smart contract executes the settlement and updates the device status, the system will enter the next time window to continue monitoring new energy transaction data, ensuring the continuous operation of the entire transaction network and the security and credibility of the data.

[0064] Example 2, please refer to Figure 2 As shown, an energy transaction protection system based on blockchain online transactions in this embodiment includes a data acquisition module, a credibility evaluation module, a comparative analysis module, a data isolation module, and a smart contract execution module; Data acquisition module: Obtain the energy transaction data corresponding to the energy transaction device, and establish an energy data change curve ET based on historical transaction records and device status. Obtain the energy data at the corresponding moment on ET every preset time interval to form an energy data sequence E; Credibility evaluation module: Verify the data integrity of the energy data sequence E, establish an energy data credibility evaluation model based on multi-source data fusion, and mark abnormal data with low credibility according to the evaluation results; Comparative analysis module: If the data points in the energy data sequence E are abnormal, trigger the traceability mechanism, trace back the data generation process, and compare with the data of adjacent energy transaction devices to determine whether the abnormality is caused by malicious tampering; Data isolation module: If the traceability result shows that the data points are maliciously tampered with, trigger the blockchain smart contract to isolate the abnormal data, and start the abnormal transaction freezing strategy to prevent the tampered data from entering the final transaction settlement; Smart contract execution module: If the credibility of all data in E meets the set threshold, upload the transaction data to the blockchain, and execute the energy transaction settlement through the smart contract, while updating the device status and energy transaction records.

[0065] The above formulas are all dimensionless and take their numerical values for calculation. The formulas are obtained by collecting a large amount of data for software simulation to get a formula closest to the actual situation. The preset parameters in the formulas are set by those skilled in the art according to the actual situation.

[0066] It should be understood that the term "and / or" in this text is merely a description of the associated relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. Here, A and B can be singular or plural. Additionally, the character " / " in this text generally indicates an "or" relationship between the associated objects before and after, but it may also represent an "and / or" relationship, which can be specifically understood by referring to the context before and after.

[0067] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in this text can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.

[0068] As described above, the above are only specific embodiments of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art within the technical scope disclosed in this application can easily think of changes or substitutions, which should all be covered within the protection scope of this application.

Claims

1. An energy trading protection method based on blockchain online transactions, characterized in that: Including: Obtain the energy trading data corresponding to the energy trading device, establish an energy data change curve ET based on historical trading records and device status, and obtain the energy data at the corresponding moment on ET every preset time interval to form an energy data sequence E; Perform data integrity verification on the energy data sequence E, establish an energy data credibility evaluation model based on multi-source data fusion, and according to the evaluation results, mark abnormal low-credibility data; If there are data points in the energy data sequence E with anomalies, the traceability mechanism is triggered to trace back the data generation process and compare it with the data of adjacent energy trading devices to determine whether the anomalies are caused by malicious tampering; If the traceability result indicates that the data point has been maliciously tampered with, the blockchain smart contract will be triggered to isolate the abnormal data, and the abnormal transaction freezing strategy will be activated to prevent the tampered data from entering the final transaction settlement; If the credibility of all data in E meets the set threshold, then upload the trading data to the blockchain, and execute energy trading settlement through a smart contract, and at the same time update the device status and energy trading records.

2. The energy trading protection method based on blockchain online trading according to claim 1, characterized in that: The energy trading device includes but is not limited to smart meters, photovoltaic power generation inverters, wind turbines, and energy storage devices, and collects energy trading data in real time through the device data interface, including power generation, power consumption, transaction amount, and transaction timestamp.

3. The energy trading protection method based on blockchain online trading according to claim 1, characterized in that: Establish an energy data credibility evaluation model based on multi-source data fusion. The multi-source data includes the stability index of the trading data link and the deviation value of energy consumption from the historical model. Normalize the stability index of the trading data link and the deviation value of energy consumption from the historical model so that they are both within [0,1], and calculate the energy data credibility score according to the normalized stability index of the trading data link and the deviation value of energy consumption from the historical model; The calculation expression of the energy data credibility evaluation model is as follows: ; In the formula, is the energy data credibility score, TLSI is the transaction data link stability index, ECD is the deviation value of energy consumption from the historical model, are the weight coefficients of the transaction data link stability index and the deviation value of energy consumption from the historical model, and are all greater than 0.

4. The energy trading protection method based on blockchain online trading according to claim 3, wherein: The method for obtaining the trading data link stability index is: calculate the initial trading data link stability index , and the expression is: ; where: represents the number of transactions without data loss or tampering in the most recent M trading data transmissions; represents the total amount of trading data in the most recent M transactions; set a time window to record the effective trading ratio at each time point t , and the calculation formula is: ; where: represents the number of transactions successfully completed within time t, represents the total number of transactions within time t, set a smoothing coefficient λ, and calculate the trading data link stability index, and the expression is: ; where: TLSI is the trading data link stability index.

5. A method for protecting energy transactions based on blockchain online transactions according to claim 4, characterized in that: The method for obtaining the deviation value of energy consumption from the historical model is: Set a time window Q to collect energy consumption data And the characteristics affecting energy consumption. Identify normal and abnormal data points by calculating the density around data points through DBSCAN, and calculate the similarity between data points using Euclidean distance , the expression is: ; where: Energy consumption value, Weather influence factor, Number of energy transactions; Divide all data points into core points, boundary points, and outlier points, and calculate the mean of all data points classified as normal clusters by DBSCAN. , calculate the deviation value between the energy consumption and the historical model, and the expression is: ; represents the actual energy consumption value at time t, and ECD is the deviation value between the energy consumption and the historical model.

6. The energy trading protection method based on blockchain online trading according to claim 5, characterized in that: Compare the obtained energy data credibility score with the pre-set energy credibility score threshold. If the energy data credibility score is greater than or equal to the pre-set energy credibility score threshold, classify the energy data as high-credibility energy data; if the energy data credibility score is less than the pre-set energy credibility score threshold, classify the energy data as low-credibility energy data, and mark the low-credibility data as abnormal.

7. A method for protecting energy transactions based on blockchain online transactions according to claim 1, characterized in that: The traceability mechanism uses blockchain hash comparison and adjacent device data comparison, specifically including: Search for trading records in the blockchain ledger, calculate the hash value of the currently stored data, and compare it with the hash value stored in the blockchain; Select adjacent energy trading devices and obtain the energy trading data with the same timestamp; Calculate the deviation MK between the abnormal data point and the average energy consumption of adjacent devices: ; where is the energy consumption data, is the average energy consumption of adjacent devices, is the standard deviation of the energy consumption of adjacent devices; If MK ≤ 2, it is considered that the data anomaly is caused by transmission error; if MK > 2, it is caused by malicious tampering.

8. A method for protecting energy transactions based on blockchain online transactions according to claim 7, characterized in that: If the traceability analysis shows that there is malicious tampering in the data point, trigger the blockchain smart contract to execute abnormal data isolation, specifically including: mark the abnormal data status as pending review and strip it from the normal transaction flow; freeze all transactions dependent on this data to prevent it from affecting the ledger settlement; record information such as device ID, transaction time, and upload node for attack traceability and anomaly analysis.

9. The energy trading protection method based on blockchain online trading according to claim 8, characterized in that: The above-mentioned transaction data is chained using the Merkle tree data structure, and transaction verification is carried out through the blockchain consensus mechanism. The transaction process is as follows: calculate the unique hash value of the transaction data; perform automatic settlement through the smart contract, calculate the transaction amount, deduct the transaction amount from the purchaser's account, and transfer it to the seller's account; after the transaction is successful, update the device status to ensure the traceability of the ledger data.

10. An energy trading protection system based on blockchain online trading, which is used to implement an energy trading protection method based on blockchain online trading according to any one of claims 1-9, and is characterized in that: It includes a data acquisition module, a credibility evaluation module, a comparative analysis module, a data isolation module, and a smart contract execution module; Data acquisition module: Obtain the energy transaction data corresponding to the energy transaction device, and establish an energy data change curve ET based on historical transaction records and device status. Obtain the energy data at the corresponding moment on ET every preset time interval to form an energy data sequence E; Credibility evaluation module: Verify the data integrity of the energy data sequence E, establish an energy data credibility evaluation model based on multi-source data fusion, and mark the low-credibility data as abnormal according to the evaluation results; Comparison and analysis module: If a data point in the energy data sequence E is abnormal, the traceability mechanism is triggered to trace back the data generation process and compare it with the data of adjacent energy trading devices to determine whether the abnormality is caused by malicious tampering; Data isolation module: If the traceability result indicates that the data point has been maliciously tampered with, the blockchain smart contract will be triggered to isolate the abnormal data, and the abnormal transaction freezing strategy will be activated to prevent the tampered data from entering the final transaction settlement; Smart contract execution module: If the credibility of all data in E meets the set threshold, chain the transaction data, execute the energy transaction settlement through the smart contract, and update the device status and energy transaction records at the same time.

Citation Information

Cited By

  • Block chain-based enterprise financing data security management system

    CN120430790A