Energy data security dynamic authentication method and system based on smart contract

The method enhances energy data security in smart contracts by using neighbor discretization and MD5 digest to reduce byte correlations, addressing vulnerabilities and ensuring secure authentication.

CN118473672BActive Publication Date: 2024-12-17ECONOMIC TECH RES INST OF STATE GRID HENAN ELECTRIC POWER +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410656695.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-24
Publication Date
2024-12-17
Estimated Expiration
2044-05-24

AI Technical Summary

Technical Problem

Energy data stored in smart contracts are vulnerable to attacks, leading to data tampering and forgery, resulting in low security.

Method used

A method and system for dynamic security authentication of energy data using smart contracts, involving data cleaning, neighbor discretization indexing, plaintext grouping, and MD5 information digest to reduce correlations between bytes, enhancing security through elementary transformations and authentication passwords.

Benefits of technology

Improves the security of energy data authentication by reducing correlations within plaintext groups, thereby preventing data tampering and ensuring secure access to energy data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118473672B_ABST
    Figure CN118473672B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of data security authentication, and in particular to a method and system for energy data security dynamic authentication based on smart contracts, the method comprising: collecting energy data sequences; obtaining neighbor energy data sequences and neighbor energy change sequences of each data point in the energy data sequence; constructing neighbor discretization indexes and plaintext information abnormal fluctuation indexes of each data point in the energy data sequence, calculating the horizontal neighbor byte difference index of each column byte and the vertical neighbor byte difference index of each row byte of the plaintext byte matrix; obtaining the plaintext byte change matrix, and then obtaining each plaintext information group, using the MD5 information digest algorithm to extract the information digest of energy information based on the plaintext information group, as the authentication password for energy data security authentication in the smart contract, and completing the security dynamic authentication of energy data. The present invention can ensure that the information digest has higher security and improve the security of dynamic authentication of energy data.
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 security authentication, and in particular to a method and system for dynamic energy data security authentication based on smart contracts. Background Art

[0002] With the development and construction of the energy industry, data and information technology continue to penetrate all aspects of energy industry production. The scale of various energy production data in the energy industry continues to grow rapidly, which has led to continuous changes in the production management methods of the energy industry. The ability to quickly and accurately obtain effective energy data and timely mine effective information has become an important competitive factor in the energy industry. Against the background of the growing scale of various energy production data in the energy industry, various energy data are usually stored securely in computers. In the subsequent scheduling, deployment and application of energy data stored in computers, access is allowed only through security certification related to smart contracts, in order to improve the security of energy data.

[0003] A smart contract refers to a computer protocol, which is generally considered to be a computer program. Once the program is developed and deployed, the computer can execute contract-related operations and generate corresponding verifiable evidence to illustrate the validity of the execution of the contract operations.

[0004] The traditional way to achieve dynamic authentication of energy data security is to deploy smart contract content and execute code through the Ethereum virtual machine, and the user interacts with the established contract on the user interface to achieve the purpose of security authentication. However, the energy data in the smart contract often has great security risks and is vulnerable to attacks by attackers, resulting in data tampering and data forgery, which leads to low security of energy data in the smart contract. Summary of the invention

[0005] In order to solve the above technical problems, the purpose of the present invention is to provide a method and system for energy data security dynamic authentication based on smart contracts. The technical solutions adopted are as follows:

[0006] In a first aspect, an embodiment of the present invention provides a method for dynamic security authentication of energy data based on a smart contract, the method comprising the following steps:

[0007] Collect multiple energy data and clean the data, and form an energy data sequence in the order of collection;

[0008] Obtain the neighbor energy data sequence and neighbor energy change sequence of each data point in the energy data sequence according to the sequence number and data difference of each data point in the energy data sequence; construct the neighbor discretization index of each data point in the energy data sequence according to the difference between each data point in the energy data sequence and the data in its neighbor energy data sequence; obtain the plaintext information variation fluctuation index of each data point in the energy data sequence according to the neighbor energy change sequence and the neighbor discretization index of each data point; obtain the plaintext grouping clustering cluster according to the plaintext information variation fluctuation index; obtain each group of initial plaintext and the corresponding plaintext byte matrix according to the plaintext grouping clustering cluster; obtain the horizontal neighbor byte difference index of each column byte and the vertical neighbor byte difference index of each row byte according to the relationship between the elements in the plaintext byte matrix; perform elementary transformation according to the horizontal neighbor byte difference index and the vertical neighbor byte difference index to obtain the plaintext byte change matrix of each group of initial plaintext;

