File storage and acquisition method, device, electronic device and storage medium
The encryption key is generated through the elliptic curve algorithm and hash algorithm, combined with the distributed storage system, and the problem of limited storage space and vulnerability in blockchain is solved, and the secure storage and rapid acquisition of files are realized, ensuring the stability and security of the system.
Patent Information
- Application Number
- CN202211649481.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-21
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2042-12-21
AI Technical Summary
In the prior art, blockchain storage space is limited and vulnerable to attack. How to combine distributed storage systems on the basis of blockchain storage to ensure both file security and file access speed is an urgent problem that needs to be solved.
The elliptic curve algorithm is used to generate asymmetrically encrypted public and private key pairs, and a hash algorithm is used to generate symmetric encryption keys. The appropriate encryption algorithm is selected according to the file size and confidentiality level, the file is encrypted, and the file ciphertext slice is uploaded to the distributed storage system to record relevant information to the blockchain.
It realizes secure storage and rapid acquisition of files, avoids files being leaked or tampered, reduces the time-consuming and waste of computing resources in the encryption process, and ensures the stability and security of the system.
Smart Images

Figure CN115859358B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, electronic device, and storage medium for storing and retrieving files. Background Art
[0002] How to protect the authenticity, integrity, availability, and security of electronic file content is a current research focus in the field of computer file storage. In the era of big data, because third-party trusted storage models are vulnerable to attack and abuse, electronic files should not be read or accessed by unauthorized third parties. Blockchain can achieve decentralized and trustless data storage, greatly ensuring the security of sensitive data in electronic files and ensuring the immutability and traceability of electronic files. As a chain-like structure, blockchain has limited storage space. To address this shortcoming, researchers have proposed combining distributed storage with blockchain storage and encrypting data before storage to increase blockchain storage space and ensure data security. However, how to specifically integrate data encryption methods to ensure file security while ensuring file access speed is an urgent issue that needs to be addressed. Summary of the Invention
[0003] In response to the above problems, the purpose of the present invention is to provide a file encryption and storage method based on blockchain and a distributed file storage system, as well as a corresponding file decryption and acquisition method, and to provide an electronic device and a non-volatile computer storage medium that can execute the encryption and decryption method.
[0004] On one hand, the present invention provides a file encryption storage method based on blockchain and a distributed file storage system, comprising:
[0005] S11, using elliptic curve algorithm to generate asymmetric encryption public and private key pairs;
[0006] S12, using a hash algorithm to calculate a file digest of the file to be encrypted;
[0007] S13, generating a symmetric encryption key from the file digest of the file to be encrypted based on a string extraction method;
[0008] S14, parsing the file to be encrypted, obtaining the file size and confidentiality level, and determining the symmetric encryption algorithm to be used based on the file size and confidentiality level; all files with a confidentiality level greater than or equal to commercial secret use the AES-256 algorithm; files with a confidentiality level of public and a file size greater than 100MB use the DES algorithm, and files less than 100MB use the AES-128 algorithm;
[0009] S15, obtaining the encryption key and symmetric encryption algorithm of S13 and S14, encrypting the file to form a ciphertext of the file and recording the size and confidentiality level of the file in the form of relevant attributes;
[0010] S16, combining the file digest and the file encryption key generated in S12 and S13 to obtain a digest to be encrypted, and encrypting the digest to be encrypted using an elliptic curve encryption algorithm to obtain a digest ciphertext;
[0011] S17: Slice the ciphertext of the file and upload it to the distributed storage system for storage. Calculate the hash value corresponding to the slice based on the content of the ciphertext slice of the file, and concatenate the identification codes of the ciphertext slices of the file to obtain an identification set code.
[0012] S18, store the identification set code in S17, the summary ciphertext of the file obtained in S6, and the relevant attributes of the file in S5 in the blockchain with the file unique identifier as the index.
[0013] Another aspect of the present invention provides a file decryption and acquisition method corresponding to the above encryption method, comprising:
[0014] S21, using the unique identifier of the file as an index, searching the block storing the file information in the blockchain, and obtaining the corresponding file digest ciphertext, the file identification set code, and file-related attributes from the block, where the related attributes include the file size and confidentiality level;
[0015] S22, obtaining the identification code of each file slice based on the file identification set code, and further searching in the distributed storage system based on the identification code to obtain the stored file ciphertext slices, and recombining the slices to obtain the complete file ciphertext;
[0016] S23, obtaining a file decryption key;
[0017] Obtain the user's own private key, decrypt the file summary ciphertext obtained in the first step using the elliptic curve encryption algorithm to obtain the file summary plaintext; adopt a predetermined strategy to parse the file summary ciphertext, obtain the file summary plaintext and obtain the file decryption key based on the summary plaintext;
[0018] S24, parsing the relevant attributes of the file, determining the size and confidentiality level of the stored file, and obtaining the decryption algorithm corresponding to the encryption algorithm of the corresponding file ciphertext;
[0019] S25, decrypt the file; decrypt the file ciphertext obtained in S22 according to the decryption key obtained in S23 and the decryption algorithm obtained in S24 to obtain the decrypted file.
[0020] Furthermore, the present application also provides a file encryption storage device, the file encryption storage device comprising:
[0021] Public and private key generation module, used to generate asymmetric public and private key pairs using elliptic curve algorithm;
[0022] A file summary generation module is used to calculate the file summary of the file to be encrypted using a hash algorithm;
[0023] An encryption key generation module, used for generating a symmetric encryption key from the file digest of the file to be encrypted based on a string extraction method;
[0024] The encryption algorithm selection module is used to parse the file to be encrypted, obtain the file size and confidentiality level, and determine the symmetric encryption algorithm to be used based on the file size and confidentiality level;
[0025] The file encryption module is used to encrypt files according to the encryption key and symmetric encryption algorithm, form file ciphertext and record the file size and confidentiality level in the form of relevant attributes;
[0026] The digest encryption module is used to combine the generated file digest and the file encryption key into a digest to be encrypted, and encrypt the digest to be encrypted using an elliptic curve encryption algorithm to obtain a digest ciphertext;
[0027] The file upload module is used to slice the ciphertext of the file and upload it to the distributed storage system for storage. The hash value corresponding to the slice is calculated based on the content of the ciphertext slice of the file, and the identification code of each ciphertext slice of the file is spliced to obtain the identification set code;
[0028] The file record module stores the file's identification set code, file summary ciphertext, and related file attributes in the blockchain using the file's unique identifier as an index.
[0029] Furthermore, the present application also provides a file decryption and acquisition device, which includes:
[0030] The file acquisition module uses the file's unique identifier as an index to retrieve the block storing the file information in the blockchain and obtain the corresponding file digest ciphertext, the file's identification set code, and file-related attributes from the block, where the relevant attributes include the file's size and confidentiality level;
[0031] The ciphertext combination module obtains the identification code of each file slice according to the file identification set code, and further searches in the distributed storage system according to the identification code to obtain the stored file ciphertext slice, recombines the slices, and obtains the complete file ciphertext;
[0032] The file decryption key acquisition module is used to obtain the file decryption key; using the user's own private key, the file summary ciphertext obtained by the file acquisition module is decrypted according to the elliptic curve encryption algorithm to obtain the file summary plaintext; the file summary ciphertext is parsed using a predetermined strategy to obtain the file summary plaintext and obtain the file decryption key based on the summary plaintext;
[0033] The file decryption algorithm acquisition module is used to analyze the relevant attributes of the file, determine the size and confidentiality level of the stored file, and obtain the decryption algorithm corresponding to the encryption algorithm of the corresponding file ciphertext;
[0034] The file decryption module is used to decrypt files; it decrypts the file ciphertext according to the decryption key and decryption algorithm to obtain the decrypted file.
[0035] The present application also provides an electronic device, comprising: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute the above-mentioned file encryption storage method or decryption acquisition method.
[0036] In addition, the present application also provides a non-volatile computer storage medium, which stores a computer program. The computer program can be executed by a processor to implement the above-mentioned file encryption storage method or decryption acquisition method.
[0037] According to the solution provided by the present invention, a method based on the combined use of blockchain and distributed storage systems is adopted, which can store files in a distributed manner and prevent the files from being leaked or tampered with due to attacks on the third-party trusted storage model. At the same time, blockchain and distributed file systems are used to maintain the storage of intermediate data in the file encryption and decryption process, avoiding the single point failure problem of the system and ensuring the stable operation of the system. The solution of the present invention uses an offline encryption method to avoid the problem of data leakage during the transmission of plain text files, so that files can be transmitted and stored more securely. The encryption method adopted is adjusted according to the confidentiality level and file size, reducing the time consumption and computing resource waste of the encryption process on the basis of ensuring file security, thereby meeting the security and availability of the file storage system.
[0038] Other features and advantages of the present invention will be described in the following description, and in part will become apparent from the description, or will be understood by practicing the present invention. The purposes and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 This is a file encryption storage method based on blockchain and distributed file storage system provided in Example 1 of the present invention.
[0040] Figure 2 This is a file decryption and acquisition method based on blockchain and distributed file storage system provided in the second embodiment of the present invention.
[0041] Figure 3 This is a file encryption storage device provided in the third embodiment of the present invention and applied to a blockchain-based and distributed file storage system.
[0042] Figure 4 A file decryption and acquisition device based on blockchain and distributed file storage system provided in the fourth embodiment of the present invention.
[0043] Figure 5 This is a block diagram of an electronic device provided in Example 5 of the present invention. DETAILED DESCRIPTION
[0044] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0045] The first embodiment of the present invention provides a file encryption storage method based on blockchain and distributed file storage system, such as Figure 1 As shown, the following steps are included:
[0046] S11 uses elliptic curve algorithms to generate asymmetric encrypted public and private key pairs. The public key is automatically uploaded to the blockchain, and the user retains the private key.
[0047] Generate a public-private key pair using the public-private key generator provided by the elliptic curve algorithm. Elliptic curve cryptography is a public key encryption algorithm that exploits the difficulty of solving the discrete logarithm problem on elliptic curves. Similar to RSA cryptography, it exploits the properties of easy computation and difficult decomposition. However, compared to RSA, elliptic curve cryptography can use smaller key lengths while providing comparable security. Furthermore, elliptic curve cryptography can define bilinear mappings between groups, enabling identity-based encryption.
[0048] The public and private key generation process can be done offline, distributed uniformly by an administrator, or generated when a user logs into the system. The public key is automatically uploaded to the blockchain, while the user retains the private key. The private key, as the sole decrypted file during decryption, is fully retained by the user to ensure it cannot be leaked. The public key, as the sole encrypted file during encryption, can be shared. Sharing public keys prevents file leaks and facilitates file sharing. Storing public keys on the blockchain leverages the blockchain's synchronization mechanism to make the distribution process more convenient and efficient.
[0049] S12 uses a hash algorithm to calculate the file digest of the file to be encrypted;
[0050] The MD5 or SHA256 algorithm can be used to calculate the file digest. In another optional method, since file size has a significant impact on the speed of file digest calculation, the time required to calculate the digest using the above file digest calculation method for larger files will be relatively long. To improve operational efficiency, a random non-repeating string, such as a UUID, can be generated based on the file first, and then the file digest corresponding to the UUID can be calculated to reduce the time required to calculate the file digest. The file digest can be used in subsequent processes to determine whether the file has been tampered with, that is, to ensure that the file has not been tampered with by comparing and verifying the file before and after storage.
[0051] S13 generates a symmetric encryption key from the file summary of the file to be encrypted based on a string extraction method;
[0052] The file digest generated by S12 is processed. A fixed-length string is extracted from the file digest, or a fixed-length string is obtained according to a regular pattern, as the symmetric encryption key. For example, a single byte of the file digest is extracted, or a string of a suitable length is obtained according to a regular pattern as the encryption key for symmetric encryption. Due to the uniqueness of the hash algorithm, the obtained key is guaranteed to be unique and random, making brute force cracking more difficult.
[0053] S14 parses the file to be encrypted, obtains the file size and confidentiality level, and determines the symmetric encryption algorithm to be used based on the file size and confidentiality level;
[0054] During file upload, the file is first parsed to determine its size and confidentiality level. The specific encryption strategy is to use the AES-256 algorithm for files with a confidentiality level of commercial or higher. For files with a public confidentiality level and a file size greater than 100MB, the DES algorithm is used, and for files less than 100MB, the AES-128 algorithm is used. DES offers faster encryption and decryption speeds than AES, but is slightly less secure. The key length of different AES algorithms also affects encryption speed; longer key lengths result in slower encryption. Therefore, different encryption algorithms can be selected based on the combination of file confidentiality level and file size to improve overall encryption efficiency while ensuring file security. AES-256 is generally considered more secure than AES-128 and DES, so it is used for files with a high confidentiality level. For files with a public confidentiality level, AES-128 or DES are used, which offer lower security but faster execution times.
[0055] S15 encrypts the file using a certain encryption algorithm, obtains the file ciphertext and records the file size and confidentiality level in the form of relevant attributes.
[0056] Obtain the encryption key and symmetric encryption algorithm for S13 and S14. Encrypt the file stream to form a ciphertext file.
[0057] S16 combines the file digest and the file encryption key generated by S12 and S13 into a digest to be encrypted, and encrypts the file digest and the encryption key using an elliptic curve encryption algorithm to obtain a digest ciphertext;
[0058] Before, during, or after the file is encrypted, the file summary and the file encryption key generated by S12 and S13 are combined, such as by concatenating the file summary and the file encryption key or by mixing the encryption key and the file summary. The public key of the elliptic curve encryption algorithm is then used for encryption, and a summary ciphertext is generated after the encryption is completed.
[0059] S17 uploads the file ciphertext slices to the distributed storage system for storage, calculates the hash value corresponding to the slice based on the content of the file ciphertext slice, and uses this as the identification code to identify each file ciphertext slice. Subsequently, the file ciphertext slice can be retrieved and obtained in the distributed storage system through the identification code, and then the identification code is combined to obtain the identification set code; the identification set code can be the code obtained by string splicing of each hash value.
[0060] S18 stores the identification set code, the summary ciphertext of the file obtained in S6, and the relevant attributes of the file in S5 in the blockchain with the file unique identifier as an index.
[0061] There are two ways to generate a unique file identifier:
[0062] S18a uses the identification set code generated in S17 as the unique identifier of the file. Since the identification set code is composed of hash values obtained by hashing each file slice by the distributed storage system, it can ensure that the unique identifier of the file will not be repeated. If the user needs to retrieve the file in the blockchain later, he can directly use the identification set code as an index.
[0063] S18b, using the file name named by the user who uploaded the file as the unique identifier. If other users subsequently upload the same file name, it will prompt that the file name is duplicated and needs to be renamed. When using this implementation method for file unique identification, certain restrictions need to be placed on its application scenarios, such as deploying the present invention within a certain enterprise or organization. Since the file is named by the user, it has a certain degree of freedom. Unlike a string code, the file unique identifier is easy for users to read and share.
[0064] This completes the encryption and distributed storage of files. This solution utilizes a blockchain-based and distributed storage system, enabling distributed file storage. This prevents file leaks or tampering caused by attacks on third-party trusted storage models. The blockchain system also records the file storage process and stores all the basic information needed to access the file. Using blockchain and a distributed file system to maintain the storage of intermediate data during file encryption and decryption avoids single points of failure in the system, ensuring stable operation of the file storage system.
[0065] Furthermore, the solution of the present invention uses offline encryption, preventing data leakage during plaintext file transmission, making file transmission and storage more secure. By adjusting the encryption method based on the confidentiality level and file size, this reduces encryption time and computing resource waste while ensuring file security, thus ensuring the security and availability of the file storage system.
[0066] The second embodiment of the present invention provides a file decryption method corresponding to the encryption method of the first embodiment, such as Figure 2 As shown, the following steps are included:
[0067] S21 uses the unique identifier of the file as an index to retrieve the block storing the file information in the blockchain, and obtains the corresponding file summary ciphertext, the file identification set code, and file-related attributes from the block, where the related attributes include the file size and confidentiality level.
[0068] S22 obtains the identification code of each file slice according to the file identification set code, and further searches in the distributed storage system according to the identification code to obtain the stored file ciphertext slice, recombine the slices, and obtain the complete file ciphertext.
[0069] S23 obtains the file decryption key;
[0070] Obtain the user's own private key and decrypt the file summary ciphertext obtained in the first step using the elliptic curve encryption algorithm to obtain the file summary plaintext. Use the predetermined strategy to parse the file summary ciphertext, obtain the file summary plaintext, and obtain the file decryption key based on the summary plaintext.
[0071] S24 obtains the decryption algorithm of the file; the encryption key and S23 parse the relevant attributes of the file to determine the size and confidentiality level of the stored file, and obtains the decryption algorithm corresponding to the encryption algorithm of the corresponding file ciphertext.
[0072] S25 decrypts the file; decrypts the file ciphertext obtained in S22 according to the decryption key obtained in S23 and the decryption algorithm obtained in S24 to obtain the decrypted file.
[0073] The third embodiment of the present invention provides a file encryption device corresponding to the method described in the first embodiment. Figure 3 As shown, the device includes:
[0074] The public and private key generation module 310 is used to generate a public and private key pair for asymmetric encryption using an elliptic curve algorithm;
[0075] A file digest generation module 320 is used to calculate the file digest of the file to be encrypted using a hash algorithm;
[0076] An encryption key generation module 330 is configured to generate a symmetric encryption key from a file digest of a file to be encrypted based on a string extraction method;
[0077] The encryption algorithm selection module 340 is used to parse the file to be encrypted, obtain the file size and confidentiality level, and determine the symmetric encryption algorithm to be used based on the file size and confidentiality level;
[0078] The file encryption module 350 is used to encrypt the file according to the encryption key and the symmetric encryption algorithm to form the file ciphertext and record the file size and confidentiality level in the form of related attributes;
[0079] A digest encryption module 360 is configured to combine the generated file digest and the file encryption key into a digest to be encrypted, and encrypt the digest to be encrypted using an elliptic curve encryption algorithm to obtain a digest ciphertext;
[0080] The file upload module 370 is used to slice the ciphertext of the file and upload it to the distributed storage system for storage. The module calculates the hash value corresponding to the slice based on the content of the ciphertext slice of the file and concatenates the identification codes of the ciphertext slices of the file to obtain the identification set code.
[0081] The file recording module 380 stores the file's identification set code, file summary ciphertext, and related attributes of the file in the blockchain using the file's unique identifier as an index.
[0082] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned encryption method, and will not be repeated here.
[0083] The fourth embodiment of the present invention provides a file decryption device corresponding to the decryption method described in the second embodiment. Figure 4 As shown, the device includes:
[0084] The file acquisition module 410 uses the unique identifier of the file as an index to search the block storing the file information in the blockchain and obtain the corresponding file digest ciphertext, the file identification set code, and file-related attributes from the block, where the related attributes include the file size and confidentiality level;
[0085] The ciphertext combination module 420 obtains the identification code of each file slice based on the file identification set code, and further searches the distributed storage system based on the identification code to obtain the stored file ciphertext slices, and recombines the slices to obtain the complete file ciphertext;
[0086] The file decryption key acquisition module 430 is used to obtain the file decryption key. It uses the user's own private key to decrypt the file summary ciphertext obtained by the file acquisition module 410 according to the elliptic curve encryption algorithm to obtain the file summary plaintext. It then uses a predetermined strategy to parse the file summary ciphertext to obtain the file summary plaintext and obtain the file decryption key based on the summary plaintext.
[0087] The file decryption algorithm acquisition module 440 is used to analyze the relevant attributes of the file, determine the size and confidentiality level of the stored file, and obtain the decryption algorithm corresponding to the encryption algorithm of the corresponding file ciphertext;
[0088] The file decryption module 450 is used to decrypt the file; decrypt the file ciphertext according to the decryption key and the decryption algorithm to obtain the decrypted file.
[0089] Based on the same inventive concept, embodiments of the present invention provide the following electronic devices and storage media.
[0090] A fifth embodiment of the present invention provides an electronic device, the structure of which can be as follows: Figure 5 As shown, it includes a memory 51, a processor 52 and a computer program stored in the memory. When the processor 52 executes the program, the method described in embodiment 1 or embodiment 2 of the present invention is implemented.
[0091] Optionally, the processor 52 may specifically include a central processing unit (CPU), an application specific integrated circuit (ASIC), one or more integrated circuits for controlling program execution, a hardware circuit developed using a field programmable gate array (FPGA), or a baseband processor.
[0092] Optionally, the processor 52 may include at least one processing core.
[0093] Optionally, the memory 51 may include a read-only memory (ROM), a random access memory (RAM), and a disk storage. The memory 51 is used to store data required by at least one processor 52 during operation. The number of memories 51 may be one or more.
[0094] A sixth embodiment of the present invention provides a non-volatile computer storage medium, wherein the computer storage medium stores an executable program. When the executable program is executed by a processor, the method described in the first or second embodiment of the present invention is implemented.
[0095] In a specific implementation process, computer storage media may include: Universal Serial Bus flash drive (USB), mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, and other storage media that can store program code.
[0096] In the embodiments of the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the units or divisions of the units are merely a logical functional division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0097] Each functional unit in the embodiment of the present invention may be integrated into one processing unit, or each unit may be an independent physical module.
[0098] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the technical solution of the embodiment of the present invention can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for enabling a computer device, such as a personal computer, a server, or a network device, or a processor to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: a universal serial bus flash drive, a mobile hard disk, ROM, RAM, a magnetic disk, or an optical disk, etc., various media that can store program code.
[0099] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0100] The present invention is described with reference to flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0101] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
Claims
1. A file encryption storage method based on blockchain and distributed file storage system, characterized in that: The steps include: S11, using the elliptic curve algorithm to generate asymmetric encryption public and private key pairs; the process of generating the public and private key pairs is done offline; S12, using a hash algorithm to calculate a file digest of the file to be encrypted; S13, generating a symmetric encryption key from the file digest of the file to be encrypted based on a string extraction method; S14, parsing the file to be encrypted, obtaining the file size and confidentiality level, and determining the symmetric encryption algorithm to be used based on the file size and confidentiality level; the determination method is as follows: if the file confidentiality level is greater than or equal to commercial secret, all files use the AES-256 algorithm; if the file confidentiality level is public and the file size is greater than 100MB, the DES algorithm is used; if the file size is less than 100MB, the AES-128 algorithm is used; S15, obtaining the encryption key and symmetric encryption algorithm of S13 and S14, encrypting the file to form a ciphertext of the file and recording the size and confidentiality level of the file in the form of relevant attributes; S16, combining the file digest and the file encryption key generated in S12 and S13 to generate a digest to be encrypted, and encrypting the digest to be encrypted using an elliptic curve encryption algorithm to obtain a digest ciphertext; S17: Slice the ciphertext of the file and upload it to the distributed storage system for storage. Calculate the hash value corresponding to the slice based on the content of the ciphertext slice of the file, and concatenate the identification codes of the ciphertext slices of the file to obtain an identification set code; the identification set code is the concatenation of the hash values obtained by the distributed storage system based on the hash calculation of the file slices. S18, store the identification set code in S17, the summary ciphertext of the file obtained in S16, and the relevant attributes of the file in S15 in the blockchain with the file unique identifier as the index.
2. The method according to claim 1, characterized in that The method for generating the summary to be encrypted in S16 is to concatenate the file summary and the file encryption key into character strings.
3. The method according to claim 1, characterized in that The method for generating the summary to be encrypted in S16 is to mix the encryption key and the file summary into character strings.
4. The method according to claim 1, wherein The unique identifier of the file in S18 is the identification set code obtained in S17.
5. The method according to claim 1, wherein The unique identifier of the file in S18 is a unique file name that is user-defined.
6. A file decryption and acquisition method corresponding to the encryption storage method according to claim 1, characterized in that: The steps include: S21, using the unique identifier of the file as an index, searching the block storing the file information in the blockchain, and obtaining the corresponding file digest ciphertext, the file identification set code, and file-related attributes from the block, where the related attributes include the file size and confidentiality level; S22, obtaining the identification code of each file slice based on the file identification set code, and further searching in the distributed storage system based on the identification code to obtain the stored file ciphertext slices, and recombining the slices to obtain the complete file ciphertext; S23, obtaining a file decryption key; Obtain the user's own private key, decrypt the file summary ciphertext obtained in the first step using the elliptic curve encryption algorithm to obtain the file summary plaintext; adopt a predetermined strategy to parse the file summary ciphertext, obtain the file summary plaintext and obtain the file decryption key based on the summary plaintext; S24, parsing the relevant attributes of the file, determining the size and confidentiality level of the stored file, and obtaining the decryption algorithm corresponding to the encryption algorithm of the corresponding file ciphertext; S25, decrypted file; The file ciphertext obtained in S22 is decrypted according to the decryption key obtained in S23 and the decryption algorithm obtained in S24 to obtain a decrypted file.
7. A file encryption storage device, characterized in that: The method according to any one of claims 1 to 5 is applied, wherein the device comprises the following functional modules: Public and private key generation module, used to generate asymmetric public and private key pairs using elliptic curve algorithm; A file summary generation module is used to calculate the file summary of the file to be encrypted using a hash algorithm; An encryption key generation module, used for generating a symmetric encryption key from the file digest of the file to be encrypted based on a string extraction method; The encryption algorithm selection module is used to parse the file to be encrypted, obtain the file size and confidentiality level, and determine the symmetric encryption algorithm to be used based on the file size and confidentiality level; The file encryption module is used to encrypt files according to the encryption key and symmetric encryption algorithm, form file ciphertext and record the file size and confidentiality level in the form of relevant attributes; The digest encryption module is used to combine the generated file digest and the file encryption key into a digest to be encrypted, and encrypt the digest to be encrypted using an elliptic curve encryption algorithm to obtain a digest ciphertext; The file upload module is used to slice the ciphertext of the file and upload it to the distributed storage system for storage. The hash value corresponding to the slice is calculated based on the content of the ciphertext slice of the file, and the identification code of each ciphertext slice of the file is spliced to obtain the identification set code; The file record module stores the file's identification set code, file summary ciphertext, and related file attributes in the blockchain using the file's unique identifier as an index.
8. A file decryption and acquisition device, characterized in that: The method according to claim 6 is applied, and the device includes the following functional modules: The file acquisition module is used to retrieve the block storing the file information in the blockchain using the file's unique identifier as an index, and obtain the corresponding file digest ciphertext, the file's identification set code, and file-related attributes from the block, where the relevant attributes include the file's size and confidentiality level; The ciphertext combination module is used to obtain the identification code of each file slice according to the file identification set code, and further search in the distributed storage system according to the identification code to obtain the stored file ciphertext slices, and recombine the slices to obtain the complete file ciphertext; The file decryption key acquisition module is used to obtain the file decryption key; using the user's own private key, the file summary ciphertext obtained by the file acquisition module is decrypted according to the elliptic curve encryption algorithm to obtain the file summary plaintext; the file summary ciphertext is parsed using a predetermined strategy to obtain the file summary plaintext and obtain the file decryption key based on the summary plaintext; The file decryption algorithm acquisition module is used to analyze the relevant attributes of the file, determine the size and confidentiality level of the stored file, and obtain the decryption algorithm corresponding to the encryption algorithm of the corresponding file ciphertext; The file decryption module is used to decrypt files; it decrypts the file ciphertext according to the decryption key and decryption algorithm to obtain the decrypted file.
9. An electronic device, characterized in that: include: processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute the method according to any one of claims 1 to 6.
10. A non-volatile computer storage medium, characterized in that The storage medium stores a computer program, which can be executed by a processor to implement the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
File security access method based on block chain and distributed storage
CN116755618A