Block chain data security storage method based on verifiable secret sharing
By combining the RAFT consensus mechanism, Shamir secret sharing and the national secret algorithm, the security issues of blockchain data storage in dynamic environments are solved, the security management of data throughout its life cycle is achieved, and the security of key management and the integrity and authenticity of data are ensured.
Patent Information
- Application Number
- CN202511058202.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-30
- Publication Date
- 2025-10-14
AI Technical Summary
Existing blockchain data storage solutions have weak adaptability in dynamic environments, sub-key groups have key management security issues, distributed system data is inconsistent, nodes are untrustworthy, and the original secret cannot be reconstructed when the number of lost shards is lower than the threshold. The lack of hashing operations on keys leads to insufficient data security.
The RAFT consensus mechanism, Shamir secret sharing, national secret SM2, SM3 and SM4 algorithms are adopted. By calculating the hash value of the ciphertext and sub-key shards and storing them on the chain, a double verification mechanism is formed. Combined with the secret sharing algorithm, the encryption key is divided into multiple sub-key shards, and a regular inspection and recovery mechanism of the consensus mechanism is introduced to ensure the security of the data throughout its life cycle.
It achieves the integrity, confidentiality and authentication of data and keys, prevents key tampering, ensures the security and business continuity of data during storage, transmission and key management, and adapts to the data security compliance requirements of specific industries or regions.
Smart Images