[0009] Each plaintext information group is obtained according to the plaintext byte change matrix of each group of initial plaintext, and the information digest of the energy information is extracted based on the plaintext information group using the MD5 information digest algorithm, which is used as the authentication password for the security authentication of energy data in the smart contract to complete the secure dynamic authentication of energy data.

[0010] Preferably, the step of obtaining a neighboring energy data sequence and a neighboring energy change sequence of each data point in the energy data sequence according to the sequence number and data difference of each data point in the energy data sequence includes:

[0011] Mark each data point in the energy data sequence with a serial number starting from 1 in ascending order, calculate the Euclidean distance between each data point in the energy data sequence and the serial numbers of other data points, sort the Euclidean distances from small to large, select the data points corresponding to the first n Euclidean distances and arrange them in ascending order of serial numbers to form a neighbor energy data sequence for each data point in the energy data sequence;

[0012] The first-order difference sequence of the neighboring energy sequence of each data point in the energy data sequence is taken as the neighboring energy change sequence of each data point in the energy data sequence.

[0013] Preferably, the step of constructing a neighbor discretization index of each data point in the energy data sequence according to the difference between each data point in the energy data sequence and the data in its neighboring energy data sequence comprises:

[0014] The absolute value of the difference between each data point in the energy data sequence and each data point in its neighboring energy data sequence is calculated, and the average of the absolute values ​​of the difference between each data point in the energy data sequence and all data points in its neighboring energy data sequence is used as the neighbor discretization index of each data point in the energy data sequence.

[0015] Preferably, the method of obtaining the plaintext information abnormal variation fluctuation index of each data point in the energy data sequence according to the neighbor energy change sequence and the neighbor discretization index of each data point includes:

[0016] Calculate the information entropy of all data in the neighboring energy data sequence of each data point in the energy data sequence, and use the opposite number of the information entropy as the exponent of an exponential function with a natural constant as the base; calculate the mean of all data in the neighboring energy change sequence of each data point in the energy data sequence, and obtain the sum of the mean and the number 1; calculate the ratio of the calculation result of the exponential function to the sum, and obtain the difference between the number 1 and the ratio;

[0017] The product of the neighbor discretization index of each data point in the energy data sequence and the difference is used as the plaintext information anomaly fluctuation index of each data point in the energy data sequence.

[0018] Preferably, obtaining a plaintext grouping cluster according to the plaintext information abnormal fluctuation index includes:

[0019] A clustering algorithm is used to cluster the plaintext information anomaly fluctuation index of all data points in the energy data sequence, and each cluster is obtained. The mean of all plaintext information anomaly fluctuation indexes in each cluster is calculated, and the cluster with the largest mean is taken as the plaintext grouping cluster.

[0020] Preferably, the step of obtaining each group of initial plaintext and the corresponding plaintext byte matrix according to the plaintext grouping clusters includes:

[0021] The energy data corresponding to all plaintext information mutation fluctuation indexes in the plaintext grouping cluster are grouped into a plaintext grouping sequence in ascending order of the plaintext information mutation fluctuation index. The energy data in the plaintext grouping sequence are initially grouped in numerical order. The energy data from (1+64×0)th to (64+64×0)th in the plaintext grouping sequence are taken as the first group of initial plaintexts. The energy data from (1+64×1)th to (64+64×1)th in the plaintext grouping sequence are taken as the second group of initial plaintexts. The energy data from (1+64×2)th to (64+64×2)th in the plaintext grouping sequence are taken as the third group of initial plaintexts. This is repeated in this way to obtain each group of initial plaintexts in the plaintext grouping sequence.

[0022] For each group of initial plaintext, an 8×8 matrix composed of all energy data in the initial plaintext is used as the plaintext matrix of the initial plaintext. Each energy data in the plaintext matrix is ​​converted into binary using UTF-8 encoding technology. The matrix obtained after binary conversion of all energy data in the initial plaintext matrix is ​​used as the plaintext byte matrix of each group of initial plaintext.

[0023] Preferably, the step of obtaining the horizontal adjacent byte difference index of each column byte and the vertical adjacent byte difference index of each row byte according to the relationship between the elements in the plaintext byte matrix includes:

[0024] The horizontal adjacent byte difference index of the b-th column byte of the plaintext byte matrix of the j-th group of initial plaintext The expression is:

[0025]

