A key management method and device combined with a blockchain in a full-mesh database

By combining blockchain and smart contracts in a fully encrypted database, key sharding and distributed storage and automated management are achieved, solving the problems of insufficient dynamism and centralized risks in traditional key management systems, and improving data security and response efficiency.

CN123184831APending Publication Date: 2026-11-27WUHAN DAMENG DATABASE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611407938.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-11
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Traditional key management systems suffer from insufficient dynamic key permissions, delayed response to leaks, and centralized risks in fully encrypted databases, resulting in inadequate data security.

Method used

By using blockchain technology to distribute and store keys across multiple nodes, and by using smart contracts to automate key management, combined with a behavior analysis engine and agent re-encryption, it can automatically respond to key permission updates and leaks.

Benefits of technology

It improves the dynamism and real-time nature of key management, reduces the risk of single points of failure, shortens the response window, and enhances data security and compliance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123184831A_ABST
    Figure CN123184831A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of key management, in particular to a key management method and device combined with a blockchain in a full-mesh database. The method comprises the following steps: generating a key in a secure environment; dividing the key into multiple key fragments, and storing each key fragment in a blockchain node; deploying the same smart contract on each blockchain node; using the smart contract to save the metadata of the key fragments stored in the blockchain node; in a key use process, when a trigger condition of the smart contract is met, automatically calling the smart contract to perform corresponding operations on the key fragments, and synchronously updating the metadata of the key fragments, so that the management of the key is completed. The application can guarantee the security of the key in a full-mesh scenario, and provide stronger security protection for user data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of key management technology, and in particular to a key management method and apparatus that combines blockchain with a fully encrypted database. Background Technology

[0002] In a fully encrypted database, data transmission, processing, and storage are always performed in encrypted form on the database server. Once the data owner (usually also the database user) encrypts the data on the client side and sends it to the server, even if an attacker exploits a system vulnerability to steal the database data, they cannot obtain valid plaintext information, thus effectively protecting data privacy. Compared to traditional encryption technologies, a fully encrypted database provides comprehensive encryption protection for data, eliminating the possibility of privacy leaks in untrusted environments such as cloud servers, and offering higher security.

[0003] Fully encrypted databases typically employ a hierarchical mechanism of master keys and data keys. That is, the master key is used to encrypt the data key, and the data key is used to encrypt user data. Since the database data is encrypted throughout its entire lifecycle (i.e., data transmission, computation, and storage), ensuring the security of the keys (master key and data key) is crucial to ensuring the security of the fully encrypted database. However, traditional key management systems have several problems, such as insufficient dynamism in key permissions: Traditional key management systems typically manage key permissions statically. When user roles change or data access policies are adjusted, key permissions are difficult to update in a timely manner, leading to… Users whose permissions have been revoked can still use their original keys to decrypt historical data, thus posing a risk of data leakage; delayed response to leakage: when keys are leaked, traditional key management systems rely on manual detection and intervention, and the key rotation process is slow. There is a long response window between the discovery of the leak and the revocation of the old key and the activation of the new key. Attackers may take advantage of this response window to continuously access sensitive data, causing serious security threats; centralization risk: traditional key management systems mostly rely on centralized key servers, which have the potential for single point of failure. Once the server is compromised, the entire key pool may be stolen or tampered with, leading to the collapse of the entire system's data security architecture.

[0004] Therefore, overcoming the shortcomings of the existing technology is an urgent problem to be solved in this technical field. Summary of the Invention

[0005] In response to the above-mentioned deficiencies or improvement needs of existing technologies, this invention proposes a key management method and device that combines blockchain with a fully encrypted database, which can ensure key security in a fully encrypted scenario and provide stronger security protection for user data.

[0006] The embodiments of the present invention adopt the following technical solutions: In a first aspect, the present invention provides a key management method that combines a fully encrypted database with a blockchain, specifically comprising: generating a key in a secure environment; dividing the key into multiple key fragments, and storing each key fragment in a blockchain node; Deploy the same smart contract on each blockchain node; use the smart contract to store metadata of the key shards stored on the blockchain node; During key usage, when the triggering conditions of the smart contract are met, the smart contract is automatically invoked to perform corresponding operations on the key shards and the metadata of the key shards is updated synchronously to complete the management of the keys.

[0007] Preferably, during key usage, when the triggering condition of the smart contract is met, the smart contract is automatically invoked to perform corresponding operations on the key shards and the metadata of the key shards is updated synchronously to complete key management, including: Collect and analyze system logs to identify abnormal behaviors in the system logs; Each identified abnormal behavior is given a risk score, and abnormal behaviors with scores exceeding a preset threshold are identified as alarm behaviors. When an alarm occurs, the smart contract is automatically invoked to perform the corresponding operation on the key shard and the metadata of the key shard is updated synchronously to complete the management of the key.

