File encryption method and device and file decryption method and device

By encrypting file metadata and contents by generating the public key derived key of the post-quantum key, the security of file encryption and decryption in the middle platform system is solved, and the security of resisting quantum computing attacks is achieved and the efficient encryption and decryption speed is improved, and the convenience of key management and file storage are improved.

CN120498841APending Publication Date: 2025-08-15CSC FINANCIAL CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510810180.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-17
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

The prior art is difficult to effectively encrypt and decrypt files uploaded by users in the middle-end system, and cannot guarantee the security of file content and the security of quantum computing attacks.

Method used

The derived key of the post-quantum key is used to generate the public key as the file content key, the metadata and file content are encrypted, and the public key and file content key are bound through the key derivation function to realize a hierarchical collaboration mechanism that facilitates and secure key management.

Benefits of technology

It realizes the anti-quantum security of files, efficient encryption and decryption speed, and improves the convenience and security of key management, and enhances the stability and security of file storage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120498841A_ABST
    Figure CN120498841A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a file encryption method and device and a file decryption method and device, and relates to the technical field of computer information security, the file encryption method comprises the steps that a file uploaded by a user is acquired, and the file comprises metadata and file content; generating a post-quantum key, and based on a public key included in the post-quantum key, generating a derived key of the public key by using a key derivation function to serve as a file content key; encrypting the metadata by using the public key to obtain encrypted metadata, and encrypting the file content by using the file content key to obtain encrypted file content; and storing the encrypted metadata and the encrypted file content. In this way, the file uploaded by the user can be encrypted and decrypted safely.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer information security technology, and in particular to a file encryption method and device, and a file decryption method and device. Background Art

[0002] After users upload files to the middle-office system, the middle-office system needs to encrypt the files to ensure the security of the file content. This helps improve the user experience of the middle-office system and enhances the user's trust in the middle-office system.

[0003] To this end, a file encryption and decryption solution needs to be provided. Summary of the Invention

[0004] The purpose of the embodiments of the present application is to provide a file encryption method and device, and a file decryption method and device to securely encrypt and decrypt files uploaded by users. The specific technical solution is as follows:

[0005] In a first aspect, an embodiment of the present application provides a file encryption method, the method comprising:

[0006] Obtaining a file uploaded by a user, wherein the file includes metadata and file content;

[0007] Generate a post-quantum key, and generate a derived key of the public key using a key derivation function based on a public key included in the post-quantum key as a file content key;

[0008] Encrypting the metadata using the public key to obtain encrypted metadata, and encrypting the file content using the file content key to obtain encrypted file content;

[0009] The encrypted metadata and the encrypted file content are stored.

[0010] Optionally, the step of generating a derived key of the public key using a key derivation function based on the public key included in the post-quantum key includes:

[0011] Extracting a pseudorandom key from the public key using a salt value and a pseudorandom function, wherein the salt value is generated using a random number generator;

[0012] The pseudo-random key is mapped to obtain a derived key of a preset length.

[0013] Optionally, before the step of generating a derived key of the public key using a key derivation function based on the public key included in the post-quantum key, the method further includes:

[0014] Splitting the file content into a first number of file content fragments based on a preset splitting strategy;

[0015] The step of generating a derived key of the public key using a key derivation function based on the public key included in the post-quantum key as the file content key includes:

[0016] Extracting a first number of pseudorandom keys from the public key using a pseudorandom function and a first number of different salt values, wherein the first number of different salt values are generated using a random number generator;

[0017] Mapping each pseudo-random key separately to obtain a first number of derived keys of preset lengths as file content keys corresponding to the file content fragments;

[0018] The step of encrypting the file content using the file content key to obtain the encrypted file content includes:

[0019] For each file content fragment, the file content fragment is encrypted using the file content key corresponding to the file content fragment.

[0020] Optionally, after the step of generating a post-quantum key, the method further includes:

[0021] Generating a plurality of first subkeys corresponding to the private key included in the post-quantum key;

[0022] locally storing a portion of the first subkeys, and distributing the first subkeys not stored locally to a plurality of first authorized devices, so that the first authorized devices store the received first subkeys;

[0023] and / or,

[0024] After the step of generating a derived key of the public key using a key derivation function as the file content key, the method further comprises:

[0025] Generating a plurality of second subkeys corresponding to the file content key;

[0026] Part of the second subkeys is stored locally, and the second subkeys not stored locally are distributed to a plurality of second authorized devices, so that the second authorized devices store the received second subkeys.

[0027] Optionally, the method further includes:

[0028] Generate updated post-quantum keys according to the set period;

[0029] Decrypting the stored encrypted metadata using a private key included in the post-quantum key before the update to obtain the metadata;

[0030] Encrypting the metadata using the public key included in the updated post-quantum key to obtain re-encrypted metadata;

[0031] Based on the public key included in the updated post-quantum key, generating a derived key of the public key using the key derivation function as the updated file content key;

[0032] Decrypting the stored encrypted file content using the file content key before updating to obtain the file content;

[0033] Encrypting the file content using the updated file content key to obtain re-encrypted file content;

[0034] The re-encrypted metadata and the re-encrypted file content are stored.

[0035] In a second aspect, an embodiment of the present application provides a file decryption method, the method comprising:

[0036] In response to a file acquisition request from a user, obtaining a private key included in a post-quantum key corresponding to a target file indicated by the file acquisition request, and obtaining a file content key corresponding to the target file;

[0037] Decrypting the encrypted metadata corresponding to the target file using the obtained private key to obtain the metadata of the target file;

[0038] Decrypting the encrypted file content corresponding to the target file using the obtained file content key to obtain the file content of the target file;

[0039] The target file is provided to the user based on the metadata and the file content.

[0040] Optionally, before the step of obtaining a private key included in a post-quantum key corresponding to the target file indicated by the file acquisition request, the method further includes:

[0041] Acquire the user's identity attributes, device attributes, and file access type, wherein the device attributes represent the permissions of the device used by the user to issue the file acquisition request, and the file access type represents the method by which the user accesses the file;

[0042] Determining whether the user has access rights to the target file indicated by the file acquisition request based on the user's identity attributes, device attributes, and file access type;

[0043] In a case where the user has the access permission, the step of obtaining a private key included in the post-quantum key corresponding to the target file indicated by the file acquisition request is performed.

[0044] Optionally, the step of obtaining a private key included in a post-quantum key corresponding to a target file indicated by the file acquisition request includes:

[0045] Obtaining at least a first threshold number of first subkeys from a local device and a plurality of first authorized devices, wherein the plurality of first subkeys corresponding to the private key included in the post-quantum key are stored locally and in the plurality of first authorized devices;

[0046] Reconstructing a private key included in the post-quantum key based on the obtained at least first threshold value of first subkeys and the generation method of the first subkeys; and / or,

[0047] The step of obtaining the file content key corresponding to the target file includes:

[0048] Obtaining at least a second threshold number of second subkeys from a local device and a plurality of second authorization devices, wherein the plurality of second subkeys corresponding to the file content key are stored locally and in the plurality of second authorization devices;

[0049] The file content key is reconstructed based on the obtained at least second threshold second subkeys and the generation method of the second subkeys.

[0050] In a third aspect, an embodiment of the present application provides a file encryption device, the device comprising:

[0051] A first acquisition module is used to acquire a file uploaded by a user, wherein the file includes metadata and file content;

[0052] A generation module, configured to generate a post-quantum key, and generate a derived key of the public key using a key derivation function based on a public key included in the post-quantum key, as a file content key;