[0026] Where Q represents the number of columns in the plaintext byte matrix of the jth group of initial plaintext, N represents the number of bytes in a column of the plaintext byte matrix of the jth group of initial plaintext, ED() represents the ED edit distance function, They represent the character strings represented by the cth byte in the bth column and the dth column of the plaintext byte matrix of the jth group of initial plaintext, respectively. δ() represents a judgment criterion. When the values ​​in the brackets are equal, δ() is 0, and when the values ​​in the brackets are not equal, δ() is 1.

[0027] The vertical adjacent byte difference index of the qth row byte of the plaintext byte matrix of the jth group of initial plaintext The expression is:

[0028]

[0029] Where F represents the number of rows in the plaintext byte matrix of the jth group of initial plaintext, G represents the number of bytes in a row of the plaintext byte matrix of the jth group of initial plaintext, Represents the string represented by the vth byte in the qth and pth row of the plaintext byte matrix of the jth group of initial plaintext.

[0030] Preferably, performing elementary transformation according to the horizontal adjacent byte difference index and the vertical adjacent byte difference index to obtain the plaintext byte change matrix of each group of initial plaintexts includes:

[0031] For each group of the plaintext byte matrix of the initial plaintext, count the columns where the smallest and second smallest horizontal adjacent byte difference indexes are located and the column where the largest horizontal adjacent byte difference index is located in the plaintext byte matrix, perform elementary column transformation on the plaintext byte matrix, use the columns where the smallest and second smallest horizontal adjacent byte difference indexes are located as the previous column and the next column of the column where the largest horizontal adjacent byte difference index is located in the plaintext byte matrix, respectively, and record the matrix after the elementary column transformation as an elementary column transformation matrix;

[0032] Count the rows with the smallest and second smallest vertical adjacent byte difference indexes and the row with the largest vertical adjacent byte difference index in the elementary column transformation matrix, perform elementary row transformation on the elementary column transformation matrix, use the rows with the smallest and second smallest vertical adjacent byte difference index as the previous row and next row of the row with the largest vertical adjacent byte difference index in the elementary column transformation matrix, respectively, and use the matrix after elementary row transformation of the elementary column transformation matrix as the plaintext byte change matrix of each group of initial plaintext.

[0033] Preferably, the obtaining each plaintext information group according to the plaintext byte change matrix of each group of initial plaintext includes:

[0034] For each group of initial plaintext byte change matrix, all bytes in the plaintext byte change matrix are combined into a plaintext information group in order from left to right and from top to bottom.

[0035] In the second aspect, an embodiment of the present invention also provides an energy data security dynamic authentication system based on smart contracts, including a memory, a processor, and a computer program stored in the memory and running on the processor, and when the processor executes the computer program, the steps of any one of the above methods are implemented.

[0036] The present invention has at least the following beneficial effects:

[0037] The present invention obtains neighbor energy data sequences and neighbor energy change sequences according to energy data, obtains neighbor discretization indexes according to neighbor energy data sequences and neighbor energy change sequences, obtains plaintext information abnormal change fluctuation indexes according to neighbor discretization indexes, obtains plaintext grouping clusters according to plaintext information abnormal change fluctuation indexes, obtains plaintext byte matrices according to plaintext grouping clusters, obtains horizontal neighbor byte difference indexes and vertical neighbor byte difference indexes according to the plaintext byte matrix, performs elementary transformation according to the horizontal neighbor byte difference indexes and vertical neighbor byte difference indexes to obtain plaintext byte change matrices, obtains plaintext information groups according to the plaintext byte change matrices, obtains information digests based on the plaintext information groups using MD5 information digest algorithm, and completes secure dynamic authentication of energy data through information digests;

[0038] A plaintext byte matrix is ​​constructed based on the abnormal fluctuation characteristics of plaintext information. By reducing the correlation between rows and columns of the plaintext byte matrix and the connection between adjacent bytes within the plaintext information group, the information summary has higher security, thereby improving the security of dynamic authentication of energy data. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0040] Figure 1 A flowchart of the steps of a method for dynamic energy data security authentication based on smart contracts provided by one embodiment of the present invention;

[0041] Figure 2 This is a schematic diagram of energy data security authentication. DETAILED DESCRIPTION

[0042] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the energy data security dynamic authentication method and system based on smart contracts proposed by the present invention, its specific implementation method, structure, features and effects are described in detail as follows in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.

[0043] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.

[0044] The specific scheme of the energy data security dynamic authentication method and system based on smart contract provided by the present invention is described in detail below with reference to the accompanying drawings.

[0045] See also Figure 1 , which shows a flowchart of a method for energy data security dynamic authentication based on smart contracts provided by an embodiment of the present invention, the method comprising the following steps:

