A data encryption method for an electricity meter
By using the combination technology of Hoffman tree and chaotic sequence in the data encryption method of the electricity meter, the statistical characteristics of the electrical energy data sequence before and after encryption are destroyed, and the problem of data statistical characteristics remain unchanged during encryption based on chaotic mapping is solved, and powerful security protection for electrical energy data is achieved.
Patent Information
- Application Number
- CN202510467770.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-15
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2045-04-15
AI Technical Summary
When encrypting the data sequence based on chaotic mapping, the statistical characteristics of the data in the data sequence before and after encryption remain unchanged, resulting in an attacker recovering some or all of the data sequences through statistical analysis, and then inferring the business secrets of the enterprise.
The electric energy data collected through the electric energy meter form an electric energy sequence, build a Hoffman tree, and continuously update the Hoffman tree with the chaotic sequence and encoded electric energy data, destroying the statistical characteristics of the electric energy data in the electric energy sequence before and after encryption, so that the encryption results have the ability to resist statistical analysis attacks.
It realizes efficient encryption of electrical energy data, destroys the possibility of attackers recovering data through statistical analysis, enhances the security of electrical energy data, and protects the business secrets of enterprises.
Smart Images

Figure CN119995833B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data encryption. More specifically, the present invention relates to a data encryption method for an electric energy meter. Background Art
[0002] The electric energy metering supervision system is a high-tech intelligent power consumption information acquisition system integrating intelligent meters, communication networks, and computer technologies. It mainly aims at accurately measuring, classifying and statistically analyzing the electric energy for college teaching and office work, enterprise production and operation, and shop lease management, etc., clarifying the energy consumption situation, assessing the energy consumption indicators, monitoring the abnormal energy consumption, and carrying out energy-saving transformation, so that the management personnel at all levels of the electricity-consuming unit can easily monitor and manage the electricity consumption of each department of the unit regardless of time and place.
[0003] In the electric energy metering monitoring and management system, the electric energy data collected by the electric energy meter is transmitted to the system master station through the communication channel, so that the system can display the electric energy data in various ways such as curve charts and bar charts, providing comprehensive power consumption analysis for users.
[0004] In enterprise production and operation, the electric energy data can reflect business secrets such as the production plan and equipment operation status of the enterprise. Therefore, it is necessary to encrypt the electric energy data to ensure that the electric energy data is not accessed and stolen without authorization.
[0005] Due to its pseudo-randomness, sensitivity to initial conditions, non-periodicity, and long-term unpredictability, chaotic mapping is suitable for encrypting data sequences with a large amount of data; encrypting the data sequence based on chaotic mapping is achieved by scrambling the positions of the data in the data sequence. The scrambling only changes the positions of the data in the data sequence, while the values of the data in the data sequence do not change. Therefore, the statistical characteristics of the data in the data sequence remain unchanged before and after encryption; attackers can infer the information in the data sequence before encryption through statistical analysis attacks on the encrypted data sequence, and may even recover part or all of the data sequence, and then speculate on some or all of the business secrets such as the production plan and equipment operation status of the enterprise. Summary of the Invention
[0006] To solve the technical problem that when encrypting a data sequence based on a chaotic map, the statistical characteristics of the data in the data sequence before and after encryption remain unchanged, resulting in an attacker being able to recover part or all of the data sequence through statistical analysis attacks and then inferring the enterprise's trade secrets, the present invention provides a data encryption method for an electric energy meter, including: collecting electric energy data through the electric energy meter, and forming an electric energy sequence from the electric energy data collected within a unit time period; obtaining the initial frequencies of all basic values according to the electric energy data in the electric energy sequence, and constructing a Huffman tree through the initial frequencies of all basic values; generating a chaotic sequence according to the key agreed upon between the electric energy meter and the system master station and a one-dimensional chaotic map; during the process of encoding the electric energy sequence through the Huffman tree, when the th updated Huffman tree is used to complete the encoding of the th to the th electric energy data, being the length of the encoding period, the th updated Huffman tree is updated for the th time, including: calculating the influence degree of the movement of each subtree in the th updated Huffman tree on the encryption result according to the encoded electric energy data, determining the node to be moved during the th update according to the chaotic sequence, and swapping the positions of the subtree with the greatest influence degree and the node to be moved to obtain the th updated Huffman tree; until the encoding of all electric energy data in the electric energy sequence is completed, taking the encoding result of the obtained electric energy sequence as the encryption result of the electric energy sequence, so as to realize the encryption of the electric energy data collected by the electric energy meter.
[0007] During the process of encoding the electric energy sequence through the Huffman tree in the present invention, by combining the chaotic sequence and the encoded electric energy data, the Huffman tree is continuously updated, destroying the statistical characteristics of the electric energy data in the electric energy sequence before and after encryption, enabling the encryption result of the electric energy sequence to have the ability to resist statistical analysis attacks, and at the same time enabling the encryption result of the electric energy sequence to have an avalanche effect, destroying the possibility for an attacker to find clues from the change relationship before and after encryption, thereby effectively resisting differential analysis attacks; further protecting the electric energy data from unauthorized access and theft, and protecting the enterprise's trade secrets such as production plans and equipment operation status.
[0008] Preferably, the electric energy data collected by the electric energy meter includes electric energy, voltage, current, power, power factor, and neutral line current.
[0009] Preferably, obtaining the initial frequencies of all basic values according to the electrical energy data in the electrical energy sequence includes: taking the electrical energy data with the same value in the electrical energy sequence as a basic value; and counting the number of times the electrical energy data equal to each basic value appears in the electrical energy sequence as the initial frequency of each basic value.
[0010] Preferably, generating a chaotic sequence according to the key agreed upon by the electricity meter and the system master station and one-dimensional chaotic mapping includes: the electricity meter and the system master station jointly agreeing on a key according to the initial conditions of the one-dimensional chaotic mapping; using the key as the initial condition of the one-dimensional chaotic mapping, and iterating the calculation formula of the one-dimensional chaotic mapping for times to obtain chaotic values, where is a preset value used to distinguish regular chaotic values from irregular chaotic values; removing the first regular chaotic values and retaining the remaining irregular chaotic values, and forming a sequence of the chaotic values from the th to the th as the chaotic sequence; where is the number of all electrical energy data in the electrical energy sequence, is the length of the coding period, and
[0011] is the floor function.
[0012] According to the initial conditions of the one-dimensional chaotic mapping, the present invention agrees on different keys for different electricity meters and system master stations, increasing the difficulty of brute-force cracking by attackers and thus improving the security of electrical energy data.
[0013] Preferably, in the process of encoding the electrical energy sequence through the Huffman tree, first encode the electrical energy data from the th to the th through the initial Huffman tree. After completing the encoding of the electrical energy data from the th to the th, perform the nd update on the initial Huffman tree. Calculate the influence degree of the movement of each subtree in the initial Huffman tree on the encryption result according to the encoded electrical energy data, determine the node to be moved during the th update according to the chaotic sequence, and swap the position of the subtree with the largest influence degree and the node to be moved to obtain the Huffman tree after the th update.
[0014] Preferably, the step of determining the first The nodes moved during the update include: For the initial Huffman tree, obtain the set of all leaf nodes in the initial Huffman tree and record it as the set ; For the subtree with the greatest influence, obtain the set of all leaf nodes in the subtree with the greatest influence and record it as the set ; Get the collection Pair Collection The relative complement of ; For relative complement All leaf nodes in , among which leaf node, as the The nodes that were moved during the update, is the first Chaos value, To round down.
[0015] Preferably, the step of determining the first The nodes moved during the update include: After the Huffman tree is updated, we get The set of all leaf nodes in the Huffman tree after the update is recorded as the set ; For the subtree with the greatest influence, obtain the set of all leaf nodes in the subtree with the greatest influence and record it as the set ; Get the collection Pair Collection The relative complement of ; For relative complement All leaf nodes in , among which leaf node, as the The nodes that were moved during the update, is the first Chaos value, To round down.
[0016] The present invention utilizes the pseudo-randomness, unpredictability and extreme sensitivity to initial conditions of chaotic mapping to determine the first sequence The nodes that are moved during the first update increase the difficulty of brute force cracking by attackers, thereby improving the security of power data.
[0017] Preferably, the initial Huffman tree / first The influence degree on the encryption result when each subtree in the Huffman tree after the next update is moved, including: ; In the formula, is the influence degree on the encryption result when the subtree is moved, is the number of all leaf nodes on the subtree, is the number of all leaf nodes on the initial Huffman tree, is for the initial frequency of the basic value corresponding to the th leaf node on the subtree, is the frequency of the basic value corresponding to the th leaf node on the subtree in the encoded power data, which refers to the number of power data equal to the th basic value in the encoded power data, is for the basic value corresponding to the th leaf node on the subtree, is the last th power data in all the encoded power data; represents the absolute value taking function.
[0018] The present invention combines the difference between the basic value and the latest encoded power data, and the difference between the initial frequency of the basic value and the frequency in the encoded power data, to represent the probability that the subsequent power data waiting to be encoded is equal to the basic value corresponding to each leaf node on the subtree, so as to ensure that updating the Huffman tree by moving the subtree can have an impact on the power sequence faster.
[0019] Preferably, the method further includes: storing the initial frequencies of all basic values and the length of the coding period as decryption information.
[0020] Storing the decryption information by the present invention can ensure the decryptability of the encryption result of the power sequence.
[0021] The beneficial effects of the present invention are as follows:
[0022] The present invention destroys the statistical characteristics of the power data in the power sequence before and after encryption, so that the encryption result of the power sequence has the ability to resist statistical analysis attacks, and at the same time makes the encryption result of the power sequence have an avalanche effect, destroying the possibility for the attacker to find clues from the change relationship before and after encryption, thereby effectively resisting differential analysis attacks; furthermore, it protects the power data from unauthorized access and theft, and protects business secrets such as the production plan and equipment operation status of the enterprise. Brief Description of the Drawings
[0023] Figure 1 is a flowchart schematically showing a data encryption method for an electric energy meter in the present invention;
[0024] Figure 2 is a schematic diagram schematically showing an initial Huffman tree;
[0025] Figure 3 is schematically showing Figure 2 a schematic diagram of all subtrees of the initial Huffman tree shown;
[0026] Figure 4 is schematically showing the schematic diagram of the Huffman tree after the
[0027] Figure 5 is schematically showing Figure 4 the schematic diagram of all subtrees of the Huffman tree after the
[0028] Figure 6 is schematically showing the schematic diagram of the Huffman tree after the Detailed implementation manners
[0029] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts shall fall within the protection scope of the present invention.
[0030] Next, the detailed implementation manners of the present invention will be described in detail in conjunction with the accompanying drawings.
[0031] An embodiment of the present invention discloses a data encryption method for an electric energy meter. Referring to Figure 1 , it includes steps S1 to S4:
[0032] S1. Collect electric energy data through an electric energy meter, and form an electric energy sequence with the electric energy data collected within a unit time period.
[0033] Specifically, collect electric energy data through an electric energy meter. The electric energy data collected by the electric energy meter includes electric energy, voltage, current, power, power factor, and neutral line current. Among them, the unit of electric energy is usually kilowatt-hour (kWh), the unit of voltage is volt (V), the units of current and neutral line current are ampere (A), the unit of power is watt (W) and kilowatt (kW), and the value range of the power factor is between [0, 1]. The closer the power factor is to 1, the higher the ratio of the active power to the apparent power in the circuit, and the higher the electric energy utilization efficiency.
[0034] Among them, the measurement accuracy of electrical energy data varies depending on the application scenario; the measurement of electrical energy and power factor is usually accurate to two or three decimal places, and the measurement of voltage, current, power, and neutral line current is usually accurate to one or two decimal places.
[0035] Furthermore, the sequence of electrical energy data collected within a unit time is used as the electrical energy sequence; in this embodiment, the unit time is set to one day.
[0036] S2. Obtain the initial frequencies of all basic values according to the electrical energy data in the electrical energy sequence for constructing a Huffman tree.
[0037] Specifically, the electrical energy data with the same value in the electrical energy sequence is used as a basic value; the number of times the electrical energy data equal to each basic value appears in the electrical energy sequence is counted as the initial frequency of each basic value.
[0038] Exemplarily, the electrical energy sequence is {107, 103, 106, 103, 101, 102, 105, 104, 103, 105, 106, 107, 101, 102, 101, 105, 107, 105, 106, 105, 102, 107, 103, 105, 102, 105, 107, 102, 103, 104, 106, 105, 107, 107, 101, 102, 102, 103, 105, 101, 102, 105, 107, 105, 106}, and the number of all electrical energy data in the electrical energy sequence is equal to 45; the electrical energy data with the same value in the electrical energy sequence is used as a basic value, so there are 7 basic values of 101, 102, 103, 104, 105, 106, and 107, and the initial frequencies of these 7 basic values are 5, 8, 6, 2, 11, 5, and 8 respectively.
[0039] Furthermore, construct a Huffman tree according to the initial frequencies of all basic values. This Huffman tree is the initial Huffman tree, and the number of all leaf nodes on the initial Huffman tree is equal to the number of all basic values; among them, the Huffman tree is a binary tree. Therefore, the nodes in the Huffman tree are divided into leaf nodes and branch nodes. A leaf node refers to a node without a subtree, and the nodes corresponding to each basic value are all leaf nodes. A branch node refers to a node with a subtree.
[0040] Exemplarily, according to the initial frequencies 5, 8, 6, 2, 11, 5, and 8 of the 7 basic values of 101, 102, 103, 104, 105, 106, and 107, the schematic diagram of constructing the initial Huffman tree is as Figure 2As shown, the number of all leaf nodes on the initial Huffman tree is equal to 7, and the encoding results of these 7 basic values are 1101, 111, 011, 1100, 10, 010, and 00 respectively.
[0041] S3. Generate a chaotic sequence according to the key agreed upon by the electricity meter and the system master station and the one-dimensional chaotic mapping.
[0042] It should be noted that for chaotic mapping, due to its characteristics such as pseudo-randomness, unpredictability, and extreme sensitivity to initial conditions, it is used to set keys, and the keys obtained according to chaotic mapping are difficult to be cracked, with high security.
[0043] The initial conditions of the one-dimensional chaotic mapping include the initial value and parameters. The electricity meter and the system master station jointly agree on a key according to the initial conditions of the one-dimensional chaotic mapping, which is used to encrypt the electricity data collected by the electricity meter and for the system master station to decrypt the obtained encrypted result; specifically, within the value range of the initial value and parameters, a set of combinations of the initial value and parameters is randomly generated as the key.
[0044] Among them, the one-dimensional chaotic mapping includes but is not limited to Logistic chaotic mapping, Singer chaotic mapping, Cubic chaotic mapping, Sine chaotic mapping, Tent chaotic mapping, Sinusoidal chaotic mapping, Piecewise chaotic mapping. These chaotic mappings are all well-known technologies and will not be elaborated here.
[0045] Exemplarily, in the initial conditions of the Logistic chaotic mapping, the value range of the initial value is , and the value range of the parameter is ; in the initial conditions of the Singer chaotic mapping, the value range of the initial value is , and the value range of the parameter is .
[0046] It should be noted that the keys agreed upon by different electricity meters and the system master station are different, increasing the difficulty of brute-force cracking by attackers, and thus improving the security of electricity data.
[0047] There are a total of electricity data in the electricity sequence, and the length of the encoding period is . Therefore, the entire encoding process contains a total of encoding periods; since each encoding period updates the Huffman tree once and each update requires the use of 1 chaotic value, the entire encoding process requires a total of chaotic values, which requires the length of the chaotic sequence to be equal to .
[0048] In addition, since the first 30 chaotic values generated according to the secret key and the one-dimensional chaotic mapping are regular, which will assist the attacker in brute-forcing the secret key, in this embodiment, the first (required to be greater than 30) regular chaotic values are deleted, and the remaining chaotic values without regularity are retained, thereby obtaining a chaotic sequence composed of chaotic values without regularity, which increases the difficulty for the attacker to brute-force the secret key.
[0049] In summary, according to the secret key agreed upon by the electricity meter and the system master station and the one-dimensional chaotic mapping, a chaotic sequence is generated; specifically, the secret key is used as the initial condition of the one-dimensional chaotic mapping, and the calculation formula of the one-dimensional chaotic mapping is iterated times to obtain chaotic values, where is the number of all electricity data in the electricity sequence, is the length of the coding period, then represents the number of times to update the Huffman tree, is the floor function, is a preset value used to distinguish regular chaotic values and chaotic values without regularity; the first regular chaotic values are removed, and the remaining chaotic values without regularity are retained, and the sequence composed of the th to the th chaotic values is used as the chaotic sequence, thereby obtaining a chaotic sequence without regularity; therefore, the length of the obtained chaotic sequence is equal to .
[0050] Among them, the length of the coding period and the preset value can be set according to the actual application scenario and requirements, and the value range of the length of the coding period is [3, 10]. Since the first 30 chaotic values in the one-dimensional chaotic mapping are regular, in order to obtain a chaotic sequence without regularity, it is required that the preset value is an integer greater than 30. In the present invention, the length of the coding period is set to 5, and is set to 40.
[0051] S4. During the process of encoding the electricity sequence through the Huffman tree, in combination with the chaotic sequence and the already encoded electricity data, the Huffman tree is continuously updated until the encoding of all electricity data in the electricity sequence is completed, and the encrypted result of the electricity sequence is obtained, thereby realizing the encryption of the electricity data collected by the electricity meter.
[0052] Encoding the electricity data in the electricity sequence through the Huffman tree, after each encoding of For each electrical energy data, update the Huffman tree once. The specific process is as follows:
[0053] (1) Through the initial Huffman tree, encode the th electrical energy data to the th electrical energy data to obtain the encoding results of the th electrical energy data to the th electrical energy data.
[0054] (2) When encoding the th electrical energy data to the th electrical energy data through the initial Huffman tree, perform the th update on the initial Huffman tree to obtain the Huffman tree after the th update. The specific operation is as follows:
[0055] Calculate the influence degree of each subtree movement in the initial Huffman tree on the encryption result according to the encoded electrical energy data. Determine the node to be moved during the th update according to the chaotic sequence, and swap the subtree with the greatest influence degree with the node to be moved to obtain the Huffman tree after the th update.
[0056] Among them, each subtree in the initial Huffman tree refers to the subtree of each branch node in the initial Huffman tree.
[0057] (3) Through the Huffman tree after the th update, encode the th electrical energy data to the th electrical energy data to obtain the encoding results of the th electrical energy data to the th electrical energy data; where , is the number of all electrical energy data in the electrical energy sequence, is the length of the encoding period, is the floor function, is the length of the encoding period.
[0058] (4) When encoding the th electrical energy data to the th electrical energy data through the Huffman tree after the th update, perform the th update on the Huffman tree after the th update to obtain the Huffman tree after the th update. The specific operation is as follows:
[0059] Calculate according to the encoded electrical energy data, the The degree of influence on the encryption result when each subtree in the Huffman tree after the th update is moved. Determine the node that is moved at the th update according to the chaotic sequence, and swap the position of the subtree with the greatest degree of influence and the moved node to obtain the Huffman tree after the
[0060] th update. Among them, each subtree in the Huffman tree after the th update refers to the subtree of each branch node in the Huffman tree after the
[0061] th update.
[0062] (5) Repeat steps (3) and (4) until the encoding of all power data in the power sequence is completed. Thus, the encoding results of all power data in the power sequence are obtained.
[0063] Further, the sequence composed of the encoding results of all power data in the power sequence is used as the encryption result of the power sequence, thereby realizing the encryption of the power data collected by the electric energy meter. In addition, the initial frequencies of all basic values and the length of the encoding period
[0064] need to be stored as decryption information to ensure the decryptability of the encryption result of the power sequence.
[0065] It should be noted that in the process of encoding the power sequence through the Huffman tree in the present invention, by combining the chaotic sequence and the encoded power data, the Huffman tree is continuously updated. Even when encrypting power data with equal values in the power sequence, due to the continuous update of the Huffman tree, different Huffman trees are used to obtain the encoding results of power data with equal values, resulting in different encryption results for power data with equal values. Thus, the statistical characteristics of the power data in the power sequence before and after encryption change greatly. Even if an attacker conducts a statistical analysis attack on the encrypted power sequence, it is impossible to infer the information in the power sequence before encryption; therefore, the encryption result of the power sequence obtained by the encryption method of the present invention has a strong ability to resist statistical analysis attacks.
[0065] In steps (2) and (4), for any subtree in the initial Huffman tree / the Huffman tree after the th update, the calculation formula for the degree of influence of the subtree on the encryption result when it is moved is as follows:
[0066] ;
[0067] In the formula, is the degree of influence of the subtree on the encryption result when it is moved, is the number of all leaf nodes in the subtree, then the number of all affected basic values is equal to , is the number of all leaf nodes in the initial Huffman tree, is the -th initial frequency of the basic value corresponding to the leaf node in the subtree, is the -th frequency of the basic value corresponding to the leaf node in the subtree in the encoded power data, which refers to the number of power data equal to the -th basic value in the encoded power data, is the number of all power data in the power sequence, is the -th basic value corresponding to the leaf node in the subtree, is the -th last power data in all the encoded power data, , is the length of the coding period, is the minimum value function; represents taking the absolute value.
[0068] Among them, the -th basic value corresponding to the leaf node in the subtree and the subsequent power data in the encoded power data, the smaller the difference between them, the greater the probability that the power data to be encoded is equal to the -th basic value. Therefore, the weight for weighting the basic value is greater; represents the frequency of the basic value in the power data to be encoded. The larger this value is, the greater the impact on the encryption result when the subtree where the basic value is located is moved. In addition, under the same degree of influence, the fewer the leaf nodes on the moved subtree, the better. Therefore, the smaller the number of all leaf nodes in the subtree, the greater the impact on the encryption result when the subtree where the basic value is located is moved.
[0069] In step (2), the specific process of determining the node to be moved at the -th update according to the chaotic sequence is as follows: For the initial Huffman tree, obtain the set composed of all leaf nodes in the initial Huffman tree and denote it as set ; For the subtree with the greatest degree of influence, obtain the set composed of all leaf nodes in the subtree with the greatest degree of influence and denote it as set ; Obtain the set For the set The relative complement of The set For the set The relative complement of Consists of all leaf nodes that belong to the set but do not belong to the set That is , Is the leaf node in the relative complement For all leaf nodes in the relative complement Record the number of all leaf nodes as Take the th leaf node as the node to be moved during the th update Is the th chaotic value in the chaotic sequence Is the floor function
[0070] In step (4), the specific process of determining the node to be moved during the th update according to the chaotic sequence is as follows: For the Huffman tree after the th update, obtain the set composed of all leaf nodes in the Huffman tree after the th update and record it as the set ; For the subtree with the greatest influence, obtain the set composed of all leaf nodes in the subtree with the greatest influence and record it as the set ; Obtain the set The relative complement of the set is The set The relative complement of the set is Consists of all leaf nodes that belong to the set but do not belong to the set That is , Is the leaf node in the relative complement For all leaf nodes in the relative complement Record the number of all leaf nodes as Take the th leaf node as the node to be moved during the th update Is the th chaotic value in the chaotic sequence Is the floor function
[0071] Exemplarily, through such as Figure 2The initial Huffman tree shown encodes the electrical energy data in the electrical energy sequence {107, 103, 106, 103, 101, 102, 105, 104, 103, 105, 106, 107, 101, 102, 101, 105, 107, 105, 106, 105, 102, 107, 103, 105, 102, 105, 107, 102, 103, 104, 106, 105, 107, 107, 101, 102, 102, 103, 105, 101, 102, 105, 107, 105, 106}. After encoding every 5 electrical energy data, the Huffman tree is updated once. The specific process is as follows:
[0072] (1) For the initial Huffman tree shown, the encoding results of 7 basic values are 1101, 111, 011, 1100, 10, 010, 00 respectively. Through the initial Huffman tree, the Figure 2 th electrical energy data to the th electrical energy data in the electrical energy sequence, namely 107, 103, 106, 103, 101, are encoded to obtain the encoding results of the th electrical energy data to the th electrical energy data, which are 00, 011, 010, 011, 1101 respectively.
[0073] (2) For the initial Huffman tree shown, there are a total of 5 subtrees. The schematic diagrams of these 5 subtrees are shown in Figure 2 . For the first subtree among them, the number of all leaf nodes on this subtree is Figure 3 , the number of all leaf nodes on the initial Huffman tree is , the basic values corresponding to all leaf nodes on this subtree are , , , . The initial frequencies of these 3 basic values are 8, 5, 6 respectively. At this time, the encoded electrical energy data include the electrical energy data 107, 103, 106, 103, 101, and the last 5 encoded electrical energy data among all the encoded electrical energy data are 107, 103, 106, 103, 101. Therefore, , , , then the influence degree of the encryption result when this subtree is moved = + + = 0.624; Similarly, for the second to fifth subtrees among them, the influence degree of the encryption result when the subtree is moved = 0.464, =0.61, =0.469, =0.526。
[0074] (3) For the 5 subtrees in the initial Huffman tree, the subtree with the greatest influence among these 5 subtrees is the 1st subtree; at this time, there are 4 nodes that can be moved, namely the nodes corresponding to the basic values 105, 102, 104, and 101. According to the chaotic sequence, it is determined that the node to be moved during the th update is the 2nd node, that is, the node corresponding to the basic value 102. Swap the positions of the subtree with the greatest influence, that is, the 1st subtree, and the node to be moved, that is, the node corresponding to the basic value 102, to obtain the th updated Huffman tree. Then, the th updated Huffman tree is shown as Figure 4 shown.
[0075] (4) For the Huffman tree after the Figure 4 th update as shown, the encoding results of the 7 basic values are 1101, 0, 11111, 1100, 10, 11110, and 1110 respectively; through the Huffman tree after the th update, encode the th to the th electrical energy data in the electrical energy sequence 102, 105, 104, 103, 105 to obtain the encoding results of the th to the th electrical energy data, which are 0, 10, 1100, 11111, and 10 respectively.
[0076] (5) For the Huffman tree after the Figure 4 th update as shown, there are a total of 5 subtrees, and the diagrams of these 5 subtrees are as Figure 5 shown; for the 1st subtree among them, the number of all leaf nodes on this subtree , the number of all leaf nodes on the initial Huffman tree , the basic values corresponding to all leaf nodes on this subtree , , , , , , the initial frequencies of these 6 basic values are 11, 2, 5, 8, 5, and 6 respectively. At this time, the encoded power data includes power data 107, 103, 106, 103, 101, 102, 105, 104, 103, 105, and the last 5 power data among all the encoded power data are 102, 105, 104, 103, 105 respectively. Therefore, , , , , , , then the degree of influence on the encryption result when this subtree is moved = + + + + + = 0.432; similarly, for the 2nd to 5th subtrees among them, the degree of influence on the encryption result when the subtree is moved = 0.288, = 0.436, = 0.404, = 0.517.
[0077] (6) For the 5 subtrees in the Huffman tree after the th update, the subtree with the greatest degree of influence among these 5 subtrees is the 5th subtree; at this time, there are 5 nodes that can be moved, which are the nodes corresponding to the basic values 102, 105, 104, 101, and 107 respectively. According to the chaotic sequence, it is determined that the node to be moved during the th update is the 3rd node, that is, the node corresponding to the basic value 104. Swap the position of the subtree with the greatest degree of influence, that is, the 5th subtree, and the node to be moved, that is, the node corresponding to the basic value 104, to obtain the Huffman tree after the th update. Then, the schematic diagram of the Huffman tree after the th update is as shown in Figure 6 . For the Huffman tree after the Figure 6 th update as shown in , the encoding results of 7 basic values are 1101, 0, 11001, 1111, 10, 11000, 1110 respectively.
[0078] (7) And so on until the encoding of all power data in the power sequence is completed.
[0079] It should be noted that in the above process, the basic value 103 is in the initial Huffman tree, the Huffman tree after the th update, and the Huffman tree after the The encoding results in the Huffman tree after the nd update are 011, 11111, and 11001 respectively, all of which are different; the basic value 106 in the initial Huffman tree, the nd updated Huffman tree, and the
[0080] rd updated Huffman tree are 010, 11110, and 11000 respectively, all of which are different; this shows that in the process of continuously updating the Huffman tree, even if the electrical energy data with equal values in the electrical energy sequence is encrypted, due to the continuous update of the Huffman tree, the encoding results of the electrical energy data with equal values are different, so that the statistical characteristics of the electrical energy data in the electrical energy sequence before and after encryption change greatly. Even if an attacker conducts a statistical analysis attack on the encrypted electrical energy sequence, it is impossible to infer the information in the electrical energy sequence before encryption.
[0081] When it is necessary to view the electrical energy data, decrypt the encryption result of the electrical energy sequence according to the key agreed upon by the electric energy meter and the system master station. The specific steps are as follows:
[0082] (1) Construct a Huffman tree according to the initial frequencies of all basic values.
[0083] (2) Generate a chaotic sequence according to the key agreed upon by the electric energy meter and the system master station and one-dimensional chaotic mapping. (3) Decode the encryption result of the electrical energy sequence through the Huffman tree. After each electrical energy data is decoded, update the Huffman tree once.
[0084] During the process of decoding the encryption result of the electrical energy sequence through the Huffman tree, when the nd updated Huffman tree is used to decode and obtain the th to the th electrical energy data, perform the rd update on the rd updated Huffman tree, including: calculating the influence degree of the movement of each subtree in the rd updated Huffman tree on the encryption result according to the decoded electrical energy data, determining the node to be moved at the rd update according to the chaotic sequence, and swapping the position of the subtree with the greatest influence degree and the node to be moved to obtain the rd updated Huffman tree; until the electrical energy sequence composed of all decoded electrical energy data is obtained, so as to realize the decoding of the encryption result of the electrical energy data.
[0085] It should be noted that when encrypting the power sequence, the Huffman tree is continuously updated based on the encoded power data, and the remaining power data is encoded through the updated Huffman tree. Therefore, when decrypting the encryption result of the power sequence, it is also necessary to continuously update the Huffman tree based on the encoded power data in order to accurately decrypt the encryption result of the power sequence through the accurate Huffman tree. Therefore, if an attacker wants to brute-force crack the encryption result of the power sequence, even if one power data is wrongly decrypted, it will cause significant changes in the subsequent decryption results, making the encryption result of the power sequence have an avalanche effect, destroying the possibility for the attacker to find clues from the change relationship before and after encryption, thus effectively resisting differential analysis attacks.
[0086] Furthermore, it should be noted that the encryption result of the power sequence obtained by the encryption method of the present invention can resist statistical analysis attacks and differential analysis attacks, thereby protecting the power data from unauthorized access and theft, and protecting business secrets such as the production plan and equipment operation status of the enterprise.
Claims
1. A data encryption method for an electric energy meter, characterized in that: include: Collect electric energy data through electric energy meters, and organize the electric energy data collected within a unit time into an electric energy sequence; Obtaining initial frequencies of all basic values according to the electric energy data in the electric energy sequence, and constructing a Huffman tree through the initial frequencies of all basic values; Generate a chaotic sequence according to the key agreed upon between the electric energy meter and the system master station and a one-dimensional chaotic map; In the process of encoding the electric energy sequence through the Huffman tree, when the The Huffman tree after the update completes the to After encoding the electric energy data, is the length of the encoding cycle, The Huffman tree after the update is The update includes calculating the The degree of influence on the encryption result when each subtree in the Huffman tree after the update is moved, where: ; is the impact on the encryption result when the subtree is moved, is the number of all leaf nodes in the subtree, is the number of all leaf nodes in the initial Huffman tree, For the subtree The initial frequency of the basic value corresponding to the leaf node, For the subtree The frequency of the basic value corresponding to the leaf node in the encoded electric energy data indicates that the frequency of the basic value corresponding to the leaf node in the encoded electric energy data is equal to The number of basic value electric energy data, is the number of all electric energy data in the electric energy sequence, For the subtree The basic value corresponding to the leaf node, The last one among all the encoded electric energy data Electric energy data; is the minimum value function; Indicates taking the absolute value; according to the chaotic sequence, determine the The node that was moved during the first update is replaced by the subtree with the most influential node. Huffman tree after update; Until the encoding of all the electric energy data in the electric energy sequence is completed, the obtained encoding result of the electric energy sequence is used as the encryption result of the electric energy sequence to realize encryption of the electric energy data collected by the electric energy meter.
2. A data encryption method for an electric energy meter according to claim 1, characterized in that: The electric energy data collected by the electric energy meter includes electric quantity, voltage, current, power, power factor and neutral current.
3. A data encryption method for electric energy meter according to claim 1, characterized in that: The step of obtaining the initial frequencies of all basic values according to the electric energy data in the electric energy sequence includes: The electric energy data with the same value in the electric energy sequence is taken as a basic value; the number of times the electric energy data equal to each basic value appears in the electric energy sequence is counted as the initial frequency of each basic value.
4. A data encryption method for electric energy meter according to claim 1, characterized in that: The method generates a chaotic sequence according to a key agreed upon between the electric energy meter and the system master station and a one-dimensional chaotic map, including: The electric energy meter and the system master station jointly agree on a key based on the initial conditions of the one-dimensional chaotic mapping; The key is used as the initial condition of the one-dimensional chaotic map, and the calculation formula of the one-dimensional chaotic map is iterated. times, obtained Chaos value, is a preset value used to distinguish regular chaotic values from irregular chaotic values; The regular chaos values are removed, and the remaining An irregular chaos value, To A sequence composed of chaotic values is called a chaotic sequence; in, is the number of all electric energy data in the electric energy sequence, is the length of the encoding cycle, is the floor function.
5. A data encryption method for electric energy meter according to claim 4, characterized in that: The electric energy meter and the system master station jointly agree on a key according to the initial conditions of the one-dimensional chaotic mapping, including: The initial conditions of the one-dimensional chaotic mapping include initial values and parameters. Within the range of the initial values and parameters, a set of combinations of initial values and parameters are randomly generated as a key.
6. A data encryption method for electric energy meter according to claim 1, characterized in that: In the process of encoding the electric energy sequence through the Huffman tree, the first to Encode the electric energy data to complete the to After encoding the electric energy data, the initial Huffman tree is The first update, based on the encoded power data, calculates the impact of each subtree in the initial Huffman tree on the encryption result when it is moved, and determines the first The node that was moved during the first update is replaced by the subtree with the most influential node. Huffman tree after update.
7. A data encryption method for an electric energy meter according to claim 6, characterized in that: The method of determining the first The nodes moved during the update include: For the initial Huffman tree, obtain the set of all leaf nodes in the initial Huffman tree and record it as the set ; For the subtree with the greatest influence, obtain the set of all leaf nodes in the subtree with the greatest influence and record it as the set ; Get the collection Pair Collection The relative complement of ; For relative complement All leaf nodes in , among which leaf node, as the The nodes that were moved during the update, is the first Chaos value, To round down.
8. A data encryption method for electric energy meter according to claim 1, characterized in that: The method of determining the first The nodes moved during the update include: For After the Huffman tree is updated, we get The set of all leaf nodes in the Huffman tree after the update is recorded as the set ; For the subtree with the greatest influence, obtain the set of all leaf nodes in the subtree with the greatest influence and record it as the set ; Get the collection Pair Collection The relative complement of ; For relative complement All leaf nodes in , among which leaf node, as the The nodes that were moved during the update, is the first Chaos value, To round down.
9. A data encryption method for electric energy meter according to claim 1, characterized in that: The method further comprises: setting the initial frequencies of all basic values and the lengths of the coding periods , stored as decrypted information.
Citation Information
Patent Citations
Adaptive Huffman coding system and method
CN114900193A