Encryption and decryption method and protection system for secret files based on national secret algorithm

Through the secret file addition and decryption method and protection system based on the national secret algorithm, the SM4 algorithm and proxy re-encryption technology are used to solve the problem of secret file access control, and efficient file encryption and secure access are achieved.

CN115396096BActive Publication Date: 2025-03-28BEIHANG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211041100.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-29
Publication Date
2025-03-28
Estimated Expiration
2042-08-29

AI Technical Summary

Technical Problem

It is difficult for the prior art to effectively protect secret files involving private information, especially in e-commerce. Once secret files are illegally accessed, private information is easily leaked, and the confidentiality requirements of commercial contracts are higher.

Method used

The secret file encrypting and decrypting method and protection system based on the national secret algorithm are adopted to encrypt secret files through the SM4 algorithm, and the proxy re-encryption technology and public key encryption are used to ensure that only users with query permission can access the secret files.

Benefits of technology

It realizes efficient encryption and access control of secret files, avoids users who do not have access permissions to access secret files, and significantly improves the security of files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115396096B_ABST
    Figure CN115396096B_ABST
Patent Text Reader

Abstract

The present invention relates to an encryption and decryption method and a protection system for secret files based on a national secret algorithm, belonging to the technical field of data protection. The method comprises the following steps: obtaining a secret file uploaded by a first user and a re-encryption key generated according to a private key of the first user and public keys of all second users who have the authority to view the secret file, encrypting the secret file using an SM4 algorithm to obtain a first ciphertext, encrypting the SM4 key used by the SM4 algorithm to encrypt the secret file using the public key of the first user to obtain a second ciphertext, performing a proxy re-encryption operation on the re-encryption key and the second ciphertext to obtain a third ciphertext, and storing the first ciphertext and the third ciphertext as a re-encrypted ciphertext. The public key of a user with the authority to view the secret file is used to participate in the encryption process, thereby ensuring that only the user with the authority to view the secret file can view and call the secret file, thereby greatly improving the security of the secret file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data protection, and in particular to an encryption and decryption method for secret files based on a national secret algorithm and an autonomous and controllable protection system. Background Art

[0002] With the continuous promotion of e-commerce, confidential documents involving private information, such as electronic contracts, also need to be transmitted, stored and managed through electronic information systems. However, as a legally binding text, contracts often carry a large amount of private information. For example, a labor contract contains the name, address and ID card number or other valid ID number of the worker, as well as daily life information such as work content. Once the content of the contract is illegally accessed, the private information will also be leaked. For confidential commercial contracts, which may also contain the company's business secrets and carry a large amount of cash flow, the confidentiality of the contract content is required to be higher. Therefore, it is necessary to ensure that the contract content, contract processing results, and identity information of contract-related personnel uploaded by users cannot be accessed in any form by other users except the contract-related personnel and authorized administrators. Based on this, there is an urgent need for a technology that can encrypt and control access to secret files. Summary of the invention

[0003] The purpose of the present invention is to provide a secret file encryption and decryption method and protection system based on a national secret algorithm, which can encrypt and control access to secret files to prevent secret files uploaded by users from being accessed by users who do not have access rights.

[0004] To achieve the above object, the present invention provides the following solutions:

[0005] A method for encrypting a secret file based on a national secret algorithm, the method comprising:

[0006] Obtaining a secret file uploaded by a first user and a re-encryption key generated by the first user; the re-encryption key is generated according to a private key of the first user and public keys of all second users who have the authority to view the secret file;

[0007] The secret file is encrypted using the SM4 algorithm to obtain a first ciphertext; the SM4 key used by the SM4 algorithm to encrypt the secret file is encrypted using the public key of the first user to obtain a second ciphertext; a proxy re-encryption operation is performed on the re-encryption key and the second ciphertext to obtain a third ciphertext; the first ciphertext and the third ciphertext constitute a re-encrypted ciphertext;

[0008] The re-encrypted ciphertext is stored.

[0009] A method for decrypting a secret file based on a national secret algorithm, the decryption method comprising:

[0010] Determine whether the third user who makes the access request is a second user who has the authority to access the secret file;

[0011] If yes, then obtaining the symmetric key generated by the third user; the symmetric key is obtained by decrypting the third ciphertext in the re-encrypted ciphertext using the private key of the third user;

[0012] The first ciphertext in the re-encrypted ciphertext is decrypted using the symmetric key to obtain the secret file.

[0013] A protection system for secret files based on a national secret algorithm, the protection system comprising: an access module, a query module, a key transmission module, an SM4 encryption and decryption module and a distributed database;

[0014] The access module is used to verify the user's authority; when the user has the authority, the user is allowed to upload and view the secret file;

[0015] The query module is used to receive a query request input by a user and return the secret file to the user;

[0016] The key transmission module is used to generate a public and private key pair for each user;