[0046] Step S001, collecting energy data from the energy data storage library of the smart contract, and preprocessing the collected energy data.

[0047] In order to ensure the security of energy data, energy data is usually stored securely in a computer. In the subsequent scheduling, deployment and application of energy data stored in the computer, it is necessary to pass the security authentication related to the smart contract to be allowed to access, so as to improve the security of energy data in this way. In this embodiment, K energy data are collected from the energy data storage library of the smart contract, and the sequence composed of the collected energy data in the order of collection is used as the energy data information sequence, where the empirical value of K is 1000. In order to avoid missing, abnormal, and repeated data collection, the data in the energy data information sequence is cleaned using data cleaning technology, and the sequence after data cleaning is used as the energy data sequence. Data cleaning is a well-known technology, and the specific process will not be repeated.

[0048] At this point, the energy data sequence is obtained, which is used for the subsequent secure dynamic authentication of energy data.

[0049] Step S002, construct the neighbor discretization index and the plaintext information variation fluctuation index, obtain the plaintext grouping cluster, obtain the plaintext byte matrix, and then calculate the horizontal neighboring byte difference index and the vertical neighboring byte difference index, construct the plaintext byte change matrix, and obtain the plaintext information group.

[0050] In order to improve the security of dynamic authentication of energy data, it is necessary to extract information from the energy data sequence and complete the dynamic authentication of the user through the summary information after information extraction. Generally, the algorithm used for energy data security authentication in smart contracts requires irreversibility, and the summary information after information extraction is used as the credential for energy data security authentication in smart contracts, so as to improve the security of dynamic authentication of energy data and prevent energy data from being tampered with.

[0051] The traditional MD5 information digest algorithm, also known as the fingerprint algorithm, has the characteristics of fast running speed and irreversibility, and is widely used in the field of data security authentication. However, when the traditional MD5 information digest algorithm performs plaintext data grouping, it lacks a measure of the effectiveness of the results of plaintext data grouping. If the continuity between the data in the result after plaintext grouping is strong, the MD5 value extracted by the MD5 information digest algorithm has a greater risk of leakage. Therefore, in order to ensure the dynamic authentication of energy data security, it is necessary to improve the way of plaintext grouping in the MD5 information digest algorithm.

[0052] Furthermore, in order to reduce the correlation between the internal bytes after the plaintext grouping, it is necessary to analyze the data characteristics of the energy data sequence. Since the data mutation within the energy data sequence can effectively reduce the correlation between the energy data, improving the plaintext grouping based on the mutational plaintext data characteristics can effectively reduce the correlation between the internal bytes after the plaintext grouping.

[0053] Specifically, each data point in the energy data sequence is marked with a serial number, that is, the serial number of the first data in the energy data sequence is marked as 1, the serial number of the second data in the energy data sequence is marked as 2, the serial number of the third data in the energy data sequence is marked as 3, and so on, the serial number of the Kth data in the energy data sequence is marked as K, where K represents the number of all energy data in the energy data sequence. In order to analyze the change rules between the data in the energy data sequence, this embodiment will extract the neighbor energy data sequence of each data point based on the Euclidean distance between the serial numbers of each data point: calculate the Euclidean distance between each data point in the energy data sequence and the serial numbers of other data points, sort the Euclidean distance from small to large, and then select the data points corresponding to the first n Euclidean distances and arrange them in ascending order of serial numbers to form the neighbor energy data sequence of each data point.

[0054] Furthermore, the first-order difference sequence of the neighboring energy sequences of each data point in the energy data sequence is used as the neighboring energy change sequence of each data point in the energy data sequence, where n is taken as 10 in this embodiment and can be set by the implementer. The calculation of the first-order difference sequence is a well-known technology and the specific process will not be repeated here.

[0055] Furthermore, based on the above analysis, the plaintext information anomaly fluctuation index of each data point in the energy data sequence is calculated:

[0056]

[0057]

[0058] In the formula, A x represents the neighbor discretization index of the xth data point in the energy data sequence, a x Represents the value of the xth data point in the energy data sequence, a x,i represents the value of the ith data point in the neighboring energy data sequence of the xth data point in the energy data sequence, and n represents the number of the ith data point in the neighboring energy data sequence of the xth data point in the energy data sequence;

[0059] B x represents the plaintext information variation fluctuation index of the xth data point in the energy data sequence, exp() represents the exponential function with natural constant as the base, μ x represents the information entropy of all data in the neighboring energy data sequence of the xth data point in the energy data sequence, ρ x It represents the mean value of all data in the neighboring energy change sequence of the xth data point in the energy data sequence. It should be noted that the calculation of information entropy and mean value are both well-known technologies, and the specific process will not be repeated here.