[0008] Preferably, a machine learning model is used to collect and analyze system logs to identify abnormal behaviors in the system logs. The training process of the machine learning model includes: The system logs are collected and analyzed, and the user operation behaviors in the system logs are classified to obtain various types of user operation behaviors; Extract feature data for various types of user operation behaviors; Based on the aforementioned feature data, a behavioral baseline reflecting normal user behavior is constructed; Based on the aforementioned behavioral baseline, feature rules for detecting abnormal behavior are constructed; based on the feature rules, high-risk behaviors in the system logs are identified. The high-risk behaviors are used as training samples and input into a machine learning model, enabling the machine learning model to identify abnormal behaviors in the system logs.

[0009] Preferably, the step of automatically invoking the smart contract to perform corresponding operations on the key shard and synchronously updating the metadata of the key shard when an alarm occurs, in order to complete the management of the key, further includes: When an alarm occurs, the user's current key will be used as the old key. Revoke the old key's usage rights on all blockchain nodes; and generate a new key. Based on the mapping relationship between the old key and the new key, proxy re-encryption is used to convert the ciphertext data encrypted with the old key into target data encrypted with the new key.

[0010] Preferably, the revocation of the old key's right to use on all blockchain nodes includes: For each blockchain node, obtain the metadata of the old key fragments on the blockchain node; Change the status of the old key fragment in the metadata to the revocation status; The mapping relationship between users and old key shards is maintained to complete the revocation of the right to use the old key on all blockchain nodes.

[0011] Preferably, the new key generation operation includes: Obtain metadata of old key fragments on the blockchain node; Determine the revocation status of the old key fragment in the metadata; If the revocation status is not revoked, a new key is generated; and the new key is split into multiple new key fragments, with each new key fragment stored in a blockchain node; For each blockchain node, the mapping relationship between users and new key shards is stored to complete the new key generation operation.

[0012] Preferably, the step of using proxy re-encryption to convert ciphertext data encrypted with the old key into target data encrypted with the new key based on the mapping relationship between the old key and the new key includes: Generate a re-encryption key for proxy re-encryption, and send the re-encryption key to an external proxy re-encryption service; The external proxy re-encryption service receives ciphertext data encrypted using the old key; The external proxy re-encryption service converts the ciphertext data into target data encrypted using the new key, based on the re-encryption key.

[0013] Preferably, the method further includes: For each blockchain node, the corresponding operation record is generated in response to the smart contract's execution of key sharding. Perform a hash calculation on the operation record to obtain the operation hash value; The hash value of the operation is stored in the blockchain.

[0014] Secondly, the present invention provides a key management device for a fully encrypted database combined with a blockchain, specifically comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the processor to perform the key management method for a fully encrypted database combined with a blockchain as described in the first aspect.

[0015] Thirdly, the present invention also provides a non-volatile computer storage medium storing computer-executable instructions that are executed by one or more processors to perform the method described in the first aspect.

[0016] Compared with existing technologies, the beneficial effects of this invention are as follows: Utilizing the decentralized nature of blockchain, key fragments are distributed and stored across multiple blockchain nodes. This effectively avoids the risk of complete key leakage due to single-point failure of centralized servers in traditional key management systems. In the method provided by this invention, even if some blockchain nodes are compromised, attackers cannot reconstruct the complete key, thus significantly reducing the possibility of the entire key being stolen and improving the system's anti-attack capability. By introducing smart contracts into the key management system, operations such as key rotation and key permission updates can be automated. When user roles change or access policies are adjusted, smart contracts can respond instantly and trigger corresponding key operations, avoiding the problem of asynchronous permissions caused by delayed manual intervention. Simultaneously, when a key is leaked, key revocation and updates can be quickly completed through smart contracts, significantly shortening the response window available to attackers and improving emergency response efficiency. The combination of blockchain and smart contracts not only enhances the security of key storage through distributed storage but also improves the dynamism and real-time nature of key management through the automated execution strategy of smart contracts. This provides a more reliable and efficient protection mechanism for key management of fully encrypted databases, offering stronger security protection for user data.

[0017] Furthermore, by introducing a behavior detection mechanism into the smart contract, when the key management system detects an alarm behavior, it can automatically upload the alarm behavior to the smart contract, triggering the smart contract to immediately execute the key rotation operation. Through this automated response mechanism, the response time for security incidents can be significantly shortened, thereby effectively reducing the risk of data leakage. In addition, each key generation, rotation, and revocation operation is recorded on the blockchain. By utilizing the immutability and traceability of the blockchain, it is ensured that all key management behaviors are securely and permanently retained. Once a high-risk behavior or security incident occurs, the key operation history can be quickly traced, and the time, subject, and context of the abnormal operation can be accurately located, providing a reliable basis for security auditing and incident response. Attached Figure Description