[0017] The SM4 encryption and decryption module is used to encrypt the secret file uploaded by the user to obtain a re-encrypted ciphertext; it is also used to decrypt the re-encrypted ciphertext to obtain the original secret file;

[0018] The distributed database is used to store the re-encrypted ciphertext.

[0019] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:

[0020] The present invention is used to provide a secret file encryption and decryption method and protection system based on a national secret algorithm, obtain a secret file and a re-encryption key uploaded by a first user, encrypt the secret file using an SM4 algorithm to obtain a first ciphertext, encrypt the SM4 key used by the SM4 algorithm to encrypt the secret file using the public key of the first user to obtain a second ciphertext, perform a proxy re-encryption operation on the re-encryption key and the second ciphertext to obtain a third ciphertext, the first ciphertext and the third ciphertext form a re-encrypted ciphertext for storage, and use the public key of a user with access authority to participate in the encryption process, ensuring that only users with access authority can access and call the secret file, greatly improving the security of the secret file. At the same time, only performing proxy re-encryption on the SM4 key can improve the encryption speed and achieve the same effect as performing proxy re-encryption on the secret file. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0022] Figure 1 A flowchart of the encryption method provided by Embodiment 1 of the present invention;

[0023] Figure 2 A schematic diagram of the review process for users to join an organization provided in Example 1 of the present invention;

[0024] Figure 3 A schematic diagram of a three-level management system provided in Example 1 of the present invention;

[0025] Figure 4 A schematic diagram of a proxy re-encryption algorithm provided in Example 1 of the present invention;

[0026] Figure 5 A flowchart of a decryption method provided by Embodiment 2 of the present invention;

[0027] Figure 6 This is a schematic diagram of the overall structure of the protection system provided in Embodiment 3 of the present invention;

[0028] Figure 7 A schematic diagram of data transmission and on-chain synchronization provided by Embodiment 3 of the present invention;

[0029] Figure 8 This is a module flow diagram for file upload provided in Example 3 of the present invention;

[0030] Fig. 9 A module flow diagram for file reading provided in Example 3 of the present invention;

[0031] Fig.10 This is a module flow diagram of the signature process provided in Example 3 of the present invention. DETAILED DESCRIPTION

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

[0033] The purpose of the present invention is to provide a secret file encryption and decryption method and protection system based on a national secret algorithm, which can encrypt and control access to secret files to prevent secret files uploaded by users from being accessed by users who do not have access rights.

[0034] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0035] Embodiment 1:

[0036] This embodiment is used to provide a method for encrypting secret files based on a national secret algorithm. Figure 1 As shown, the encryption method includes:

[0037] S1: Obtain a secret file uploaded by a first user and a re-encryption key generated by the first user; the re-encryption key is generated according to the private key of the first user and the public keys of all second users who have the authority to view the secret file;

[0038] This embodiment can also verify the authority of the first user to determine whether the first user has the authority to upload the secret file. Before S1, the encryption method of this embodiment also includes: obtaining first login information input by the first user, the first login information including the account number and password of the first user; determining whether the first login information is correct; if correct, the first user has logged in successfully, and determining whether the first user has the authority to upload the secret file based on the first login information; if so, obtaining the secret file uploaded by the first user; if not, not allowing the first user to upload the secret file.

[0039] In order to complete the function of determining whether the first user has the authority to upload secret files according to the first login information, this embodiment provides a preferred implementation method. Before determining whether the first user has the authority to upload secret files according to the first login information, the encryption method of this embodiment also includes: after the first user completes the registration to obtain the first login information, the application for joining the organization proposed by the first user is reviewed, and after the review is passed, the first user information of the first user is generated, the first login information and the first user information are matched, so as to obtain the first user information according to the first login information, and further determine whether the first user has the authority to upload secret files according to the first user information. It should be noted that the registration can use the existing registration process, and the first user can register by mobile phone number or other methods.

[0040] Among them, Figure 2 As shown, reviewing the application for joining the organization submitted by the first user, and after the review is passed, generating the first user information of the first user may include:

[0041] (1) Use the CA private key and SM2 signature algorithm to sign the first user's employee ID, the department applied for, and the employee role information to obtain an authorization code, and send the authorization code to the first user. The employee role information includes the first user's user type and permissions. Figure 3 As shown, user types include common users, common administrators, and organization administrators.

[0042] (2) Obtaining the organization ID and authorization code of the organization to be joined input by the first user;

[0043] Each authorization code is unique and will become invalid after use.

[0044] (3) Use the CA public key and SM2 verification algorithm to verify the authorization code; if the verification is successful, the first user's higher-level user node will conduct an audit; if the audit is successful, the first user joins the organization and the first user information of the first user is generated; if the first user is an ordinary user, his higher-level user node is an ordinary administrator; if the first user is an ordinary administrator, his higher-level user node is an organization administrator; if the first user is an organization administrator, his higher-level user node is a super administrator; the first user information includes employee ID, time of joining the organization, reviewer, department to which he belongs, and employee role information.