[0053] an encryption module, configured to encrypt the metadata using the public key to obtain encrypted metadata, and to encrypt the file content using the file content key to obtain encrypted file content;

[0054] A storage module is used to store the encrypted metadata and the encrypted file content.

[0055] Optionally, the generating module is specifically configured to:

[0056] Extracting a pseudorandom key from the public key using a salt value and a pseudorandom function, wherein the salt value is generated using a random number generator;

[0057] The pseudo-random key is mapped to obtain a derived key of a preset length.

[0058] Optionally, the device further includes:

[0059] a splitting module, configured to split the file content into a first number of file content fragments based on a preset splitting strategy before the step of generating a derived key of the public key using a key derivation function based on the public key included in the post-quantum key;

[0060] The generation module is specifically used to:

[0061] Extracting a first number of pseudorandom keys from the public key using a pseudorandom function and a first number of different salt values, wherein the first number of different salt values are generated using a random number generator;

[0062] Mapping each pseudo-random key separately to obtain a first number of derived keys of preset lengths as file content keys corresponding to the file content fragments;

[0063] The encryption module is specifically used to:

[0064] For each file content fragment, the file content fragment is encrypted using the file content key corresponding to the file content fragment.

[0065] Optionally, the device further includes:

[0066] The first distribution module is configured to, after the step of generating the post-quantum key, generate multiple first subkeys corresponding to the private key included in the post-quantum key; locally store some of the first subkeys, and distribute the first subkeys not locally stored in the first subkeys to multiple first authorized devices, so that the first authorized devices store the received first subkeys.

[0067] Optionally, the device further includes:

[0068] The second distribution module is used to generate multiple second subkeys corresponding to the file content key after the step of using the key derivation function to generate a derived key of the public key as the file content key; locally store some subkeys in the second subkeys, and distribute the second subkeys in the second subkeys that are not locally stored to multiple second authorized devices, so that the second authorized devices store the received second subkeys.

[0069] Optionally, the device further includes:

[0070] The update module is configured to generate an updated post-quantum key according to a set period; decrypt the stored encrypted metadata using the private key included in the post-quantum key before the update to obtain the metadata; encrypt the metadata using the public key included in the updated post-quantum key to obtain re-encrypted metadata; generate a derived key of the public key using the key derivation function based on the public key included in the updated post-quantum key as an updated file content key; decrypt the stored encrypted file content using the file content key before the update to obtain the file content; encrypt the file content using the updated file content key to obtain re-encrypted file content; and store the re-encrypted metadata and the re-encrypted file content.

[0071] In a fourth aspect, an embodiment of the present application provides a file decryption device, the device comprising:

[0072] A second acquisition module is configured to, in response to a file acquisition request from a user, acquire a private key included in a post-quantum key corresponding to a target file indicated by the file acquisition request, and acquire a file content key corresponding to the target file;

[0073] a first decryption module, configured to decrypt the encrypted metadata corresponding to the target file using the acquired private key to obtain the metadata of the target file;

[0074] A second decryption module is used to decrypt the encrypted file content corresponding to the target file using the obtained file content key to obtain the file content of the target file;

[0075] A providing module is used to provide the target file to the user based on the metadata and the file content.

[0076] Optionally, the device further includes:

[0077] A verification module is configured to obtain, before the step of obtaining a private key included in a post-quantum key corresponding to a target file indicated by the file acquisition request, the user's identity attributes, device attributes, and file access type, wherein the device attributes represent the authority of the device used by the user to issue the file acquisition request, and the file access type represents the manner in which the user accesses the file; determine, based on the user's identity attributes, device attributes, and file access type, whether the user has access rights to access the target file indicated by the file acquisition request; and trigger the second acquisition module if the user has the access rights.

[0078] Optionally, the second acquisition module is specifically configured to:

[0079] Obtaining at least a first threshold number of first subkeys from a local device and a plurality of first authorized devices, wherein the plurality of first subkeys corresponding to the private key included in the post-quantum key are stored locally and in the plurality of first authorized devices;

[0080] Based on the obtained at least a first threshold value of first subkeys and a generation method of the first subkeys, a private key included in the post-quantum key is reconstructed.

[0081] Optionally, the second acquisition module is specifically configured to:

[0082] Obtaining at least a second threshold number of second subkeys from a local device and a plurality of second authorization devices, wherein the plurality of second subkeys corresponding to the file content key are stored locally and in the plurality of second authorization devices;

[0083] The file content key is reconstructed based on the obtained at least second threshold second subkeys and the generation method of the second subkeys.

[0084] In a fifth aspect, an embodiment of the present application provides an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus.

[0085] Memory for storing computer programs;

[0086] The processor is configured to implement any of the methods described in the first or second aspect above when executing a program stored in the memory.

[0087] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the method described in any one of the first and second aspects above.

[0088] In a seventh aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the methods described in the first or second aspect above.

[0089] Beneficial effects of the embodiments of the present application:

[0090] In the technical solution provided by the embodiments of the present application, an electronic device obtains a file uploaded by a user, first generates a post-quantum key for the file's metadata, and then uses the public key included in the post-quantum key to generate a derived key as the file content key. The electronic device encrypts the metadata using the public key included in the post-quantum key and encrypts the file content using the file content key, and then stores the encrypted file. Because the post-quantum key can resist quantum computing attacks, and the derived key, as a symmetric key, has efficient encryption and decryption speed, this ensures the security of the file in the face of quantum computing attacks, that is, quantum security, while also ensuring efficient encryption and decryption speed and storage performance.

[0091] In addition, since the key derivation function is used to bind the public key included in the post-quantum key with the file content key, the adoption of such a layered collaborative mechanism makes key management more convenient and secure, providing a strong guarantee for the stable operation of the entire encryption and decryption mechanism.

[0092] Of course, it is not necessary to achieve all the advantages described above at the same time when implementing any product or method of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0093] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other embodiments can also be obtained based on these drawings.

[0094] Figure 1 A flowchart of a file encryption method provided in an embodiment of the present application;

[0095] Figure 2 Based on Figure 1 A flow chart of a method for performing key update according to the illustrated embodiment;

[0096] Figure 3 A flowchart of a file decryption method provided in an embodiment of the present application;

[0097] Figure 4 A schematic diagram of the structure of a file encryption device provided in an embodiment of the present application;

[0098] Figure 5 A schematic diagram of the structure of a file decryption device provided in an embodiment of the present application;

[0099] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0100] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field based on this application are within the scope of protection of this application.

[0101] In order to securely encrypt and decrypt files uploaded by users, embodiments of the present application provide a file encryption method, a file decryption method, a file encryption device, a file decryption device, an electronic device, a computer-readable storage medium, and a computer program product. The following first introduces the file encryption method provided in embodiments of the present application.

[0102] The file encryption method provided in the embodiment of the present application can be applied to any electronic device that needs to provide file storage services, for example, a server, file processing device, file management device, etc. deployed with a file management middle-end system.

[0103] like Figure 1 As shown, a file encryption method includes the following steps S101-S104.

[0104] S101, obtaining files uploaded by users.

[0105] The file includes metadata and file content.

[0106] S102: Generate a post-quantum key. Based on the public key included in the post-quantum key, use a key derivation function to generate a derived key of the public key as the file content key.

[0107] S103: Encrypt the metadata using the public key to obtain encrypted metadata, and encrypt the file content using the file content key to obtain encrypted file content.

[0108] S104: Store the encrypted metadata and the encrypted file content.