[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments of the present invention will be briefly described below. Obviously, the drawings described below are merely some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without any creative effort.

[0019] Figure 1 This is a structural diagram of a key management system provided in an embodiment of the present invention; Figure 2 This is a flowchart illustrating a key management method combining a fully encrypted database with a blockchain, provided by an embodiment of the present invention. Figure 3 This is a flowchart illustrating the specific implementation method of step 103 provided in this embodiment of the invention; Figure 4 This is a flowchart illustrating the specific implementation method of step 203 provided in an embodiment of the present invention; Figure 5 This is a flowchart of a smart contract automatic execution key revocation method provided in an embodiment of the present invention; Figure 6 This is a flowchart of a smart contract automatic execution key rotation method provided by an embodiment of the present invention; Figure 7 A schematic diagram of a key management device combining a fully encrypted database with a blockchain, provided as an embodiment of the present invention; The reference numerals in the attached figures are as follows: 21: Processor; 22: Memory. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0021] Unless the context otherwise requires, throughout the specification and claims, the term "comprising" is interpreted as openly inclusive, meaning "including, but not limited to." In the description of the specification, terms such as "one embodiment," "some embodiments," "exemplary embodiment," "example," "specific example," or "some examples" are intended to indicate that a particular feature, structure, material, or characteristic associated with that embodiment or example is included in at least one embodiment or example of this disclosure. The illustrative representations of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics mentioned may be included in any suitable manner in any one or more embodiments or examples; that is, although they may be incorporated into embodiments or examples using the above terms for reasons such as order and position, it does not limit them to be incorporated in combination by a single embodiment or example.

[0022] In the description of this invention, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined with "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of embodiments of this disclosure, unless otherwise stated, "a plurality of" means two or more. Furthermore, for example, the description may use the prefix "A" or "B" to describe the same type of nouns as two independent entities. In this case, the corresponding features defined with "A" and "B" are used only to distinguish between similar entities and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features.

[0023] In the description of this invention, the expression “A and / or B” (where A and B are used to formally represent specific features) will be used. The corresponding expression includes the following three combinations: only A, only B, and a combination of A and B.

[0024] As used in this invention, “about,” “approximately,” or “approximately” includes the stated value and the average value within an acceptable range of deviation from a particular value, wherein the acceptable range of deviation is determined by a person skilled in the art taking into account the measurement under discussion and the error associated with the measurement of the particular quantity (i.e., the limitations of the measurement system).

[0025] Furthermore, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0026] Example 1: This embodiment proposes a key management method that integrates blockchain into a fully encrypted database. This method is applicable to both master key management and data key management. Furthermore, while key management is typically performed on the client side, the method proposed in this embodiment can also be implemented on the client side.

[0027] Key management refers to the management of the entire lifecycle of a key, which includes key generation, key rotation, key binding, and key revocation.

[0028] The key management method provided in this embodiment is applied to a key management system, such as... Figure 1 As shown, the key management system is built on blockchain technology, utilizing smart contracts to automate the execution of key management strategies and integrating a proxy re-encryption service to support secure sharing of encrypted data. The blockchain provides distributed storage, with each blockchain node storing key shards. Leveraging the blockchain's immutability, all operations throughout the key's lifecycle are recorded in a key operation log. A behavioral analysis engine is introduced into the smart contracts for real-time analysis and decision-making. When a risk is detected, the smart contract is triggered to automatically execute the corresponding operation. Throughout the key's lifecycle, after key generation, key shards are distributed and stored using blockchain nodes. A smart contract maintains the mapping relationship between users and key shards (i.e., key binding). During key usage, when a risk is detected, the smart contract is triggered to automatically execute the corresponding operation (key revocation and key rotation, etc.). When the smart contract automatically executes key revocation or key rotation, a new key is generated, which is also stored on the blockchain. Furthermore, after the new key is generated, a proxy re-encryption service is used to convert the encrypted data encrypted with the old key into the target data encrypted with the new key.

[0029] like Figure 2 As shown, Embodiment 1 of the present invention provides a key management method combining a fully encrypted database with a blockchain, the method specifically including the following steps: Step 101: Generate a key in a secure environment; divide the key into multiple key fragments, and store each key fragment in a blockchain node.

[0030] In one embodiment, a secure environment is used to ensure that the key is not leaked, tampered with, or illegally accessed during the generation process. Cryptographic algorithms can be used to split the key into multiple key fragments, each distributed across blockchain nodes. When a user uses the key, they need to combine a preset number of key fragments to recover the complete key (e.g., if there are 5 key fragments, 3 fragments need to be combined to recover the complete key). Due to the decentralized nature of blockchain, even if a single node is compromised by an attacker, the key will not be leaked. In this case, the attacker would need to compromise more than a threshold number of nodes simultaneously to obtain the complete key, greatly reducing the risk of single-point leakage. For example, if the key is divided into 5 key fragments, the attacker would need to compromise 3 nodes simultaneously to obtain the complete key. The preset number and threshold number can be set according to actual conditions. To ensure the distributed storage of the blockchain functions effectively (i.e., the attacker needs to compromise more than a threshold number of nodes simultaneously to obtain the complete key) while also having a certain degree of fault tolerance, the threshold number is generally set between 50% and 75% of the total number of fragments. The examples of the preset number and threshold number given above do not limit this embodiment.