[0045] Specifically, using the CA public key and SM2 verification algorithm to verify the authorization code may include: using the CA public key and SM2 verification algorithm to decrypt the authorization code to obtain the employee ID, applied department and employee role information of the first user, and comparing the decrypted employee ID, applied department and employee role information of the first user with the employee ID, applied department and employee role information of the first user used for the signature. If they are exactly the same, the input authorization code is correct, the verification passes, and the application submitted by the first user to join the organization is uploaded to the first user's higher-level user node; otherwise, the input authorization code is incorrect, the verification fails, and the application submitted by the first user to join the organization is invalidated.

[0046] like Figure 3 As shown, in this embodiment, there are three types of users, that is, there are three categories of roles: organization administrator, general administrator and general user. Each type of role corresponds to a different type of authorization code. When the first user joins the organization, the first user's joining application will be distributed to different roles for review according to different types of authorization codes: (1) The general user's joining application will be reviewed by the general administrator; (2) The general administrator's joining application will be reviewed by the organization administrator; (3) Since the organization administrator has great power, its reliability and authenticity must be guaranteed. Therefore, the organization administrator's joining application will be authenticated and authorized by the super administrator. In order to limit the power of the organization administrator and share its affairs, an organization may have multiple organization administrators at the same time.

[0047] After the application submitted by the first user to join the organization is approved, when the first user logs in later, the department and employee role information of the first user can be automatically retrieved according to the employee ID after logging in to determine the permissions of the first user, and thus determine whether the first user has the permission to upload secret files. The permissions of each user can be customized.

[0048] The above application review process for joining the organization can be completed by the CA organization. The CA organization is a component of each organization and is mainly responsible for the generation of public and private keys and the issuance of certificates.

[0049] As an optional method, users have the right to review secret files in which they participate. Participation here means: (1) initiated by oneself; (2) participated in approval; (3) participated in signing; (4) participated in confirmation. Ordinary administrators can review all secret files of the department they manage, and organization administrators can review all secret files of the organization. If a user wants to review secret files that he does not have the right to review, it can be handled in the following ways: (1) Ordinary users want to review secret files of the same department, and can apply to the ordinary administrator who manages the department; (2) Ordinary users and ordinary administrators want to review secret files of another department, and can apply to the ordinary administrator of the other department. After the application is approved, they will obtain the right to review. Therefore, all second users who have the right to review secret files described in this embodiment are ordinary users who participate in the secret file, ordinary administrators of the department to which the secret file belongs, organization administrators, and ordinary users and ordinary administrators who are granted the right to review by the ordinary administrator of the department to which the secret file belongs.

[0050] S2: Encrypt the secret file using the SM4 algorithm to obtain a first ciphertext; encrypt the SM4 key used by the SM4 algorithm to encrypt the secret file using the public key of the first user to obtain a second ciphertext; perform a proxy re-encryption operation on the re-encryption key and the second ciphertext to obtain a third ciphertext; the first ciphertext and the third ciphertext constitute a re-encrypted ciphertext;

[0051] Considering the privacy of user data, the private data stored by users on the server is in encrypted form. Since the data owner does not fully trust the cloud service provider, the key for decrypting the ciphertext cannot be sent to the cloud, which will decrypt and share it. The proxy re-encryption algorithm can realize the sharing of ciphertext data in the cloud without leaking the decryption key of the data owner. Therefore, this embodiment adopts this mechanism to realize the sharing of ciphertext by authorized users.

[0052] Alice is the sender of the secret file and Bob is the receiver of the secret file. The proxy re-encryption algorithm is as follows: Figure 4 The specific description is as follows:

[0053] 1.1: Alice requests the key distribution server to generate her own public-private key pair.

[0054] 1.2: The key distribution server generates Alice's public and private key pair and returns it to Alice.

[0055] 1.3: Bob requests the key distribution server to generate his own public-private key pair.

[0056] 1.4: The key distribution server generates Bob's public and private key pair and returns it to Bob.

[0057] 2.1: Alice uses the SM4 algorithm to encrypt data M to generate ciphertext C1, and uses her own public key to encrypt the SM4 key to generate ciphertext C2.

[0058] 2.2: Alice uploads ciphertexts C1 and C2 to the system server.

[0059] 3.1: Alice requests Bob’s public key from the key distribution server.

[0060] 3.2: The key distribution server returns Bob's public key to Alice.

[0061] 3.3: Alice uses Bob’s public key and her own private key to generate the re-encryption key K A→B .

[0062] 3.4: Alice generates the re-encryption key K A→B Upload to the system server.

[0063] 4: Re-encryption algorithm ReEnc(params,CT i ,rk i→j ): Given a public key pk i and the second layer ciphertext CT i , the algorithm uses the re-encryption key rk i→j Generate a public key rk j The first layer of ciphertext CT j Based on this, the system server uses the re-encryption key K A→B Perform proxy re-encryption operation on the ciphertext C2 uploaded by Alice previously to generate new ciphertext C3.