[0109] In the technical solution provided by the embodiments of the present application, an electronic device obtains a file uploaded by a user, first generates a post-quantum key for the file's metadata, and then uses the public key included in the post-quantum key to generate a derived key as the file content key. The electronic device encrypts the metadata using the public key included in the post-quantum key and encrypts the file content using the file content key, and then stores the encrypted file. Because the post-quantum key can resist quantum computing attacks, and the derived key, as a symmetric key, has efficient encryption and decryption speed, this ensures the security of the file in the face of quantum computing attacks, that is, quantum security, while also ensuring efficient encryption and decryption speed and storage performance.

[0110] In addition, since the key derivation function is used to bind the public key included in the post-quantum key with the file content key, the adoption of such a layered collaborative mechanism makes key management more convenient and secure, providing a strong guarantee for the stable operation of the entire encryption and decryption mechanism.

[0111] After a user uploads a file to an electronic device, the electronic device can retrieve the uploaded file. Files include metadata and file content. Metadata includes file attributes and tags. File attributes can represent information such as the file's status and permissions. File attributes can include: creation time, modification time, storage space occupied, owner and permissions, readability, and modifiability. File tags can be user-defined markers added to files to facilitate searching and organizing files. For example, file tags can include: file name, whether the file is "personal" or "work," etc.

[0112] After receiving the file uploaded by the user, the electronic device generates a post-quantum key consisting of a public key and a private key. The public key is used for encryption, and the private key is used for decryption. The electronic device can use post-quantum cryptographic algorithms such as NTRU (Number Theory Research Unit) and latticed-based cryptographic algorithms to generate post-quantum keys.

[0113] The electronic device can then use a key derivation function to generate a derived key from the public key included in the post-quantum key, using the public key as the file content key. The file content key can be a symmetric key, such as an AES-256 key. The electronic device then uses the public key included in the generated post-quantum key to encrypt the metadata, obtaining the encrypted metadata, and then uses the file content key to encrypt the file content, obtaining the encrypted file content.

[0114] As an implementation method, the electronic device can store the encrypted metadata and encrypted file content locally. In one possible implementation method, to prevent the locally stored encrypted metadata and encrypted file content from being damaged, resulting in the user being unable to access the file, the electronic device can also synchronously store the locally stored encrypted metadata and encrypted file content to a cloud server, an edge node in the network where the electronic device is located, or a user terminal. Through heterogeneous distributed storage, the risk of single point failure can be reduced, the high availability of the file storage service provided by the electronic device can be guaranteed, and the disaster recovery capability and robustness of the entire electronic device for file management can be improved.

[0115] As an implementation method of an embodiment of the present application, the step of generating a derived key of the public key using a key derivation function based on the public key included in the post-quantum key in the above-mentioned step S102 may include: extracting a pseudo-random key from the public key using a salt value and a pseudo-random function, wherein the salt value is generated using a random number generator; and mapping the pseudo-random key to obtain a derived key of a preset length.

[0116] To enhance the security of the derived key, the electronic device can use a random number generator to generate a salt value. The salt value and a pseudo-random function are then used to extract a pseudo-random key from the public key. The extracted pseudo-random key also includes a random string corresponding to the salt value. The electronic device then maps the pseudo-random key to obtain a derived key of a predetermined length.

[0117] Take the HMAC-based Key Derivation Function (HKDF) as an example. First, the electronic device generates a salt value based on a random number generator. The salt value and the public key are then used as inputs to the HMAC (Hash-based Message Authentication Code) function, resulting in a pseudo-random key output. The electronic device then uses the pseudo-random key and a preset information string, which can be an empty string, as inputs to the HMAC function, resulting in a derived key output.

[0118] It can be seen that in the embodiment of the present application, the electronic device uses a salt value and a pseudo-random function to extract a pseudo-random key from a public key. The obtained pseudo-random key also includes a random character string corresponding to the salt value, which increases the complexity of the obtained pseudo-random key, and further increases the complexity of the derived key obtained based on the pseudo-random key, thereby improving the security of the obtained derived key.

[0119] As an implementation method of an embodiment of the present application, before the step of generating a derived key of the public key using a key derivation function based on the public key included in the post-quantum key in the above-mentioned step S102, the above-mentioned file encryption method may further include: splitting the file content into a first number of file content fragments based on a preset splitting strategy.

[0120] In this case, the step of generating a derived key of the public key using a key derivation function based on the public key included in the post-quantum key in the above step S102 as the file content key may include: extracting a first number of pseudo-random keys from the public key using a pseudo-random function and a first number of different salt values, wherein the first number of different salt values are generated using a random number generator; mapping each pseudo-random key to obtain a first number of derived keys of a preset length as the file content keys corresponding to the file content fragments; the step of encrypting the file content using the file content key to obtain the encrypted file content in the above step S103 may include: encrypting the file content fragment using the file content key corresponding to the file content fragment for each file content fragment.

[0121] To improve the security of file storage, the electronic device may split the file content into a first number of file content fragments according to a preset splitting strategy, wherein the preset splitting strategy may be set based on file size, file type, and file sensitivity level.

[0122] Specifically, with respect to file size, a preset splitting strategy can be determined based on a size threshold for each file content fragment. For example, a preset splitting strategy can be set based on file size such that each file content fragment is no larger than 10KB. Thus, for a 1MB file, since 1MB / 10KB = 102.4, the electronic device can split it into 103 file content fragments according to the preset splitting strategy.

[0123] To ensure the accuracy of the data in each file content fragment for different file types, the electronic device can split the file content according to the file structure of the file type, so that the content of each file content fragment has a certain degree of independence. For example, for a device information statistics table file, each row in the table represents the device information corresponding to a device. The electronic device can split a specified number of rows into file content fragments in the order of arrangement in the table file.

[0124] In a specific example, a table file includes 100 rows of data, each row in the table file represents device information corresponding to a device, and the specified number of rows is 10. The electronic device can first split the data in rows 1-10 of the table file into one file content fragment, then split the data in rows 11-20 of the table file into one file content fragment, and then split rows 21-30, 31-40, 41-50, 51-60, 61-70, 71-80, 81-90, and 91-100 of the table file into eight file content fragments, respectively.

[0125] In order to improve security, a more complex splitting strategy can be used for files with higher sensitivity levels to increase the difficulty of recovery. The specific settings can be made according to actual conditions.

[0126] For example, for files with higher sensitivity levels, the electronic device can first classify the file content according to pre-classified sensitivity levels. The electronic device can then separate the file content belonging to the pre-classified high sensitivity levels from the file as high-sensitivity file content fragments, and separate the file content belonging to the pre-classified low sensitivity levels from the file as low-sensitivity file content fragments. The electronic device can then encrypt and store the separated file content fragments separately.

[0127] Furthermore, the electronic device can subsequently encrypt highly sensitive file content fragments using a relatively more secure file content key, while encrypting less sensitive file content fragments using a faster decryption key. Alternatively, the electronic device can encrypt highly sensitive file content fragments using multiple keys, while encrypting less sensitive file content fragments using a single key to ensure faster decryption.

[0128] After the splitting is complete, the electronic device uses a key derivation function to generate different file content keys for each of the first number of file content fragments. The electronic device can use a random number generator to generate a first number of different salt values, and then use a pseudorandom function and the first number of salt values to extract a first number of pseudorandom keys from the public key. The electronic device then maps each pseudorandom key to obtain a first number of derived keys of a preset length, which serve as the file content keys corresponding to the file content fragments.