[0031] Furthermore, to ensure rapid tracing of key operation history in the event of high-risk behavior or security incidents, the immutability and traceability of blockchain can be utilized to record all key generation, binding, rotation, and revocation operations in hash form on the blockchain. Specifically, for each blockchain node, in response to the smart contract's corresponding operation on key sharding, a corresponding operation record is generated; the operation record is hashed to obtain an operation hash value; and the operation hash value is stored in the blockchain. This method ensures that all key management activities are securely and permanently retained, meeting compliance audit requirements.

[0032] Step 102: Deploy the same smart contract on each blockchain node; use the smart contract to store the metadata of the key shards stored on the blockchain node.

[0033] In one embodiment, a smart contract is an automated program deployed on blockchain nodes that can automatically execute corresponding operations when the triggering conditions of the smart contract are met. Before building the blockchain, users pre-agree on the smart contract and deploy it to each blockchain node, ensuring that each blockchain node runs the same smart contract to manage local key sharding.

[0034] In one embodiment, the smart contract stores metadata about key shards on the blockchain nodes to ensure that all blockchain nodes maintain a consistent understanding of the key shard status and to provide a foundation for subsequent automatic execution of corresponding operations by the smart contract. This metadata includes the user's currently used key identity document (ID), historical keys, key status (whether it has been revoked), key rotation time, the mapping relationship between the user and the key, and the hash of alarm events pushed by the behavior analysis engine, etc.

[0035] Step 103: During key usage, when the triggering conditions of the smart contract are met, the smart contract is automatically invoked to perform corresponding operations on the key shards and the metadata of the key shards is updated synchronously to complete the management of the key.

[0036] In one embodiment, the triggering conditions for a smart contract may include one or more of the following: timed triggering, event-driven triggering, and manual triggering. Timed triggering can involve periodically calling a smart contract function via an external scheduler (such as Chainlink Keepers). That is, using an external automated system to periodically call a function in a smart contract deployed on the blockchain according to a set time (e.g., every Monday morning) or condition. Event-driven triggering can involve the Human Resources (HR) system calling a smart contract interface to revoke the permissions of a departing employee. In this case, the HR system will push an employee departure event, or a behavioral analysis engine will detect an anomaly (e.g., the behavioral analysis engine marks high-risk behavior). Manual triggering can involve an administrator proactively executing key rotation. After the smart contract is triggered, it automatically executes operations such as key generation, key binding, key revocation, proxy re-encryption, and key rotation (including key generation and proxy re-encryption operations). This rapid response eliminates the delay caused by manual intervention. For example, upon detecting an abnormal login by an account, the system automatically performs key revocation and proxy re-encryption operations within one second. This real-time and rapid response can shorten the response window, reduce the risk of data leakage, and simultaneously record the corresponding event (i.e., an abnormal login by an account) on the blockchain, generating a compliance analysis report.

[0037] In one embodiment, the smart contract performs corresponding operations on key shards under different triggering conditions. For example, when the HR system pushes an employee resignation event, the smart contract automatically revokes the old key, converts the encrypted data accessed by that employee into target data encrypted with the new key, and only assigns the new key to new employees, ensuring a one-to-one correspondence between employee identity and the new key, and guaranteeing that the old key cannot decrypt any data. When the administrator actively performs key rotation, the smart contract automatically generates a new key and replaces the encrypted data encrypted with the old key with the encrypted data encrypted with the new key.

[0038] In this embodiment, leveraging the decentralized nature of blockchain, keys are sharded and distributed across multiple blockchain nodes. This effectively avoids the risk of complete key leakage due to single-point failure of centralized servers in traditional key management systems. In the method provided by this invention, even if some blockchain nodes are compromised, attackers cannot reconstruct the complete key, significantly reducing the possibility of the entire key being stolen and enhancing the system's anti-attack capability. By introducing smart contracts into the key management system, operations such as key rotation and key permission updates can be automated. When user roles change or access policies are adjusted, smart contracts can respond instantly and trigger corresponding key operations, avoiding permission asynchrony issues caused by delayed manual intervention. Simultaneously, when a key is leaked, key revocation and updates can be quickly completed through smart contracts, significantly shortening the response window available to attackers and improving emergency response efficiency. The combination of blockchain and smart contracts not only enhances the security of key storage through distributed storage but also improves the dynamism and real-time nature of key management through the automated execution strategy of smart contracts. This provides a more reliable and efficient protection mechanism for key management of fully encrypted databases, offering stronger security protection for user data.