[0064] 5.1: Bob requests the system server to decrypt the ciphertext C1 corresponding to the data M.

[0065] 5.2: The system server sends the re-encrypted ciphertext C3 and C1 to Bob.

[0066] 5.3: Bob uses his private key to decrypt the ciphertext C3 to obtain the symmetric key, and then uses the symmetric key to decrypt C1 to obtain the original plaintext data M.

[0067] Through the above interactive process, the system server converts one user's ciphertext into another user's decryptable ciphertext without leaking the user's private key and plaintext information. This method is mainly end-to-end, ensuring that relevant sensitive information is not leaked.

[0068] This embodiment performs the encryption process of the secret file based on the above-mentioned proxy re-encryption algorithm, obtains the re-encryption key generated by the first user according to the private key of the first user and the public keys of all second users who have the authority to view the secret file, encrypts the secret file using the SM4 algorithm to obtain the first ciphertext; encrypts the SM4 key using the public key of the first user to obtain the second ciphertext; performs a proxy re-encryption operation on the re-encryption key and the second ciphertext to obtain the third ciphertext; the first ciphertext and the third ciphertext constitute the re-encrypted ciphertext.

[0069] S3: Storing the re-encrypted ciphertext.

[0070] This embodiment can store it in a distributed server.

[0071] Secret files, such as the wording and text details of contracts, have a great impact on whether the contract is effective and what effects it has. Users must ensure that the content and format of the contract they upload have not changed after being transmitted through the system. Therefore, it is necessary to provide a reliable integrity check for the contract content to ensure that the contract content is accurately conveyed. Based on this, after generating the re-encryption key, the encryption method of this embodiment also includes: performing a hash operation on the secret file to obtain a first hash value of the secret file; uploading the first hash value to the blockchain. Optionally, this embodiment can also obtain a digital signature obtained by the first user signing the business data using the first user's private key and the SM2 signature algorithm. The business data includes a prefix representing the signature QR code, the id number of the secret file, the user name of the first user, and the time of signing. At the same time, the id number, effective time, initiator, signer, digital signature of the first user, file type and first hash value of the secret file are uploaded to the blockchain for subsequent integrity checks. After this operation, the blockchain can record the key information of the secret file uploaded by the first user after each business operation, which is convenient for subsequent tracing.

[0072] As an optional implementation method, the secret file of this embodiment needs to be signed by several signatories to obtain the handwritten signature of each signatory; after obtaining the handwritten signature of each signatory, the encryption method of this embodiment also includes: for each signatory, obtaining the digital signature of the signatory obtained by the signatory using his own private key and SM2 signature algorithm to sign the business data; generating a signature QR code based on the business data and the digital signature; the business data includes the prefix representing the signature QR code, the id number of the secret file, the user name of the signatory and the time of the signature; synthesizing the secret file and the handwritten signature and signature QR code of each signatory to obtain a signed file; performing hash calculation on the signed file to obtain the file hash value of the signed file; uploading the id number, effective time, initiator, signatory, digital signatures of all signatories, file type and file hash value of the secret file to the blockchain.

[0073] This embodiment encrypts the secret file before storing it, and utilizes the public key of the user with access permission to participate in the encryption process, ensuring that only the user with access permission can view and call the secret file. The secret file can be encrypted and access controlled to prevent the secret file uploaded by the user from being accessed by users without access permission, thereby greatly improving the security of the secret file.

[0074] Embodiment 2:

[0075] This embodiment is used to provide a method for decrypting secret files based on a national secret algorithm. Figure 5 As shown, the decryption method includes:

[0076] T1: Determine whether the third user who makes the access request is a second user who has the authority to access the secret file;

[0077] This embodiment may also utilize the login information of the third user to obtain the user information of the third user, and further determine whether the third user has the authority to view the secret file based on the user information of the third user.

[0078] T2: If yes, obtain the symmetric key generated by the third user; the symmetric key is obtained by decrypting the third ciphertext in the re-encrypted ciphertext using the private key of the third user;

[0079] T3: Decrypt the first ciphertext in the re-encrypted ciphertext using the symmetric key to obtain the secret file.

[0080] This embodiment also performs a decryption process based on a proxy re-encryption algorithm, obtains a symmetric key obtained by a third user using the third user's private key to decrypt the third ciphertext in the re-encrypted ciphertext, and then uses the symmetric key to decrypt the first ciphertext in the re-encrypted ciphertext to obtain a secret file. This embodiment designs a decryption method used in conjunction with the encryption method of Embodiment 1. Since the public key of a user with access authority is used to participate in the encryption process, only the private key of a user with access authority can decrypt the re-encrypted ciphertext, ensuring that only users with access authority can view and call secret files, and can perform access control on secret files, preventing secret files uploaded by users from being accessed by users who do not have access authority, greatly improving the security of secret files.