[0129] Continuing with the key derivation function HKDF as an example, the electronic device first uses a random number generator to generate n different salt values, salt1, salt2, ..., saltn, where n is a first number. The electronic device then uses salt1 and the public key as inputs to an HMAC function, obtaining the output function result as the first pseudo-random key P1. It then uses salt2 and the public key as inputs to the HMAC function, obtaining the output function result as the second pseudo-random key P2. ... The electronic device then uses saltn and the public key as inputs to the HMAC function, obtaining the output function result as the nth pseudo-random key Pn.

[0130] The electronic device then uses P1 and a preset information string as inputs to the HMAC function, obtaining the output function result as the first derived key. The electronic device then uses P2 and a preset information string as inputs to the HMAC function, obtaining the output function result as the second derived key. ... Finally, the electronic device uses Pn and a preset information string as inputs to the HMAC function, obtaining the output function result as the nth derived key. The electronic device uses the obtained n derived keys as the file content keys corresponding to the n file content fragments. In other words, these n derived keys correspond one-to-one to the n file content fragments.

[0131] For each file content fragment, the electronic device may use the file content key corresponding to the file content fragment to encrypt the file content fragment to obtain the encrypted file content fragment.

[0132] It can be seen that in the embodiment of the present application, the electronic device splits the file content into multiple file content fragments and encrypts each file content fragment separately. On the one hand, it can improve the encryption efficiency and avoid the slow encryption speed caused by a single file being too large. On the other hand, it can improve the security of the file content. Even if the electronic device is attacked and some file content fragments are leaked, it is difficult for the attacker to restore the complete file content.

[0133] As an implementation method of an embodiment of the present application, after the step of generating a post-quantum key in the above-mentioned step S102, the above-mentioned file encryption method may further include the following steps: generating multiple first sub-keys corresponding to the private key included in the post-quantum key; locally storing part of the sub-keys in the first sub-keys, and distributing the first sub-keys that are not locally stored in the first sub-keys to multiple first authorized devices, so that the first authorized devices store the received first sub-keys.

[0134] In order to further enhance the security of metadata storage, the electronic device may convert the private key used for decrypting metadata into multiple first subkeys, and store the multiple first subkeys locally and in multiple first authorized devices respectively.

[0135] In one example, the electronic device may first determine a second number of first subkeys to be generated and a third number of first subkeys required to successfully recover the private key, where the second number is greater than or equal to the third number. The electronic device may generate the first subkey using a polynomial, where the polynomial is as follows:

[0136] f1(x)=S1+a1x+a2x 2 +…+a t-1 x t-1 ;

[0137] Wherein, t is the third number, x is the identifier of the first subkey, x=1, 2, ..., m, m is the second number; S1 is the private key, a1, a2, ..., a t-1 is a randomly selected coefficient, and f1(x) is the first subkey identified as x.

[0138] The electronic device can substitute x=1, x=2, ..., x=m into the above polynomial respectively to obtain m first subkeys f1(1), f1(2), ..., f1(m) respectively.

[0139] The electronic device can locally store some of the generated multiple first subkeys and distribute the first subkeys not stored locally to multiple first authorized devices. The first authorized devices can store the received first subkeys. In the subsequent decryption process, the electronic device needs to obtain at least a third number of first subkeys from the local device and the first authorized device respectively, so as to calculate the coefficients a1, a2, ..., a in the above polynomial based on the obtained first subkeys. t-1 And the constant term S1, so as to obtain the private key which is the constant term S1.

[0140] As can be seen, in this embodiment of the present application, the electronic device generates multiple first subkeys based on the private key and stores them locally and on multiple first authorized devices. During the subsequent decryption process, the electronic device needs to obtain sufficient first subkeys from both the local device and the first authorized device to restore the private key and complete the decryption of the metadata. In other words, the electronic device and the first authorized device must work together to complete the decryption of the metadata, greatly enhancing the security of metadata storage.

[0141] As an implementation method of an embodiment of the present application, after the step of using a key derivation function to generate a derived key of a public key as a file content key in the above step S102, the above file encryption method may further include the following steps: generating multiple second subkeys corresponding to the file content key; locally storing part of the second subkeys, and distributing the second subkeys that are not locally stored in the second subkeys to multiple second authorization devices, so that the second authorization devices store the received second subkeys.

[0142] To further enhance the security of file content storage, the electronic device may convert the file content key used to encrypt and decrypt file content into multiple second subkeys, and store the multiple second subkeys locally and on multiple second authorized devices respectively.

[0143] In one example, the electronic device may first determine a fourth number of second subkeys to be generated and a fifth number of second subkeys required to successfully recover the file content key, where the fourth number is greater than or equal to the fifth number. The electronic device may generate the second subkey using a polynomial, which is as follows:

[0144] f2(y)=S2+b1y+b2y 2 +…+b k-1 y k-1 ;

[0145] Wherein, k is the fifth number, y is the identifier of the second subkey, y=1, 2, ..., q, q is the fourth number; S2 is the file content key, b1, b2, ..., b k-1 is a randomly selected coefficient, and f2(y) is the second subkey identified as y.

[0146] The electronic device can substitute y=1, y=2, ..., y=q into the above polynomials respectively to obtain q second subkeys f2(1), f2(2), ..., f2(q) respectively.

[0147] The electronic device may locally store some of the generated second subkeys and distribute the second subkeys not stored locally to multiple second authorized devices. The second authorized devices may store the received second subkeys. The second authorized devices may be the same device as the first authorized device or different devices, without limitation.

[0148] In the subsequent decryption process, the electronic device needs to obtain at least the fifth number of second subkeys from the local and second authorized devices respectively, so as to calculate the coefficients b1, b2, ..., b in the above polynomial based on the obtained second subkeys. t-1 and the constant term S2, thereby obtaining the file content key, which is the constant term S2.

[0149] As can be seen, in the embodiments of the present application, the electronic device generates multiple second subkeys based on the file content key and stores them locally and on multiple second authorized devices. During the subsequent decryption process, the electronic device needs to obtain sufficient second subkeys from both the local device and the second authorized devices to restore the file content key and complete the decryption of the file content. In other words, the electronic device and the second authorized device must work together to complete the decryption of the file content, greatly enhancing the security of the file content storage.

[0150] As an implementation method of the embodiment of the present application, the electronic device may also periodically update the above-mentioned post-quantum key and file content key. In this case, Figure 2 As shown, the above file encryption method may further include the following steps S201-S207.

[0151] S201: Generate an updated post-quantum key according to a set period.

[0152] The set period can be set according to actual needs, such as one month, half a month, 20 days, etc. The electronic device can generate an updated post-quantum key according to the set period. The electronic device can use a post-quantum cryptographic algorithm to generate a post-quantum key that is different from the post-quantum key before the update.

[0153] In one possible implementation, after the electronic device generates an updated post-quantum key, it can also generate multiple first subkeys corresponding to the private key included in the updated post-quantum key, locally store some of the first subkeys, and distribute the unstored first subkeys to multiple first authorized devices. This can enhance the security of metadata storage.

[0154] S202: Decrypt the stored encrypted metadata using the private key included in the post-quantum key before the update to obtain the metadata.

[0155] The electronic device can obtain the private key included in the pre-update post-quantum key and decrypt the stored encrypted metadata to obtain the metadata. A more detailed decryption process can be found in the description of the file decryption method later in this article and will not be explained here.

[0156] S203: Encrypt the metadata using the public key included in the updated post-quantum key to obtain re-encrypted metadata.

[0157] The electronic device can use the public key included in the updated post-quantum key to encrypt the metadata to obtain the re-encrypted metadata. The electronic device can also delete the post-quantum key before the update, or archive the post-quantum key before the update to a secure library for subsequent tracing.

[0158] S204: Based on the public key included in the updated post-quantum key, a key derivation function is used to generate a derived key of the public key as the updated file content key.