Figure CN120785533A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of blockchain, especially the technical branches of data storage, storage encryption, distributed storage, data sharding, secret sharing, key agreement, national encryption algorithm, and RAFT consensus mechanism in blockchain, and in particular, relates to a blockchain data security storage method based on verifiable secret sharing. BACKGROUND
[0002] Data information, as a production factor, is an important asset for the new round of intelligent and digital development. However, due to the open nature of the digital network space, data faces various types and levels of security threats during storage and sharing. Traditional encryption methods can ensure data confidentiality, but there are key security management problems such as easy loss or leakage of master keys. These risks pose a great challenge to the development of digital economy.
[0003] Secret sharing is a technology that splits sensitive information into multiple independent data fragments through cryptographic means and distributes them to different participants. The core is to control the dispersion of the complete secret, ensuring that a single participant cannot recover the original content alone, and only when the number of submissions reaches the predetermined share, can multiple parties reconstruct the secret.
[0004] Currently, secret sharing technology still faces many challenges. One typical technical problem is that existing schemes are not very adaptable to dynamic environments, making it difficult to deal with situations where some sub-key shards fail or are lost. However, the sub-key group generated by secret sharing alone has security issues in key management, and the distributed system used for data and key storage also has problems such as data inconsistency and untrusted nodes.
[0005] Regarding data security protection, scholars such as Feng Yu and Ren Yawei proposed a blockchain sharding storage model based on verifiable secret sharing (Computer Engineering and Design, Issue 12, 2023). By introducing verifiable secret sharing technology and key agreement protocol, the core problems of poor scalability of blockchain storage and vulnerability of collaborative storage on the chain to malicious node attacks were solved. The model classifies blocks into high stability and low stability based on block stability: high stability blocks are directly stored using verifiable secret sharing technology to reduce storage redundancy; low stability blocks bind shards with storage node identities through a key agreement protocol to ensure the security and identity authentication of the shard transmission process. This scheme can improve the security of the blockchain storage system while ensuring storage scalability.
[0006] However, the above existing technologies do not provide ideal solutions to the following technical problems.
[0007] First, existing solutions primarily focus on blockchain storage scalability and protection against malicious node spoofing attacks. While these solutions improve the security of blockchain storage systems, they don't explicitly address the need to build a layered encryption key management system to protect data throughout its lifecycle. This can lead to inadequate data security at certain stages, such as inadequate consistency in data encryption and key management, impacting the security of data from generation to destruction.
[0008] Second, existing solutions directly use valid, unlost shards to restore the original block data. However, when the number of lost shards falls below a threshold, the original secret cannot be reconstructed. This poses a significant risk in practical applications. Once a large number of shards are lost, data cannot be recovered, severely impacting normal data use and business continuity.
[0009] Furthermore, while existing solutions utilize verifiability and identity binding to enhance collaborative storage security, deriving keys through data hashing, they do not perform hashing operations on the keys. This lack of sharded hashing of keys exposes keys to the risk of tampering during storage and transmission. Once a key is maliciously modified, the confidentiality, integrity, and authenticity of the data cannot be guaranteed, impacting the security of the entire data storage system. Summary of the Invention
[0010] The purpose of the present invention is to provide a blockchain data security storage method based on verifiable secret sharing. The method of the present invention combines the RAFT consensus mechanism, Shamir secret sharing, and the national secret SM2, SM3, and SM4 algorithms to solve the problems in the prior art such as the weak adaptability of secret sharing schemes to dynamic environments, key management security issues in sub-key groups, inconsistent distributed system data, and untrustworthy nodes, as well as the problems in the existing closest technical solutions such as the inability to reconstruct the original secret when the number of lost shards is lower than a threshold and the failure to perform hash operations on the keys. The method realizes security management and control of the entire life cycle of data, ensures the integrity, confidentiality, and authentication of data and keys, and guarantees the security of data during storage, transmission, and key management.
[0011] According to a first main aspect of the present invention, a method for securely storing blockchain data based on verifiable secret sharing is provided, comprising the following steps executed by a computer:
[0012] Receive the data to be stored, encrypt it to obtain ciphertext, store the ciphertext in the distributed file system and obtain the storage address, and calculate the hash value of the ciphertext;
[0013] Split the encryption key into several sub-key fragments according to the set parameters, and calculate the hash value of each sub-key fragment;
[0014] Encapsulate the subkey shard, subkey shard hash value, and ciphertext hash value into a transaction unit and write it into the blockchain;
[0015] reconstructing the encryption key when the number of valid sub-key fragments submitted reaches a threshold value;
[0016] obtaining the ciphertext from the distributed file system, verifying the hash value thereof, and decrypting the ciphertext with the reconstructed encryption key to obtain plaintext.
[0017] As a further preferred solution, in the foregoing method, the encryption key is divided into a plurality of sub-key fragments according to the set parameters, including:
[0018] According to the set total number and the minimum number required for reconstruction, the encryption key is divided into a corresponding number of sub-key fragments using a secret sharing algorithm, each fragment carrying a unique identifier, and the hash value of each fragment being associated with the fragment.
[0019] As a further preferred solution, in the foregoing method, the encryption key is reconstructed when the number of valid sub-key fragments submitted reaches a threshold value, including:
[0020] First, verify whether the hash value of the sub-key fragment is consistent with the corresponding hash value stored in the blockchain, and filter the valid fragments;
[0021] When the number of valid fragments reaches the minimum number required for reconstruction, the encryption key is reconstructed.
[0022] As a further preferred solution, in the foregoing method, the verification of the hash value includes:
[0023] Verify whether the hash value of the ciphertext obtained from the distributed file system is consistent with the ciphertext hash value stored in the blockchain.
[0024] As a further preferred solution, in the foregoing method, the method further includes:
[0025] Periodically checking the integrity of the sub-key fragments in the blockchain based on a consensus mechanism;
[0026] When the number of fragments is insufficient due to invalidation or loss of fragments, start the key reconstruction process to regenerate the missing sub-key fragments;
[0027] Update the newly generated fragments and their hash values to the blockchain to maintain the total number of fragments.
[0028] As a further preferred solution, in the foregoing method, the encryption processing of the data to be stored to obtain the ciphertext includes:
[0029] The calculation of the hash value of the ciphertext includes:
[0030] As a further preferred solution, in the foregoing method, the step of encapsulating the sub-key fragments, the sub-key fragment hash values and the ciphertext hash value as a transaction unit for writing into the blockchain comprises: combining the sub-key fragments, the sub-key fragment hash values and the ciphertext hash value according to a preset data structure to form a transaction unit, and recording the transaction unit into a block of the blockchain after consensus verification by a blockchain node.
[0031] Based on the second main aspect of the present application, a blockchain data security storage device based on verifiable secret sharing is provided, comprising:
[0032] An encryption storage unit is configured to encrypt received data to be stored to obtain ciphertext, store the ciphertext into a distributed file system and obtain a storage address, and calculate a ciphertext hash value.
[0033] A key processing unit is configured to split an encryption key into sub-key fragments according to a set parameter, and calculate hash values of the fragments.
[0034] An on-chain unit is configured to encapsulate the sub-key fragments, the sub-key fragment hash values and the ciphertext hash value as a transaction unit for writing into the blockchain.
[0035] A decryption verification unit is configured to receive a decryption request, reconstruct the encryption key when the number of valid sub-key fragments reaches a threshold, obtain the ciphertext from the distributed file system and verify the hash value thereof, and decrypt the ciphertext using the reconstructed key to obtain plaintext.
[0036] Based on the third main aspect of the present application, an electronic device is provided, comprising: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to invoke the instructions stored in the memory to execute the foregoing blockchain data security storage method based on verifiable secret sharing.
[0037] Based on the fourth main aspect of the present application, a computer-readable storage medium is provided, which stores computer program instructions, and the computer program instructions are executed by a processor to implement the foregoing blockchain data security storage method based on verifiable secret sharing.
[0038] Compared with the prior art, the present application forms a double verification mechanism by calculating hash values of the ciphertext and the sub-key fragments respectively and storing them on the chain. The prior art usually only performs hash verification on the data itself, while the present application increases the sub-key fragment hash verification in the key management link, which can effectively prevent the key from being tampered with during transmission or storage, ensure the integrity of the whole process from encryption to decryption, and solve the problem that the key is easily modified maliciously in the traditional storage scheme.
[0039] Secondly, the application adopts a secret sharing algorithm to divide the encryption key into multiple sub-key fragments, and a threshold number of valid fragments is required to reconstruct the key. Compared with the single key storage or simple fragment management in the prior art, the scheme greatly reduces the risk of key single-point leakage. Even if part of the fragments are attacked or lost, the security of the original key can still be guaranteed, and the ability of the system to resist malicious node attacks is improved.
[0040] Thirdly, the application introduces a sub-key fragment periodic inspection and recovery mechanism based on a consensus mechanism. When the number of fragments is insufficient, the missing fragments can be automatically reconstructed and supplemented. The prior art often cannot recover data when the number of missing fragments exceeds the threshold. By dynamically maintaining the integrity of the fragments, the application ensures that data can be normally decrypted and used in the case of node failure or fragment loss, ensuring business continuity and long-term data availability.
[0041] Fourthly, the application clearly adopts a national secret algorithm (symmetric encryption algorithm, hash algorithm) for data encryption and verification. Compared with the prior art which relies on general encryption algorithms, it is more in line with the data security compliance requirements of specific industries or regions, enhances the adaptability of the scheme in sensitive fields such as domestic government and finance, and expands the application scenarios of the technology.
[0042] Finally, the application stores the ciphertext in a distributed file system and chains the core verification information, realizing efficient cooperation of on-chain storage and off-chain storage. Compared with the storage redundancy problem caused by full data chaining in the prior art, the application stores key verification information on the blockchain, reduces the storage pressure on the chain, and improves data access efficiency using the high scalability of the distributed file system, balancing security and system performance. BRIEF DESCRIPTION OF DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the embodiments of the application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description only some embodiments of the application, and for those skilled in the art, other drawings obtained from these drawings without creative labor are still within the scope of the application.
[0044] Figure 1 The figure shows the overall flow of the blockchain data security storage method based on verifiable secret sharing in one embodiment of the application;
[0045] Figure 2 The figure shows a verifiable secret sharing protocol based on a consensus mechanism in one embodiment of the application;
[0046] Figure 3 The figure shows a data encryption and authentication algorithm based on a national secret in one embodiment of the application;
[0047] Figure 4 A blockchain-based data security storage scheme in one embodiment of the present application is shown. DETAILED DESCRIPTION
[0048] The preferred embodiments of the present application will be described in detail with the following examples, so as to make the purpose, characteristics and advantages of the present application more clear. It should be understood that the following examples are not a limitation on the scope of the present application, but only to illustrate the essential content of the technical solutions of the present application.
[0049] In the following description, for the purpose of explaining various disclosed embodiments, certain specific details are set forth in order to provide a thorough understanding of various disclosed embodiments. However, one skilled in the relevant arts will recognize that embodiments can be practiced without one or more of the specific details, or with other methods, components, materials, and so forth. In other instances, well-known structures associated with the present application can not be shown or described in order to avoid unnecessarily obscuring descriptions of various embodiments.
[0050] Reference throughout this specification to "one embodiment" or "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment. Thus, the appearances of the phrase "in one embodiment" or "in an embodiment" in various places throughout this specification are not necessarily all referring to the same embodiment. Furthermore, the particular features, structures, or characteristics can be combined in any suitable manner in one or more embodiments.
[0051] As shown in Figure 1 In one embodiment of the present application, a blockchain data security storage method based on verifiable secret sharing includes the following steps executed by a computer:
[0052] Receiving data to be stored, encrypting the data to obtain ciphertext, storing the ciphertext to a distributed file system and obtaining a storage address, and calculating a hash value of the ciphertext;
[0053] According to the set parameters, the encryption key is divided into a plurality of sub-key fragments, and the hash values of the sub-key fragments are calculated;
[0054] The sub-key fragments, the hash values of the sub-key fragments, and the hash value of the ciphertext are encapsulated as a transaction unit and written to the blockchain;
[0055] Receiving a decryption request, and reconstructing the encryption key when the number of valid sub-key fragments submitted reaches a threshold value;
[0056] Obtaining the ciphertext from the distributed file system, verifying the hash value, and decrypting the ciphertext with the reconstructed encryption key to obtain plaintext.
[0057] In the implementation process, the application constructs a blockchain data security storage scheme based on verifiable secret sharing based on the RAFT consensus mechanism, Shamir secret sharing, national secret SM2, SM3 and SM4 algorithm.
[0058] Firstly, the data sharer encrypts the shared file by using the SM4 algorithm, stores the ciphertext file through the IPFS interstellar file system, and calculates the ciphertext file hash digest by using the SM3 algorithm.
[0059] Then, the sharing parameters (n, k) are provided, the SM4 master key is divided into n sub-keys by using Shamir secret sharing, and the sub-key hash digest is calculated by using the SM3 algorithm. At this time, the system writes the sub-key, the sub-key hash digest and the ciphertext file hash digest into the blockchain.
[0060] When decrypting, the data user submits the sub-key greater than or equal to the threshold based on Shamir secret sharing, and reconstructs the SM4 master key.
[0061] Then, the ciphertext file hash digest is obtained from the blockchain, the ciphertext file is obtained from the IPFS interstellar file system, and the ciphertext file hash digest is calculated by using the SM3 algorithm for comparison, so that the secure storage, transmission and key management of the shared file are realized, and the integrity, confidentiality and authenticity of the data and the key are ensured, and the data life cycle security is ensured.
[0062] The above scheme can solve the following problems of the prior art:
[0063] (1) In the existing scheme, the original block data is directly recovered by using the effective fragments that are not lost, and when the number of lost fragments is less than the threshold, the original secret cannot be reconstructed.
[0064] (2) Although the existing scheme improves the security of collaborative storage by using verifiability and identity binding, the key is not subjected to a hash operation.
[0065] The method proposed in the application solves the above problems, which is specifically shown as follows:
[0066] (1) The application combines the RAFT consensus mechanism, and the leader will start the fragment integrity check at regular intervals, and regenerate the key fragments if necessary, to ensure that the number of fragments is consistent with the pre-allocated parameters.
[0067] (2) The application combines the national secret SM3 hash algorithm, and designs a data security authentication scheme based on the national secret, to realize the security protection of the key fragments.
[0068] In one feasible embodiment, the technical solution of the present application is: a blockchain data security storage scheme based on verifiable secret sharing, which combines a RAFT consensus mechanism, a Shamir secret sharing protocol, an SM3 hash algorithm, an SM4 block cipher algorithm, a blockchain and an IPFS interstellar file system to construct a data storage scheme with easy-to-manage and secure keys, and realizes the safe management and control of the whole life cycle of data.
[0069] Specifically, the following stages are included:
[0070] (1) Initialization stage
[0071] This part is the existing conventional technology, and one feasible implementation is as follows:
[0072] The computer hardware system deploys and runs a group of Redis node servers , a MySQL server , and initializes three types of node identities of the RAFT consensus mechanism as , starts to run the core mechanisms of the RAFT leader election , log replication R, etc.:
[0073] .
[0074] (2) Data encryption upload stage
[0075] That is, receiving the data to be stored, encrypting the data to obtain ciphertext, storing the ciphertext to a distributed file system and obtaining the storage address, and calculating the hash value of the ciphertext.
[0076] One feasible implementation is as follows:
[0077] The data sharer uses a symmetric encryption key to encrypt the data file M to be shared to obtain ciphertext CT; and uses the SM3 hash algorithm to perform a hash digest on the data file M to obtain , and then uploads CT to IPFS to return the file hash address :
[0078]
[0079]
[0080] .
[0081] (3) Sub-key generation on-chain stage
[0082] That is, according to the set parameters, the encryption key is divided into several sub-key fragments, and the hash value of each sub-key fragment is calculated. The sub-key fragment, sub-key fragment hash value and ciphertext hash value are packaged as a transaction unit and written to the blockchain.
[0083] One of the feasible implementations is as follows:
[0084] The data sharer sets the number of shares n and the threshold k, and uses the secret sharing protocol in this paper to generate multiple sub-key fragments KEY , and the hash digest of the sub-key fragment is obtained , and and are packaged as a transaction unit and uploaded to the chain:
[0085]
[0086]
[0087] .
[0088] (4) Ciphertext hash and sub-key acquisition stage
[0089] The data user acquires the ciphertext hash value , the sub-key hash value and the sub-key fragment f(x):
[0090] .
[0091] (5) Key reconstruction stage
[0092] That is, receiving a decryption request, reconstructing the encryption key when the number of submitted valid sub-key fragments reaches the threshold;
[0093] One of the feasible implementations is as follows:
[0094] The data user submits more than or equal to the threshold number of sub-keys based on the Shamir secret sharing, and reconstructs the SM4 master key. For example, the data user submits at least k sub-key fragments , and the encryption key KEY is obtained through the secret sharing protocol in this paper:
[0095] .
[0096] The core action of this step is to complete the reconstruction of the encryption key based on the secret sharing protocol, and the threshold number is the key condition to trigger the reconstruction, which ensures that the key can be recovered only when the minimum number of fragments is met, and embodies the threshold feature of secret sharing.
[0097] (6) Ciphertext download stage
[0098] That is, obtain the ciphertext from the distributed file system.
[0099] One of the possible implementations is as follows:
[0100] The data user obtains the ciphertext CT from the IPFS through
[0101] .
[0102] (7) Decryption verification phase
[0103] That is, after verifying the ciphertext hash value, the plaintext is obtained by decryption using the reconstructed encryption key.
[0104] One of the possible implementations is as follows:
[0105] The data user decrypts the ciphertext CT using the key KEY to obtain the plaintext , and obtains the hash digest of CT , uses and for comparison to verify the integrity of the ciphertext CT:
[0106]
[0107]
[0108] .
[0109] Both of the above two phases include two core steps: first, verify the integrity of the ciphertext by comparing the hash values (to ensure that it has not been tampered with), and then decrypt the plaintext using the reconstructed encryption key, forming a complete closed loop of downloading-verification-decryption, ensuring the security of the data from acquisition to use.
[0110] As a further preferred solution, in some embodiments, in the sub-key generation chaining phase, each sub-key slice forms a three-tuple structure containing the slice ID, slice data, and sub-key hash value, which is packaged together with the ciphertext hash value as a transaction unit written to the blockchain, used for identity identification and integrity pre-verification of the sub-key slice.
[0111] As a further preferred solution, in some embodiments, the verification in the key reconstruction phase includes two steps: first, verify whether the submitted sub-key slice hash value is consistent with the corresponding sub-key hash value stored in the blockchain by the SM3 hash algorithm; second, verify the validity of the valid sub-key slice using the Shamir secret sharing protocol, and only keep the sub-key slices that pass both verification steps for reconstruction.
[0112] One of the possible implementations is as follows:
[0113] As Figures 2-4 shown, the verifiable design of the protocol is embodied in the two-way verification mechanism of shard generation and recovery. The specific implementation is as follows:
[0114] (1) Shard generation phase. When the user (User A) performs data sharing operation, the system will generate a corresponding number of sub-key shards according to the sharing parameters n submitted by the user. Each sub-key shard will be calculated by the data encryption authentication algorithm based on the national secret to form a three-tuple structure containing shard ID, shard data, and hash value, which is used for subsequent key reconstruction verification.
[0115] (2) Secret reconstruction phase. This phase will adopt two-step verification, the first step is to verify the integrity of the shard data through SM3 hash, and the second step is to verify the validity of at least k shards submitted by the user using Shamir secret sharing protocol, and to reject invalid or tampered shards. The consistency guarantee mechanism of RAFT log ensures that all nodes store the same shard verification parameters, preventing malicious nodes from providing historical shards to implement replay attacks.
[0116] As a further preferred scheme, in some embodiments, the shard integrity verification based on the consensus mechanism includes: the RAFT leader node sends a shard verification request to all nodes through a timing heartbeat mechanism, and each node returns the three-tuple information of the local sub-key shard; the leader node compares the information of each node, and if it finds that the number of sub-key shards is inconsistent with the preset parameters (n, k), it starts the master key reconstruction process, restores the master key based on the valid shards, generates the missing shards again, and synchronizes the three-tuple information of the new shards to all nodes and the blockchain.
[0117] One possible implementation is as follows: In terms of recovery mechanism, the scheme innovatively combines the Leader election mechanism of RAFT with the secret shard recovery process. The specific implementation is as follows:
[0118] When the system detects that a shard node has failed, it first checks whether the Leader node has failed, if it is not the leader node, it verifies the integrity and validity of the shard, when the shard is lost or the integrity is damaged, it reconstructs the original key and generates the number of valid shards that meet the original n value, and distributes them. If it is the leader node, the cluster quickly elects a new leader through the Term term increment mechanism. The new leader automatically verifies the integrity and validity of the shard, and similarly reconstructs the original key to generate the number of valid shards that meet the original n value, and distributes the new shards to all nodes.
[0119] Therefore, a key aspect of this invention lies in establishing a secret shard recovery mechanism. This mechanism regularly verifies the integrity and validity of shards, regenerates secret shards, and ensures consistency with pre-assigned parameters. This mechanism is based on a national secret data encryption and authentication algorithm. Its core logic is to achieve full data lifecycle protection through the deep coupling of cryptographic techniques with a verifiable secret sharing protocol based on a consensus mechanism.
[0120] In the solutions provided in the above embodiments, the present invention fully considers the situation in practical applications where excessive key loss can render secrets unreconstructable. By establishing a secret shard recovery mechanism, secret shards can be regenerated, ensuring that secrets can always be reconstructed. Furthermore, the present invention constructs a hierarchical encryption key management system based on national secret algorithms. By integrating cryptographic techniques with a verifiable secret sharing protocol based on a consensus mechanism, it achieves full data lifecycle protection while preventing data and key forgery and tampering.
[0121] As a further preferred solution, in some embodiments, the subkey shard is also attached with an outer identity credential generated based on the SM2 digital signature algorithm, and the identity credential is bound to the subkey shard; in the decryption verification phase, in addition to verifying the hash value of the subkey shard, the legitimacy of the identity credential is also verified through the SM2 public key of the subkey generator to confirm the authenticity of the source of the subkey shard.
[0122] One feasible embodiment is as follows: The present invention builds a hierarchical encryption key management system based on the national secret algorithm. Its core logic is to achieve data full life cycle protection through the deep coupling of cryptographic technology and a verifiable secret sharing protocol based on a consensus mechanism, such as Figure 3 shown.
[0123] During the data storage phase, the system uses a standard key derivation function to generate a 256-bit encryption key. The original data submitted by user A is first encrypted using the SM4 block cipher algorithm. The SM3 hash algorithm then calculates the hash value of the ciphertext file. The resulting ciphertext and its hash value are then stored in distributed storage nodes.
[0124] For key management, the present invention divides the SM4 master key KEY into n sub-key shards through a verifiable secret sharing protocol based on the RAFT consensus mechanism. To ensure the integrity and verifiability of the sub-keys, double verification is added: the inner check code calculates the hash value of the shard content through the SM3 hash algorithm, and the outer check code generates a transaction identity certificate based on the SM2 digital signature algorithm to ensure the integrity and source verifiability of the shards during transmission and storage.
[0125] When decrypting data, participants need to submit at least k subkey shards. The system first performs integrity verification on each shard:
[0126] (1) Recalculate the shard hash value using the SM3 hash algorithm, and compare it with the embedded hash value in the shard to detect whether the data has been tampered with.
[0127] (2) Verify the SM2 digital signature of the shard through the SM2 public key of the user (User A) to confirm the legitimacy of the shard source. Shards that fail verification will be excluded and trigger a security alert event, which will be recorded in the audit log.
[0128] As a further preferred solution, in some embodiments, when writing sub-key shard information to the blockchain, a Redis and MySQL dual-writing mechanism is used: first, write the transaction unit to Redis cache to quickly respond to queries, and then asynchronously synchronize to MySQL database to realize persistent storage, ensuring high availability and data consistency of blockchain transaction information.
[0129] As shown in Figure 4 , and in combination with Figure 2 and Figure 3 , in the present application, the data storage scheme mainly includes 6 entities. The following will be described in detail:
[0130] (1) User A. User A, as a data sharer, sets the parameters and threshold (n, k) of secret sharing, and initiates the operation of data storage and transmission.
[0131] (2) User B. User B, as a data user, first reconstructs the SM4 master key KEY using the verifiable secret sharing protocol based on the RAFT consensus mechanism, then obtains the ciphertext file from IPFS, and the SM3 hash value of the ciphertext from the blockchain, and performs decryption and verification to obtain the plaintext data.
[0132] (3) RAFT consensus mechanism. Consists of three types of nodes: L (Leader), F (Follower), and C (Candidate), responsible for sub-key distribution and master key reconstruction support.
[0133] (4) Blockchain network. Responsible for storing sub-keys, sub-key hash values, and hash values of ciphertext files and returning the IPFS hash address of data storage to data users.
[0134] (5) IPFS Interplanetary File System. Responsible for storing shared file data encrypted by the SM4 algorithm.
[0135] (6) MySQL database. Responsible for persistent storage of blockchain information and provides basic data-related operations.
[0136] Specifically, through the chain cooperation of the RAFT consensus mechanism and the national secret algorithm, the security management and control of the entire life cycle of data are realized.
[0137] When a user (User A) needs to share data, first, a main key and a ciphertext file are generated by using a national secret data encryption authentication algorithm, and the ciphertext file is uploaded to an IPFS interstellar file system, the IPFS returns a hash address of a location for saving the data, which is used by a data user to obtain the corresponding stored data.
[0138] Then, n sub-key fragments are generated by using a consensus mechanism verifiable secret sharing protocol. At this time, a three-tuple of a fragment metadata (fragment ID, fragment data, hash value), a ciphertext hash value and the like are collectively encapsulated as a block chain transaction unit.
[0139] The block chain network completes transaction verification and block generation, wherein a leader node (Leader) quickly coordinates a log replication process through a heartbeat timeout mechanism, ensures consistency of full node information of the fragment storage, and synchronizes block chain transaction information through a Redis and MySQL double writing mechanism.
[0140] In the above embodiments, the technical terms, technical principles or technical means related to the technical solutions of the present application are involved, and the above content is not described in detail, which is the known technology or common means mastered by the person skilled in the art.
[0141] The above shows and describes the basic principles and main features of the present application and the advantages of the present application. It should be understood by those skilled in the art that the present application is not limited by the above embodiments, and the above embodiments and descriptions in the specification are only to illustrate the principles of the present application. Without departing from the spirit and scope of the present application, various changes and improvements can be made to the present application, and these changes and improvements all fall within the scope of the claimed present application. The scope of protection of the present application is defined by the appended claims and their equivalents.
Claims
1. A blockchain data security storage method based on verifiable secret sharing, characterized in that: The following steps are performed by the computer hardware: Receive the data to be stored, encrypt it to obtain ciphertext, store the ciphertext in the distributed file system and obtain the storage address, and calculate the hash value of the ciphertext; Split the encryption key into several sub-key fragments according to the set parameters, and calculate the hash value of each sub-key fragment; Encapsulate the subkey shard, subkey shard hash value, and ciphertext hash value into a transaction unit and write it into the blockchain; Receive decryption requests and reconstruct the encryption key when the number of valid subkey shards submitted reaches a threshold; Obtain the ciphertext from the distributed file system, verify its hash value, and then decrypt it using the reconstructed encryption key to obtain the plaintext.
2. The blockchain data security storage method based on verifiable secret sharing according to claim 1 is characterized in that: The encryption key is divided into several sub-key fragments according to the set parameters, including: According to the set total number and the minimum number required for reconstruction, the secret sharing algorithm is used to split the encryption key into a corresponding number of sub-key shards. Each shard carries a unique identifier, and the hash value of each shard is associated with the shard.
3. The blockchain data security storage method based on verifiable secret sharing according to claim 1 is characterized in that: The reconstructing the encryption key when the number of submitted valid subkey fragments reaches a threshold includes: First, verify whether the hash value of the subkey shard is consistent with the corresponding hash value stored in the blockchain, and select the valid shard; The encryption key is reconstructed when the number of valid shards reaches the minimum number required for reconstruction.
4. The blockchain data security storage method based on verifiable secret sharing according to claim 1 is characterized in that: Verifying the hash value includes: Verify that the hash value of the ciphertext obtained from the distributed file system is consistent with the ciphertext hash value stored in the blockchain.
5. The blockchain data security storage method based on verifiable secret sharing according to claim 1 is characterized in that: The method further comprises: Regular integrity checks of sub-key shards in the blockchain based on the consensus mechanism; When it is detected that the number of shards is insufficient due to failure or loss, the key reconstruction process is initiated to regenerate the missing subkey shards; Update the newly generated shards and their hash values to the blockchain to maintain the total number of shards.
6. The blockchain data security storage method based on verifiable secret sharing according to claim 1 is characterized in that: The encrypting process to obtain ciphertext includes: encrypting the data to be stored using a national secret symmetric encryption algorithm to generate corresponding ciphertext; The calculating of the hash value of the ciphertext includes: performing a hash operation on the ciphertext using a national secret hash algorithm to obtain a hash value for verifying the integrity of the ciphertext.
7. The blockchain data security storage method based on verifiable secret sharing according to claim 1 is characterized in that: The encapsulating of the subkey shards, the subkey shard hash values and the ciphertext hash values into transaction units and writing them into the blockchain includes: combining the subkey shards, the subkey shard hash values and the ciphertext hash values according to a preset data structure to form a transaction unit, and recording the transaction unit into a block of the blockchain after verification by consensus of the blockchain nodes.
8. A blockchain data security storage device based on verifiable secret sharing, characterized in that: include: The encryption storage unit is used to encrypt the received data to be stored to obtain ciphertext, store the ciphertext in the distributed file system and obtain the storage address, and calculate the ciphertext hash value; A key processing unit, configured to split the encryption key into subkey fragments according to set parameters and calculate the hash value of each fragment; The on-chain unit is used to encapsulate the subkey shards, subkey shard hash values, and ciphertext hash values into transaction units and write them into the blockchain; The decryption verification unit is used to receive decryption requests, reconstruct the encryption key when the number of valid subkey shards reaches a threshold, obtain the ciphertext from the distributed file system and verify its hash value, and then decrypt the plaintext with the reconstructed key.
9. An electronic device, characterized in that: include: processor; A memory for storing processor-executable instructions; wherein the processor is configured to call the instructions stored in the memory to execute the blockchain data secure storage method based on verifiable secret sharing as described in any one of claims 1 to 7.
10. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method for securely storing blockchain data based on verifiable secret sharing as described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Payment method and system based on shared key
CN114650127A
Data distributed storage method and system based on secret sharing technology
CN119172077A
Encryption and decryption method and system fusing quantum key and secret sharing, and medium
CN120320945A
Cited By
Data management method and device and electronic equipment
CN120956535A
Medical data security protection method and system based on block chain
CN121486085A