[0081] In order to achieve a reliable integrity check of the secret file, after obtaining the secret file, the decryption method of this embodiment also includes: calculating the hash value of the secret file to obtain a second hash value; obtaining the first hash value of the secret file from the blockchain; comparing the first hash value and the second hash value; if the first hash value and the second hash value are the same, the secret file has not been tampered with; if the first hash value and the second hash value are different, the secret file has been tampered with and the secret file is discarded.

[0082] Embodiment 3:

[0083] The security of the electronic file protection system is jointly guaranteed by many cryptographic algorithms and security protocols. The user's trust in the protection system is also based on the trust in the machine based on the trust in the algorithms and protocols. Therefore, the protection system needs to ensure that the algorithms it uses are proven to be safe and reliable in practice. The security of the SM2 algorithm and the SM4 algorithm has been double-verified in theory and practice, and can ensure autonomy and control. The use of the SM2 algorithm and the SM4 algorithm for digital signatures and asymmetric encryption can ensure the confidentiality, integrity and authentication of secret files, and can meet the user's security requirements for secret files. Based on this consideration, this embodiment uses the contract business processing system as a carrier to design a protection system for secret files based on the national secret algorithm, combined with proxy re-encryption algorithms, digital signatures, blockchain and other security technologies to provide security protection for user secret files.

[0084] This embodiment is used to provide a protection system for secret files based on the national secret algorithm, such as Figure 6 As shown, the protection system includes: a data transmission module, an access module, a query module, a key transmission module, an SM4 encryption and decryption module, an SM2 signature module, a file generation module, an on-chain synchronization module and a distributed database (SQLite database).

[0085] The access module is used to verify the user's authority. When the user has the authority, the user is allowed to upload and view the secret file. The query module is used to receive the user's input of the view request and return the secret file to the user. The key transmission module is used to generate the public and private key pairs of each user. The SM4 encryption and decryption module is used to encrypt the secret file uploaded by the user to obtain the re-encrypted ciphertext, and is also used to decrypt the re-encrypted ciphertext to obtain the original secret file. The distributed database is used to store the re-encrypted ciphertext. The SM2 signature module is used to sign the business data using the SM2 signature algorithm to obtain a digital signature. The file generation module is used to generate a signature QR code using a digital signature, and synthesize the handwritten signature, the signature QR code and the secret file to obtain a signed file. The on-chain synchronization module is used to upload the digital signature and the hash value obtained by hashing the secret file or the signed file to the blockchain.

[0086] More specifically, the functions of each module in this embodiment are as follows:

[0087] (1) Access Module

[0088] After registering, each user needs to join an organization to use the full functionality of this protection system. The review process for applying to join an organization is completed by the admission module. The process is as follows: Figure 2 As shown, the CA organization of the organization first generates an authorization code through the SM2 signature algorithm based on the employee ID number, the department applied for and the employee role information {uid, department, status} (status includes three user types, and also includes the specific permissions of each user, which can be customized). The authorization code is managed and distributed by the CA organization. When the user uses the protection system for the first time, he needs to enter the organization ID number and authorization code {organizationid, authorizationCode} of the organization he wants to join. Each authorization code is unique and will be invalidated after use. Use the CA public key to decrypt the authorization code through the SM2 verification algorithm to determine whether the authorization code is correct. When the input authorization code is wrong, the application is directly invalidated and not uploaded to a higher-level user node; when the authorization code is correct, the application is uploaded to a higher-level user node for review. After the review is passed, the user successfully joins the organization and generates the user information: employee ID, time of joining the organization, reviewer, department, employee role information {uid, joinTime, reviewer, department, status}, and the user information will be automatically saved in the access module. After that, each time the user logs in, the access module will automatically call out the department and status information based on the uid to manage and allocate the user's access rights.

[0089] like Figure 3 As shown in the figure, in this protection system, there are three types of roles: organization administrator, general administrator and general user. Each type of role corresponds to a different type of authorization code. When joining an organization, the protection system will distribute the joining application to different roles for review based on different types of authorization codes: (1) The application of general users will be reviewed by general administrators; (2) The application of general administrators will be reviewed by organization administrators; (3) Since organization administrators have great power, their reliability and authenticity must be guaranteed, so they are authenticated and authorized by super administrators; and in order to limit the power of organization administrators and share their affairs, there will be multiple organization administrators in the protection system at the same time.