[0159] The electronic device can use a key derivation function to generate a derived key from the public key included in the updated post-quantum key, using the public key derivation function as the updated file content key. The process for generating the derived key is similar to the process for generating the derived key described in step S102 above. Only the public key used to generate the derived key is updated, and will not be further described here.

[0160] When the file content is split into a first number of file content fragments, the electronic device can also use a key derivation function to generate a first number of derived keys of the public key based on the public key included in the updated post-quantum key, as the updated file content keys corresponding to each file content fragment.

[0161] S205: Decrypt the stored encrypted file content using the file content key before updating to obtain the file content.

[0162] The electronic device can obtain the file content key before the update and decrypt the stored encrypted file content to obtain the file content. For a more detailed decryption process, please refer to the description of the file decryption method below, which will not be explained here.

[0163] S206: Encrypt the file content using the updated file content key to obtain re-encrypted file content.

[0164] The electronic device can use the updated file content key to encrypt the file content to obtain the re-encrypted file content. The electronic device can also delete (i.e., destroy) the file content key before the update, or archive the file content key before the update to a secure library for subsequent tracing.

[0165] S207: Store the re-encrypted metadata and the re-encrypted file content.

[0166] The electronic device may store the re-encrypted metadata and the re-encrypted file content.

[0167] The execution order of the above steps S202-S203 and steps S204-S206 is not specifically limited. Steps S202-S203 can be executed first, or steps S204-S206 can be executed first. Of course, steps S202-S203 and steps S204-S206 can also be executed in parallel.

[0168] In one possible implementation, after the electronic device generates an updated file content key, it can also generate multiple second subkeys corresponding to the updated file content key, locally store some of the second subkeys, and distribute the unstored second subkeys to multiple second authorized devices. This can enhance the security of file content storage.

[0169] It can be seen that in the embodiment of the present application, the electronic device will regularly update the post-quantum key and file content key, further enhancing the security of the key.

[0170] In one possible implementation, the key generation, distribution, update, and destruction processes described above can be performed by an HSM (Hardware Security Module) integrated into the electronic device. The HSM can distribute the first and second subkeys to the first and second authorized devices, respectively, via a secure channel. The key transmitted through this channel is encrypted using another pair of generated keys, and the channel uses a secure communication protocol to transmit the key. Before key transmission, the HSM verifies the key storage permissions of the first and second authorized devices to prevent the key from being distributed to authorized devices that do not have key storage permissions.

[0171] In this way, during the generation phase, the HSM can employ the aforementioned post-quantum cryptographic algorithms and key derivation functions to generate strong, difficult-to-guess keys. During the distribution phase, the HSM securely transmits the keys to the first or second authorized device via a secure channel. During the update phase, the HSM can regularly update keys, ensuring that the keys are not overly time-sensitive, thereby enhancing key security. After the update is complete, during the historical key destruction phase, the HSM securely deletes the keys to prevent malicious recovery and exploitation. The HSM's unified and comprehensive protection and management of the key lifecycle effectively prevents key leakage, improves key security, and thus enhances the security of file metadata and content storage.

[0172] Corresponding to the above-mentioned file encryption method, the embodiment of the present application also provides a file decryption method, such as Figure 3 As shown, the method includes the following steps S301-S304.

[0173] The file decryption method provided in the embodiment of the present application can be applied to any electronic device that needs to provide file storage services, for example, an electronic device deployed with a file management middle-end system.

[0174] S301, in response to a file acquisition request from a user, obtaining a private key included in a post-quantum key corresponding to a target file indicated by the file acquisition request, and obtaining a file content key corresponding to the target file.

[0175] S302: Decrypt the encrypted metadata corresponding to the target file using the acquired private key to obtain the metadata of the target file.

[0176] S303: Decrypt the encrypted file content corresponding to the target file using the obtained file content key to obtain the file content of the target file.

[0177] S304: Provide the target file to the user based on the metadata and the file content.

[0178] In the technical solution provided by the embodiment of the present application, the electronic device responds to the user's file acquisition request, obtains the private key included in the post-quantum key corresponding to the target file indicated by the file acquisition request, and obtains the file content key corresponding to the target file. The encrypted metadata is then decrypted using the obtained private key, and the encrypted file content is decrypted using the obtained file content key, respectively, to obtain the metadata and file content of the target file, and the target file is provided to the user based on the metadata and file content. Since the post-quantum key can resist quantum computing attacks, and the derived key as a symmetric key has an efficient encryption and decryption speed, this can ensure the security of the file when facing quantum computing attacks, that is, ensure anti-quantum security, and also ensure efficient encryption and decryption speed and storage performance.

[0179] In addition, since the key derivation function is used to bind the public key included in the post-quantum key with the file content key, the adoption of such a layered collaborative mechanism makes key management more convenient and secure, providing a strong guarantee for the stable operation of the entire encryption and decryption mechanism.

[0180] A user can send a file retrieval request to an electronic device to retrieve the desired target file. In response to the user's file retrieval request, the electronic device retrieves the private key included in the post-quantum key corresponding to the target file and the file content key corresponding to the target file. These private and file content keys can be stored locally on the electronic device or on another device that has established a secure communication connection with the electronic device.

[0181] The electronic device can determine the identification of the target file from the file acquisition request, such as the file name, file number, etc., and then, based on the identification of the target file, obtain the private key included in the post-quantum key corresponding to the target file from the local electronic device or other devices, and obtain the file content key corresponding to the target file.

[0182] The electronic device can use the obtained private key to decrypt the encrypted metadata corresponding to the target file to obtain the metadata of the target file; and use the obtained file content key to decrypt the encrypted file content corresponding to the target file to obtain the file content of the target file.

[0183] After decryption is completed, the electronic device may further use a redundancy check algorithm to check whether the metadata and file content obtained by decryption are complete. For example, the redundancy check algorithm may be a Reed Solomon (error correction code) algorithm.

[0184] In one possible implementation, the file content can be split into multiple file content fragments and stored separately and encrypted. In this case, after decrypting each file content fragment, the electronic device uses a redundancy check algorithm to verify the integrity of the data in each decrypted file content fragment. After the verification is complete, the electronic device can combine the multiple file content fragments in the order of content represented by the file content fragment identifiers to obtain the original file content of the target file.

[0185] Furthermore, the electronic device can provide the target file to the user based on the metadata and file content of the target file obtained after decryption.

[0186] In one possible implementation, if a file is split into multiple fragments and a user requests a preview, the electronic device can decrypt the file content contained in the fragments in the order in which they appear in the original file. The electronic device then displays the decrypted fragments to the user for preview. This allows the user to preview the desired portion of the file on demand. Once the user has previewed the desired portion, they can terminate access early, eliminating the need for the electronic device to continue decrypting subsequent fragments, thus saving computing resources.

[0187] In addition, if the user requests to download a file, during the process of sequentially decrypting multiple file content fragments, the electronic device may also display a loading icon or text to prompt the user that the target file is being loaded.

[0188] In one possible implementation, when a user accesses a file, such as when a user previews the file content, the electronic device can also record the user's preview operation in real time and issue a real-time alarm message when abnormal preview behavior is detected to ensure the security of files stored in the electronic device.

[0189] As an implementation method of an embodiment of the present application, before responding to a user's file acquisition request, the electronic device may first verify the user's permissions. That is, before the step of obtaining the private key included in the post-quantum key corresponding to the target file indicated by the file acquisition request in step S301 above, the above-mentioned file decryption method may also include the following steps: obtaining the user's identity attributes, device attributes, and file access type; and determining whether the user has access rights to access the target file indicated by the file acquisition request based on the user's identity attributes, device attributes, and file access type.

