Key storage method, device, equipment and storage medium
By sharding and storing keys to blockchain nodes, and using consensus node verification and feature identification to determine storage nodes, the problem of easy leakage of keys stored in a single node is solved, and high security and flexibility of keys are achieved. storage.
Patent Information
- Application Number
- CN202010212029.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-24
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2040-09-24
AI Technical Summary
In the existing technology, keys stored on blockchain nodes are easily leaked by illegal intruders, causing data security to be threatened. How to improve the security of key storage has become an urgent problem that needs to be solved.
By fragmenting the target key into multiple segment keys and storing them to different key storage nodes in the blockchain, the consensus node is used to verify the matching of the segment key and the target key, and based on the characteristics Identify the storage node corresponding to each segment key and implement decentralized storage to reduce the risk of leakage.
By decentrally storing keys, the risk of key leakage is reduced, the flexibility of key storage and quick retrieval capabilities are improved, and data security is enhanced.
Smart Images

Figure CN111428254B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a key storage method, device, equipment and storage medium. Background Art
[0002] With the continuous development of blockchain technology, the security of data transmission and data storage is becoming more and more important. Therefore, data encryption is required in most data processing links. For example, symmetric encryption and asymmetric encryption are implemented using keys to improve data security.
[0003] However, although encrypting data improves data security, the key is generally stored in a server, that is, in a node of the blockchain. Once the server serving as a node is illegally invaded, the key will be easily leaked, and data security will face greater threats.
[0004] Therefore, how to improve the security of key storage has become an urgent problem to be solved. Summary of the invention
[0005] The embodiments of the present application provide a key storage method, apparatus, device, and storage medium, which can improve the security of key storage and have high applicability.
[0006] The present invention provides a key storage method, which includes:
[0007] Obtain a target key, and fragment the target key to obtain multiple segmented keys, wherein the target key carries a key identifier;
[0008] Sending the plurality of segment keys to a consensus node in the blockchain so that the consensus node verifies whether the plurality of segment keys match the target key;
[0009] In the case where the plurality of segment keys match the target key, determining a characteristic identifier of each segment key, and determining a key storage node corresponding to each segment key from the blockchain according to the characteristic identifier of each segment key;
[0010] Each of the above segmented keys is stored in a corresponding key storage node, and the storage address of each of the above segmented keys is obtained so that when the above target key is obtained again, the above target key can be obtained from the above blockchain according to the above key identifier and the above storage address.
[0011] The present application provides a key storage device, which includes:
[0012] A processing module, used for obtaining a target key, and sharding the target key to obtain a plurality of segmented keys, wherein the target key carries a key identifier;
[0013] A verification module, used to send the multiple segment keys to a consensus node in the blockchain, so that the consensus node verifies whether the multiple segment keys match the target key;
[0014] a determination module, configured to determine a characteristic identifier of each segment key when the plurality of segment keys match the target key, and determine a key storage node corresponding to each segment key from the blockchain according to the characteristic identifier of each segment key;
[0015] A storage module is used to store each of the above-mentioned segmented keys to a corresponding key storage node, and obtain the storage address of each of the above-mentioned segmented keys so that when the above-mentioned target key is obtained again, the above-mentioned target key can be obtained from the above-mentioned blockchain according to the above-mentioned key identifier and the above-mentioned storage address.
[0016] In a possible implementation, the processing module includes:
[0017] A first determining unit is used to determine the number of bytes M of the target key and the number N of the key storage nodes in the blockchain, where N and M are positive integers;
[0018] A first processing unit, configured to, when M is an integer multiple of N, evenly fragment the target key to obtain N segment keys;
[0019] The second processing unit is used for padding the target key according to a preset padding character to obtain a padding key whose number of bytes is an integer multiple of N when M is not an integer multiple of N, and evenly sharding the padding key to obtain N segment keys.
[0020] In a possible implementation, the determination module includes:
[0021] A second determination unit is used to determine the occurrence frequency of each character in each segment key, and determine the character with the highest occurrence frequency as the target character;
[0022] a third determining unit, configured to, when there is one target character in each of the segment keys, determine the one target character as a characteristic identifier of each of the segment keys; and, when there are multiple target characters in each of the segment keys, determine the target character that first appears in each of the multiple target characters as the characteristic identifier of each of the segment keys;
[0023] a fourth determining unit, configured to determine the number of bytes of each segment key;
[0024] The fifth determination unit is used to determine the middle character of each segment key as the characteristic identifier of each segment key when the number of bytes of each segment key is an odd number, and to determine the middle two characters of each segment key as the characteristic identifier of each segment key when the number of bytes of each segment key is an even number.
[0025] In a possible implementation, the determination module includes:
[0026] A sixth determining unit, used to determine a feature identification range of each key storage node in the above blockchain;
[0027] The seventh determining unit is used to determine the key storage node corresponding to each segment key according to each feature identification range, wherein the feature identification of each segment key is within the feature identification range of the corresponding key storage node.
[0028] In a possible implementation, the determination module includes:
[0029] an eighth determining unit, configured to determine a hash value of a characteristic identifier of each segment key, and determine an index value corresponding to each segment key according to each hash value;
[0030] The ninth determination unit is used to determine the correspondence between each index value and the key storage node in the above-mentioned blockchain, and determine the key storage node corresponding to each of the above-mentioned segmented keys according to the above-mentioned correspondence.
[0031] In a possible implementation, the storage module includes:
[0032] An adding unit, used for adding a position identifier to each of the segmented keys, wherein the position identifier of each of the segmented keys is used for marking the position of each of the segmented keys in the target key;
[0033] The third processing unit is used to serialize each segment key with a position identifier added thereto to obtain a plurality of storage keys, and store the plurality of storage keys in a corresponding key storage node.
[0034] In a possible implementation, the storage module includes:
[0035] An acquisition unit, used to acquire the encryption key of each key storage node, encrypt the corresponding segment key according to the encryption key of each key storage node, and obtain the encrypted storage key of each segment key;
[0036] The storage unit is used to store the encrypted storage key of each segment key to the corresponding key storage node.
[0037] The embodiment of the present application provides a device, the device includes a processor and a memory, the processor and the memory are connected to each other. The memory is used to store a computer program that supports the terminal device to execute the key storage method provided by the embodiment of the present application, the computer program includes program instructions, and the processor is configured to call the above program instructions to execute the key storage method provided by the embodiment of the present application.
[0038] An embodiment of the present application provides a computer-readable storage medium, which stores a computer program. The computer program is executed by a processor to implement the key storage method provided by the embodiment of the present application.
[0039] In the embodiment of the present application, by sharding the target key to obtain multiple segmented keys, and storing the multiple segmented keys in different key storage nodes, the target key can be stored in a dispersed manner, reducing the risk of leakage of the target key. On the other hand, by determining the key storage node corresponding to each segmented key through the characteristic identifier of the segmented key, the key storage node corresponding to the segmented key can be quickly determined, and the flexibility of the segmented key storage is improved, which has high applicability. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0041] Figure 1 It is a schematic diagram of the principle of the key storage method provided in the embodiment of the present application;
[0042] Figure 2 It is a flowchart of a key storage method provided in an embodiment of the present application;
[0043] Figure 3a This is a schematic diagram of a scenario of the key sharding method provided in an embodiment of the present application;
[0044] Figure 3b This is another scenario schematic diagram of the key sharding method provided in an embodiment of the present application;
[0045] Figure 4a This is a schematic diagram of a scenario for determining a feature identifier provided in an embodiment of the present application;
[0046] Figure 4b This is another schematic diagram of a scenario for determining a feature identifier provided in an embodiment of the present application;
[0047] Figure 5a This is a schematic diagram of a scenario for determining a key storage node provided in an embodiment of the present application;
[0048] Figure 5b is another schematic diagram of a scenario for determining a key storage node provided in an embodiment of the present application;
[0049] Figure 6 is a schematic diagram of the structure of a key storage device provided in an embodiment of the present application;
[0050] Figure 7 It is a schematic diagram of the structure of the device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0051] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0052] See also Figure 1 , Figure 1 Schematic diagram of the principle of the key storage method provided in the embodiment of the present application. Figure 1In the example, the target key 10 can be the user public key used by the blockchain 20 to decrypt the digital signature carried by the transaction data when the blockchain 20 performs signature verification on the transaction data after receiving the transaction data submitted by the user, or the target key 10 can be the encryption key used by the blockchain 20 to symmetrically encrypt any data to be processed in any data processing link. The specific type of the above target key 10 can be determined according to the actual application scenario and is not limited here. Among them, node A, node B and node C are some key storage nodes in the blockchain 20, and can also be nodes in the blockchain 20 that have other functions or have key storage functions while having other functions, such as consensus nodes, etc., which can be determined according to the actual application scenario and are not limited here. After obtaining the above target key 10, the target key 10 can be fragmented to obtain multiple segmented keys, such as segmented key 101, segmented key 102 and segmented key 103. Further, in order to ensure that the target key 10 is correctly sharded and each segment key obtained after sharding matches the target key 10 (for example, the target key 10 can be obtained after each segment key is reorganized), each segment key can be sent to the consensus node so that the consensus node verifies whether each segment key matches the target key 10. In the case where the segment key 101, the segment key 102, and the segment key 103 match the target key 10, the characteristic identifier of each segment key can be determined, and the key storage node corresponding to each segment key can be determined from the blockchain 20 according to the characteristic identifier of each segment key. For example, the segment key 101 corresponds to node A, the segment key 102 corresponds to node B, and the segment key 103 corresponds to node C. After determining the correspondence between each segment key and the key storage node, the segment key 101 can be stored in node A, the segment key 102 can be stored in node B, and the segment key 103 can be stored in node C to complete the storage of the target key 10.
[0053] Further, in order to facilitate the acquisition of the target key 10 after the target key 10 is stored, the key identifier carried by the target key 10 can be obtained when the target key 10 is first acquired, and the storage address of each segment key can be obtained after the target key 10 is stored, so that when the target key 10 is acquired again, each segment key can be obtained from each storage node according to the storage address of each segment key of the key identifier of the target key 10, and the target key 10 can be obtained according to each segment key. Among them, the above-mentioned key storage node can be a server, terminal device, etc. connected to the blockchain 20, which can be determined according to the actual application scenario and is not limited here.
[0054] See also Figure 2 , Figure 2 It is a flowchart of the key storage method provided in an embodiment of the present application. Figure 2The key storage method shown may include the following steps S201 to S204.
[0055] S201. Obtain a target key, and fragment the target key to obtain multiple segment keys.
[0056] In some feasible implementations, the target key may be an encryption key or decryption key in an asymmetric encryption algorithm, or a symmetric key in a symmetric encryption algorithm, or an encryption key or decryption key for any other user to process data or information, which may be determined according to the actual application scenario and is not limited here. For example, when the blockchain receives transaction data submitted by a user and encrypts it using an asymmetric encryption method, the blockchain needs to obtain the user's public key to digitally sign and verify the transaction data, and the user's public key is the target key obtained. When the blockchain encrypts a certain information in the blockchain using an asymmetric encryption method, the private key of the blockchain is the target key. Alternatively, when a node in the blockchain encrypts another information using a symmetric encryption method, since the encryption key and decryption key in the symmetric encryption method are the same key, the encryption key or decryption key used by the node when performing symmetric encryption can be the target key. Therefore, the specific type and form of expression of the target key may be determined according to the actual application scenario and are not limited here.
[0057] In some feasible implementations, in order to avoid the high risk of key leakage caused by storing the target key in a key storage node and improve the storage security of the target key, after obtaining the target key, the target key can be fragmented to obtain multiple segmented keys, so that the multiple segmented keys are dispersedly stored to ensure the storage security of the target key. When the target key is fragmented, in order to make each storage node in the blockchain store a partial key of the target key, the target key can be evenly fragmented according to the number of key storage nodes in the blockchain to obtain segmented keys with equal byte numbers. Specifically, when the number of bytes of the target key is M (M is a positive integer), the number of key storage nodes is N (N is a positive integer), and M is an integer multiple of N, the target key can be evenly divided into N parts according to the number of bytes to obtain N segmented keys. When M is not an integer multiple of N, the target key can be padded according to a preset padded character to obtain a padded key with a byte number that is an integer multiple of N, and then the padded key can be evenly fragmented according to the number of bytes to obtain N segmented keys. Among them, the above-mentioned preset padding characters are numbers, letters, symbols, etc. pre-set in the blockchain, and a fixed number of bytes can correspond to a fixed preset padding character. For example, when the target key needs to be padded with one byte, the preset padding character can be 0, and when it needs to be padded with two bytes, the padding character can be 11. The above-mentioned preset padding characters can be determined according to the actual application scenario and are not limited here.
[0058] See also Figure 3a , Figure 3a Schematic diagram of a scenario of the key sharding method provided in the embodiment of the present application. Figure 3a In the example, ABCABCAABBCC is assumed to be the target key, so it can be known that the target key has 12 bytes. When the number of storage nodes is 3, the 12-byte target key can be evenly sharded to obtain segment key 1 (ABCA), segment key 2 (BCAA) and segment key (BBCC), and segment key 1, segment key 2 and segment key 3 are all 4 bytes, thereby completing the average sharding of the target key.
[0059] See also Figure 3b , Figure 3b Schematic diagram of another scenario of the key sharding method provided in the embodiment of the present application. Figure 3b In the example, ABCABCAABBC is assumed to be the target key, so it can be known that the target key has 11 bytes. When the number of storage nodes is 3, since the target key has 11 bytes, the target key cannot be evenly sharded at this time. In the above case, the preset padding of the blockchain can be further determined (assuming it is 0 at this time), and then the padding 0 can be padded to the last bit of the target key to obtain a 12-byte padding key. At this time, the 12-byte padding key can be evenly sharded to obtain segment key 1 (ABCA), segment key 2 (BCAA) and segment key (BBC0), and segment key 1, segment key 2 and segment key 3 are all 4 bytes, thereby completing the average sharding of the target key.
[0060] When the number of bytes of the target key is not an integer multiple of the number of storage nodes, a portion of the target key can be evenly sharded and the remaining portion can be used as another segment key. Figure 3b The first 9 bytes of the target key are evenly sharded to obtain three segment keys (ABC, ABC, AAB), and the remaining part BC is used as the fourth segment key. When the number of bytes of the target key is not an integer multiple of the number of storage nodes, the specific implementation method of sharding the target key can be determined according to the actual application scenario and is not limited here.
[0061] Optionally, when sharding the target key, other preset sharding rules can also be used to shard the target key, such as traversing the target key from left to right, and sharding the target key once when a preset character appears (the specific character can be determined according to the actual application scenario and is not limited here), until multiple segmented keys are obtained when traversing the target key.
[0062] Optionally, the target key can also be fragmented according to a preset number of bytes, wherein the preset number of bytes can be 5, 10 or 20, etc., which can be determined according to the actual application scenario and is not limited here. Similarly, the target key is traversed according to the preset number of bytes, and fragmented every time the preset number of bytes appears, and the last part of the target key that does not meet the preset number of bytes is determined as the last segmented key, thereby completing the fragmentation of the target key. On the basis of the fragmentation of the preset number of bytes, each time the number of bytes of a fixed window (such as 2 bytes) is traversed, the fragmentation is performed once, thereby increasing the complexity of the segmented key and improving the security of the segmented key.
[0063] Optionally, the target key can also be randomly sharded, that is, after obtaining the target key, a arrays (b, c) are randomly generated according to the number of bytes of the target key, where a, b and c are positive integers, a represents the number of segmented keys into which the target key is divided, b represents the nth segmented key, and c represents the number of bytes of the bth segmented key, and the target key can be sharded according to the generated data.
[0064] Optionally, a sharding algorithm may be used when sharding the target key, including but not limited to an exact sharding algorithm, a range sharding algorithm, a compound sharding algorithm, etc. The specific sharding algorithm may be determined according to the actual application scenario and is not limited here.
[0065] S202: Send the multiple segment keys to a consensus node in the blockchain, so that the consensus node verifies whether the multiple segment keys match the target key.
[0066] In some feasible implementations, after the target key is sharded to obtain multiple segment keys, in order to ensure that no sharding error occurs during the sharding process, resulting in the mismatch between the segment key and the target key, the multiple segment keys can be sent to the consensus node in the blockchain, so that the consensus node verifies that the multiple segment keys match the target key, ensuring that the sharding process is accurate. Among them, each consensus node in the blockchain can verify whether the multiple segment keys match the target key separately, and send a signature confirmation message when it is determined that the multiple segment keys match the target key. Among them, the above-mentioned signature confirmation message is sent after each consensus node signs the confirmation message with its private key to ensure that the confirmation message is not tampered with and the source of the confirmation message can be marked. Further, after all consensus nodes complete the matching verification, the signature confirmation message sent by the consensus node can be received, and when the number of signature confirmation messages exceeds half of the number of all consensus nodes (it can also be other proportions, such as two-thirds, etc., which can be determined according to the actual application scenario, and is not limited here), it is determined that each segment key matches the target key, that is, no sharding anomaly occurs during the sharding of the target key. When verifying whether the multiple segmented keys match the target key, each consensus node may fragment the target key in the same manner, compare the obtained multiple segmented keys with the received segmented keys, and if they are consistent, the consensus node may determine that the received multiple segmented keys match the target key. Alternatively, each consensus node may obtain a reorganized key from the multiple segmented keys in the opposite manner of the same fragmentation method, and match the reorganized key with the target key, and if the two are consistent, it can be said that the received multiple segmented keys match the target key.
[0067] S203. When multiple segment keys match the target key, determine a characteristic identifier of each segment key, and determine a key storage node corresponding to each segment key from the blockchain according to the characteristic identifier of each segment key.
[0068] In some feasible implementations, when multiple segmented keys match the target key, the key storage node corresponding to each segmented key can be determined to store each segmented key in the corresponding key storage node. Among them, the characteristic identifier of each segmented key can be determined first, and the key storage node corresponding to each segmented key can be determined from the blockchain according to the characteristic identifier of each segmented key. Specifically, the frequency of occurrence of each character in each segmented key can be determined, and the character with the highest frequency of occurrence can be first determined as the target character. The number of target characters corresponding to each segmented key can be further determined. When there is one target character in a segmented key, the target character can be determined as the characteristic identifier of the segmented key. When there are multiple target characters in a segmented key, the target characters that appear for the first time (or the last time, which can be determined according to the actual application scenario and is not limited here) in the corresponding segmented key can be determined as the characteristic identifier of each segmented key. See. Figure 4a , Figure 4a Schematic diagram of a scenario for determining a feature identifier provided by an embodiment of the present application. Figure 4a In , it is assumed that the segment key is fragmented to obtain segment key 1 (ABCA), segment key 2 (BCAA) and segment key (BCD0). Among them, the character A in segment key 1 and segment key 2 has the highest frequency of occurrence, and there are no other characters with the same frequency of occurrence, so character A can be determined as the characteristic identifier of segment key 1 and segment key 2. For segment key 3, the frequency of occurrence of characters B, character C, character D and character 0 is the same. Since character B appears for the first time, character B can be determined as the characteristic identifier of the segment key.
[0069] Optionally, when determining the characteristic identifier of each segment key, the number of bytes of each segment key may also be determined. When the number of bytes of a segment key is an odd number, the middle character of the segment key with the single byte number may be determined as the characteristic identifier of the segment key. When the number of bytes of a segment key is an even number, the middle two characters of the segment key with the double byte number may be determined as the characteristic identifier of the segment key with the double byte number. Figure 4b , Figure 4b is another schematic diagram of a scenario for determining a feature identifier provided in an embodiment of the present application. Figure 4b In the example, assuming that the number of bytes of segment key 1 (BCAAB) is 5, the middle character A can be determined as the characteristic identifier of the segment key. Assuming that the number of bytes of segment key 2 (ABCA) is 4, the middle two characters BC can be determined as the characteristic identifier of the segment key.
[0070] Optionally, in some feasible implementations, when determining the characteristic identifier of each segment key, the segment value of each segment key may be determined as the characteristic identifier of the corresponding segment key, and the segment value is used to indicate which segment each segment key is in the target key. Characters with a fixed number of digits in each segment key may also be determined as the characteristic identifier of the corresponding segment key, or the determined characters may be directly mapped to the corresponding characteristic identifier as the characteristic identifier of the segment key based on a preset character identifier mapping table. The specific determination may be based on the actual application scenario and is not limited here.
[0071] In some feasible implementations, after determining the characteristic identifier of each segmented key, the key storage node corresponding to each segmented key can be determined from the blockchain according to the characteristic identifier. Specifically, the characteristic identifier range corresponding to each key storage node in the blockchain can be determined, and the characteristic identifier of each segmented key can be compared with the characteristic identifier range corresponding to each key storage node, and then the key storage node corresponding to each characteristic identifier can be determined to determine the storage node corresponding to each segmented key. Figure 5a , Figure 5a Schematic diagram of a scenario for determining a key storage node provided by an embodiment of the present application. Figure 5a In the example, it is assumed that the characteristic identification range of key storage node 1 in the blockchain is (0, 100), the characteristic identification range of key storage node 2 is (101, 200), and the characteristic identification range of storage node 3 is (201, 300). When the characteristic identification of segmented key 1 is 150, it can be determined that the key storage node corresponding to segmented key 1 is key storage node 2. When the characteristic identification of segmented key 2 is 150, it can be determined that the key storage node corresponding to segmented key 2 is key storage node 1.
[0072] In some feasible implementations, the hash value of the characteristic identifier of each segmented key can also be determined, and when the hash value is a number, the index value of each segmented key can be determined according to the hash value of each characteristic identifier, so that the key storage node corresponding to each segmented key can be determined according to the corresponding relationship between the index value and the key storage node. Specifically, when determining the index value of each hash value, the division hash method can be used to perform a remainder operation on the hash value, and the divisor can be 16 (which can be determined according to the actual application scenario and is not limited here), and the remainder obtained is the index value of each segmented key.
[0073] Optionally, the index value of each segment key can be determined by a square hashing method. That is, the square of the hash value is used as the dividend, 2 28 The quotient is used as the divisor and the index value of each segment key is obtained.
[0074] Optionally, when the hash value of each segment key is an integer with a fixed number of digits, the Fibonacci hashing method can also be used to find the index value of each segment key. That is, for a 16-bit integer, the product of the hash value and 40503 can be used as the dividend, and 2 28 As the divisor, the quotient is the index value of the corresponding segment key; for a 32-bit integer, the product of the hash value and 2654435769 can be used as the dividend, and 2 28 As the divisor, the quotient is the index value of the corresponding segment key; for a 64-bit integer, the product of the hash value and 11400714819323198485 can be used as the dividend, and 2 28 As the divisor, the quotient obtained is the index value of the corresponding segment key.
[0075] Optionally, each hash value may be squared, and a certain number of digits in the middle of the square result may be used as the index value of each segment key. 2 The result is 1522765, and 227 can be used as the index value of the segment key.
[0076] Optionally, when the number of bits of the hash value of each feature identifier is large, the hash value can be divided into several parts, and the superposition sum is taken as the index value of the corresponding segment key. For example, when the hash value is 123456789, the hash value can be divided into three parts: 123, 456, and 789, and the superposition sum of the three parts is 61254 as the index value of the corresponding segment key.
[0077] In some feasible implementations, after determining the index value corresponding to each segmented key, the correspondence between each index value and the key storage node in the blockchain can be determined. Specifically, the node identifier of each key storage can be hashed to obtain the hash value corresponding to the node identifier, and the index value of each node identifier is determined in the same manner as the index value of the segmented key. Further, the index value of each key storage node and the index value corresponding to each segmented key are mapped to the corresponding hash ring, so that the key storage node corresponding to each key storage node can be determined clockwise on the hash ring. Among them, the above-mentioned node identifier can be the node serial number of the key storage node or the IP address of the key storage node, which can be determined according to the actual application scenario and is not limited here. Among them, the above-mentioned hash ring is determined by the calculation method of the index value. For example, when the index value is determined by the square hash method, 2 28The points form a ring in clockwise order from large to small, and the ring is the above hash ring. At this time, the index value of each segment key and the index value of each key storage node can be mapped to the hash. For any segment key index value, the key storage node corresponding to the index value of the next (clockwise) key storage node in the ring is the key storage node corresponding to the segment key corresponding to the index value. Based on the above implementation method, the key storage node corresponding to each segment key can be determined. See Figure 5b , Figure 5b is another schematic diagram of a scenario for determining a key storage node provided by an embodiment of the present application. Figure 5b In the hash ring in , the index value of key storage node 1 is 200, the index value of key storage node 2 is 400, and the index value of key storage node 3 is 300. For segment key 1, its corresponding index value is 500, so the positions of the index values corresponding to the segment key, the index values corresponding to key storage node 1, the index values corresponding to key storage node 2, and the index values corresponding to key storage node 3 in the hash ring are as follows: Figure 5b As shown. Figure 5b It is not difficult to find that the index value corresponding to the next (clockwise) key storage node of the index value corresponding to segment key 1 is 200, and its corresponding key storage node is key storage node 1, that is, the key storage node corresponding to segment key 1 is key storage node 1.
[0078] It should be noted that the selection of the key storage node corresponding to each segmented key can also be determined by a preset corresponding relationship based on the length and importance of the segmented key. For example, the longer the key is or the higher its importance is, the more likely it is to be stored in a key storage node with higher information security. The specific implementation method is again not restricted.
[0079] S204: Store each segmented key in a corresponding key storage node, obtain the storage address of each segmented key, and when obtaining the target key again, obtain the target key from the blockchain according to the key identifier and the storage address.
[0080] In some feasible implementations, when each key segment key is stored in the corresponding key storage node, in order to obtain the target key from the segment key after the segment key is obtained from the key storage node, a position identifier can be added to each segment key. Among them, the position identifier of each segment key is used to mark the position of each segment key in the target key. Among them, when adding the position identifier to the segment key, the segment key can be processed into a data structure, such as the value field in the data structure represents the segment key, and the index field represents the position identifier of the segment key. Optionally, the storage address of the segment key can also be added to the above data structure, such as the address field to illustrate the storage address. At the same time, in order to reduce the storage space of the key storage node and improve the storage efficiency of the segment key, the above data structure can be serialized to obtain the serialized segment key, and then the serialized segment key can be stored in the corresponding key storage node. Specifically, when the above data structure is serialized, it can be serialized based on a serialization tool. Among them, the above serialization tool includes but is not limited to Fastjson, Gson and Jackson, etc., and the specific selection of the serialization tool can be determined based on the actual application scenario, which is not limited here. Optionally, in order to effectively serialize the above data structure and improve serialization efficiency, the data type of the above data structure may be determined first, and the serialization rule corresponding to the data type may be determined. Thus, the above data structure may be serialized based on the serialization rule corresponding to the data type to obtain the serialized segment key. Among them, the above serialization rules include but are not limited to XML serialization rules, JSOM serialization rules, Hessian serialization rules, Avro serialization rules, and Protobuf serialization rules, etc., which can be determined based on the actual application scenario and are not limited here.
[0081] In some feasible implementations, in order to further improve the storage security of the segmented key, the segmented key or the serialized segmented key may be encrypted to obtain an encryption key, and then the encryption key may be stored in the corresponding key storage node. Specifically, when encrypting the segmented key or the serialized segmented key, symmetric encryption or asymmetric encryption may be used. Among them, when symmetric encryption is used, the encryption key may be encrypted using the encryption key of the key storage node or the blockchain itself; when asymmetric encryption is used, the encryption key may be encrypted using the private key of the key storage node. Optionally, the segmented key or the serialized segmented key may also be encrypted by means of a data processing node in the blockchain, calling an encrypted smart contract, etc., which may be determined according to the actual application scenario and is not limited here.
[0082] In some feasible implementations, after the segmented keys are stored in the corresponding key storage nodes, the storage address of each segmented key can be obtained, and the segmented keys stored in the key storage nodes can be marked with the key identifier of the target key. The storage address of each segmented key includes the key storage node address corresponding to the segmented key and the storage address in the key storage node. Then, when the target key needs to be obtained again, each segmented key can be obtained from each key storage node according to the storage address of each segmented key and the key identifier of the target key. Specifically, after each segmented key is obtained from the storage node, it can be determined whether each segmented key is an encryption key. If it is an encryption key, the decryption key of each segmented key is determined to decrypt each segmented key. Furthermore, when each segmented key is not encrypted, or after the encryption key is decrypted, it can be determined whether it is a serialized segmented key. If it is a serialized segmented key, the deserialization rule corresponding to the serialization rule is adopted to deserialize to obtain the data structure of the segmented key, and the position identifier of each segmented key is obtained therefrom, so as to reorganize each segmented key according to the position identifier of each segmented key to obtain the final target key. Among them, when the above target key is the user's private key or public key, before obtaining each segmented key from the key storage node, the user needs to be authenticated and each segmented key is obtained after the authentication is passed.
[0083] In the embodiment of the present application, by sharding the target key to obtain multiple segmented keys, and storing the multiple segmented keys in different key storage nodes, the target key can be stored in a dispersed manner, reducing the risk of leakage of the target key. On the other hand, by determining the key storage node corresponding to each segmented key through the characteristic identifier of the segmented key, the key storage node corresponding to the segmented key can be quickly determined, and the flexibility of the segmented key storage is improved, which has high applicability.
[0084] See also Figure 6 , Figure 6 1 is a schematic diagram of the structure of a key storage device provided in an embodiment of the present application. The device 1 provided in an embodiment of the present application includes:
[0085] The processing module 11 is used to obtain a target key, and to fragment the target key to obtain a plurality of segmented keys, wherein the target key carries a key identifier;
[0086] A verification module 12, used to send the multiple segment keys to a consensus node in the blockchain, so that the consensus node verifies whether the multiple segment keys match the target key;
[0087] A determination module 13, configured to determine a characteristic identifier of each segment key when the plurality of segment keys match the target key, and determine a key storage node corresponding to each segment key from the blockchain according to the characteristic identifier of each segment key;
[0088] The storage module 14 is used to store each of the above-mentioned segmented keys to the corresponding key storage node, obtain the storage address of each of the above-mentioned segmented keys so that when the above-mentioned target key is obtained again, the above-mentioned target key can be obtained from the above-mentioned blockchain according to the above-mentioned key identifier and the above-mentioned storage address.
[0089] In some feasible implementations, the processing module 11 includes:
[0090] The first determining unit 111 is used to determine the number of bytes M of the target key and the number N of the key storage nodes in the blockchain, where N and M are positive integers;
[0091] The first processing unit 112 is configured to, when M is an integer multiple of N, evenly fragment the target key to obtain N segment keys;
[0092] The second processing unit 113 is used for padding the target key according to a preset padding character to obtain a padding key whose number of bytes is an integer multiple of N when M is not an integer multiple of N, and evenly sharding the padding key to obtain N segment keys.
[0093] In some feasible implementations, the determination module 13 includes:
[0094] The second determining unit 131 is used to determine the occurrence frequency of each character in each segment key, and determine the character with the highest occurrence frequency as the target character;
[0095] The third determining unit 132 is configured to, when there is one target character in each segment key, determine the one target character as the characteristic identifier of each segment key; when there are multiple target characters in each segment key, determine the target character that first appears in each segment key among the multiple target characters as the characteristic identifier of each segment key;
[0096] The fourth determining unit 133 is used to determine the number of bytes of each segment key;
[0097] The fifth determining unit 134 is used to determine the middle character of each segment key as the characteristic identifier of each segment key when the number of bytes of each segment key is an odd number, and to determine the middle two characters of each segment key as the characteristic identifier of each segment key when the number of bytes of each segment key is an even number.
[0098] In some feasible implementations, the determination module 13 includes:
[0099] A sixth determining unit 135, configured to determine a feature identification range of each key storage node in the blockchain;
[0100] The seventh determining unit 136 is configured to determine the key storage node corresponding to each segment key according to each feature identifier range, wherein the feature identifier of each segment key is within the feature identifier range of the corresponding key storage node.
[0101] In some feasible implementations, the determination module 13 includes:
[0102] An eighth determining unit 137, configured to determine a hash value of a characteristic identifier of each segment key, and determine an index value corresponding to each segment key according to each hash value;
[0103] The ninth determination unit 138 is used to determine the correspondence between each index value and the key storage node in the above-mentioned blockchain, and determine the key storage node corresponding to each of the above-mentioned segmented keys according to the above-mentioned correspondence.
[0104] In some feasible implementations, the storage module 14 includes:
[0105] An adding unit 141 is used to add a position identifier to each segment key, where the position identifier of each segment key is used to mark the position of each segment key in the target key;
[0106] The third processing unit 142 is used to perform serialization processing on each segment key with a position identifier added thereto to obtain multiple storage keys, and store the multiple storage keys in corresponding key storage nodes.
[0107] In some feasible implementations, the storage module 14 includes:
[0108] The acquiring unit 143 is used to acquire the encryption key of each key storage node, and encrypt the corresponding segment key according to the encryption key of each key storage node to obtain the encrypted storage key of each segment key;
[0109] The storage unit 144 is used to store the encrypted storage key of each segment key to a corresponding key storage node.
[0110] In a specific implementation, the above-mentioned device 1 can execute the above-mentioned functions through its built-in functional modules. Figure 2 For the implementation methods provided in each step, please refer to the implementation methods provided in the above steps for details, which will not be repeated here.
[0111] In the embodiment of the present application, by sharding the target key to obtain multiple segmented keys, and storing the multiple segmented keys in different key storage nodes, the target key can be stored in a dispersed manner, reducing the risk of leakage of the target key. On the other hand, by determining the key storage node corresponding to each segmented key through the characteristic identifier of the segmented key, the key storage node corresponding to the segmented key can be quickly determined, and the flexibility of the segmented key storage is improved, which has high applicability.
[0112] See also Figure 7 , Figure 7 Schematic diagram of the structure of the device provided in the embodiment of the present application. Figure 7 As shown, the device 1000 in this embodiment may include: a processor 1001, a network interface 1004 and a memory 1005. In addition, the above-mentioned device 1000 may also include: a user interface 1003, and at least one communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. Among them, the user interface 1003 may include a display screen (Display), a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1004 may be a high-speed RAM memory, or it may be a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 1005 may optionally also be at least one storage device located away from the aforementioned processor 1001. As Figure 7 As shown, the memory 1005 as a computer-readable storage medium may include an operating system, a network communication module, a user interface module, and a device control application program.
[0113] exist Figure 7 In the device 1000 shown, the network interface 1004 can provide a network communication function; the user interface 1003 is mainly used to provide an input interface for the user; and the processor 1001 can be used to call the device control application stored in the memory 1005 to achieve:
[0114] Obtain a target key, and fragment the target key to obtain multiple segmented keys, wherein the target key carries a key identifier;
[0115] Sending the plurality of segment keys to a consensus node in the blockchain so that the consensus node verifies whether the plurality of segment keys match the target key;
[0116] In the case where the plurality of segment keys match the target key, determining a characteristic identifier of each segment key, and determining a key storage node corresponding to each segment key from the blockchain according to the characteristic identifier of each segment key;
[0117] Each of the above segmented keys is stored in a corresponding key storage node, and the storage address of each of the above segmented keys is obtained so that when the above target key is obtained again, the above target key can be obtained from the above blockchain according to the above key identifier and the above storage address.
[0118] In some feasible implementations, the processor 1001 is configured to:
[0119] Determine the number of bytes M of the target key and the number N of the key storage nodes in the blockchain, where N and M are positive integers;
[0120] When M is an integer multiple of N, the target key is evenly sharded to obtain N segment keys;
[0121] When M is not an integer multiple of N, the target key is padded according to a preset padding character to obtain a padded key whose number of bytes is an integer multiple of N, and the padded key is evenly fragmented to obtain N segmented keys.
[0122] In some feasible implementations, the processor 1001 is configured to:
[0123] Determine the frequency of occurrence of each character in each segment key, and determine the character with the highest frequency of occurrence as the target character;
[0124] When there is one target character in each segment key, the target character is determined as the characteristic identifier of each segment key; when there are multiple target characters in each segment key, the target character that first appears in each segment key among the multiple target characters is determined as the characteristic identifier of each segment key;
[0125] Alternatively, determine the number of bytes of each segment key;
[0126] When the number of bytes of each segment key is an odd number, the middle character of each segment key is determined as the characteristic identifier of each segment key; when the number of bytes of each segment key is an even number, the middle two characters of each segment key are determined as the characteristic identifier of the segment key.
[0127] In some feasible implementations, the processor 1001 is configured to:
[0128] Determine the characteristic identification range of each key storage node in the above blockchain;
[0129] The key storage node corresponding to each segment key is determined according to each feature identification range, wherein the feature identification of each segment key is within the feature identification range of the corresponding key storage node.
[0130] In some feasible implementations, the processor 1001 is configured to:
[0131] Determine a hash value of a characteristic identifier of each segment key, and determine an index value corresponding to each segment key according to each hash value;
[0132] Determine the correspondence between each index value and the key storage node in the above blockchain, and determine the key storage node corresponding to each of the above segmented keys based on the above correspondence.
[0133] In some feasible implementations, the processor 1001 is configured to:
[0134] Adding a position identifier for each of the segmented keys, where the position identifier for each of the segmented keys is used to mark the position of each of the segmented keys in the target key;
[0135] Serialization is performed on each segment key with a location identifier added thereto to obtain a plurality of storage keys, and the plurality of storage keys are stored in corresponding key storage nodes.
[0136] In some feasible implementations, the processor 1001 is configured to:
[0137] Obtaining the encryption key of each key storage node, encrypting the corresponding segment key according to the encryption key of each key storage node, and obtaining the encrypted storage key of each segment key;
[0138] The encrypted storage key of each segment key is stored in the corresponding key storage node.
[0139] It should be understood that in some feasible implementations, the processor 1001 may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The memory may include a read-only memory and a random access memory, and provide instructions and data to the processor. A portion of the memory may also include a non-volatile random access memory. For example, the memory may also store information about the device type.
[0140] In a specific implementation, the device 1000 can execute the above-mentioned functions through its built-in functional modules. Figure 2 For the implementation methods provided in each step, please refer to the implementation methods provided in the above steps for details, which will not be repeated here.
[0141] In the embodiment of the present application, by sharding the target key to obtain multiple segmented keys, and storing the multiple segmented keys in different key storage nodes, the target key can be stored in a dispersed manner, reducing the risk of leakage of the target key. On the other hand, by determining the key storage node corresponding to each segmented key through the characteristic identifier of the segmented key, the key storage node corresponding to the segmented key can be quickly determined, and the flexibility of the segmented key storage is improved, which has high applicability.
[0142] The present application also provides a computer-readable storage medium, which stores a computer program and is executed by a processor to implement Figure 2 For the methods provided in each step, please refer to the implementation methods provided in the above steps for details, which will not be repeated here.
[0143] The computer-readable storage medium may be an internal storage unit of the task processing device provided in any of the aforementioned embodiments, such as a hard disk or memory of an electronic device. The computer-readable storage medium may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc., equipped on the electronic device. The computer-readable storage medium may also include a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc. Further, the computer-readable storage medium may also include both an internal storage unit of the electronic device and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the electronic device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
[0144] The terms "first", "second", etc. in the claims, specification and drawings of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices. Mentioning "embodiment" in this article means that the specific features, structures or characteristics described in conjunction with the embodiment may be included in at least one embodiment of the present application. Displaying the phrase at various positions in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments. The term "and / or" used in the present application specification and the attached claims refers to any combination of one or more of the items listed in association and all possible combinations, and includes these combinations.
[0145] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Professional and technical personnel may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0146] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A key storage method, It is characterized in that The method comprises: Obtaining a target key, and sharding the target key to obtain a plurality of segmented keys, wherein the target key carries a key identifier; Sending the plurality of segment keys to a consensus node in a blockchain so that the consensus node verifies whether the plurality of segment keys match the target key; In the case where the multiple segmented keys match the target key, determine the characteristic identifier of each segmented key, determine the hash value of the characteristic identifier of each segmented key, determine the index value corresponding to each segmented key according to each hash value, determine the correspondence between each index value and the key storage node in the blockchain, and determine the key storage node corresponding to each segmented key according to the correspondence; wherein, a hash operation is performed on the node identifier of each key storage node to obtain a hash value corresponding to the node identifier, the index value of each key storage node is determined according to the hash value corresponding to the node identifier, the index value of each key storage node and the index value corresponding to each segmented key are mapped to a corresponding hash ring, and the key storage node corresponding to each segmented key is determined on the corresponding hash ring; Each segmented key is stored in a corresponding key storage node, and the storage address of each segmented key is obtained so that when the target key is obtained again, the target key can be obtained from the blockchain according to the key identifier and the storage address.
2. The method according to claim 1, It is characterized in that The slicing of the target key to obtain a plurality of segment keys comprises: Determine the number of bytes M of the target key and the number N of the key storage nodes in the blockchain, where N and M are positive integers; When M is an integer multiple of N, the target key is evenly fragmented to obtain N segment keys; When M is not an integer multiple of N, the target key is padded according to a preset padding character to obtain a padded key whose number of bytes is an integer multiple of N, and the padded key is evenly fragmented to obtain N segmented keys.
3. The method according to claim 1, It is characterized in that Determining the characteristic identifier of each segment key includes: Determine the frequency of occurrence of each character in each segment key, and determine the character with the highest frequency of occurrence as the target character; When there is one target character in each segment key, the one target character is determined as the characteristic identifier of each segment key; when there are multiple target characters in each segment key, the target character that first appears in each segment key among the multiple target characters is determined as the characteristic identifier of each segment key; Alternatively, determine the number of bytes of each segment key; When the number of bytes of each segment key is an odd number, the middle character of each segment key is determined as the characteristic identifier of each segment key; when the number of bytes of each segment key is an even number, the middle two characters of each segment key are determined as the characteristic identifier of the segment key.
4. The method according to claim 1, It is characterized in that The step of determining, from the blockchain, a key storage node corresponding to each segment key according to the characteristic identifier of each segment key comprises: Determining a characteristic identification range of each key storage node in the blockchain; The key storage node corresponding to each segment key is determined according to each feature identification range, wherein the feature identification of each segment key is within the feature identification range of the corresponding key storage node.
5. The method according to claim 1, It is characterized in that The storing each segment key to the corresponding key storage node comprises: Adding a position identifier for each segment key, wherein the position identifier of each segment key is used to mark the position of each segment key in the target key; Serialization is performed on each segment key to which a position identifier is added to obtain a plurality of storage keys, and the plurality of storage keys are stored in corresponding key storage nodes.
6. The method according to claim 1, It is characterized in that The storing each segment key to the corresponding key storage node comprises: Obtaining the encryption key of each key storage node, encrypting the corresponding segment key according to the encryption key of each key storage node, and obtaining the encrypted storage key of each segment key; The encrypted storage key of each segment key is stored in the corresponding key storage node.
7. A key storage device, It is characterized in that The device comprises: A processing module, used for obtaining a target key, and slicing the target key to obtain a plurality of segmented keys, wherein the target key carries a key identifier; A verification module, configured to send the plurality of segment keys to a consensus node in a blockchain so that the consensus node verifies whether the plurality of segment keys match the target key; A determination module, used to determine the characteristic identifier of each segmented key when the multiple segmented keys match the target key, determine the hash value of the characteristic identifier of each segmented key, determine the index value corresponding to each segmented key according to each hash value, determine the correspondence between each index value and the key storage node in the blockchain, and determine the key storage node corresponding to each segmented key according to the correspondence; wherein a hash operation is performed on the node identifier of each key storage node to obtain a hash value corresponding to the node identifier, the index value of each key storage node is determined according to the hash value corresponding to the node identifier, the index value of each key storage node and the index value corresponding to each segmented key are mapped to a corresponding hash ring, and the key storage node corresponding to each segmented key is determined on the corresponding hash ring; A storage module is used to store each segmented key to a corresponding key storage node, and obtain the storage address of each segmented key so that when the target key is obtained again, the target key can be obtained from the blockchain according to the key identifier and the storage address.
8. A key storage device, It is characterized in that comprising a processor and a memory, wherein the processor and the memory are connected to each other; The memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 6.
