Blockchain data security storage method based on verifiable secret sharing
Patent Information
- Application Number
- CN202511058202.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-30
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2045-07-30
AI Technical Summary
[0010]本发明目的是提供一种基于可验证秘密共享的区块链数据安全存储方法,本发明的方法结合RAFT共识机制、Shamir秘密共享、国密SM2、SM3及SM4算法,解决现有技术中秘密共享方案对动态环境适应性弱、子密钥组存在密钥管理安全性问题、分布式系统数据不一致和节点不可信等问题,以及现有最接近技术方案中丢失分片数低于阈值时无法重构原始秘密、未对密钥进行哈希操作等问题,实现数据全生命周期的安全管控,确保数据和密钥的完整性、保密性和可认证性,保障数据在存储、传输及密钥管理等过程中的安全
[0038] Compared with existing technologies, this invention forms a dual verification mechanism by calculating hash values for ciphertext and subkey fragments separately and storing them on the blockchain. Existing technologies often only perform hash verification on the data itself, while this invention adds subkey fragment hash verification in the key management stage, which can effectively prevent the key from being tampered with during transmission or storage, ensure the integrity of the data throughout the entire process from encryption to decryption, and solve the problem of keys being easily maliciously modified in traditional storage schemes.
Smart Images

Figure CN120785533B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of blockchain-related technologies, particularly to blockchain technologies such as data storage, storage encryption, distributed storage, data sharding, secret sharing, key negotiation, national cryptographic algorithms, and RAFT consensus mechanism. In particular, it relates to a secure data storage method for blockchain based on verifiable secret sharing. Background Technology
[0002] Data, as a factor of production, is a crucial asset for the new round of intelligent and digital development. However, due to the open nature of cyberspace, data faces various types and levels of security threats during storage and sharing. While traditional encryption methods can ensure data confidentiality, they suffer from key security management issues such as the easy loss or leakage of master keys. These risks pose significant challenges to the development of the digital economy.
[0003] Secret sharing is a technique that uses cryptographic methods to divide sensitive information into multiple independent data fragments and distribute them to different participants. Its core lies in distributing control of the complete secret, ensuring that no single participant can recover the original content alone. The secret can only be reconstructed through collaboration among multiple parties when a predetermined number of submissions are made.
[0004] Currently, secret sharing technology still faces many challenges. One typical technical problem is that existing solutions are not very adaptable to dynamic environments and struggle to cope with situations where some subkey fragments fail or are lost. However, using only subkey groups generated through secret sharing presents security issues in key management, and distributed systems used for data and key storage also suffer from problems such as data inconsistency and untrusted nodes.
[0005] Regarding data security protection, scholars such as Fu Yuli and Ren Yawei proposed a blockchain sharding storage model based on verifiable secret sharing (Computer Engineering and Design, No. 12, 2023). This model addresses the core issues of poor scalability of blockchain storage and vulnerability to malicious node spoofing attacks in on-chain collaborative storage by introducing verifiable secret sharing technology and a key negotiation protocol. Based on block stability, the model categorizes blocks into high-stability and low-stability types: high-stability blocks are directly sharded using verifiable secret sharing technology to reduce storage redundancy; low-stability blocks are sharded and their identities bound to storage nodes through a key negotiation protocol, ensuring the security and authentication of the sharding transmission process. This solution improves the security of the blockchain storage system while maintaining storage scalability.
[0006] However, the existing technologies mentioned above fail to provide ideal solutions to some of the following technical problems.
[0007] First, existing solutions primarily focus on the scalability of blockchain storage and resistance to malicious node spoofing attacks. While these improve the security of the blockchain storage system, they do not explicitly address the need to build a layered encryption key management system to achieve full lifecycle protection of data. This may result in insufficient security guarantees for data at certain stages, such as insufficient consistency between data encryption and key management, affecting the security of data from its creation to its destruction.
[0008] Secondly, existing solutions directly utilize the unlost, valid shards to recover the original block data. However, when the number of lost shards is below a threshold, the original secret cannot be reconstructed. This poses a significant risk in practical applications; if a large number of shards are lost, the data cannot be recovered, severely impacting normal data usage and business continuity.
[0009] Furthermore, while existing solutions enhance collaborative storage security through verifiability and identity binding, deriving keys through data hashing, they do not perform hashing operations on the keys themselves. This lack of key fragmentation hashing exposes keys to the risk of tampering during storage and transmission. If a key is maliciously modified, the confidentiality, integrity, and authentication of the data cannot be guaranteed, impacting the security of the entire data storage system. Summary of the Invention
[0010] The purpose of this invention is to provide a secure blockchain data storage method based on verifiable secret sharing. This method combines the RAFT consensus mechanism, Shamir secret sharing, and the Chinese national cryptographic algorithms SM2, SM3, and SM4 to solve problems in existing secret sharing schemes, such as weak adaptability to dynamic environments, key management security issues in subkey groups, data inconsistency in distributed systems, and untrustworthy nodes. It also addresses issues in the closest existing technical solutions, such as the inability to reconstruct the original secret when the number of lost fragments is below a threshold and the lack of hashing operations on the keys. This invention achieves secure management throughout the entire data lifecycle, ensuring the integrity, confidentiality, and verifiability of data and keys, and guaranteeing data security during storage, transmission, and key management.
[0011] Based on a first key 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] The encryption key is divided into several subkey fragments according to the set parameters, and the hash value of each subkey fragment is calculated.
[0014] The subkey fragment, subkey fragment hash value, and ciphertext hash value are encapsulated into transaction units and written into the blockchain;
[0015] Receive decryption requests and reconstruct the encryption key when the number of valid subkey fragments submitted reaches a threshold.
[0016] The ciphertext is obtained from the distributed file system, its hash value is verified, and then the plaintext is decrypted using the reconstructed encryption key.
[0017] As a further preferred embodiment, in the aforementioned method, the step of dividing the encryption key into several sub-key fragments according to set parameters includes:
[0018] Based on the set total number and the minimum number required for reconstruction, the encryption key is divided into a corresponding number of subkey fragments using a secret sharing algorithm. Each fragment carries a unique identifier, and the hash value of each fragment is associated with the fragment.
[0019] As a further preferred embodiment, in the aforementioned method, the step of reconstructing the encryption key when the number of submitted valid subkey fragments reaches a threshold includes:
[0020] First, verify whether the hash value of the subkey fragment is consistent with the corresponding hash value stored in the blockchain, and then filter out the valid fragments;
[0021] The encryption key is reconstructed when the number of valid fragments reaches the minimum number required for reconstruction.
[0022] As a further preferred embodiment, in the aforementioned method, verifying its hash value includes:
[0023] Verify whether the hash value of the ciphertext obtained from the distributed file system is consistent with the hash value of the ciphertext stored in the blockchain.
[0024] As a further preferred embodiment, the aforementioned method further includes:
[0025] Periodic integrity checks are performed on subkey fragments in the blockchain based on a consensus mechanism.
[0026] When a fragment failure or loss is detected, resulting in an insufficient number of fragments, the key reconstruction process is initiated to regenerate the missing subkey fragments.
[0027] The newly generated shards and their hash values are updated to the blockchain to maintain the total number of shards.
[0028] As a further preferred embodiment, in the aforementioned method, the step of encrypting the data to obtain ciphertext includes: encrypting the data to be stored using a national standard symmetric encryption algorithm to generate the corresponding ciphertext;
[0029] The calculation of the hash value of the ciphertext includes: performing a hash operation on the ciphertext using the national cryptographic hash algorithm to obtain a hash value used to verify the integrity of the ciphertext.
[0030] As a further preferred embodiment, in the aforementioned method, the step of encapsulating the subkey fragment, subkey fragment hash value, and ciphertext hash value into a transaction unit and writing it into the blockchain includes: combining the subkey fragment, subkey fragment hash value, and 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 the blockchain nodes.
[0031] Based on a second key aspect of the present invention, a blockchain data security storage device based on verifiable secret sharing is provided, comprising:
[0032] The encrypted 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;
[0033] The key processing unit is used to divide the encryption key into subkey fragments according to the set parameters and calculate the hash value of each fragment;
[0034] The on-chain unit is used to encapsulate the subkey fragment, subkey fragment hash value, and ciphertext hash value into a transaction unit and write it to the blockchain;
[0035] The decryption verification unit is used to receive decryption requests, reconstruct the encryption key when the number of valid subkey fragments reaches a threshold, obtain the ciphertext from the distributed file system and verify its hash value, and then decrypt it with the reconstructed key to obtain the plaintext.
[0036] Based on a third key aspect of the present invention, 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 aforementioned blockchain data security storage method based on verifiable secret sharing.
[0037] Based on a fourth key aspect of the present invention, a computer-readable storage medium is provided having computer program instructions stored thereon, which, when executed by a processor, implement the aforementioned blockchain data security storage method based on verifiable secret sharing.
[0038] Compared with existing technologies, this invention forms a dual verification mechanism by calculating hash values for ciphertext and subkey fragments separately and storing them on the blockchain. Existing technologies often only perform hash verification on the data itself, while this invention adds subkey fragment hash verification in the key management stage, which can effectively prevent the key from being tampered with during transmission or storage, ensure the integrity of the data throughout the entire process from encryption to decryption, and solve the problem of keys being easily maliciously modified in traditional storage schemes.
[0039] Secondly, this invention employs a secret sharing algorithm to divide the encryption key into multiple subkey fragments. A threshold number of valid fragments are required to reconstruct the key. Compared to existing technologies that use single-key storage or simple fragment management, this scheme significantly reduces the risk of single-point key leakage. Even if some fragments are attacked or lost, the security of the original key is still guaranteed, enhancing the system's ability to resist malicious node attacks.
[0040] Third, this invention introduces a consensus-based subkey fragment periodic verification and recovery mechanism. When the number of fragments is insufficient, it can automatically reconstruct and supplement missing fragments. Existing technologies often cannot recover data when fragment loss exceeds a threshold, while this invention ensures that data can still be decrypted and used normally in scenarios of node failure or fragment loss by dynamically maintaining fragment integrity, thus guaranteeing business continuity and long-term data availability.
[0041] Fourth, this invention explicitly adopts national cryptographic algorithms (symmetric encryption algorithms, hash algorithms) for data encryption and verification. Compared with existing technologies that rely 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 solution in sensitive areas such as domestic government affairs and finance, and expands the application scenarios of the technology.
[0042] Finally, this invention stores the encrypted data in a distributed file system and uploads the core verification information to the blockchain, achieving efficient collaboration between on-chain evidence storage and off-chain storage. Compared to the storage redundancy problem caused by uploading all data to the blockchain in existing technologies, this invention reduces on-chain storage pressure by storing key verification information on the blockchain, while leveraging the high scalability of the distributed file system to improve data access efficiency, thus balancing security and system performance. Attached Figure Description
[0043] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, obtaining other drawings based on these drawings without creative effort still falls within the scope of the present invention.
[0044] Figure 1 This illustrates the overall flow of a blockchain data security storage method based on verifiable secret sharing in one embodiment of the present invention;
[0045] Figure 2 This invention illustrates a verifiable secret-sharing protocol based on a consensus mechanism in one embodiment.
[0046] Figure 3 This invention illustrates a data encryption and authentication algorithm based on national cryptographic standards in one embodiment.
[0047] Figure 4 An embodiment of the present invention illustrates a blockchain-based data security storage scheme. Detailed Implementation
[0048] The preferred embodiments of the present invention will be described in detail below to provide a clearer understanding of the purpose, features, and advantages of the invention. It should be understood that the following embodiments are not intended to limit the scope of the invention, but are merely illustrative of the essential content of the technical solution of the present invention.
[0049] In the following description, certain specific details are set forth for the purpose of illustrating various disclosed embodiments in order to provide a thorough understanding of the various disclosed embodiments. However, those skilled in the art will recognize that embodiments may be practiced without one or more of these specific details. In other instances, well-known techniques associated with the invention may not have been shown or described in detail to avoid unnecessarily obscuring the description of the embodiments.
[0050] Throughout this specification, references to "an embodiment" or "an embodiment" indicate that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment. Therefore, the appearance of "in an embodiment" or "an embodiment" in various places throughout the specification does not necessarily refer to the same embodiment. Furthermore, a particular feature, structure, or characteristic may be combined in any manner in one or more embodiments.
[0051] like Figure 1 As shown, in one embodiment of the present invention, a blockchain data security storage method based on verifiable secret sharing includes the following steps executed by a computer:
[0052] 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;
[0053] The encryption key is divided into several subkey fragments according to the set parameters, and the hash value of each subkey fragment is calculated.
[0054] The subkey fragment, subkey fragment hash value, and ciphertext hash value are encapsulated into transaction units and written into the blockchain;
[0055] Receive decryption requests and reconstruct the encryption key when the number of valid subkey fragments submitted reaches a threshold.
[0056] The ciphertext is obtained from the distributed file system, its hash value is verified, and then the plaintext is decrypted using the reconstructed encryption key.
[0057] In its implementation, this invention constructs a blockchain data security storage solution based on verifiable secret sharing, using the RAFT consensus mechanism, Shamir secret sharing, and the national cryptographic algorithms SM2, SM3, and SM4.
[0058] First, the data sharer uses the SM4 algorithm to encrypt the shared file, stores the encrypted file through the IPFS interplanetary file system, and uses the SM3 algorithm to calculate the hash digest of the encrypted file.
[0059] Next, the shared parameters (n, k) are provided, and the SM4 master key is divided into n subkeys using Shamir secret sharing. The SM3 algorithm is then used to calculate the hash digest of each subkey. At this point, the system writes the subkeys, their hash digests, and the ciphertext file hash digests to the blockchain.
[0060] During decryption, the data user reconstructs the SM4 master key by submitting a subkey greater than or equal to the threshold based on the Shamir secret share.
[0061] Next, the encrypted file hash digest is obtained from the blockchain; the encrypted file is obtained from the IPFS interplanetary file system, and the SM3 algorithm is used to calculate the encrypted file hash digest for comparison, thereby realizing the secure storage, transmission and key management of shared files, ensuring the integrity, confidentiality and authentication of data and keys, and guaranteeing the security of data throughout its entire lifecycle.
[0062] The above solution can solve the following problems of the existing technology:
[0063] (1) In the existing scheme, the original block data is recovered by directly using the valid fragments that have not been lost. 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 and derives the key through data hashing, it does not perform hashing operation on the key.
[0065] The method proposed in this invention solves the above problems, specifically in the following ways:
[0066] (1) In this invention, the leader will periodically start the fragment integrity check and regenerate the key fragments when necessary to ensure that the number of fragments is consistent with the pre-allocated parameters.
[0067] (2) This invention combines the national cryptographic SM3 hash algorithm to design a data security authentication scheme based on national cryptographic standards, and realizes the security protection of key fragmentation.
[0068] In a feasible specific embodiment, the technical solution of the present invention is as follows: based on a blockchain data security storage scheme with verifiable secret sharing, a data storage scheme that is easy to manage and secure is constructed by combining the RAFT consensus mechanism, Shamir secret sharing protocol, SM3 hash algorithm, SM4 block cipher algorithm, blockchain and IPFS interplanetary file system, so as to realize the security control of the entire data life cycle.
[0069] Specifically, it includes the following stages:
[0070] (1) Initialization phase
[0071] This section describes existing conventional technology, and one feasible embodiment is as follows:
[0072] The computer hardware system deploys and runs a set of Redis node servers. MySQL server And initialize the three types of node identities of the RAFT consensus mechanism as follows: RAFT leader election begins Core mechanisms of R, such as log replication:
[0073] .
[0074] (2) Data encryption and uploading stage
[0075] That is: 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.
[0076] One feasible implementation is as follows:
[0077] Data sharers use symmetric encryption keys Encrypt the data file M to be shared to obtain the ciphertext CT; then use the SM3 hash algorithm to perform a hash digest on the data file M, resulting in... Then upload the CT file to IPFS and return the file hash address. :
[0078]
[0079]
[0080] .
[0081] (3) Subkey generation on-chain stage
[0082] In other words, the encryption key is divided into several subkey fragments according to the set parameters, and the hash value of each subkey fragment is calculated. The subkey fragments, their hash values, and the ciphertext hash values are then encapsulated into transaction units and written to the blockchain.
[0083] One feasible implementation is as follows:
[0084] The data sharer sets the number of shares n and a threshold k, and uses the secret sharing protocol described in this paper to generate multiple subkey fragments from the KEY. And perform hash digests on the subkey fragments to obtain ,Will and Encapsulate it into a transaction unit and upload it to the blockchain:
[0085]
[0086]
[0087] .
[0088] (4) Ciphertext hashing and subkey acquisition stage
[0089] Data users obtain ciphertext hash values from the blockchain. Subkey hash value Subkey fragmentation f(x):
[0090] .
[0091] (5) Key reconstruction stage
[0092] That is: receive decryption requests and reconstruct the encryption key when the number of valid subkey fragments submitted reaches a threshold;
[0093] One feasible implementation is as follows:
[0094] Data users reconstruct the SM4 master key by submitting subkeys greater than or equal to a threshold based on the Shamir secret share. For example, a data user submits at least k subkey fragments. The encryption key KEY is obtained through the secret sharing protocol described in this article:
[0095] .
[0096] The core action of this step is to reconstruct the encryption key based on the secret sharing protocol. It emphasizes that the threshold number is the key condition for triggering reconstruction, ensuring that the key can only be recovered when the minimum number of fragments is met, which reflects the threshold characteristic of secret sharing.
[0097] (6) Encrypted text download stage
[0098] That is, to obtain ciphertext from a distributed file system.
[0099] One feasible implementation is as follows:
[0100] Data users through Download encrypted CT from IPFS:
[0101] .
[0102] (7) Decryption and verification stage
[0103] That is, after verifying the ciphertext hash value, the plaintext is obtained by decrypting it with the reconstructed encryption key.
[0104] One feasible implementation is as follows:
[0105] Data users use the key KEY to decrypt the ciphertext CT to obtain the plaintext. And obtain a hash digest of CT. ,use and A comparison was performed to verify the integrity of the encrypted CT scan:
[0106]
[0107]
[0108] .
[0109] Both of the above stages involve two core steps: first, verifying the integrity of the ciphertext by comparing hash values (ensuring it has not been tampered with), and then decrypting it with the reconstructed encryption key to obtain the plaintext, forming a complete closed loop of download-verification-decryption, which ensures the security of data from acquisition to use.
[0110] As a further preferred embodiment, in some embodiments, during the subkey generation and on-chain stage, each subkey shard forms a triplet structure containing a shard ID, shard data, and subkey hash value. The triplet structure and the ciphertext hash value are encapsulated together as a transaction unit and written into the blockchain for the identification and integrity pre-verification of the subkey shard.
[0111] As a further preferred embodiment, in some embodiments, the verification in the key reconstruction stage includes two steps: the first step is to verify whether the submitted subkey fragment hash value is consistent with the corresponding subkey hash value stored in the blockchain using the SM3 hash algorithm; the second step is to verify the validity of the valid subkey fragment using the Shamir secret sharing protocol, and only the subkey fragments that pass both steps of verification are retained for reconstruction.
[0112] A feasible implementation is as follows:
[0113] like Figures 2-4 As shown, the verifiability design of the protocol is reflected in the two-way verification mechanism for fragment generation and recovery. The specific implementation is as follows:
[0114] (1) Fragment generation stage. When a user (User A) performs a data sharing operation, the system will generate a corresponding number of subkey fragments based on the sharing parameter n submitted by the user. Each subkey fragment will have its hash digest calculated by a data encryption and authentication algorithm based on national cryptographic standards, forming a triplet structure containing fragment ID, fragment data, and hash value, which will be used for subsequent key reconstruction verification.
[0115] (2) Secret Reconstruction Phase. This phase employs a two-step verification process. The first step verifies the integrity of the sharded data using SM3 hashing. The second step utilizes the Shamir secret sharing protocol to verify the validity of at least k shards submitted by the user, rejecting invalid or tampered shards. The consistency guarantee mechanism of the RAFT log ensures that all nodes store the same shard verification parameters, preventing malicious nodes from providing historical shards to launch replay attacks.
[0116] As a further preferred embodiment, in some implementations, the consensus-based shard integrity verification includes: the RAFT leader node sending a shard verification request to all nodes through a timed heartbeat mechanism, and each node returning the triple information of its local subkey shards; the leader node comparing the information of each node, and if it finds that the number of subkey shards is inconsistent with the preset parameters (n, k), it initiates the master key reconstruction process, recovers the master key based on the valid shards, regenerates the missing shards, and synchronizes the triple information of the new shards to all nodes and the blockchain.
[0117] One feasible implementation is as follows: Regarding the recovery mechanism, the solution innovatively combines RAFT's Leader election mechanism with a secret sharding recovery process. The specific implementation is as follows:
[0118] When the system detects a shard node failure, it first checks if the failure is caused by the Leader node. If not, it verifies the integrity and validity of the shards. If a shard is lost or its integrity is compromised, it reconstructs the original key, generates a valid number of shards that satisfy the original value of n, and distributes them. If the failure is caused by the Leader node, the cluster quickly elects a new Leader using a Term increment mechanism. The new Leader automatically verifies the integrity and validity of the shards, similarly reconstructs the original key, generates a valid number of shards that satisfy the original value of n, and distributes the new shards to all nodes.
[0119] Therefore, a core aspect of this invention lies in establishing a secret fragment recovery mechanism. The integrity and validity of the fragments are periodically checked to regenerate the secret fragments, ensuring consistency with pre-allocated parameters. Furthermore, it is based on a national cryptographic data encryption and authentication algorithm. Its core logic achieves full lifecycle data protection through deep coupling of cryptographic technology and a verifiable secret sharing protocol based on a consensus mechanism.
[0120] In the solutions provided in the above embodiments, this invention fully considers the situation in practical applications where excessive key loss leads to the inability to reconstruct the secret. It establishes a secret fragment recovery mechanism to regenerate secret fragments, ensuring that the secret can always be reconstructed. Furthermore, this invention constructs a hierarchical encryption key management system based on national cryptographic algorithms. By integrating cryptographic technology with a verifiable secret sharing protocol based on a consensus mechanism, it achieves full lifecycle protection of data while preventing data and keys from being forged and tampered with.
[0121] As a further preferred embodiment, in some embodiments, the subkey fragment is further attached with an outer identity credential generated based on the SM2 digital signature algorithm, and the identity credential is bound to the subkey fragment; during the decryption verification stage, in addition to verifying the hash value of the subkey fragment, the legality 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 fragment.
[0122] One feasible implementation is as follows: This invention constructs a hierarchical encryption key management system based on national cryptographic algorithms. Its core logic is to achieve full lifecycle protection of data through deep coupling of cryptographic technology and a verifiable secret sharing protocol based on a consensus mechanism. Figure 3 As shown.
[0123] During the data storage phase, the system uses a standard-defined key derivation function to generate a 256-bit encryption key. For the original data submitted by the user (User A), it is first encrypted using the SM4 block cipher algorithm, then the hash value of the ciphertext file is calculated using the SM3 hash algorithm, and the generated ciphertext and its hash value are stored in the distributed storage node.
[0124] For key management, this invention divides the SM4 master key KEY into n subkey fragments using a verifiable secret sharing protocol based on the RAFT consensus mechanism. To ensure the integrity and verifiability of the subkeys, double verification is added: the inner check code calculates the hash value of the fragment content using the SM3 hash algorithm, and the outer check code generates a transaction identity certificate based on the SM2 digital signature algorithm, ensuring the integrity and verifiability of the fragments during transmission and storage.
[0125] When data decryption is required, participants must submit at least k subkey fragments. The system first performs integrity verification on each fragment:
[0126] (1) Use the SM3 hash algorithm to recalculate the shard hash value and compare it with the embedded hash value of the shard to detect whether the data has been tampered with.
[0127] (2) Verify the SM2 digital signature of the fragment using the user's (User A) SM2 public key to confirm the legitimacy of the fragment's origin. Fragments that fail verification will be removed and a security alert event will be triggered and recorded in the audit log.
[0128] As a further preferred solution, in some embodiments, when writing information such as subkey fragments into the blockchain, a dual-write mechanism of Redis and MySQL is adopted: first, the transaction unit is written to the Redis cache for quick response to queries, and then asynchronously synchronized to the MySQL database to achieve persistent storage, ensuring high availability and data consistency of blockchain transaction information.
[0129] like Figure 4 As shown, and in combination Figure 2 and Figure 3 In this invention, the data storage scheme mainly comprises six entities. These are described in detail below:
[0130] (1) User A. User A, as the data sharer, sets the parameters and threshold (n, k) for secret sharing and initiates data storage and transmission operations.
[0131] (2) User B. As a data user, User B 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, obtains the SM3 hash value of the ciphertext from the blockchain, and performs decryption and verification to obtain the original data.
[0132] (3) RAFT consensus mechanism. It consists of three types of nodes: L (Leader), F (Follower), and C (Candidate), which are responsible for distributing subkeys and supporting the reconstruction of master keys.
[0133] (4) Blockchain network. It is responsible for storing subkeys, subkey hash values, hash values of ciphertext files, and returning the IPFS hash address of the data storage to data users.
[0134] (5) IPFS Interplanetary File System. It is responsible for storing shared file data encrypted with the SM4 algorithm.
[0135] (6) MySQL database. Responsible for persistent storage of blockchain information and providing basic data-related operations.
[0136] Specifically, through the chain-like collaboration of the RAFT consensus mechanism and the national cryptographic algorithm, secure management and control of data throughout its entire lifecycle can be achieved.
[0137] When a user (User A) needs to share data, the system first uses the national cryptographic data encryption and authentication algorithm to generate a master key and a ciphertext file, and then uploads the ciphertext file to the IPFS interplanetary file system. IPFS will return a hash address that stores the location of the data, which the data user can use to retrieve the corresponding stored data.
[0138] Subsequently, a verifiable secret sharing protocol based on a consensus mechanism is used to generate n subkey shards. At this point, the shard metadata (shard ID, shard data, hash value) triples, ciphertext hash values, etc., are collectively encapsulated into a blockchain transaction unit.
[0139] The blockchain network completes transaction verification and block generation. The leader node quickly coordinates the log replication process through a heartbeat timeout mechanism to ensure the consistency of information across all nodes in the sharded storage, and synchronizes blockchain transaction information through a dual-write mechanism using Redis and MySQL.
[0140] The technical terms, principles, or means related to the technical solutions of the present invention mentioned in the above embodiments, which are not described in detail above, are all well-known technologies or common practices that are known to those skilled in the art.
[0141] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the present invention as claimed. The scope of protection of this invention 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, This includes the following steps performed by computer hardware: The process involves receiving data to be stored, encrypting it to obtain ciphertext, storing the ciphertext in a distributed file system and obtaining its storage address, and calculating the hash value of the ciphertext. This includes the use of a symmetric encryption key by the data sharers. Encrypt the data file M to be shared to obtain the ciphertext CT; then use the SM3 hash algorithm to perform a hash digest on the data file M, resulting in... Then upload the CT file to IPFS and return the file hash address. ; The encryption key is divided into several subkey fragments according to the set parameters, and the hash value of each subkey fragment is calculated. The subkey fragments, their hash values, and the ciphertext hash values are encapsulated into transaction units and written to the blockchain. Each subkey fragment forms a triplet structure containing a fragment ID, fragment data, and a subkey hash value. This triplet structure, along with the ciphertext hash value, is encapsulated into a transaction unit and written to the blockchain for identification and integrity pre-verification of the subkey fragments. This includes: the data sharer setting the number of shares n and a threshold k, and using a secret sharing protocol to generate multiple subkey fragments from the KEY. And perform hash digests on the subkey fragments to obtain ,Will and Encapsulate it into a transaction unit and upload it to the blockchain; Receive decryption requests and reconstruct the encryption key when the number of valid subkey fragments submitted reaches a threshold. The ciphertext is obtained from the distributed file system, its hash value is verified, and then the plaintext is decrypted using the reconstructed encryption key. The method further includes: performing periodic integrity checks on subkey shards in the blockchain based on a consensus mechanism; when a shard failure or loss is detected, resulting in an insufficient number, initiating a key reconstruction process to regenerate the missing subkey shards; and updating the newly generated shards and their hash values to the blockchain to maintain the total number of shards. The consensus-based shard integrity verification includes: the RAFT leader node sends a shard verification request to all nodes through a timed heartbeat mechanism, and each node returns the triple information of its local subkey shard; the leader node compares the information of each node, and if it finds that the number of subkey shards is inconsistent with the preset parameters, it initiates the master key reconstruction process, restores the master key based on the valid shards, regenerates the missing shards, and synchronizes the triple information of the new shards to all nodes and the blockchain.
2. The blockchain data security storage method based on verifiable secret sharing according to claim 1, characterized in that, The step of dividing the encryption key into several sub-key fragments according to the set parameters includes: Based on the set total number and the minimum number required for reconstruction, the encryption key is divided into a corresponding number of subkey fragments using a secret sharing algorithm. Each fragment carries a unique identifier, and the hash value of each fragment is associated with the fragment.
3. The blockchain data security storage method based on verifiable secret sharing according to claim 1, characterized in that, The step of 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 fragment is consistent with the corresponding hash value stored in the blockchain, and then filter out the valid fragments; The encryption key is reconstructed when the number of valid fragments reaches the minimum number required for reconstruction.
4. The blockchain data security storage method based on verifiable secret sharing according to claim 1, characterized in that, The verification of its hash value includes: Verify whether the hash value of the ciphertext obtained from the distributed file system is consistent with the hash value of the ciphertext stored in the blockchain.
5. The blockchain data security storage method based on verifiable secret sharing according to claim 1, characterized in that, The step of encrypting the data to obtain ciphertext includes: encrypting the data to be stored using the national standard symmetric encryption algorithm to generate the corresponding ciphertext; The calculation of the hash value of the ciphertext includes: performing a hash operation on the ciphertext using the national cryptographic hash algorithm to obtain a hash value used to verify the integrity of the ciphertext.
6. The blockchain data security storage method based on verifiable secret sharing according to claim 1, characterized in that, The step of encapsulating the subkey fragment, subkey fragment hash value, and ciphertext hash value into a transaction unit and writing it into the blockchain includes: combining the subkey fragment, subkey fragment hash value, and 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 the blockchain nodes.
7. A blockchain data security storage device based on verifiable secret sharing for implementing the method of claim 1, characterized in that, include: The encrypted 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; The key processing unit is used to divide the encryption key into subkey fragments according to the set parameters and calculate the hash value of each fragment; The on-chain unit is used to encapsulate the subkey fragment, subkey fragment hash value, and ciphertext hash value into a transaction unit and write it to the blockchain; The decryption verification unit is used to receive decryption requests, reconstruct the encryption key when the number of valid subkey fragments reaches a threshold, obtain the ciphertext from the distributed file system and verify its hash value, and then decrypt it with the reconstructed key to obtain the plaintext.
8. An electronic device, characterized in that, include: processor; A memory for storing processor-executable instructions; wherein the processor is configured to invoke the instructions stored in the memory to execute the blockchain data security storage method based on verifiable secret sharing as described in any one of claims 1-6.
9. A computer-readable storage medium having computer program instructions stored thereon, characterized in that, When the computer program instructions are executed by the processor, they implement the blockchain data security storage method based on verifiable secret sharing as described in any one of claims 1-6.
Citation Information
Patent Citations
Data distributed storage method and system based on secret sharing technology
CN119172077A