[0039] A behavior analysis engine can be introduced into a key management system. This engine monitors user actions (e.g., login time, access frequency, operation type), and uses machine learning or rule engines to analyze whether these actions are abnormal. If abnormal behavior is detected, the abnormal event is uploaded to the smart contract, triggering it (this triggering condition is event-driven). The smart contract then automatically executes the corresponding operation. Combining the behavior analysis engine with the smart contract enables automated key management and a secure closed loop. Specifically, when any of the triggering conditions—timed triggering, event-driven triggering, or manual triggering—is met, the smart contract will automatically be invoked to perform the corresponding operation on key sharding. The following explanation uses the behavior analysis engine triggering the smart contract in event-driven triggering as an example.

[0040] The behavior analysis engine includes a data acquisition layer, a data processing layer, an analysis and monitoring layer, and an output and triggering layer.

[0041] like Figure 3 As shown, this embodiment provides a method for step 103, which specifically includes the following steps: Step 201: Collect and analyze system logs to identify abnormal behaviors in the system logs.

[0042] In one embodiment, system logs include database audit logs, system operation logs, and application programming interface (API) call logs. Database audit logs primarily record database-related access and operation behaviors, with metrics including database login time, device Internet Protocol (IP) address, access frequency, and request size. System operation logs primarily record user operations, command execution, and service start / stop at the operating system level, with metrics including user login time, device IP address, and access frequency. API call logs primarily record API requests and responses provided by the system, with metrics including login time, device IP address, access frequency, and request size. Different logs, tailored to different access subjects, will have corresponding metrics related to login or access.

[0043] In one embodiment, a machine learning model can be used to collect and analyze system logs to identify abnormal behaviors in the system logs. The training process of the machine learning model specifically includes: collecting and analyzing system logs; classifying user actions in the system logs to obtain various types of user actions; extracting feature data for each type of user action; constructing a behavioral baseline reflecting normal user behavior based on the feature data; constructing feature rules for detecting abnormal behavior based on the behavioral baseline; identifying high-risk behaviors in the system logs based on the feature rules; and inputting the high-risk behaviors as training samples into the machine learning model, enabling the machine learning model to identify abnormal behaviors in the system logs.

[0044] In one embodiment, the data acquisition layer can analyze the metric data in the system logs through message queues such as Kafka / Pulsar and classify the user operation behaviors in the system logs to obtain various types of user operation behaviors; the data processing layer uses Flink / Spark Streaming to process the behavior streams and extract feature data of various types of user operation behaviors; it establishes a behavior baseline reflecting the normal behavior of each user (e.g., common login time periods, frequently used devices, frequently accessed data tables); the analysis and monitoring layer builds predefined strategies based on the behavior baselines; through this strategy, high-risk behaviors in the system logs can be identified (e.g., "more than 100 high-frequency accesses at 2 AM are set as high risk"), and high-risk behaviors are used as training samples. Unsupervised learning algorithms (such as Isolation Forest) are combined for anomaly detection, or deep learning models (such as Long Short-Term Memory networks) are used to model the temporal patterns of user behavior, thereby training a machine learning model that can identify abnormal behaviors in the system logs.

[0045] Step 202: Calculate the risk score for each of the identified abnormal behaviors, and determine the abnormal behaviors with scores exceeding the preset threshold as alarm behaviors.

[0046] In one embodiment, the analysis and monitoring layer performs risk scoring on all identified abnormal behaviors, and determines abnormal behaviors with scores exceeding a preset threshold as alarm behaviors. The preset threshold can be freely set according to needs.

[0047] Step 203: When an alarm occurs, the smart contract is automatically invoked to perform the corresponding operation on the key shard and the metadata of the key shard is updated synchronously to complete the management of the key.

[0048] In one embodiment, the output and triggering layer writes the alarm behavior into the message bus as an event and calls the smart contract API to upload the alarm behavior to the smart contract via the API.

[0049] Furthermore, the output and triggering layer writes the alert behavior into the audit database so that the security team can trace it when an alert behavior occurs.

[0050] When an alarm occurs, the smart contract automatically executes the security policy (revokes the old key and generates a new key), where the old key is the key currently used by the user.

[0051] like Figure 4 As shown, this embodiment provides a method for step 203, which specifically includes the following steps: Step 301: When an alarm occurs, use the key currently used by the user as the old key.

[0052] Step 302: Revoke the old key's usage rights on all blockchain nodes; and generate a new key.

[0053] In one embodiment, when an alarm occurs, it indicates that key security has been compromised. In this case, the old key's access rights on all blockchain nodes must be revoked to ensure that users cannot use the old key to decrypt data, prevent plaintext leakage, and generate a new key for subsequent encryption operations.