[0190] Electronic devices can obtain the user's identity attributes, device attributes, and file access type from a file retrieval request. Device attributes represent the permissions of the device used by the user to issue the file retrieval request, while file access type represents the method by which the user accesses the file. User identity attributes may include the user's department and position level; device attributes may include the device identifier and IP address used by the user to issue the file retrieval request; and file access types may include preview, edit, and download.

[0191] The electronic device can determine whether the user has access rights to the target file indicated by the file acquisition request based on the user's attributes, device attributes, and file access type. Specifically, the electronic device can match the user's attributes, device attributes, and file access type with pre-stored access rights information for the target file. If this information matches, the electronic device determines that the user has access rights to the target file. The pre-stored access rights information for the target file can be set by the uploader of the target file or by other administrators.

[0192] In one possible implementation, in order to more accurately determine the user's access rights, the electronic device can also generate an access token for the user in real time, and set the validity period of the access token to minutes, which will automatically expire after a timeout. The electronic device can determine whether the user has access rights based on the access token. Before triggering the decryption process, in addition to information such as the user's identity attributes, device attributes, and file access type electronic device, the electronic device can also perform MFA (Multi Factor Authentication) based on other information included in the access token, such as the user's specific position, to determine whether the user has access rights.

[0193] If the user has access rights, the electronic device may continue to execute the step of obtaining the private key included in the post-quantum key corresponding to the target file indicated by the file acquisition request in step S301.

[0194] As can be seen, in the embodiment of the present application, before providing the target file to the user, the electronic device also verifies the user's access rights. Only when the user has access rights will the electronic device obtain the key to decrypt the metadata and file content corresponding to the target file. By implementing fine-grained permission control, the problem of extensive permission management is solved, thereby improving the security of target file storage.

[0195] As an implementation method of an embodiment of the present application, the private key included in the post-quantum key can correspond to multiple first subkeys, and these multiple first subkeys can be stored locally and on multiple first authorized devices. In this case, the step of obtaining the private key included in the post-quantum key corresponding to the target file indicated by the file acquisition request in step S301 above can include: obtaining at least a first threshold value of first subkeys from the local and multiple first authorized devices; based on the obtained at least first threshold value of first subkeys and the generation method of the first subkey, reconstructing the private key included in the post-quantum key.

[0196] The electronic device may also pre-store the addresses of the storage nodes of each first sub-key, that is, the address of the first authorization device, so that the electronic device can obtain the first sub-key locally, and obtain at least a first threshold value of first sub-keys from multiple first authorization devices according to the pre-stored address of the first authorization device, and then reconstruct the private key included in the post-quantum key based on the at least first threshold value of first sub-keys obtained and the generation method of the first sub-key.

[0197] For example, the first subkey is generated using the following polynomial:

[0198] f1(x)=S1+a1x+a2x 2 +…+a t-1 x t-1 ;

[0199] Wherein, t is the first threshold value, i.e., the third number mentioned above, for example, t can be 3, x is the identifier of the first subkey, x=1, 2, ..., m, m is the total number of generated first subkeys, i.e., the second number mentioned above, for example, m can be 5; S1 is the private key, a1, a2, ..., a t-1 are the polynomial coefficients, and f1(x) is the first subkey identified by x.

[0200] The electronic device can substitute the obtained t first subkeys and corresponding identifiers into the above polynomial to obtain t polynomials about a1, a2, ..., a t-1 And the equation of S1. For example, for the first subkey f1(3) identified as 3, substituting the above polynomial into the equation, the equation is:

[0201] f1(3)=S1+3×a1+9×a2+…+3 t-1 ×a t-1 ;

[0202] The electronic device can calculate the solution of the equation system consisting of the t equations obtained by substituting them into the equations, that is, calculate the coefficients a1, a2, ..., a in the above polynomials. t-1 and the constant term S1, and the calculated constant term S1 is used as the file content key.

[0203] As can be seen, in the embodiment of the present application, multiple first subkeys generated from the private key are stored locally and on multiple first authorized devices. During the decryption process, the electronic device needs to obtain sufficient first subkeys from both the local device and the first authorized devices to restore the private key and complete the decryption of the metadata. In other words, the electronic device and the first authorized device must work together to complete the decryption of the metadata. Even if the first subkey stored in the electronic device or an individual first authorized device is leaked, it is difficult to complete the decryption of the metadata. This prevents metadata leakage and greatly enhances the security of metadata storage.

[0204] As one implementation of an embodiment of the present application, a file content key may correspond to multiple second subkeys, and these multiple second subkeys may be stored locally and on multiple second authorized devices. In this case, the step of obtaining the file content key corresponding to the target file in step S301 may include: obtaining at least a second threshold number of second subkeys from the local computer and multiple second authorized devices; and reconstructing the file content key based on the obtained at least second threshold number of second subkeys and the method for generating the second subkeys.

[0205] The electronic device may also pre-store the addresses of the storage nodes of each second subkey, that is, the address of the second authorization device, so that the electronic device can obtain the second subkey locally, and obtain at least a second threshold value of second subkeys from multiple second authorization devices according to the pre-stored addresses of the second authorization device, and then reconstruct the file content key based on the obtained at least second threshold value of second subkeys and the generation method of the second subkey.

[0206] For example, the second subkey is generated using the following polynomial:

[0207] f2(y)=S2+b1y+b2y 2 +…+b k-1 y k-1 ;

[0208] Wherein, k is the second threshold value, i.e., the fifth number mentioned above; y is the identifier of the second subkey, y=1, 2, ..., q, q is the total number of second subkeys generated, i.e., the fourth number mentioned above; S2 is the file content key, b1, b2, ..., b k-1 are the polynomial coefficients, and f2(y) is the second subkey identified as y.

[0209] The electronic device can substitute the obtained k second subkeys and corresponding identifiers into the above polynomial to obtain k polynomials about b1, b2, ..., b t-1 And the equation of S2. For the second subkey f2(2) identified as 2, substituting the above polynomial into the equation, the equation is:

[0210] f2(2)=S2+2×b1+4×b2+…+2 k-1 ×b k-1 ;

[0211] The electronic device can calculate the solution of the equation system consisting of the k equations obtained by substituting them into the equations, that is, calculate the coefficients b1, b2, ..., b in the above polynomials. t-1 and the constant term S2, and the calculated constant term S2 is used as the file content key.

[0212] As can be seen, in the embodiments of the present application, multiple second subkeys generated based on the file content key are stored locally and on multiple second authorized devices. During the decryption process, the electronic device needs to obtain sufficient second subkeys from both the local device and the second authorized devices to restore the file content key and complete the decryption of the file content. In other words, the electronic device and the second authorized device must work together to complete the decryption of the file content. Even if the second subkey stored in the electronic device or an individual second authorized device is leaked, it will be difficult to complete the decryption of the file content. This can prevent the leakage of file content and greatly enhance the security of file content storage.

[0213] In one possible implementation, before decrypting the encrypted metadata and the encrypted file content in step S302, the electronic device may first create a virtual operating system, also known as a sandbox. The virtual operating system is created for the user and is only used to process the target file that the user wants to access. The electronic device can use the obtained private key in the virtual operating system to decrypt the encrypted metadata corresponding to the target file to obtain the metadata of the target file, and use the obtained file content key to decrypt the encrypted file content corresponding to the target file to obtain the file content of the target file. Afterwards, the electronic device performs sandbox rendering based on the metadata and file content through the virtual operating system to provide the target file to the user.

