Disclosure of Invention
The application provides a private data encryption method based on a block chain, which can improve the encryption effect of MTF (modulation transfer function) codes.
In a first aspect, the present application provides a blockchain-based private data encryption method, including:
determining characters affecting the coding encryption effect in the original data, and taking all the characters affecting the coding encryption effect as characters to be processed, wherein the positions of the characters in the characters to be processed are provided with continuous characteristics;
calculating the forward movement correction distance of each character in the characters to be processed in a character list;
and encoding the character to be processed based on the forward correction distance of each character in the character list, and encoding the other characters except the character to be processed in the original data based on the initial forward correction distance so as to obtain an encoding result.
In one embodiment, determining characters in the original data that affect the effect of encoding encryption includes:
and determining the character affecting the coding encryption effect in the original data based on the frequency of the character combination corresponding to the character at the current position in the original data.
In one embodiment, determining the character in the original data that affects the effect of encoding encryption based on the frequency of the character combination corresponding to the character in the current position in the original data includes:
obtaining the frequency of the character combination corresponding to the character at the current position in the original data based on the sum of the frequency of the character combination formed by the character at the current position in the original data and the n adjacent characters around;
if the frequency of the character combination corresponding to the character at the current position is larger than the preset value, determining that the character at the current position is the character affecting the coding encryption effect.
In one embodiment, calculating the forward correction distance for each of the characters to be processed includes:
determining the consistency relation between each character in the characters to be processed and a character list;
calculating a forward motion correction coefficient corresponding to each character in the characters to be processed based on the consistent relation between each character in the characters to be processed and the character list and the frequency of the character combination corresponding to each character;
and determining the forward correction distance of each character in the characters to be processed based on the forward correction coefficient corresponding to each character in the characters to be processed.
In one embodiment, determining a correspondence of each of the characters to be processed to the list of characters includes:
if the adjacent previous character of the jth position of the characters to be processed in the character list is the (j+1) th position of the characters to be processed, the consistent relation between the (j+1) th position of the characters and the j+1 th position of the characters and the character list is P1;
if the adjacent previous character of the jth position of the characters to be processed in the character list is the jth+2th position of the characters to be processed, the consistency relationship among the jth position of the characters, the jth+1th position of the characters, the jth+2th position of the characters and the character list is P2;
if the adjacent previous character in the character list of the j-th position in the characters to be processed is not the j+2-th position in the characters to be processed, the consistent relation among the j-th position characters, the j+1-th position characters and the character list is P3, and the consistent relation among the j+2-th position characters and the character list is 0.
In an embodiment, calculating the forward motion correction coefficient corresponding to each character in the characters to be processed based on the coincidence relation between each character in the characters to be processed and the character list and the frequency of the character combination corresponding to each character includes:
and calculating the product between the consistent relation between each character in the characters to be processed and the character list and the frequency of the character combination corresponding to each character, and carrying out normalization processing on the calculated product to obtain the forward motion correction coefficient corresponding to each character in the characters to be processed.
In one embodiment, determining the forward correction distance for each of the characters to be processed based on the forward correction coefficient corresponding to each of the characters to be processed includes:
calculating the forward movement distance correction of the character at the current position based on the forward movement correction coefficient corresponding to the character at the current position in the character to be processed and the forward movement correction distance of the character at the position before the character at the current position;
based on the difference between the forward movement distance of the character in the original character list and the forward movement distance correction value of the character in the current position, the forward movement correction distance of the character in the current position in the character to be processed is obtained, and further the forward movement correction distance of each character in the character to be processed is obtained.
In an embodiment, the method further comprises:
storing a secret key corresponding to the coding result; the key comprises a final character list after encryption is completed, a forward movement correction coefficient of each character in the characters to be processed and a forward movement correction distance of each character in the characters to be processed.
In one embodiment, the raw data includes resident health information.
The application has the beneficial effects that, unlike the prior art, the privacy data encryption method based on the block chain comprises the following steps: determining characters affecting the coding encryption effect in the original data, and taking all the characters affecting the coding encryption effect as characters to be processed; calculating the forward movement correction distance of each character in the characters to be processed in a character list; and encoding the character to be processed based on the forward correction distance of each character in the character list, and encoding the other characters except the character to be processed in the original data based on the initial forward correction distance so as to obtain an encoding result. The method of the application corrects the forward movement distance of the character affecting the coding encryption effect in the character list to obtain the forward movement correction distance of the character affecting the coding encryption effect in the character list, codes the character to be processed through the forward movement correction distance, and codes the other characters except the character to be processed in the original data based on the initial forward movement distance to obtain the coding result. Therefore, the exposure of the character combination relation can be reduced, and the coding encryption result can be improved.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The original data is generally encrypted using an MTF coding scheme. When the original data is encrypted, hiding is carried out according to the corresponding relation between the original characters and the index values. The hiding effect of the corresponding relation between the original characters and the index value is influenced by the relative position relation between the adjacent character combinations of the original data and the relative position relation between the corresponding characters in the character list, so that the application corrects the forward movement of the characters according to the consistent relation between the character combinations and the character list, and realizes the efficient encryption of the original data.
The counted health information is mainly represented as descriptions of different health indexes, and at the moment, a large number of repeated characters are contained in all corresponding data, so that the MTF is often utilized to carry out coding processing, and the encryption of the data is realized by hiding an initial list of the MTF.
The MTF coding mainly converts the characters into index values in a character corresponding list, and the same index value corresponds to different original characters at different coding positions through updating of the character list, so that the corresponding relation between the index values and the original characters is hidden, and encryption of the original characters is achieved. Since the update of the character list has a relation with the position of the character in the character list, the MTF code can obtain the original data through the reverse push of the character list, so the character list is required as a key in the encryption process.
In MTF encoding of the original data, the obtained encoding result is an index value of the corresponding character in the character list, and the encryption effect of the data depends only on the character list. And the updating of the character list has regularity relative to the character sequence of the original data, so that the MTF coding is dependent on the corresponding relation between the character list and the characters of the original data.
In the actual encoding process, the output encoding result is the index value of the character in the character list, and after outputting a one-bit character index value, the character is moved forward to the first bit of the character list, and at this time, for the adjacent characters of the original data, the corresponding characters are adjacent in the character list after encoding. Then, the same index value is output for the adjacent characters in the character list and adjacent to the original data, and the relative position relations of the corresponding characters in the character list before and after encoding are consistent.
Assuming that the character string is abcabd, the character list is abcd, and the encoding result is 123334. As shown in the following table (1):
watch (1)
As shown in the above example, for adjacent character cab in the original character string abcab, the character list is represented as bac before encoding, and at this time, the character cab advances in the order of cab in encoding, so that the index value corresponding to each character of character cab is consistent when encoding is performed, and the character list is represented as bac after encoding is performed, at this time, when cab characters repeatedly appear in the original data, the encoding result will repeatedly appear as a continuous consistent encoding result. Therefore, in the current encoding process, for the adjacent character combinations repeatedly appearing in the original data, the same number of continuous consistent codes are also represented in the encoding result, so that the encoding result also has the original character combination representation, and the original data character combination is exposed, so that the encoding result is easy to crack.
Based on the analysis, the application needs to correct the forward movement of repeated character combinations in the coding process according to the original data character combination relation, thereby avoiding the exposure of the original data character combinations by the coding result and improving the coding encryption effect. The present application will be described in detail with reference to the accompanying drawings and examples.
Referring to fig. 1, fig. 1 is a flowchart of an embodiment of a blockchain-based private data encryption method according to the present application, which specifically includes:
step S11: and determining characters affecting the coding encryption effect in the original data, and taking all the characters affecting the coding encryption effect as characters to be processed.
And the digital platform performs statistics of resident health information to obtain original data. The departments corresponding to the same region acquire statistical information data for unified management, and particularly, the statistical information data of the same region are encrypted and stored in the same node in a subsequent step by using a block chain technology.
In one embodiment, the characters in the original data that affect the effect of encoding encryption are determined based on the frequency of the character combinations corresponding to the characters in the current position in the original data. Specifically, the frequency of the character combination corresponding to the character at the current position in the original data is obtained based on the sum of the frequency of the character combination formed by the character at the current position in the original data and n adjacent characters around; if the frequency of the character combination corresponding to the character at the current position is larger than the preset value, determining that the character at the current position is the character affecting the coding encryption effect.
In the original data, since the repeated character combinations affect the coding encryption effect, in order to correct the forward movement of the character list of the repeated character combinations, the repeated character combinations and the corresponding combination frequencies in the original data need to be obtained first, and the character combinations formed by the same character at different positions have different frequencies. And marking the character at the current position in the original data as the character at the ith position, and obtaining the frequency of the character combination corresponding to the character at the ith position in the original data based on the sum of the frequencies of the character at the ith position and the character combination formed by n adjacent characters around. The frequency of character combinations corresponding to the character at the ith position isWherein->Frequency of character combination representing that the character at the i-th position corresponds to n characters adjacent to the i-th position,/th position>Representing the maximum extent of the searched character combinations, the present application sets +.>(experience value),>the frequency of the character corresponding to the i-th position is reflected by the frequency of the character corresponding to the i-th position and the surrounding different character combinations.
The greater the frequency of the character combinations is known, the greater the effect on the encryption effect, and at this time, characters at a plurality of positions affecting the coding encryption effect are determined by screening according to the frequency of the character combinations at each of the obtained positions. First, the maximum and minimum normalization method is adopted to normalize the frequency of the character combinations corresponding to the characters at all positionsNormalizing to obtain a result of->At this time will +.>And determining the characters at the corresponding positions as characters influencing the coding encryption effect, and then removing single independent character positions from the determined character positions, so that the screened character positions have continuous characteristics, and further obtaining the characters to be processed. I.e. the position of the character in the character to be processed has a continuous character. Wherein a preset value +.>(empirical values).
Step S12: and calculating the forward movement correction distance of each character in the characters to be processed in the character list.
And determining the character positions needing to carry out character forward correction in the original data by utilizing the frequency of character combinations at different positions, namely correcting the forward movement of the characters at the coding positions in the list when the original data is coded to the characters at the screened positions, so as to obtain the forward movement correction distance.
In the MTF coding process, an initial character list formed by corresponding characters of original data is firstly set, and the front-back sequence of the character list is generally determined according to the sequence from the big character frequency to the small character frequency. And then, according to the determined initial character list, character encoding is carried out on characters in the characters to be processed by combining the forward correction distance obtained after the forward correction of the characters corresponding to the screened character positions.
In one embodiment, referring to fig. 2, step S12 specifically includes:
step S21: and determining the consistent relation between each character in the characters to be processed and the character list.
In the encoding process, when the j-th position of the characters to be processed corresponds to the character, the j-th position of the characters to be processed is adjacent to the subsequent j+1 position and possibly adjacent to the j+2 position, and the position relation of the j-th position of the characters to be processed and the j+1 position or possibly continuous j+2 position corresponding character combination in the current character list is judged at the moment, so that the consistent relation of each character and the character list is determined.
The relative position relation between the character combination and the character list is mainly expressed as the adjacent relation of the characters in the character list, namely judging whether the previous character adjacent to the jth position of the characters to be processed in the character list is the (j+1) th position of the characters to be processed; if the adjacent previous character of the jth position of the characters to be processed in the character list is the j+1th position of the characters to be processed, the consistent relation between the j-th position of the characters and the j+1th position of the characters and the character list is P1. Otherwise, the coincidence relation between the characters at the j-th position and the characters at the j+1th position and the character list is 0.
If the adjacent previous character of the jth position of the characters to be processed in the character list is the jth+2th position of the characters to be processed, the consistency relationship among the jth position of the characters, the jth+1th position of the characters, the jth+2nd position of the characters and the character list is P2. If the adjacent previous character in the character list of the j-th position in the characters to be processed is not the j+2-th position in the characters to be processed, the consistent relation among the j-th position characters, the j+1-th position characters and the character list is P3, and the consistent relation among the j+2-th position characters and the character list is 0.
The maximum length of the searched character combination is 3, so that the consistency relationship between the character combination and the character list is thatWherein M is the number of characters in the same positional relationship, so +.>2 in the molecule indicates that the number of characters in the same positional relationship is 2, including the character of the j-th position andcharacters at j+1th position; />3 in the molecule represents that the number of characters of the same position relation is 3, and the characters comprise characters of the j position, characters of the j+1th position and characters of the j+2th position; />2 in the molecule indicates that the number of characters in the same positional relationship is 2, including the number of characters in the j-th position and the j+1-th position.
According to the steps, the consistent relation between all characters in the characters to be processed and the character list is determined, and at the moment, the consistent relation between the original data characters and the character list is mainly destroyed for character forward correction, so that exposure of the same coding result corresponding to the same repeated character combination to the original character combination relation is avoided, and the encryption effect of the original data is improved.
Step S22: and calculating the forward motion correction coefficient corresponding to each character in the characters to be processed based on the consistent relation between each character in the characters to be processed and the character list and the frequency of the character combination corresponding to each character.
In one embodiment, a product between a consistent relation between each character in the characters to be processed and the character list and a frequency of a character combination corresponding to each character is calculated, and normalization processing is performed on the calculated product to obtain a forward motion correction coefficient corresponding to each character in the characters to be processed.
For the character requiring forward correction, the higher the correspondence between the character and the character list, the greater the degree of forward correction. And the higher the frequency of the original data character combination, the greater the influence of the encoding result on the whole data, so the greater the degree of forward correction. Accordingly, the forward motion correction coefficient corresponding to each character in the characters to be processed is determined as follows:
;
wherein the method comprises the steps ofRepresenting the coincidence relation between the j-th position of the character to be processed and the character list,/->Frequency of character combination corresponding to the j-th position of the character to be processed is represented by +.>Representing the normalization function.
Specifically, the character advancing of the original data is known to need to advance the character to the first position of the character list, so that continuous characters in the original data are adjacent in the character list after advancing, and the repeated adjacent character combinations are consistent in coding result due to the adjacent corresponding characters in the character list, so that the original data combination relation is exposed. The forward correction factor obtained by the above procedure is used to mainly change the forward distance of the corresponding character, and the damaged character combination is not adjacent after forward movement.
Step S23: and determining the forward correction distance of each character in the characters to be processed based on the forward correction coefficient corresponding to each character in the characters to be processed.
Calculating the forward movement distance correction of the character at the current position based on the forward movement correction coefficient corresponding to the character at the current position in the character to be processed and the forward movement correction distance of the character at the position before the character at the current position; based on the difference between the forward movement distance of the character in the original character list and the forward movement distance correction value of the character in the current position, the forward movement correction distance of the character in the current position in the character to be processed is obtained, and further the forward movement correction distance of each character in the character to be processed is obtained.
The forward correction distance of each character in the characters to be processed is
;
Wherein the method comprises the steps ofRepresenting the forward distance of the j-th position corresponding character in the character to be processed in the character list of the original character,/>Forward motion correction coefficient of character representing j-th position in character to be processed, +.>Forward shift correction distance of character representing j-1 th position in character to be processed,/->The forward distance correction of the character representing the j-1 th position,the forward shift correction distance of the character representing the j-th position in the character to be processed. Wherein->Representing a rounding-up in whichI.e. the forward correction distance of the character in position 1 of the characters to be processed is equal to the forward correction distance of the character in position 1 in the original character list.
And correcting the forward movement distance of the character by utilizing the steps, avoiding the consistent coding of the repeated occurrence of the corresponding repeated character combination, thereby reducing the exposure of the character combination relation, simultaneously, the correction process is based on the forward movement distance of the previous character, and avoiding that the adjacent characters have the same coding result, thereby reducing the consistent relation between the coding result and the original character combination, and increasing the encryption effect of the original data.
Step S13: and encoding the character to be processed based on the forward correction distance of each character in the character list, and encoding the other characters except the character to be processed in the original data based on the initial forward correction distance so as to obtain an encoding result.
And determining the forward correction distance of each position character in the coding process according to the steps, performing MTF coding on the resident health information counted currently based on the determined forward correction distance, obtaining a coding result which is the ciphertext of the current encryption process, and finally, taking a character list after encryption as a secret key, and simultaneously, reserving the forward correction distance and a corresponding correction coefficient as the secret key. Namely, a secret key corresponding to the coding result is saved; the key comprises a final character list after encryption is completed, a forward movement correction coefficient of each character in the characters to be processed and a forward movement correction distance of each character in the characters to be processed. After encryption of the original resident health information is completed, the ciphertext data is stored in the corresponding same node.
The method corrects the character forward movement according to the consistent relation between the character combination and the character list, avoids the consistent coding of the repeated corresponding occurrence of the repeated character combination, reduces the exposure of the character combination relation and improves the encryption effect. The character forward correction distance is corrected based on the forward correction distance of the previous character, so that adjacent characters are prevented from having the same coding result, the consistency relation between the coding result and the original character combination is reduced, and the encryption effect of the original data is improved.
The foregoing is only the embodiments of the present application, and therefore, the patent scope of the application is not limited thereto, and all equivalent structures or equivalent processes using the descriptions of the present application and the accompanying drawings, or direct or indirect application in other related technical fields, are included in the scope of the application.