[0054] In one embodiment, revoking the right to use the old key on all blockchain nodes specifically involves: for each blockchain node, obtaining the metadata of the old key shard on the blockchain node; changing the status corresponding to the old key shard in the metadata to the revocation status; saving the mapping relationship between the user and the old key shard to complete the revocation operation of the right to use the old key on all blockchain nodes; in addition, updating the old key metadata. This processing of each blockchain node can ensure that all blockchain nodes have the same understanding of the key shard status.

[0055] In one embodiment, the new key generation operation specifically involves: obtaining the metadata of the old key shard on the blockchain node; determining the revocation status of the old key shard in the metadata; if the revocation status is not revoked, generating a new key; splitting the new key into multiple new key shards, and storing each new key shard in the blockchain node; for each blockchain node, saving the mapping relationship between users and new key shards to complete the new key generation operation; in addition, the smart contract saves the new key ID and the old key, and uses the time of generating the new key as the rotation time of the new key shard to complete the update of the new key metadata.

[0056] Step 303: Based on the mapping relationship between the old key and the new key, use proxy re-encryption to convert the ciphertext data encrypted with the old key into target data encrypted with the new key.

[0057] In one embodiment, there is a response window between revoking the old key and enabling the new key. Attackers may exploit this response window to continuously access sensitive data, posing a serious security threat. This embodiment uses a proxy re-encryption method to directly convert the ciphertext without decryption, transforming the ciphertext data encrypted with the old key into the target data encrypted with the new key. This ensures that the data is always in an encrypted state, meeting the security requirements of a fully encrypted database. Furthermore, the re-encryption is performed asynchronously in the background, with the old and new keys taking effect in parallel, ensuring uninterrupted query services.

[0058] Furthermore, due to the high cost of executing complex encryption algorithms on the blockchain, the smart contract itself does not perform re-encryption calculations. Instead, it is responsible for generating re-encryption task events. The actual re-encryption operation is completed by calling a proxy re-encryption interface, and the result is written back to the blockchain via the smart contract. Specifically, calling the proxy re-encryption interface to complete the re-encryption operation involves: generating a re-encryption key for proxy re-encryption; sending the re-encryption key to an external proxy re-encryption service; the external proxy re-encryption service receiving ciphertext data encrypted with the old key; and the external proxy re-encryption service converting the ciphertext data into target data encrypted with the new key based on the re-encryption key.

[0059] The pseudocode for the proxy re-encryption interface is as follows: event ReEncryptionTask(address indexed user, uint256 oldKey, uint256newKey, uint256 timestamp); To more clearly describe the key processes of the key management system, the core operational logic of the smart contract is abstracted and expressed in pseudocode below, including key steps such as the smart contract storing metadata of key shards, the smart contract automatically executing key rotation, the smart contract automatically executing key revocation, the smart contract automatically executing security policies, and key operations being written to on-chain events.