[0214] In this way, the decryption process of the target file's metadata and file content is carried out in the sandbox, and the sandboxes corresponding to each user are isolated from each other, which can prevent the decrypted data from being leaked.

[0215] By applying the technical solutions provided in the embodiments of this application, multi-level protection of files is achieved using post-quantum keys and file content keys. At the metadata encryption level, post-quantum cryptographic algorithms are used to encrypt key metadata such as file attributes and tags, effectively enhancing the security of files in the face of quantum computing attacks. At the file content encryption level, a high-performance symmetric encryption algorithm is used to ensure high-intensity security and the confidentiality and integrity of file content during storage and transmission, while also ensuring efficient encryption and decryption speeds, achieving high file storage throughput and low latency.

[0216] Corresponding to the above-mentioned file encryption method, the embodiment of the present application also provides a file encryption device, such as Figure 4 As shown, the device includes:

[0217] The first acquisition module 401 is used to acquire a file uploaded by a user, wherein the file includes metadata and file content;

[0218] A generation module 402 is configured to generate a post-quantum key, and generate a derived key of the public key using a key derivation function based on the public key included in the post-quantum key, as the file content key;

[0219] The encryption module 403 is used to encrypt the metadata using the public key to obtain the encrypted metadata, and to encrypt the file content using the file content key to obtain the encrypted file content;

[0220] The storage module 404 is configured to store the encrypted metadata and the encrypted file content.

[0221] In the technical solution provided by the embodiments of the present application, an electronic device obtains a file uploaded by a user, first generates a post-quantum key for the file's metadata, and then uses the public key included in the post-quantum key to generate a derived key as the file content key. The electronic device encrypts the metadata using the public key included in the post-quantum key and encrypts the file content using the file content key, and then stores the encrypted file. Because the post-quantum key can resist quantum computing attacks, and the derived key, as a symmetric key, has efficient encryption and decryption speed, this ensures the security of the file in the face of quantum computing attacks, that is, quantum security, while also ensuring efficient encryption and decryption speed and storage performance.

[0222] In addition, since the key derivation function is used to bind the public key included in the post-quantum key with the file content key, the adoption of such a layered collaborative mechanism makes key management more convenient and secure, providing a strong guarantee for the stable operation of the entire encryption and decryption mechanism.

[0223] As an implementation of an embodiment of the present application, the above-mentioned generating module 402 can be specifically used to:

[0224] Extracting a pseudo-random key from the public key using a salt value and a pseudo-random function, wherein the salt value is generated using a random number generator;

[0225] Map the pseudo-random key to obtain a derived key of a preset length.

[0226] As an implementation of the embodiment of the present application, the above-mentioned file encryption device may further include:

[0227] a splitting module, configured to split the file content into a first number of file content fragments based on a preset splitting strategy before the step of generating a derived key of the public key using a key derivation function based on the public key included in the post-quantum key;

[0228] The generation module 402 may be specifically used to:

[0229] Extracting a first number of pseudorandom keys from the public key using a pseudorandom function and a first number of different salt values, wherein the first number of different salt values are generated using a random number generator;

[0230] Mapping each pseudo-random key separately to obtain a first number of derived keys of preset lengths as file content keys corresponding to the file content fragments;

[0231] The encryption module 403 may be used to:

[0232] For each file content fragment, the file content fragment is encrypted using the file content key corresponding to the file content fragment.

[0233] As an implementation of the embodiment of the present application, the above-mentioned file encryption device may further include:

[0234] The first distribution module is used to generate multiple first subkeys corresponding to the private key included in the post-quantum key after the step of generating the post-quantum key; locally store some subkeys in the first subkeys, and distribute the first subkeys that are not locally stored in the first subkeys to multiple first authorized devices, so that the first authorized devices store the received first subkeys.

[0235] As an implementation of the embodiment of the present application, the above-mentioned file encryption device may further include:

[0236] The second distribution module is used to generate a plurality of second subkeys corresponding to the file content key after using a key derivation function to generate a derived key of the public key as the file content key; locally store part of the second subkeys, and distribute the second subkeys that are not locally stored in the second subkeys to a plurality of second authorized devices, so that the second authorized devices store the received second subkeys.

[0237] As an implementation of the embodiment of the present application, the above-mentioned file encryption device may further include:

[0238] The update module is configured to generate an updated post-quantum key according to a set period; decrypt the stored encrypted metadata using the private key included in the post-quantum key before the update to obtain the metadata; encrypt the metadata using the public key included in the updated post-quantum key to obtain re-encrypted metadata; generate a derived key of the public key using a key derivation function based on the public key included in the updated post-quantum key as an updated file content key; decrypt the stored encrypted file content using the file content key before the update to obtain the file content; encrypt the file content using the updated file content key to obtain re-encrypted file content; and store the re-encrypted metadata and the re-encrypted file content.

[0239] Corresponding to the above-mentioned file decryption method, the embodiment of the present application also provides a file decryption device, such as Figure 5 As shown, the device includes:

[0240] The second acquisition module 501 is configured to respond to a file acquisition request from a user, acquire a private key included in a post-quantum key corresponding to a target file indicated in the file acquisition request, and acquire a file content key corresponding to the target file;

[0241] A first decryption module 502 is configured to decrypt the encrypted metadata corresponding to the target file using the acquired private key to obtain the metadata of the target file;

[0242] The second decryption module 503 is used to decrypt the encrypted file content corresponding to the target file using the obtained file content key to obtain the file content of the target file;

[0243] The providing module 504 is configured to provide the target file to the user based on the metadata and the file content.

[0244] In the technical solution provided by the embodiment of the present application, the electronic device responds to the user's file acquisition request, obtains the private key included in the post-quantum key corresponding to the target file indicated by the file acquisition request, and obtains the file content key corresponding to the target file. The encrypted metadata is then decrypted using the obtained private key, and the encrypted file content is decrypted using the obtained file content key, respectively, to obtain the metadata and file content of the target file, and the target file is provided to the user based on the metadata and file content. Since the post-quantum key can resist quantum computing attacks, and the derived key as a symmetric key has an efficient encryption and decryption speed, this can ensure the security of the file when facing quantum computing attacks, that is, ensure anti-quantum security, and also ensure efficient encryption and decryption speed and storage performance.

[0245] In addition, since the key derivation function is used to bind the public key included in the post-quantum key with the file content key, the adoption of such a layered collaborative mechanism makes key management more convenient and secure, providing a strong guarantee for the stable operation of the entire encryption and decryption mechanism.

[0246] As an implementation of the embodiment of the present application, the above-mentioned file decryption device may further include:

[0247] The verification module is used to obtain the user's identity attributes, device attributes, and file access type before the step of obtaining the private key included in the post-quantum key corresponding to the target file indicated by the file acquisition request, wherein the device attributes represent the authority of the device used by the user to issue the file acquisition request, and the file access type represents the method by which the user accesses the file; based on the user's identity attributes, device attributes, and file access type, determine whether the user has the access authority to access the target file indicated by the file acquisition request; and trigger the second acquisition module if the user has the access authority.

[0248] As an implementation of an embodiment of the present application, the second acquisition module 501 may be specifically configured to:

[0249] Obtaining at least a first threshold number of first subkeys from a local device and a plurality of first authorized devices, wherein the plurality of first subkeys corresponding to the private key included in the post-quantum key are stored locally and in the plurality of first authorized devices;

[0250] Based on the obtained at least first threshold value of first subkeys and the generation method of the first subkeys, a private key included in the post-quantum key is reconstructed.