[0060] Difference between values ​​|a x-a x,i The larger the | is, the greater the difference between the data point and the data points in the neighboring energy data sequence of the data point is, which to a certain extent reflects that the position of the data point in the energy data sequence fluctuates greatly, that is, the greater the difference between the data point and the adjacent data points, the greater the neighbor discretization index is;

[0061] Therefore, the neighbor discretization index A x The larger the value is, the greater the fluctuation of the data point in the energy data sequence is. x The larger the data mean ρ x The larger it is, the greater the degree of confusion of all data in the neighboring energy data sequence of the data point, and the larger the data mean in the neighboring energy change sequence. Since the neighboring energy change sequence is obtained by the neighboring energy data sequence to obtain the first-order difference sequence, that is, the data in the neighboring energy change sequence can reflect the growth change of the data in the neighboring energy data sequence, it means that the greater the growth change of the data in the neighboring energy data sequence, to a certain extent, the greater the degree of abnormal fluctuation of the energy data represented by the data point in the energy data sequence, and the greater the plaintext information abnormal fluctuation index.

[0062] Furthermore, based on the above analysis, the plaintext information anomaly fluctuation index of each data point in the energy data sequence is obtained. In order to obtain a better plaintext grouping result, further analysis is performed based on the plaintext information anomaly fluctuation index.

[0063] Specifically, the energy data is initially grouped based on the classification results of the plaintext information anomaly fluctuation index. The plaintext information anomaly fluctuation index of all data points in the energy data sequence is used as the input of the k-means clustering algorithm. In this embodiment, the preset parameter k is 2, and the output of the k-means clustering algorithm is used as the clustering result of the plaintext information anomaly fluctuation index of all data points in the energy data sequence. The clustering result includes 2 clusters, wherein the k-means clustering algorithm is a well-known technology, and the specific process is not repeated here.

[0064] Furthermore, the mean of all plaintext information mutation fluctuation indexes in each cluster is calculated, and the cluster with the largest mean is used as the plaintext grouping cluster. The mutation fluctuation index of all plaintext information in the plaintext grouping cluster represents the degree of fluctuation of the energy data represented by each data point in the energy data sequence. The greater the degree of fluctuation, the better it can reduce the correlation between plaintext information, thereby reducing the correlation between bytes after plaintext grouping. It should be noted that each plaintext information mutation fluctuation index in the plaintext grouping cluster corresponds to an energy data in the energy data sequence.

[0065] The energy data corresponding to all the plaintext information anomaly fluctuation indexes in the plaintext grouping cluster are taken as a sequence composed of the plaintext information anomaly fluctuation indexes in ascending order as the plaintext grouping sequence, and the energy data in the plaintext grouping sequence are initially grouped in the order of numerical arrangement, specifically: the energy data from the (1+64×0)th to the (64+64×0)th in the plaintext grouping sequence are taken as the first group of initial plaintexts, the energy data from the (1+64×1)th to the (64+64×1)th in the plaintext grouping sequence are taken as the second group of initial plaintexts, the energy data from the (1+64×2)th to the (64+64×2)th in the plaintext grouping sequence are taken as the third group of initial plaintexts, and so on, until the number of ungrouped energy data in the plaintext grouping sequence is less than 64.

[0066] Furthermore, for each group of initial plaintext, an 8×8 matrix composed of all energy data in the initial plaintext is used as the plaintext matrix of the initial plaintext, and each group of initial plaintext corresponds to a plaintext matrix. The UTF-8 encoding technology (Unicode Transformation Format-8) is used to perform 8-bit binary conversion on each energy data in the plaintext matrix to obtain each 8-bit binary byte, and the result of binary conversion of all energy data in the initial plaintext matrix is ​​used as the plaintext byte matrix of each group of initial plaintext, wherein the UTF-8 encoding technology is a well-known technology, and the specific process is not repeated here.

[0067] In the traditional MD5 information digest algorithm, the result after plaintext grouping is multiple 512-bit plaintext information groups. The present invention constructs the plaintext byte matrix of each group of initial plaintext by analyzing the volatility of plaintext information mutation, which has preliminarily reduced the correlation of plaintext information. Furthermore, it is necessary to analyze the plaintext byte matrix of each group of initial plaintext to obtain each 512-bit plaintext information group after the plaintext grouping.