[0060] In one embodiment, the pseudocode for a smart contract to store metadata about key shards is as follows: struct KeyInfo{ uint256 currentKey; uint256[] keyHistory; bool isRevoked; uint256 lastRotationTime; } mapping(address =>KeyInfo) public userKeys; mapping(bytes32 =>bool) public riskAlerts; In one embodiment, the pseudocode for the smart contract to automatically perform key rotation (generate a new key and trigger a backend agent to re-encrypt) is as follows: function rotateKey(address user) public { KeyInfo storage info = userKeys[user]; require(!info.isRevoked,"User revoked"); uint256 newKey = uint256(keccak256(abi.encodePacked(user,block.timestamp))); info.keyHistory.push(info.currentKey); info.currentKey = newKey; info.lastRotationTime = block.timestamp; emit KeyRotated(user, newKey, block.timestamp); } In one embodiment, the pseudocode for the smart contract to automatically revoke the key upon detecting high-risk behavior is as follows: function revokeKey(address user) public onlyAdmin { KeyInfo storage info = userKeys[user]; info.isRevoked = true; emit KeyRevoked(user, info.currentKey, block.timestamp); } In one embodiment, when the behavior analysis engine pushes an alert, the pseudocode for the smart contract automatically executing a security policy (revokeing the user's old key, generating a new key, and triggering forced proxy re-encryption) is as follows: function triggerAlert(bytes32 alertId, address user) publiconlyEngine { require(!riskAlerts[alertId], "Alert already handled"); riskAlerts[alertId] = true; revokeKey(user); rotateKey(user); } In one embodiment, all key operations are written to on-chain events for querying by the audit and compliance system. The pseudocode for writing key operations to on-chain events is as follows: event KeyRotated(address indexed user, uint256 newKey, uint256timestamp); event KeyRevoked(address indexed user, uint256 oldKey, uint256timestamp); event RiskAlertTriggered(address indexed user, bytes32 alertId, uint256 timestamp); Example 2: The following are examples illustrating the application scenarios of key management methods that combine blockchain with fully encrypted databases.

[0061] In one embodiment, a top-tier hospital uses a fully encrypted database to store patients' electronic medical records. This fully encrypted database needs to meet the requirements of dynamic access control, data leakage prevention, and compliance auditing. The key management method provided in this embodiment can meet the needs of the fully encrypted database used by this top-tier hospital. Specifically, regarding the requirement for dynamic access control, key permissions can be automatically adjusted through smart contracts. When a doctor is reassigned, the smart contract automatically revokes the doctor's access to historical data, achieving immediate revoke of permissions. Regarding the requirement for data leakage prevention, blockchain is used to distribute and store key shards. Even if a key shard held by a doctor is leaked, attackers cannot obtain the complete key, thus preventing the decryption of all data and effectively ensuring data security. Regarding the requirement for compliance auditing, all key-related operations are recorded on the blockchain in hash form. In the event of abnormal access or a security incident, complete audit evidence can be provided through the blockchain, meeting regulatory compliance requirements.

[0062] In one embodiment, when a doctor leaves the company, the HR system marks the doctor as departing, which then triggers a smart contract to automatically perform the following actions. (See [link to relevant documentation]). Figure 5 Specifically, this involves: revoking the key, which means marking the old key associated with the doctor as invalid and generating a new key, while recording this key rotation event on the blockchain; performing data re-encryption, which uses a proxy re-encryption service to convert the encrypted electronic medical record data that the doctor previously accessed into encrypted data encrypted with the new key; and completing the permission revoke, whereby the new key is only bound to the doctor who treated the patient, ensuring that the old key of the departing doctor can no longer decrypt any data, thereby ensuring data security and precise control of permissions.

[0063] In one embodiment, when a departing doctor maliciously leaks their key and attempts to access the system, the attacker uses fragments of the old key to try to log into the database. The behavioral analysis engine detects the abnormal access behavior in real time, the risk score rises rapidly, and the smart contract automatically responds. See also Figure 6 Specifically, the smart contract initiates a department-wide key rotation mechanism within seconds, marking all relevant old keys as invalid and generating new ones; the new keys are then used to re-encrypt all existing encrypted data. Due to the rapid key rotation, attackers can only decrypt a very small amount of data before the key rotation and cannot obtain subsequent information. The entire attack and system response process are fully recorded on the blockchain, ensuring traceability and providing reliable evidence for subsequent judicial investigation.

[0064] By combining with this blockchain key management mechanism, the security of the keys can be highly guaranteed, and the response is fast, significantly improving efficiency.

[0065] In summary, this invention proposes a key management method combining a fully encrypted database with blockchain. This method utilizes decentralized storage and trusted auditing of key management, smart contracts to drive automated strategy execution, behavioral analysis for real-time risk awareness, and proxy re-encryption to ensure seamless business upgrades, thus constructing a secure key management system for a fully encrypted database. In highly sensitive scenarios such as healthcare, finance, and government affairs, this key management method can effectively defend against internal leaks, external attacks, and compliance risks, providing a reliable infrastructure for protecting privacy data.

[0066] Example 3: Based on the key management method combining a fully encrypted database with a blockchain provided in the foregoing embodiments, the present invention also provides an apparatus for key management combining a fully encrypted database with a blockchain, which can be used to implement the above method. Figure 7 The diagram shown is a schematic representation of the device architecture according to an embodiment of the present invention. The device for key management in a fully encrypted database combined with blockchain in this embodiment includes one or more processors 21 and a memory 22. Wherein, Figure 7 Take a processor 21 as an example.

[0067] Processor 21 and memory 22 can be connected via a bus or other means. Figure 7 Taking the example of a connection between China and Israel via a bus.

[0068] The memory 22, as a non-volatile computer-readable storage medium for key management methods combining a fully encrypted database with blockchain, can be used to store non-volatile software programs and non-volatile computer-executable programs, such as the key management method combining a fully encrypted database with blockchain in the aforementioned embodiments. The processor 21 executes various functional applications and data processing of the key management device combining a fully encrypted database with blockchain by running the non-volatile software programs, instructions, and modules stored in the memory 22, thereby implementing the key management method combining a fully encrypted database with blockchain in the aforementioned embodiments.

[0069] Memory 22 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 22 may include memory remotely located relative to processor 21, which can be connected to processor 21 via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0070] The program instructions / modules are stored in memory 22. When executed by one or more processors 21, they perform the key management method combined with blockchain in the fully encrypted database described in the foregoing embodiments. For example, they perform the methods described above. Figures 2-4The steps shown.

[0071] This invention also provides a non-volatile computer storage medium storing computer-executable instructions that are executed by one or more processors, for example... Figure 7 One of the processors 21 can enable the one or more processors to execute the key management method combined with blockchain in the fully encrypted database of the foregoing embodiments, for example, to execute the above-described Figures 2-4 The steps shown.