[0251] As an implementation of an embodiment of the present application, the second acquisition module 501 may be specifically configured to:

[0252] Obtaining at least a second threshold number of second subkeys from a local device and a plurality of second authorization devices, wherein the plurality of second subkeys corresponding to the file content key are stored in the local device and the plurality of second authorization devices;

[0253] The file content key is reconstructed based on the obtained at least second threshold value second subkeys and the generation method of the second subkeys.

[0254] The present application also provides an electronic device, such as Figure 6 As shown, it includes a processor 601 , a communication interface 602 , a memory 603 and a communication bus 604 , wherein the processor 601 , the communication interface 602 , and the memory 603 communicate with each other via the communication bus 604 .

[0255] Memory 603, used for storing computer programs;

[0256] The processor 601 is configured to implement the file encryption method or the file decryption method described in any of the above embodiments when executing the program stored in the memory 603 .

[0257] The communication bus mentioned in the electronic device mentioned above may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.

[0258] The communication interface is used for communication between the above electronic device and other devices.

[0259] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage. Alternatively, the memory may be at least one storage device located away from the processor.

[0260] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.

[0261] In another embodiment provided by the present application, a computer-readable storage medium is further provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned file encryption methods or file decryption methods are implemented.

[0262] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any one of the file encryption methods or file decryption methods in the above embodiments.

[0263] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).

[0264] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.

[0265] Each embodiment in this specification is described in a related manner. Similar portions between embodiments can be referenced to each other. Each embodiment focuses on the differences between other embodiments. In particular, the device, electronic device, computer-readable storage medium, and computer program product embodiments are generally similar to the method embodiments, so their descriptions are relatively simple. For related portions, reference can be made to the descriptions of the method embodiments.

[0266] The above description is only a preferred embodiment of the present application and is not intended to limit the scope of protection of the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application are included in the scope of protection of the present application.

Claims

1. A file encryption method, characterized in that: The method comprises: Obtaining a file uploaded by a user, wherein the file includes metadata and file content; Generate a post-quantum key, and generate a derived key of the public key using a key derivation function based on a public key included in the post-quantum key as a file content key; Encrypting the metadata using the public key to obtain encrypted metadata, and encrypting the file content using the file content key to obtain encrypted file content; The encrypted metadata and the encrypted file content are stored.

2. The method according to claim 1, characterized in that The step of generating a derived key of the public key using a key derivation function based on the public key included in the post-quantum key comprises: Extracting a pseudorandom key from the public key using a salt value and a pseudorandom function, wherein the salt value is generated using a random number generator; The pseudo-random key is mapped to obtain a derived key of a preset length.

3. The method according to claim 1, characterized in that Before the step of generating a derived key of the public key using a key derivation function based on the public key included in the post-quantum key, the method further includes: Splitting the file content into a first number of file content fragments based on a preset splitting strategy; The step of generating a derived key of the public key using a key derivation function based on the public key included in the post-quantum key as the file content key includes: Extracting a first number of pseudorandom keys from the public key using a pseudorandom function and a first number of different salt values, wherein the first number of different salt values are generated using a random number generator; Mapping each pseudo-random key separately to obtain a first number of derived keys of preset lengths as file content keys corresponding to the file content fragments; The step of encrypting the file content using the file content key to obtain the encrypted file content includes: For each file content fragment, the file content fragment is encrypted using the file content key corresponding to the file content fragment.

4. The method according to any one of claims 1 to 3, characterized in that After the step of generating a post-quantum key, the method further comprises: Generating a plurality of first subkeys corresponding to the private key included in the post-quantum key; locally storing a portion of the first subkeys, and distributing the first subkeys not stored locally to a plurality of first authorized devices, so that the first authorized devices store the received first subkeys; and / or, After the step of generating a derived key of the public key using a key derivation function as the file content key, the method further comprises: Generating a plurality of second subkeys corresponding to the file content key; Part of the second subkeys is stored locally, and the second subkeys not stored locally are distributed to a plurality of second authorized devices, so that the second authorized devices store the received second subkeys.

5. The method according to any one of claims 1 to 3, characterized in that The method further comprises: Generate updated post-quantum keys according to the set period; Decrypting the stored encrypted metadata using a private key included in the post-quantum key before the update to obtain the metadata; Encrypting the metadata using the public key included in the updated post-quantum key to obtain re-encrypted metadata; Based on the public key included in the updated post-quantum key, generating a derived key of the public key using the key derivation function as the updated file content key; Decrypting the stored encrypted file content using the file content key before updating to obtain the file content; Encrypting the file content using the updated file content key to obtain re-encrypted file content; The re-encrypted metadata and the re-encrypted file content are stored.

6. A file decryption method, characterized in that: The method comprises: In response to a file acquisition request from a user, obtaining a private key included in a post-quantum key corresponding to a target file indicated by the file acquisition request, and obtaining a file content key corresponding to the target file; Decrypting the encrypted metadata corresponding to the target file using the obtained private key to obtain the metadata of the target file; Decrypting the encrypted file content corresponding to the target file using the obtained file content key to obtain the file content of the target file; The target file is provided to the user based on the metadata and the file content.

7. The method according to claim 6, characterized in that Before the step of obtaining a private key included in the post-quantum key corresponding to the target file indicated by the file acquisition request, the method further includes: Acquire the user's identity attributes, device attributes, and file access type, wherein the device attributes represent the permissions of the device used by the user to issue the file acquisition request, and the file access type represents the method by which the user accesses the file; Determining whether the user has access rights to the target file indicated by the file acquisition request based on the user's identity attributes, device attributes, and file access type; In a case where the user has the access permission, the step of obtaining a private key included in the post-quantum key corresponding to the target file indicated by the file acquisition request is performed.

8. The method according to claim 6, characterized in that The step of obtaining a private key included in the post-quantum key corresponding to the target file indicated by the file acquisition request includes: Obtaining at least a first threshold number of first subkeys from a local device and a plurality of first authorized devices, wherein the plurality of first subkeys corresponding to the private key included in the post-quantum key are stored locally and in the plurality of first authorized devices; Reconstructing a private key included in the post-quantum key based on the obtained at least first threshold value of first subkeys and the generation method of the first subkeys; and / or, The step of obtaining the file content key corresponding to the target file includes: Obtaining at least a second threshold number of second subkeys from a local device and a plurality of second authorization devices, wherein the plurality of second subkeys corresponding to the file content key are stored in the local device and the plurality of second authorization devices; The file content key is reconstructed based on the obtained at least second threshold value second subkeys and the generation method of the second subkeys.

9. A file encryption device, characterized in that: The device comprises: A first acquisition module is used to acquire a file uploaded by a user, wherein the file includes metadata and file content; A generation module, configured to generate a post-quantum key, and generate a derived key of the public key using a key derivation function based on a public key included in the post-quantum key, as a file content key; an encryption module, configured to encrypt the metadata using the public key to obtain encrypted metadata, and to encrypt the file content using the file content key to obtain encrypted file content; A storage module is used to store the encrypted metadata and the encrypted file content.

10. A file decryption device, characterized in that: The device comprises: A second acquisition module is configured to, in response to a file acquisition request from a user, acquire a private key included in a post-quantum key corresponding to a target file indicated by the file acquisition request, and acquire a file content key corresponding to the target file; a first decryption module, configured to decrypt the encrypted metadata corresponding to the target file using the acquired private key to obtain the metadata of the target file; A second decryption module is used to decrypt the encrypted file content corresponding to the target file using the obtained file content key to obtain the file content of the target file; A providing module is used to provide the target file to the user based on the metadata and the file content.