[0068] Furthermore, in order to reduce the correlation between adjacent bytes in a plaintext information group, the plaintext byte matrix of each group of initial plaintext is analyzed horizontally and vertically, and the horizontal adjacent byte difference index of each column byte of the plaintext byte matrix of each group of initial plaintext and the vertical adjacent byte difference index of each row byte of the plaintext byte matrix of each group of initial plaintext are calculated:

[0069]

[0070]

[0071] In the formula, represents the horizontal adjacent byte difference index of the bth column byte of the plaintext byte matrix of the jth group of initial plaintext, Q represents the number of columns in the plaintext byte matrix of the jth group of initial plaintext, N represents the number of bytes in a column of the plaintext byte matrix of the jth group of initial plaintext, ED() represents the ED edit distance function, The string represented by the cth byte in the bth column of the plaintext byte matrix of the jth group of initial plaintext, The string represented by the cth byte in the dth column of the plaintext byte matrix of the jth group of initial plaintext, The ED edit distance between the string represented by the cth byte in the bth column of the plaintext byte matrix of the jth group of initial plaintext and the string represented by the cth byte in the dth column of the plaintext byte matrix is ​​represented. δ(b, d) represents a judgment criterion. When b=d, the value is 0, and when b≠d, the value is 1.

[0072] represents the longitudinal adjacent byte difference index of the qth row byte of the plaintext byte matrix of the jth group of initial plaintext, F represents the number of rows in the plaintext byte matrix of the jth group of initial plaintext, G represents the number of bytes in a row of the plaintext byte matrix of the jth group of initial plaintext, The string represented by the vth byte in the qth row of the plaintext byte matrix of the jth group of initial plaintext, The string represented by the vth byte in the pth row of the plaintext byte matrix of the jth group of initial plaintext, It represents the ED edit distance between the string represented by the vth byte in the qth row of bytes of the plaintext byte matrix of the jth group of initial plaintext and the string represented by the vth byte in the pth row of bytes. δ(q,p) represents a judgment criterion. When b=d, the value is 0, and when b≠d, the value is 1.

[0073] ED edit distance The larger the value is, the smaller the similarity between the strings is. To a certain extent, it reflects that the greater the difference between the bytes in this column and the bytes in other columns, the greater the difference index of the horizontal adjacent bytes.

[0074] In addition, ED edit distance The larger the value is, the smaller the similarity between the strings is. Since the comparison is between the changes in the row bytes in the plaintext byte matrix, it reflects to a certain extent that the difference between the row bytes and other row bytes is large, the vertical adjacent byte difference index is.

[0075] Furthermore, in order to reduce the correlation between adjacent bytes in the plaintext byte matrix, the security of the plaintext information group obtained by plaintext grouping is improved. For the plaintext byte matrix of each group of initial plaintext, the columns where the smallest and second smallest horizontal adjacent byte difference indexes are located and the column where the largest horizontal adjacent byte difference index is located in the plaintext byte matrix are counted, and the plaintext byte matrix is ​​subjected to elementary column transformation. The result after the elementary column transformation is that the columns where the smallest and second smallest horizontal adjacent byte difference indexes are located are respectively used as the previous column and the next column of the column where the largest horizontal adjacent byte difference index is located, and the matrix after the elementary column transformation is recorded as the elementary column transformation matrix; finally, the elementary column change matrix is ​​subjected to elementary row transformation. First, the rows where the smallest and second smallest vertical adjacent byte difference indexes are located and the row where the largest vertical adjacent byte difference index is located in the elementary column transformation matrix are counted, and the elementary column transformation matrix is ​​subjected to elementary row transformation, that is, the rows where the smallest and second smallest vertical adjacent byte difference indexes are located are respectively used as the previous row and the next row of the row where the largest vertical adjacent byte difference index is located in the elementary column transformation matrix, and the matrix after the elementary row transformation of the elementary column transformation matrix is ​​used as the plaintext byte change matrix of each group of initial plaintext.

[0076] Based on the above analysis, the correlation between columns and rows in the plaintext byte matrix is ​​reduced, and the two columns and rows with the smallest differences are disconnected respectively to avoid large correlation between rows or columns with small differences, thereby improving the security of the plaintext information group and thus improving the security of dynamic authentication of energy data.

[0077] Furthermore, for each group of initial plaintext byte change matrices, a sequence of all bytes in the plaintext byte change matrix in a left-to-right and top-to-bottom order is taken as a plaintext information group. It should be noted that each character consists of 8 bits of binary, and there are 64 characters in the plaintext information group, so each plaintext information group consists of 512 bits of binary numbers.