[0072] It is worth noting that the information interaction and execution process between the modules and units in the above-mentioned device and system are based on the same concept as the processing method embodiment of the present invention. For details, please refer to the description in the method embodiment of the present invention, and will not be repeated here.

[0073] Those skilled in the art will understand that all or part of the steps in the various methods of the embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0074] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A key management method combining blockchain with a fully encrypted database, characterized in that, include: Generate keys in a secure environment; The key is divided into multiple key fragments, and each key fragment is stored in a blockchain node; Deploy the same smart contract on each blockchain node; The smart contract is used to store the metadata of the key fragments stored on the blockchain node; During key usage, when the triggering conditions of the smart contract are met, the smart contract is automatically invoked to perform corresponding operations on the key shards and the metadata of the key shards is updated synchronously to complete the management of the keys.

2. The key management method combining blockchain in a fully encrypted database according to claim 1, characterized in that, During key usage, when the triggering conditions of the smart contract are met, the smart contract is automatically invoked to perform corresponding operations on the key shards and the metadata of the key shards is updated synchronously to complete key management, including: Collect and analyze system logs to identify abnormal behaviors in the system logs; Each identified abnormal behavior is given a risk score, and abnormal behaviors with scores exceeding a preset threshold are identified as alarm behaviors. When an alarm occurs, the smart contract is automatically invoked to perform the corresponding operation on the key shard and the metadata of the key shard is updated synchronously to complete the management of the key.

3. The key management method combining blockchain in a fully encrypted database according to claim 2, characterized in that, The system logs are collected and analyzed using a machine learning model to identify abnormal behaviors in the system logs. The training process of the machine learning model includes: The system logs are collected and analyzed, and the user operation behaviors in the system logs are classified to obtain various types of user operation behaviors; Extract feature data for various types of user operation behaviors; Based on the aforementioned feature data, a behavioral baseline reflecting normal user behavior is constructed; Based on the aforementioned behavioral baseline, feature rules for detecting abnormal behavior are constructed; based on the feature rules, high-risk behaviors in the system logs are identified. The high-risk behaviors are used as training samples and input into a machine learning model, enabling the machine learning model to identify abnormal behaviors in the system logs.

4. The key management method combining blockchain in a fully encrypted database according to claim 2, characterized in that, The method of automatically invoking the smart contract to perform corresponding operations on the key shards and synchronously updating the metadata of the key shards when an alarm occurs, in order to complete the management of the keys, also includes: When an alarm occurs, the user's current key will be used as the old key. Revoke the old key's usage rights on all blockchain nodes; and generate a new key. Based on the mapping relationship between the old key and the new key, proxy re-encryption is used to convert the ciphertext data encrypted with the old key into target data encrypted with the new key.

5. The key management method combining blockchain in a fully encrypted database according to claim 4, characterized in that, The revocation of the right to use the old key on all blockchain nodes includes: For each blockchain node, obtain the metadata of the old key fragments on the blockchain node; Change the status of the old key fragment in the metadata to the revocation status; The mapping relationship between users and old key shards is maintained to complete the revocation of the right to use the old key on all blockchain nodes.

6. The key management method combining blockchain in a fully encrypted database according to claim 4, characterized in that, The new key generation process includes: Obtain metadata of old key fragments on the blockchain node; Determine the revocation status of the old key fragment in the metadata; If the revocation status is not revoked, a new key is generated; and the new key is split into multiple new key fragments, with each new key fragment stored in a blockchain node; For each blockchain node, the mapping relationship between users and new key shards is stored to complete the new key generation operation.

7. The key management method combining blockchain in a fully encrypted database according to claim 1, characterized in that, The step of using proxy re-encryption to convert ciphertext data encrypted with the old key into target data encrypted with the new key, based on the mapping relationship between the old and new keys, includes: Generate a re-encryption key for proxy re-encryption, and send the re-encryption key to an external proxy re-encryption service; The external proxy re-encryption service receives ciphertext data encrypted using the old key; The external proxy re-encryption service converts the ciphertext data into target data encrypted using the new key, based on the re-encryption key.

8. The key management method combining blockchain in a fully encrypted database according to claim 1, characterized in that, The method further includes: For each blockchain node, the corresponding operation record is generated in response to the smart contract's execution of key sharding. Perform a hash calculation on the operation record to obtain the operation hash value; The hash value of the operation is stored in the blockchain.

9. A key management device for a fully encrypted database combined with blockchain, characterized in that, The device includes: At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the processor for performing a key management method in conjunction with a blockchain in a fully encrypted database as described in any one of claims 1-8.

10. A non-volatile computer storage medium, characterized in that, The computer storage medium stores computer-executable instructions, which are executed by one or more processors to perform the key management method combined with blockchain in a fully encrypted database as described in any one of claims 1-8.