[0090] The creation process of an organization can be reviewed by a super administrator. Specifically, the super administrator is the programmer responsible for operating and maintaining the protection system server, and has been authorized when the protection system was created. When creating an organization, the organization administrator needs to submit relevant information of the organization to the protection system (such as the company's address, registration number, and other real information). The super administrator will review the authenticity of the organization, and the organization can only be created in the protection system after the review is passed. The super administrator does not have the authority to access the internal information of each organization, ensuring that the internal information of each organization will not be obtained by a third party.

[0091] (2) Query Module

[0092] When the system business is in progress, users can see the current business process and basic information through the visual application on the front-end web page, including the contract stage, contract name, initiator, initiation time, validity period, contract type, and signatory {contractStep, contractName, initiator, initiationTime, validTime, contractType, [signer]}. For participants who have not completed the signature, users can remind them to complete it on time.

[0093] The query module of this embodiment is used to determine whether the user has the right to review. The user can review the contract documents in which he / she participates. Participation here refers to: (1) initiated by oneself; (2) participating in approval; (3) participating in signing; (4) participating in confirmation. In addition, ordinary administrators can review all contracts of the department they manage, and organizational administrators can review all contracts of the organization. If a user wants to review a contract that he / she does not have the right to review, it can be handled in the following ways: (1) ordinary users who want to review the contract of the same department can apply to the ordinary administrator who manages the department; (2) ordinary users and ordinary administrators who want to review the contract of another department can apply to the administrator of the department and obtain the right to review after the application is approved. Therefore, all second users who have the right to review secret files are ordinary users who participate in the secret file, ordinary administrators of the department to which the secret file belongs, organizational administrators, and ordinary users and ordinary administrators who are granted the right to review by the ordinary administrator of the department to which the secret file belongs.

[0094] (3) Key transmission module

[0095] This module needs to undertake management functions such as key generation, key distribution and ciphertext sharing. It has an SM2 key generation algorithm inside, which can be expanded to other algorithms such as AES and ECC as needed. The SM2 key generation algorithm generates corresponding public and private key pairs when users, organizations and even seal devices are established, and records corresponding information for subsequent signatures and session services. The key transmission module keeps the public key, and the private key is destroyed and not retained after being assigned to the corresponding user. Therefore, when the private key is needed to generate other data, the user needs to operate and then provide the data to the protection system, such as re-encryption keys, symmetric keys, etc.

[0096] (4) File storage and transmission module

[0097] Stored procedures such as Figure 7 As shown in the figure, the on-chain synchronization module and the distributed database together constitute the file storage and transmission module. The encrypted files are stored in the distributed database and corresponding backups are provided. The key information of the secret file (such as the contract) such as the contract ID, the effective time of the contract, the initiator, the signer, the digital signature of the participant, the contract type, and the file hash value {contractid, sxTime, initiator, [signer], [participantSig], contentType, Hash(contract)} will be synchronized on the blockchain. When the user consults the contract, the contract is decrypted using the re-encryption key provided by the key transmission module and sent to the user after decryption. After the user receives the contract, the hash value of the contract is calculated, and then the obtained value is compared with the value on the chain. If they are equal, the contract is retained, otherwise it is discarded. The https security protocol is used in the transmission, and sensitive information is encrypted.

[0098] (5)SM2 signature module

[0099] In system applications, the key exchange protocol is called by the platform when the user registers, generates a unique key pair for the user, binds it to the user information, and stores it secretly on the platform terminal. The signature module is called when the user performs business operations, and electronically signs the behavior information such as contract signing or stamping to achieve identity authentication and store the operation information on the chain, ensuring the legal validity of the electronic signature. The signature verification module is called in the following scenarios: platform contract validity review, user behavior validity review, user identity verification, etc.

[0100] (6)SM4 encryption and decryption module

[0101] In actual applications, SM4 is often used for encrypted storage and transmission of platform files. The SM4 algorithm is called to encrypt and store secret files. When a user initiates an application to access a secret file, the decryption algorithm is called after the identity is confirmed to extract the corresponding secret file from the distributed database, establish a session, and send the secret file to the user through a secure channel. After the user receives the secret file, the file hash is compared with the information on the chain, and it can be received and accessed after verification that there is no change.

[0102] Table 1 Privacy data to be encrypted

[0103] usr_id Applicant ID information manager_id Person in charge ID information seal_data Printing result information contract_data Electronic contract document after synthetic signature

[0104] (7) File generation module

[0105] When it comes to on-chain business that requires the generation of a signed file, the digital signature obtained by the SM2 signature module will be passed to the file generation module to generate a signature QR code, and the signature file will be synthesized by combining the front-end contract content and handwritten signature image information. The signed file is passed to the data transmission module and uploaded to the front-end web application for users to download.

[0106] The signature QR code contains [sig, cid, username, stime, esig]. The sig string is used as a prefix to indicate that this is a signature QR code; cid is the ID number of the contract; username represents the username of the signatory, and there is no duplicate username in the system; stime represents the time of the signature; esig is the SM2 digital signature of the signatory on [sig, cid, username, stime], which is signed with the signatory's private key and verified with the public key to ensure the authenticity of this signature. The contract document, the user's handwritten signature, and the signature QR code are aggregated into a PDF as a signed file.

[0107] Based on the functions of the above modules, the data flow between the modules included in the protection system is given here, as follows:

[0108] (1) File upload & business creation

[0109] like Figure 8 As shown, when creating a new business or uploading a secret file, the user passes the secret file to the data transmission module through the front-end web application, and the data transmission module passes the login information to the access module. The access module verifies the user's identity through the login information and determines whether it has the authority to create a new business or upload a secret file. If it is determined that the user has the corresponding authority, the key transmission module passes the user's re-encryption key to the SM4 encryption and decryption module, and at the same time transmits the secret file to the SM4 encryption and decryption module, performs proxy re-encryption in the SM4 encryption and decryption module, and passes the re-encrypted ciphertext to the distributed database for storage. At the same time, the business data including the secret file is passed to the on-chain synchronization module to obtain the hash value, and a transaction block is generated for on-chain storage.

[0110] (2) File reading

[0111] Users with the permission to view secret files need to read the secret files through the following process, such as Fig. 9 As shown, the data transmission module first passes the request data and login information to the access module. The access module verifies the user's authority. If it is determined that the user has the authority to view the requested secret file, the re-encryption key is passed to the query module through the key transmission module. The query module searches for the re-encrypted ciphertext from the distributed database and passes it to the SM4 encryption and decryption module for decryption. The original secret file is returned to the data transmission module and displayed on the front-end web application for the user to read.

[0112] (3) Signature Process

[0113] The process when a user signs a document is as follows Fig.10 As shown: First, the data transmission module passes the handwritten signature image and login information obtained by the front-end web application to the access module. The access module verifies the identity and authority of the user. If it is determined that the user is the person in charge of the business, the re-encryption key is passed to the query module through the key transmission module to read the contract file. At the same time, the user's private key and related business data are passed to the SM2 signature module for signing. The generated digital signature and business data are passed to the file generation module for generating the signature QR code and synthesizing the signed file. Finally, the business data including the digital signature and the signed electronic file are passed to the on-chain synchronization module to calculate the hash value and generate a transaction block for on-chain evidence storage.

[0114] The digital signature exists in the signed file in the form of a QR code image, which can be easily read during verification. Uploading the file content to the chain can protect the integrity of the data, and the signature ensures non-repudiation.

[0115] The protection system provided in this embodiment uses the end-to-end encryption storage and transmission of the user's sensitive contracts or documents using the national secret algorithm. Through the secret key authorization and distribution mechanism, it supports authorized users to read and share sensitive files, avoiding the risk of sensitive data leakage caused by the corruption of system administrators or the system being hacked under the centralized platform. All business data involving privacy are encrypted with the organization administrator's key through the SM4 encryption and decryption module and stored in the database. Only the administrator and the users participating in the contract can use the key to view and call. After the user is verified by the access module, the key transmission module can pass the key to the SM4 module for decryption. This process is completed inside the system server to ensure that the organization's key will not be leaked to ordinary users, ensuring the controllability of privacy information and the security of the key.

[0116] Most current file management systems use a single database on a centralized server to directly store plain text, and the management of user access rights is usually based on the system management level, without protecting its reliability based on cryptographic technology. This protection system uses an independent and controllable national secret algorithm to design a complete sensitive file protection system. It not only uses cryptographic technology to protect the storage of sensitive files, but also synchronizes key summary information on the chain to ensure data traceability and integrity. This system uses proxy re-encryption for secret file sharing, so that the trust of both users in the confidentiality of the entire information interaction process is no longer based on the reliability of a third-party system, but on verifiable machine trust, which is a technological innovation in the file management system.

[0117] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0118] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of ​​the present invention. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A method for encrypting secret files based on a national secret algorithm, characterized in that: The encryption method comprises: Obtaining a secret file uploaded by a first user and a re-encryption key generated by the first user; the re-encryption key is generated according to a private key of the first user and public keys of all second users who have the authority to view the secret file; The secret file is encrypted using the SM4 algorithm to obtain a first ciphertext; the SM4 key used by the SM4 algorithm to encrypt the secret file is encrypted using the public key of the first user to obtain a second ciphertext; a proxy re-encryption operation is performed on the re-encryption key and the second ciphertext to obtain a third ciphertext; the first ciphertext and the third ciphertext constitute a re-encrypted ciphertext; The re-encrypted ciphertext is stored; when the third user who makes the access request is the second user who has the authority to access the secret file, the third ciphertext in the re-encrypted ciphertext is decrypted using the private key of the third user to obtain a symmetric key, and the first ciphertext in the re-encrypted ciphertext is decrypted using the symmetric key to obtain the secret file; Before obtaining the secret file uploaded by the first user, the encryption method further includes: obtaining first login information input by the first user; the first login information includes the account number and password of the first user; judging whether the first login information is correct; if correct, the first user has successfully logged in, and determining whether the first user has the authority to upload the secret file according to the first login information; if yes, obtaining the secret file uploaded by the first user; Before determining whether the first user has the authority to upload secret files according to the first login information, the encryption method further includes: after the first user completes registration to obtain the first login information, reviewing the application for joining the organization submitted by the first user, and generating first user information of the first user after the review is passed; matching the first login information with the first user information to obtain the first user information according to the first login information, and determining whether the first user has the authority to upload secret files according to the first user information; The reviewing of the application for joining the organization submitted by the first user and generating the first user information of the first user after the review is passed specifically includes: The employee ID, the applied department and the employee role information of the first user are signed using the CA private key and the SM2 signature algorithm to obtain an authorization code, and the authorization code is sent to the first user; the employee role information includes the user type and the permissions of the first user; the user types include ordinary users, ordinary administrators and organization administrators; Obtaining the organization ID of the organization to be joined and the authorization code input by the first user; The authorization code is verified using the CA public key and the SM2 verification algorithm; if the verification is successful, the higher-level user node of the first user will conduct an audit; if the audit is successful, the first user joins the organization and the first user information of the first user is generated; if the first user is the ordinary user, the higher-level user node is the ordinary administrator; if the first user is the ordinary administrator, the higher-level user node is the organization administrator; if the first user is the organization administrator, the higher-level user node is the super administrator; the first user information includes the employee ID, the time of joining the organization, the reviewer, the department to which he belongs, and the employee role information; Verifying the authorization code by using the CA public key and the SM2 verification algorithm includes: decrypting the authorization code by using the CA public key and the SM2 verification algorithm to obtain the employee ID, the applied department, and the employee role information of the first user, and comparing the employee ID, the applied department, and the employee role information of the first user obtained by decrypting the authorization code with the employee ID, the applied department, and the employee role information of the first user used for signing. If they are exactly the same, the input authorization code is correct and the verification is passed; otherwise, the input authorization code is incorrect and the verification fails; The secret document needs to be signed by a number of signatories, and a handwritten signature of each signatory is obtained; after obtaining the handwritten signature of each signatory, the encryption method further includes: For each of the signatories, a digital signature generated by the signatories is obtained, and a signature QR code is generated based on the business data and the digital signature; the digital signature is obtained by signing the business data using the signatories' private key and the SM2 signature algorithm; the business data includes a prefix representing the signature QR code, the ID number of the secret file, the user name of the signatories, and the time of signing; Synthesize the secret document and the handwritten signature and signature QR code of each signatory to obtain a signed document; Performing hash calculation on the signed file to obtain a file hash value of the signed file; The id number, effective time, initiator, signer, digital signatures of all signatories, file type and file hash value of the secret file are uploaded to the blockchain.