[0078] So far, each plaintext information group can be obtained according to the above process of this embodiment.

[0079] Step S003, using the MD5 information digest algorithm to obtain an information digest based on the plaintext information group, and completing the secure dynamic authentication of the energy data through the information digest.

[0080] Furthermore, all plaintext information groups are used as inputs to the MD5 information digest algorithm, which outputs the information digest of the energy data. The MD5 information digest algorithm is a well-known technology, and the specific process is not repeated here. The information digest of the energy data is used as the authentication password for energy data security authentication in the smart contract. Only when the user enters the correct authentication password can he get the permission to access the energy data, thereby improving the security of dynamic authentication of energy data. The schematic diagram of energy data security authentication is shown in the figure. Figure 2 shown.

[0081] Based on the same inventive concept as the above method, an embodiment of the present invention also provides an energy data security dynamic authentication system based on smart contracts, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, the steps of any one of the above-mentioned energy data security dynamic authentication methods based on smart contracts are implemented.

[0082] It should be noted that the sequence of the above embodiments of the present invention is only for description and does not represent the advantages and disadvantages of the embodiments. The above is a description of a specific embodiment of this specification. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0083] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.

[0084] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for dynamic security authentication of energy data based on smart contracts, characterized in that: The method comprises the following steps: Collect multiple energy data and clean the data, and form an energy data sequence in the order of collection; Obtain the neighbor energy data sequence and neighbor energy change sequence of each data point in the energy data sequence according to the sequence number and data difference of each data point in the energy data sequence; construct the neighbor discretization index of each data point in the energy data sequence according to the difference between each data point in the energy data sequence and the data in its neighbor energy data sequence; obtain the plaintext information variation fluctuation index of each data point in the energy data sequence according to the neighbor energy change sequence and the neighbor discretization index of each data point; obtain the plaintext grouping clustering cluster according to the plaintext information variation fluctuation index; obtain each group of initial plaintext and the corresponding plaintext byte matrix according to the plaintext grouping clustering cluster; obtain the horizontal neighbor byte difference index of each column byte and the vertical neighbor byte difference index of each row byte according to the relationship between the elements in the plaintext byte matrix; perform elementary transformation according to the horizontal neighbor byte difference index and the vertical neighbor byte difference index to obtain the plaintext byte change matrix of each group of initial plaintext; Obtain each plaintext information group according to the plaintext byte change matrix of each group of initial plaintext, and use the MD5 information digest algorithm to extract the information digest of energy information based on the plaintext information group, which is used as the authentication password for energy data security authentication in the smart contract to complete the secure dynamic authentication of energy data; The step of obtaining a neighboring energy data sequence and a neighboring energy change sequence of each data point in the energy data sequence according to the sequence number and data difference of each data point in the energy data sequence includes: Mark each data point in the energy data sequence with a serial number starting from 1 in ascending order, calculate the Euclidean distance between each data point in the energy data sequence and the serial numbers of other data points, sort the Euclidean distances from small to large, select the data points corresponding to the first n Euclidean distances and arrange them in ascending order of serial numbers to form a neighbor energy data sequence for each data point in the energy data sequence; The first-order difference sequence of the neighboring energy sequence of each data point in the energy data sequence is used as the neighboring energy change sequence of each data point in the energy data sequence; The method of obtaining the plaintext information abnormal variation fluctuation index of each data point in the energy data sequence according to the neighbor energy change sequence and the neighbor discretization index of each data point includes: Calculate the information entropy of all data in the neighboring energy data sequence of each data point in the energy data sequence, and use the opposite number of the information entropy as the exponent of an exponential function with a natural constant as the base; calculate the mean of all data in the neighboring energy change sequence of each data point in the energy data sequence, and obtain the sum of the mean and the number 1; calculate the ratio of the calculation result of the exponential function to the sum, and obtain the difference between the number 1 and the ratio; The product of the neighbor discretization index of each data point in the energy data sequence and the difference is used as the plaintext information abnormal fluctuation index of each data point in the energy data sequence; The obtaining of plaintext grouping clusters according to the plaintext information abnormal fluctuation index includes: A clustering algorithm is used to cluster the plaintext information anomaly fluctuation index of all data points in the energy data sequence, and each cluster is obtained. The mean of all plaintext information anomaly fluctuation indexes in each cluster is calculated, and the cluster with the largest mean is taken as the plaintext grouping cluster.

2. The energy data security dynamic authentication method based on smart contract as claimed in claim 1, characterized in that: The method of constructing a neighbor discretization index of each data point in the energy data sequence according to the difference between each data point in the energy data sequence and the data in its neighboring energy data sequence comprises: The absolute value of the difference between each data point in the energy data sequence and each data point in its neighboring energy data sequence is calculated, and the average of the absolute values ​​of the difference between each data point in the energy data sequence and all data points in its neighboring energy data sequence is used as the neighbor discretization index of each data point in the energy data sequence.

3. The energy data security dynamic authentication method based on smart contract as claimed in claim 1, characterized in that: The step of obtaining each group of initial plaintext and the corresponding plaintext byte matrix according to the plaintext grouping clustering clusters includes: The energy data corresponding to all the plaintext information mutation fluctuation indexes in the plaintext grouping cluster are grouped into plaintext grouping sequences in ascending order of the plaintext information mutation fluctuation indexes. The energy data in the plaintext grouping sequence are initially grouped in the order of numerical arrangement. to The energy data of each group is taken as the first group of initial plaintext, and the first group of plaintext in the group sequence is to The energy data of each group is used as the second initial plaintext group, and the first to The energy data of each group is taken as the third group of initial plaintext, and so on, to obtain the initial plaintext of each group of the plaintext grouping sequence; For each set of initial plaintext, all energy data in the initial plaintext will be The matrix is ​​used as the plaintext matrix of the initial plaintext, and each energy data in the plaintext matrix is ​​converted into binary using the UTF-8 encoding technology. The matrix obtained after the binary conversion of all energy data in the initial plaintext matrix is ​​used as the plaintext byte matrix of each group of initial plaintext.

4. The energy data security dynamic authentication method based on smart contract as claimed in claim 1, characterized in that: The step of obtaining the horizontal adjacent byte difference index of each column byte and the vertical adjacent byte difference index of each row byte according to the relationship between the elements in the plaintext byte matrix includes: The horizontal adjacent byte difference index of the b-th column byte of the plaintext byte matrix of the j-th group of initial plaintext The expression is: ; In the formula, represents the number of columns in the plaintext byte matrix of the jth group of initial plaintext, represents the number of bytes in a column of the plaintext byte matrix of the jth group of initial plaintext, represents the ED edit distance function, They represent the character strings represented by the cth byte in the bth and dth columns of the plaintext byte matrix of the jth group of initial plaintext, respectively. Indicates a judgment criterion. When the values ​​in the brackets are equal, is 0. When the values ​​in the brackets are not equal, is 1; The vertical adjacent byte difference index of the qth row byte of the plaintext byte matrix of the jth group of initial plaintext The expression is: ; In the formula, represents the number of rows in the plaintext byte matrix of the jth group of initial plaintext, The number of bytes in a row of the plaintext byte matrix representing the jth group of initial plaintext, Represents the string represented by the vth byte in the qth and pth row of the plaintext byte matrix of the jth group of initial plaintext.

5. The energy data security dynamic authentication method based on smart contract as claimed in claim 1, characterized in that: The step of performing elementary transformation according to the horizontal adjacent byte difference index and the vertical adjacent byte difference index to obtain the plaintext byte change matrix of each group of initial plaintexts includes: For each group of the plaintext byte matrix of the initial plaintext, count the columns where the smallest and second smallest horizontal adjacent byte difference indexes are located and the column where the largest horizontal adjacent byte difference index is located in the plaintext byte matrix, perform elementary column transformation on the plaintext byte matrix, use the columns where the smallest and second smallest horizontal adjacent byte difference indexes are located as the previous column and the next column of the column where the largest horizontal adjacent byte difference index is located in the plaintext byte matrix, respectively, and record the matrix after the elementary column transformation as an elementary column transformation matrix; Count the rows with the smallest and second smallest vertical adjacent byte difference indexes and the row with the largest vertical adjacent byte difference index in the elementary column transformation matrix, perform elementary row transformation on the elementary column transformation matrix, use the rows with the smallest and second smallest vertical adjacent byte difference index as the previous row and next row of the row with the largest vertical adjacent byte difference index in the elementary column transformation matrix, respectively, and use the matrix after elementary row transformation of the elementary column transformation matrix as the plaintext byte change matrix of each group of initial plaintext.

6. The energy data security dynamic authentication method based on smart contract as claimed in claim 1, characterized in that: The step of obtaining each plaintext information group according to the plaintext byte change matrix of each group of initial plaintext includes: For each group of initial plaintext byte change matrix, all bytes in the plaintext byte change matrix are combined into a plaintext information group in order from left to right and from top to bottom.

7. A smart contract-based energy data security dynamic authentication system, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.