2. The encryption method according to claim 1, characterized in that: After generating the re-encryption key, the encryption method further includes: Performing a hash operation on the secret file to obtain a first hash value of the secret file; The first hash value is uploaded to the blockchain.

3. A method for decrypting secret files based on a national secret algorithm, characterized in that: The decryption method comprises: Determine whether the third user who makes the access request is a second user who has the authority to access the secret file; If so, obtaining a symmetric key generated by the third user; the symmetric key is obtained by decrypting the third ciphertext in the re-encrypted ciphertext using the private key of the third user; the re-encrypted ciphertext is obtained by encrypting the secret file using the encryption method described in claim 1; The first ciphertext in the re-encrypted ciphertext is decrypted using the symmetric key to obtain the secret file.

4. The decryption method according to claim 3, characterized in that: After obtaining the secret file, the decryption method further comprises: Calculate the hash value of the secret file to obtain a second hash value; Obtaining a first hash value of the secret file from the blockchain; The first Hash value and the second Hash value are compared; if the first Hash value and the second Hash value are the same, the secret file has not been tampered with; if the first Hash value and the second Hash value are different, the secret file has been tampered with, and the secret file is discarded.

5. A secret file protection system based on a national secret algorithm, characterized in that: The protection system includes: an access module, a query module, a key transmission module, an SM4 encryption and decryption module and a distributed database; The access module is used to verify the user's authority; when the user has the authority, the user is allowed to upload and view the secret file; The query module is used to receive a query request input by a user and return the secret file to the user; The key transmission module is used to generate a public and private key pair for each user; The SM4 encryption and decryption module is used to encrypt the secret file uploaded by the user using the encryption method described in claim 1 to obtain a re-encrypted ciphertext; and is also used to decrypt the re-encrypted ciphertext using the decryption method described in claim 4 to obtain the original secret file; The distributed database is used to store the re-encrypted ciphertext.

6. The protection system according to claim 5, characterized in that: The protection system also includes: an SM2 signature module, a file generation module and an on-chain synchronization module; The SM2 signature module is used to sign the business data using the SM2 signature algorithm to obtain a digital signature; The file generation module is used to generate a signature QR code using the digital signature, and synthesize the handwritten signature, the signature QR code and the secret file to obtain a signed file; The on-chain synchronization module is used to upload the digital signature and the hash value obtained by performing a hash operation on the secret file or the signed file to the blockchain.

Citation Information

Patent Citations

  • Method for confirming electronic contract signer by combining digital signature with handwritten signature

    CN110674523A

  • Cloud data encryption storage and sharing method, device and system

    CN112702160A